hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
24932dd2e0c69eea57a3e33e574645b2e0a6504d | 349 | cpp | C++ | src/CScheduleAlgorithm.cpp | aw32/sched | b6ef35c5b517875a5954c70e2dc366fab3721a60 | [
"BSD-2-Clause"
] | null | null | null | src/CScheduleAlgorithm.cpp | aw32/sched | b6ef35c5b517875a5954c70e2dc366fab3721a60 | [
"BSD-2-Clause"
] | null | null | null | src/CScheduleAlgorithm.cpp | aw32/sched | b6ef35c5b517875a5954c70e2dc366fab3721a60 | [
"BSD-2-Clause"
] | null | null | null | // Copyright 2019, Alex Wiens <awiens@mail.upb.de>, Achim Lösch <achim.loesch@upb.de>
// SPDX-License-Identifier: BSD-2-Clause
#include "CScheduleAlgorithm.h"
using namespace sched::algorithm;
CScheduleAlgorithm::CScheduleAlgorithm(std::vector<CResource*>& rResources):
mrResources(rResources)
{
}
CScheduleAlgorithm::~CScheduleAlgorithm(){
}
| 21.8125 | 85 | 0.770774 | [
"vector"
] |
2493de7448e23933487ac46ba86fa5317bfeccb4 | 1,446 | cc | C++ | test/model.cc | fengwang/ceras | 15d10e8909ded656f45201aecc45b8eefe961b2d | [
"BSD-3-Clause"
] | 65 | 2020-12-07T01:15:41.000Z | 2022-03-28T01:17:33.000Z | test/model.cc | fengwang/ceras | 15d10e8909ded656f45201aecc45b8eefe961b2d | [
"BSD-3-Clause"
] | 1 | 2021-04-08T13:20:39.000Z | 2021-04-09T00:37:02.000Z | test/model.cc | fengwang/ceras | 15d10e8909ded656f45201aecc45b8eefe961b2d | [
"BSD-3-Clause"
] | 7 | 2021-01-07T08:52:39.000Z | 2022-03-08T13:04:37.000Z | #include "../include/ceras.hpp"
#include <iostream>
int main()
{
using namespace ceras;
auto a = Input(); // (4,)
auto b = Dense( 11, 4 )( a );
auto m1 = model{ a, b }; // 4->11
auto x = Input(); // ( 7, )
auto y = Dense( 4, 7 )( x );
auto m2 = model{ x, y }; // 7->4
auto input = Input();// // (7, )
auto output = m1( m2( input ) ); // 7->4->11
auto mm = model{ input, output };
unsigned long const batch_size = 16;
auto data = random<float>( {batch_size, 7} );
auto output_data_1 = mm.predict( data );
auto output_data_2 = m1.predict( m2.predict( data ) );
auto diff = output_data_2 - output_data_1;
std::cout << "The output of the composed model are:\n" << output_data_1 << std::endl;
std::cout << "The difference between composed model and seperated models are:\n" << diff << std::endl;
std::cout << "\nTesting model trainable method.\n";
mm.trainable( false );
auto output_data_3 = mm.predict( data );
std::cout << "The output of the composed model at input 3, after setting non-trainable, are:\n" << output_data_3 << std::endl;
mm.expression_.backward( random<float>( {batch_size, 11} ) );
auto output_data_4 = mm.predict( data );
std::cout << "The output of the composed model at input 4, after backpropagate random gradient, (should be the same as the previous output) are:\n" << output_data_4 << std::endl;
return 0;
}
| 32.133333 | 183 | 0.609267 | [
"model"
] |
24941b1d1db1fcfe0f4f3b8e614c95923ed3fe74 | 2,443 | cc | C++ | bethe-xxz/frontend-testprecision.cc | robhagemans/bethe-solver | 77b217c6cc23842b284ecd2d7b01fe28310cc32e | [
"MIT"
] | null | null | null | bethe-xxz/frontend-testprecision.cc | robhagemans/bethe-solver | 77b217c6cc23842b284ecd2d7b01fe28310cc32e | [
"MIT"
] | null | null | null | bethe-xxz/frontend-testprecision.cc | robhagemans/bethe-solver | 77b217c6cc23842b284ecd2d7b01fe28310cc32e | [
"MIT"
] | null | null | null | /*
* properties of XXZ chains
*
* Rob Hagemans, instituut voor theoretische fysica, universiteit van Amsterdam
*
*/
#include <math.h>
#include <complex>
#include <vector>
#include <iostream>
using namespace std;
#include "bethe.h"
#include "square.h"
#include "det.h"
#include "strip.h"
#include "exception.h"
#include "chain.h"
#include "base.h"
#include "state.h"
#include "scan.h"
int run(void)
{
int quantity_type;
cout<< " 0 for Szff, nonzero for Smff >> ";
cin>> quantity_type;
double zeta, delta;
cout << " anisotropy Delta >> ";
cin >> delta;
int chain_length;
cout<< " chain length N >> ";
cin>>chain_length;
Chain* p_chain = newChain (delta, chain_length);
int state_id =0;
int number_spinons=0;
int number_types;
int left_number_down;
cout<<" number of down spins of left state M >> ";
cin >> left_number_down;
cout<<" number of non-real types in base >> ";
cin>>number_types;
vector<int>structure (p_chain->numberTypes());
if (number_types+1> p_chain->numberTypes()) throw "Too many string types";
int number_excited_rapidities=0;
cout<<" non-real part of base >> ";
for (int i=1; i < number_types+1; ++i) cin>>structure[i];
int number_infinite=0;
cout<<" number of infinite rapidities >> ";
cin>>number_infinite;
cout<<" number of spinons s >> ";
cin >> number_spinons;
Base* p_ground_base = newGroundBase (*p_chain, left_number_down);
State* p_oregon = newGroundState (*p_ground_base);
Quantity* p_quantity = newQuantity(quantity_type, *p_oregon);
Base* p_base = newBase (*p_chain, p_quantity->rightNumberDown(left_number_down), structure, number_spinons, number_infinite);
cout<<endl<<" state number (0 <= id < "<<p_base->limId().back();
cout<<") id >> ";
cin>> state_id;
cout<<endl<<endl;
cout.precision(20);
State* p_florida = newState (*p_base, state_id);
Policy policy = DEFAULT_POLICY;
for (int i=0; i<50; ++i ) {
policy.precision = pow (10, -1.0*i);
p_oregon->setFreeRapidities();
p_florida->setFreeRapidities();
if (!p_oregon->solve (1000, policy.precision)) cout<<"GROUND STATE NOT CONVERGED "<<endl;
if (!p_florida->admissible()) cout<<"INADMISSIBLE STATE " <<endl;
if (!p_florida->solve (1000, policy.precision)) cout<<"NOT CONVERGED "<<endl;
cout << policy.precision <<SEP<< p_oregon->convergence<<SEP<<p_florida->convergence <<SEP<< (*p_quantity) (*p_florida) <<endl;
}
}
| 25.185567 | 129 | 0.672534 | [
"vector"
] |
24950efe2749fa54d2864017ed43ac5b852c51d3 | 849 | hpp | C++ | alignment/datastructures/alignment/CmpFile.hpp | ggraham/blasr_libcpp | 4abef36585bbb677ebc4acb9d4e44e82331d59f7 | [
"RSA-MD"
] | 4 | 2015-07-03T11:59:54.000Z | 2018-05-17T00:03:22.000Z | alignment/datastructures/alignment/CmpFile.hpp | ggraham/blasr_libcpp | 4abef36585bbb677ebc4acb9d4e44e82331d59f7 | [
"RSA-MD"
] | 79 | 2015-06-29T18:07:21.000Z | 2018-09-19T13:38:39.000Z | alignment/datastructures/alignment/CmpFile.hpp | ggraham/blasr_libcpp | 4abef36585bbb677ebc4acb9d4e44e82331d59f7 | [
"RSA-MD"
] | 19 | 2015-06-23T08:43:29.000Z | 2021-04-28T18:37:47.000Z | #ifndef _BLASR_CMP_FILE_HPP_
#define _BLASR_CMP_FILE_HPP_
#include <vector>
#include <alignment/datastructures/alignment/CmpIndexedStringTable.h>
#include <pbdata/Enumerations.h>
#include <pbdata/reads/ReadType.hpp>
#include <pbdata/saf/AlnGroup.hpp>
#include <pbdata/saf/AlnInfo.hpp>
#include <pbdata/saf/MovieInfo.hpp>
#include <pbdata/saf/RefGroup.hpp>
#include <pbdata/saf/RefInfo.hpp>
class CmpFile
{
public:
int lastRow;
std::string readTypeString, index, version, commandLine;
ReadType::ReadTypeEnum readType;
void StoreReadType(std::string &readTypeStringP);
CmpIndexedStringTable readGroupTable, movieNameTable, refSeqTable;
std::vector<std::string> colNames;
PlatformId platformId;
AlnGroup alnGroup;
AlnInfo alnInfo;
RefGroup refGroup;
RefInfo refInfo;
MovieInfo movieInfo;
};
#endif
| 24.257143 | 70 | 0.762073 | [
"vector"
] |
2498cc2effa5e353ee29a13c25e5c4aee93b1eb8 | 1,744 | cpp | C++ | test/cpp/threadlocal.cpp | reqshark/nan | cd36a057ca7ed6e118ebec59e0e7935b114f38ba | [
"MIT"
] | null | null | null | test/cpp/threadlocal.cpp | reqshark/nan | cd36a057ca7ed6e118ebec59e0e7935b114f38ba | [
"MIT"
] | null | null | null | test/cpp/threadlocal.cpp | reqshark/nan | cd36a057ca7ed6e118ebec59e0e7935b114f38ba | [
"MIT"
] | null | null | null | /*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2015 NAN contributors
*
* MIT License <https://github.com/rvagg/nan/blob/master/LICENSE.md>
********************************************************************/
#include <nan.h>
#define _(e) NAN_TEST_EXPRESSION(e)
// Based on test-thread.c from libuv.
class TlsTest : public NanAsyncWorker {
public:
TlsTest(NanTap *t) : NanAsyncWorker(NULL), t(t), i(0) {
NanScope();
t->plan(7);
t->ok(_(0 == nauv_key_create(&tls_key)));
t->ok(_(NULL == nauv_key_get(&tls_key)));
nauv_key_set(&tls_key, this);
t->ok(_(this == nauv_key_get(&tls_key)));
}
void Execute() {
ok(_(NULL == nauv_key_get(&tls_key)));
nauv_key_set(&tls_key, &i);
ok(_(&i == nauv_key_get(&tls_key)));
nauv_key_set(&tls_key, NULL);
ok(_(NULL == nauv_key_get(&tls_key)));
}
void WorkComplete() {
NanScope();
for (unsigned j = 0; j < i; ++j)
t->ok(res[j].ok, res[j].msg);
nauv_key_delete(&tls_key);
t->ok(_(NULL == ErrorMessage()));
delete t;
}
private:
nauv_key_t tls_key;
NanTap *t;
struct { bool ok; const char* msg; } res[3];
unsigned i;
void ok(bool isOk, const char *msg) {
assert(i < sizeof(res)/sizeof(res[0]));
res[i].ok = isOk;
res[i].msg = msg;
++i;
}
};
NAN_METHOD(thread_local_storage) {
NanScope();
NanTap *t = new NanTap(args[0]);
NanAsyncQueueWorker(new TlsTest(t));
return_NanUndefined();
}
void Init(v8::Handle<v8::Object> exports) {
exports->Set(
NanNew<v8::String>("thread_local_storage")
, NanNew<v8::FunctionTemplate>(thread_local_storage)->GetFunction()
);
}
NODE_MODULE(threadlocal, Init)
| 25.275362 | 71 | 0.577408 | [
"object"
] |
2498d7aee7003200cb48f608a09654e9d757e2a2 | 23,155 | cpp | C++ | lib/WalletLegacy/WalletTransactionSender.cpp | exploshot/qwertycoin | 1f0bb2fdfadfa46788094454711db5c4796be84a | [
"MIT"
] | 55 | 2018-02-19T20:37:11.000Z | 2021-12-30T03:47:12.000Z | lib/WalletLegacy/WalletTransactionSender.cpp | exploshot/qwertycoin | 1f0bb2fdfadfa46788094454711db5c4796be84a | [
"MIT"
] | 112 | 2018-02-28T21:44:47.000Z | 2021-12-05T15:11:16.000Z | lib/WalletLegacy/WalletTransactionSender.cpp | exploshot/qwertycoin | 1f0bb2fdfadfa46788094454711db5c4796be84a | [
"MIT"
] | 74 | 2018-02-28T21:05:29.000Z | 2022-02-20T02:31:21.000Z | // Copyright (c) 2012-2017, The CryptoNote developers, The Bytecoin developers
// Copyright (c) 2018, Karbo developers
// Copyright (c) 2018-2021, The Qwertycoin Group.
//
// This file is part of Qwertycoin.
//
// Qwertycoin 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 3 of the License, or
// (at your option) any later version.
//
// Qwertycoin 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 Qwertycoin. If not, see <http://www.gnu.org/licenses/>.
#include <random>
#include <crypto/crypto.h> // for rand()
#include <CryptoNoteCore/Account.h>
#include <CryptoNoteCore/CryptoNoteBasicImpl.h>
#include <CryptoNoteCore/CryptoNoteFormatUtils.h>
#include <CryptoNoteCore/CryptoNoteTools.h>
#include <CryptoNoteCore/TransactionApi.h>
#include <Logging/LoggerGroup.h>
#include <WalletLegacy/WalletTransactionSender.h>
#include <WalletLegacy/WalletUtils.h>
using namespace Crypto;
using namespace CryptoNote;
namespace {
uint64_t countNeededMoney(uint64_t fee, const std::vector<WalletLegacyTransfer> &transfers)
{
uint64_t needed_money = fee;
for (auto &transfer: transfers) {
throwIf(transfer.amount == 0, error::ZERO_DESTINATION);
throwIf(transfer.amount < 0, error::WRONG_AMOUNT);
needed_money += transfer.amount;
throwIf(static_cast<int64_t>(needed_money) < transfer.amount, error::SUM_OVERFLOW);
}
return needed_money;
}
void createChangeDestinations(
const AccountPublicAddress &address,
uint64_t neededMoney,
uint64_t foundMoney,
TransactionDestinationEntry &changeDts)
{
if (neededMoney < foundMoney) {
changeDts.addr = address;
changeDts.amount = foundMoney - neededMoney;
}
}
void constructTx(
const AccountKeys keys,
const std::vector<TransactionSourceEntry> &sources,
const std::vector<TransactionDestinationEntry> &splittedDests,
const std::string &extra,
uint64_t unlockTimestamp,
uint64_t sizeLimit,
Transaction &tx,
const std::vector<tx_message_entry> &messages,
uint64_t ttl,
const std::string &sender,
Crypto::SecretKey &tx_key)
{
std::vector<uint8_t> extraVec;
extraVec.reserve(extra.size());
std::for_each(extra.begin(), extra.end(), [&extraVec](const char el) {
extraVec.push_back(el);
});
Logging::LoggerGroup nullLog;
bool r = constructTransaction(
keys,
sources,
splittedDests,
messages,
sender,
ttl,
extraVec,
tx,
unlockTimestamp,
tx_key,
nullLog
);
throwIf(!r, error::INTERNAL_WALLET_ERROR);
throwIf(getObjectBinarySize(tx) >= sizeLimit, error::TRANSACTION_SIZE_TOO_BIG);
}
std::shared_ptr<WalletLegacyEvent> makeCompleteEvent(
WalletUserTransactionsCache &transactionCache,
size_t transactionId,
std::error_code ec)
{
transactionCache.updateTransactionSendingState(transactionId, ec);
return std::make_shared<WalletSendTransactionCompletedEvent>(transactionId, ec);
}
} // namespace
namespace CryptoNote {
WalletTransactionSender::WalletTransactionSender(
const Currency ¤cy,
WalletUserTransactionsCache &transactionsCache,
AccountKeys keys,
ITransfersContainer &transfersContainer)
: m_currency(currency),
m_transactionsCache(transactionsCache),
m_isStoping(false),
m_keys(keys),
m_transferDetails(transfersContainer),
m_upperTransactionSizeLimit(m_currency.maxTransactionSizeLimit())
{
}
void WalletTransactionSender::stop()
{
m_isStoping = true;
}
bool WalletTransactionSender::validateDestinationAddress(const std::string &address)
{
AccountPublicAddress ignore;
return m_currency.parseAccountAddressString(address, ignore);
}
void WalletTransactionSender::validateTransfersAddresses(
const std::vector<WalletLegacyTransfer> &transfers)
{
for (const WalletLegacyTransfer &tr : transfers) {
if (!validateDestinationAddress(tr.address)) {
throw std::system_error(make_error_code(error::BAD_ADDRESS));
}
}
}
std::shared_ptr<WalletRequest> WalletTransactionSender::makeSendRequest(
TransactionId &transactionId,
std::deque<std::shared_ptr<WalletLegacyEvent>> &events,
const std::vector<WalletLegacyTransfer> &transfers,
uint64_t fee,
const std::string &extra,
uint64_t mixIn,
uint64_t unlockTimestamp,
const std::vector<TransactionMessage> &messages,
uint64_t ttl,
const std::string &sender)
{
using namespace CryptoNote;
throwIf(transfers.empty(), error::ZERO_DESTINATION);
validateTransfersAddresses(transfers);
uint64_t neededMoney = countNeededMoney(fee, transfers);
std::shared_ptr<SendTransactionContext> context = std::make_shared<SendTransactionContext>();
context->foundMoney = selectTransfersToSend(
neededMoney,
mixIn == 0,
context->dustPolicy.dustThreshold,
context->selectedTransfers);
throwIf(context->foundMoney < neededMoney, error::WRONG_AMOUNT);
transactionId = m_transactionsCache.addNewTransaction(
neededMoney,
fee,
extra,
transfers,
unlockTimestamp,
messages
);
context->transactionId = transactionId;
context->mixIn = mixIn;
context->ttl = ttl;
context->sender = sender;
for (const TransactionMessage &message : messages) {
AccountPublicAddress address;
bool extracted = m_currency.parseAccountAddressString(message.address, address);
if (!extracted) {
throw std::system_error(make_error_code(error::BAD_ADDRESS));
}
context->messages.push_back({message.message, true, address });
}
if(context->mixIn) {
std::shared_ptr<WalletRequest> request = makeGetRandomOutsRequest(context);
return request;
}
return doSendTransaction(context, events);
}
std::shared_ptr<WalletRequest> WalletTransactionSender::makeSendDustRequest(
TransactionId &transactionId,
std::deque<std::shared_ptr<WalletLegacyEvent>> &events,
const std::vector<WalletLegacyTransfer> &transfers,
uint64_t fee,
const std::string &extra,
uint64_t mixIn,
uint64_t unlockTimestamp)
{
using namespace CryptoNote;
throwIf(transfers.empty(), error::ZERO_DESTINATION);
validateTransfersAddresses(transfers);
uint64_t neededMoney = countNeededMoney(fee, transfers);
std::shared_ptr<SendTransactionContext> context = std::make_shared<SendTransactionContext>();
context->foundMoney = selectDustTransfersToSend(
neededMoney,
m_currency.defaultDustThreshold(),
context->selectedTransfers
);
throwIf(context->foundMoney < neededMoney, error::WRONG_AMOUNT);
transactionId = m_transactionsCache.addNewTransaction(
neededMoney,
fee,
extra,
transfers,
unlockTimestamp
);
context->transactionId = transactionId;
context->mixIn = mixIn;
if (context->mixIn) {
std::shared_ptr<WalletRequest> request = makeGetRandomOutsRequest(context);
return request;
}
return doSendTransaction(context, events);
}
std::shared_ptr<WalletRequest> WalletTransactionSender::makeSendFusionRequest(
TransactionId &transactionId,
std::deque<std::shared_ptr<WalletLegacyEvent>> &events,
const std::vector<WalletLegacyTransfer> &transfers,
const std::list<TransactionOutputInformation> &fusionInputs,
uint64_t fee,
const std::string &extra,
uint64_t mixIn,
uint64_t unlockTimestamp)
{
using namespace CryptoNote;
throwIf(transfers.empty(), error::ZERO_DESTINATION);
validateTransfersAddresses(transfers);
uint64_t neededMoney = countNeededMoney(fee, transfers);
std::shared_ptr<SendTransactionContext> context = std::make_shared<SendTransactionContext>();
for (auto &out : fusionInputs) {
context->foundMoney += out.amount;
}
throwIf(context->foundMoney < neededMoney, error::WRONG_AMOUNT);
context->selectedTransfers = fusionInputs;
transactionId = m_transactionsCache.addNewTransaction(
neededMoney,
fee,
extra,
transfers,
unlockTimestamp
);
context->transactionId = transactionId;
context->mixIn = mixIn;
if (context->mixIn) {
std::shared_ptr<WalletRequest> request = makeGetRandomOutsRequest(context);
return request;
}
return doSendTransaction(context, events);
}
std::shared_ptr<WalletRequest> WalletTransactionSender::makeGetRandomOutsRequest(
std::shared_ptr<SendTransactionContext> context)
{
// add one to make possible (if need) to skip real output key
uint64_t outsCount = context->mixIn + 1;
std::vector<uint64_t> amounts;
for (const auto &td : context->selectedTransfers) {
amounts.push_back(td.amount);
}
return std::make_shared<WalletGetRandomOutsByAmountsRequest>(
amounts,
outsCount,
context,
std::bind(
&WalletTransactionSender::sendTransactionRandomOutsByAmount,
this,
context,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3
)
);
}
void WalletTransactionSender::sendTransactionRandomOutsByAmount(
std::shared_ptr<SendTransactionContext> context,
std::deque<std::shared_ptr<WalletLegacyEvent>> &events,
boost::optional<std::shared_ptr<WalletRequest>> &nextRequest,
std::error_code ec)
{
if (m_isStoping) {
ec = make_error_code(error::TX_CANCELLED);
}
if (ec) {
events.push_back(makeCompleteEvent(m_transactionsCache, context->transactionId, ec));
return;
}
auto scanty_it = std::find_if(
context->outs.begin(),
context->outs.end(),
[&](COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount& out) {
return out.outs.size() < context->mixIn;
}
);
if (scanty_it != context->outs.end()) {
events.push_back(makeCompleteEvent(
m_transactionsCache,
context->transactionId,
make_error_code(error::MIXIN_COUNT_TOO_BIG)
));
return;
}
std::shared_ptr<WalletRequest> req = doSendTransaction(context, events);
if (req) {
nextRequest = req;
}
}
std::shared_ptr<WalletRequest> WalletTransactionSender::doSendTransaction(
std::shared_ptr<SendTransactionContext> context,
std::deque<std::shared_ptr<WalletLegacyEvent>> &events)
{
if (m_isStoping) {
events.push_back(makeCompleteEvent(
m_transactionsCache,
context->transactionId,
make_error_code(error::TX_CANCELLED))
);
return std::shared_ptr<WalletRequest>();
}
try {
WalletLegacyTransaction &transaction =
m_transactionsCache.getTransaction(context->transactionId);
std::vector<TransactionSourceEntry> sources;
prepareInputs(context->selectedTransfers, context->outs, sources, context->mixIn);
TransactionDestinationEntry changeDts;
changeDts.amount = 0;
uint64_t totalAmount = -transaction.totalAmount;
createChangeDestinations(m_keys.address, totalAmount, context->foundMoney, changeDts);
std::vector<TransactionDestinationEntry> splittedDests;
splitDestinations(
transaction.firstTransferId,
transaction.transferCount,
changeDts,
context->dustPolicy,
splittedDests
);
Transaction tx;
constructTx(
m_keys,
sources,
splittedDests,
transaction.extra,
transaction.unlockTime,
m_upperTransactionSizeLimit,
tx,
context->messages,
context->ttl,
context->sender,
context->tx_key
);
getObjectHash(tx, transaction.hash);
m_transactionsCache.updateTransaction(
context->transactionId,
tx,
totalAmount,
context->selectedTransfers,
context->tx_key
);
notifyBalanceChanged(events);
return std::make_shared<WalletRelayTransactionRequest>(
tx,
std::bind(
&WalletTransactionSender::relayTransactionCallback,
this,
context,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3
)
);
} catch(std::system_error &ec) {
events.push_back(makeCompleteEvent(m_transactionsCache, context->transactionId, ec.code()));
} catch(std::exception &) {
events.push_back(makeCompleteEvent(
m_transactionsCache,
context->transactionId,
make_error_code(error::INTERNAL_WALLET_ERROR))
);
}
return std::shared_ptr<WalletRequest>();
}
void WalletTransactionSender::relayTransactionCallback(
std::shared_ptr<SendTransactionContext> context,
std::deque<std::shared_ptr<WalletLegacyEvent>> &events,
boost::optional<std::shared_ptr<WalletRequest>> &nextRequest,
std::error_code ec)
{
if (m_isStoping) {
return;
}
events.push_back(makeCompleteEvent(m_transactionsCache, context->transactionId, ec));
}
void WalletTransactionSender::splitDestinations(
TransferId firstTransferId,
size_t transfersCount,
const TransactionDestinationEntry &changeDts,
const TxDustPolicy &dustPolicy,
std::vector<TransactionDestinationEntry> &splittedDests)
{
uint64_t dust = 0;
digitSplitStrategy(
firstTransferId,
transfersCount,
changeDts,
dustPolicy.dustThreshold,
splittedDests,
dust
);
throwIf(dustPolicy.dustThreshold < dust, error::INTERNAL_WALLET_ERROR);
if (0 != dust && !dustPolicy.addToFee) {
splittedDests.push_back(TransactionDestinationEntry(dust, dustPolicy.addrForDust));
}
}
void WalletTransactionSender::digitSplitStrategy(
TransferId firstTransferId,
size_t transfersCount,
const TransactionDestinationEntry &change_dst,
uint64_t dust_threshold,
std::vector<TransactionDestinationEntry> &splitted_dsts,
uint64_t &dust)
{
splitted_dsts.clear();
dust = 0;
for (TransferId idx = firstTransferId; idx < firstTransferId + transfersCount; ++idx) {
WalletLegacyTransfer& de = m_transactionsCache.getTransfer(idx);
AccountPublicAddress addr;
if (!m_currency.parseAccountAddressString(de.address, addr)) {
throw std::system_error(make_error_code(error::BAD_ADDRESS));
}
decompose_amount_into_digits(
de.amount,
dust_threshold,
[&](uint64_t chunk) {
splitted_dsts.push_back(TransactionDestinationEntry(chunk, addr));
},
[&](uint64_t a_dust) {
splitted_dsts.push_back(TransactionDestinationEntry(a_dust, addr));
}
);
}
decompose_amount_into_digits(
change_dst.amount,
dust_threshold,
[&](uint64_t chunk) {
splitted_dsts.push_back(TransactionDestinationEntry(chunk, change_dst.addr));
},
[&](uint64_t a_dust) {
dust = a_dust;
}
);
}
void WalletTransactionSender::prepareInputs(
const std::list<TransactionOutputInformation> &selectedTransfers,
std::vector<COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount> &outs,
std::vector<TransactionSourceEntry> &sources,
uint64_t mixIn)
{
size_t i = 0;
for (const auto &td : selectedTransfers) {
sources.resize(sources.size() + 1);
TransactionSourceEntry &src = sources.back();
src.amount = td.amount;
// paste mixin transaction
if(!outs.empty()) {
std::sort(
outs[i].outs.begin(),
outs[i].outs.end(),
[](const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::out_entry &a,
const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::out_entry &b) {
return a.global_amount_index < b.global_amount_index;
}
);
for (auto &daemon_oe : outs[i].outs) {
if(td.globalOutputIndex == daemon_oe.global_amount_index) {
continue;
}
TransactionSourceEntry::OutputEntry oe;
oe.first = static_cast<uint32_t>(daemon_oe.global_amount_index);
oe.second = daemon_oe.out_key;
src.outputs.push_back(oe);
if(src.outputs.size() >= mixIn) {
break;
}
}
}
// paste real transaction to the random index
auto it_to_insert = std::find_if(
src.outputs.begin(),
src.outputs.end(),
[&](const TransactionSourceEntry::OutputEntry &a) {
return a.first >= td.globalOutputIndex;
}
);
TransactionSourceEntry::OutputEntry real_oe;
real_oe.first = td.globalOutputIndex;
real_oe.second = td.outputKey;
auto interted_it = src.outputs.insert(it_to_insert, real_oe);
src.realTransactionPublicKey = td.transactionPublicKey;
src.realOutput = interted_it - src.outputs.begin();
src.realOutputIndexInTransaction = td.outputInTransaction;
++i;
}
}
void WalletTransactionSender::notifyBalanceChanged(
std::deque<std::shared_ptr<WalletLegacyEvent>> &events)
{
uint64_t unconfirmedOutsAmount = m_transactionsCache.unconfrimedOutsAmount();
uint64_t change = unconfirmedOutsAmount - m_transactionsCache.unconfirmedTransactionsAmount();
uint64_t actualBalance = m_transferDetails.balance(ITransfersContainer::IncludeKeyUnlocked)
- unconfirmedOutsAmount;
uint64_t pendingBalance = m_transferDetails.balance(ITransfersContainer::IncludeKeyNotUnlocked)
+ change;
events.push_back(std::make_shared<WalletActualBalanceUpdatedEvent>(actualBalance));
events.push_back(std::make_shared<WalletPendingBalanceUpdatedEvent>(pendingBalance));
}
namespace {
template<typename URNG, typename T>
T popRandomValue(URNG &randomGenerator, std::vector<T> &vec)
{
assert(!vec.empty());
if (vec.empty()) {
return T();
}
std::uniform_int_distribution<size_t> distribution(0, vec.size() - 1);
size_t idx = distribution(randomGenerator);
T res = vec[idx];
if (idx + 1 != vec.size()) {
vec[idx] = vec.back();
}
vec.resize(vec.size() - 1);
return res;
}
} // namespace
uint64_t WalletTransactionSender::selectTransfersToSend(
uint64_t neededMoney,
bool addDust,
uint64_t dust,
std::list<TransactionOutputInformation> &selectedTransfers)
{
std::vector<size_t> unusedTransfers;
std::vector<size_t> unusedDust;
std::vector<size_t> unusedUnmixable;
std::vector<TransactionOutputInformation> outputs;
m_transferDetails.getOutputs(outputs, ITransfersContainer::IncludeKeyUnlocked);
for (size_t i = 0; i < outputs.size(); ++i) {
const auto &out = outputs[i];
if (!m_transactionsCache.isUsed(out)) {
if (is_valid_decomposed_amount(out.amount)) {
if (dust < out.amount) {
unusedTransfers.push_back(i);
} else {
unusedDust.push_back(i);
}
} else {
unusedUnmixable.push_back(i);
}
}
}
std::default_random_engine randomGenerator(
Crypto::rand<std::default_random_engine::result_type>()
);
bool selectOneUnmixable = addDust && !unusedUnmixable.empty();
uint64_t foundMoney = 0;
while (foundMoney < neededMoney
&& (!unusedTransfers.empty() || !unusedDust.empty() || !unusedUnmixable.empty())) {
size_t idx;
if (selectOneUnmixable) {
idx = popRandomValue(randomGenerator, unusedUnmixable);
selectOneUnmixable = false;
} else {
idx = !unusedTransfers.empty() ? popRandomValue(randomGenerator, unusedTransfers)
: popRandomValue(randomGenerator, unusedDust);
}
selectedTransfers.push_back(outputs[idx]);
foundMoney += outputs[idx].amount;
}
return foundMoney;
}
uint64_t WalletTransactionSender::selectDustTransfersToSend(
uint64_t neededMoney,
uint64_t dust,
std::list<TransactionOutputInformation> &selectedTransfers)
{
std::vector<size_t> unusedTransfers;
std::vector<size_t> unusedDust;
std::vector<size_t> unusedUnmixable;
uint64_t neededUnmixable = 0;
std::vector<TransactionOutputInformation> outputs;
m_transferDetails.getOutputs(outputs, ITransfersContainer::IncludeKeyUnlocked);
for (size_t i = 0; i < outputs.size(); ++i) {
const auto &out = outputs[i];
if (!m_transactionsCache.isUsed(out)) {
if (is_valid_decomposed_amount(out.amount)) {
if (dust < out.amount) {
unusedTransfers.push_back(i);
} else {
unusedDust.push_back(i);
}
} else {
unusedUnmixable.push_back(i);
neededUnmixable += out.amount;
}
}
}
std::default_random_engine randomGenerator(
Crypto::rand<std::default_random_engine::result_type>()
);
uint64_t foundMoney = 0;
// Sweep unmixable
if (!unusedUnmixable.empty()) {
while (foundMoney < neededUnmixable && !unusedUnmixable.empty()) {
size_t idx;
idx = popRandomValue(randomGenerator, unusedUnmixable);
foundMoney += outputs[idx].amount;
selectedTransfers.push_back(outputs[idx]);
}
}
// Sweep dust
if (foundMoney < neededMoney) {
while (foundMoney < neededMoney && !unusedDust.empty()) {
size_t idx;
idx = popRandomValue(randomGenerator, unusedDust);
selectedTransfers.push_back(outputs[idx]);
foundMoney += outputs[idx].amount;
}
}
// Optimize larger amounts if needed
if (foundMoney < neededMoney) {
while (foundMoney < neededMoney && !unusedTransfers.empty()) {
size_t idx;
idx = popRandomValue(randomGenerator, unusedTransfers);
selectedTransfers.push_back(outputs[idx]);
foundMoney += outputs[idx].amount;
}
}
return foundMoney;
}
} // namespace CryptoNote
| 31.248313 | 100 | 0.657094 | [
"vector"
] |
24a5199e24d4a90fa1f7bd78b11a1d105c2da1b6 | 3,312 | cpp | C++ | CF/div2.E/726.1.cpp | klxu03/CompetitiveProgramming | fd83200b5c8af3542fb639d504e3948427f69efc | [
"MIT"
] | null | null | null | CF/div2.E/726.1.cpp | klxu03/CompetitiveProgramming | fd83200b5c8af3542fb639d504e3948427f69efc | [
"MIT"
] | null | null | null | CF/div2.E/726.1.cpp | klxu03/CompetitiveProgramming | fd83200b5c8af3542fb639d504e3948427f69efc | [
"MIT"
] | null | null | null | // Problem: https://codeforces.com/contest/1537/problem/E1
#include <bits/stdc++.h>
using namespace std;
#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a, b, c) max(a, max(b, c))
#define pb push_back
#define f first
#define s second
#define mp(a, b) make_pair(a, b)
using ll = long long;
/* Print a vector */
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "[";for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];}return cout << "]";}
/* For Debugging Purposes */
#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define DEBUG(...) 6
#endif
template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template <typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i=0, b=0; i<(int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++;
else if (s[i] == ')' || s[i] == '}') b--; else if (s[i] == ',' && b == 0) {cerr << s.substr(0, i) << " = " << x << " | "; debug(s.substr(s.find_first_not_of(' ', i + 1)), args...); break;}}
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n, q, Q, T, t, k, l, r, x, y, z, g;
int main() {
io;
cin >> n >> k;
string s;
cin >> s;
DEBUG(s, s[s.length() - 1], 'a' < 'c', true);
ll s_length = 1;
s += s; // Double the string length now so I can always compare left and right side without it going out of bounds on the right side with total string being 10 long, and string A being 6 long and B being 4 long. Now total string is 20 long, so it can go all the way to 10 and 10
while (true) {
DEBUG(s_length, s.substr(0, s_length), s.substr(s_length, s_length));
// Brute force method of doing the bottom part
// string leftSide = s.substr(0, s_length);
// string rightSide = s.substr(s_length, s_length);
// if (leftSide >= rightSide && s_length < s.length()/2) {
// s_length++;
// } else {
// break;
// }
// Better way of doing the top part without taking up so much string memory
bool condition = true;
f0r(i, s_length) {
if (s[i] > s[i + s_length]) {
break;
} else if (s[i] < s[i + s_length]) {
condition = false;
}
}
if (condition && s_length < s.length()/2) {
s_length++;
} else {
break;
}
}
s = s.substr(0, s_length);
// Prune out the ending substrings that are exactly the same as the first part
s_length = s.length();
string og_string = s;
f0r(i, k/s_length + 1) {
s += og_string;
}
s = s.substr(0, k);
cout << s;
} | 36.395604 | 282 | 0.548007 | [
"vector"
] |
24ac9f3a954a867614727627d3857e85d2a934f5 | 47,129 | cc | C++ | src/reader/wgsl/parser_impl_error_msg_test.cc | jhanssen/tint | 30c1f25a7a4e180419444c12046348edb0f8fdd0 | [
"Apache-2.0"
] | null | null | null | src/reader/wgsl/parser_impl_error_msg_test.cc | jhanssen/tint | 30c1f25a7a4e180419444c12046348edb0f8fdd0 | [
"Apache-2.0"
] | null | null | null | src/reader/wgsl/parser_impl_error_msg_test.cc | jhanssen/tint | 30c1f25a7a4e180419444c12046348edb0f8fdd0 | [
"Apache-2.0"
] | null | null | null | // Copyright 2020 The Tint 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.
#include "gtest/gtest.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
namespace tint {
namespace reader {
namespace wgsl {
namespace {
const diag::Formatter::Style formatter_style{
/* print_file: */ true, /* print_severity: */ true,
/* print_line: */ true, /* print_newline_at_end: */ false};
class ParserImplErrorTest : public ParserImplTest {};
#define EXPECT(SOURCE, EXPECTED) \
do { \
std::string source = SOURCE; \
std::string expected = EXPECTED; \
auto p = parser(source); \
p->set_max_errors(5); \
EXPECT_EQ(false, p->Parse()); \
EXPECT_EQ(true, p->diagnostics().contains_errors()); \
EXPECT_EQ(expected, \
diag::Formatter(formatter_style).format(p->diagnostics())); \
} while (false)
TEST_F(ParserImplErrorTest, AdditiveInvalidExpr) {
EXPECT("fn f() -> void { return 1.0 + <; }",
"test.wgsl:1:31 error: unable to parse right side of + expression\n"
"fn f() -> void { return 1.0 + <; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, AndInvalidExpr) {
EXPECT("fn f() -> void { return 1 & >; }",
"test.wgsl:1:29 error: unable to parse right side of & expression\n"
"fn f() -> void { return 1 & >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ArrayIndexExprInvalidExpr) {
EXPECT("fn f() -> void { x = y[^]; }",
"test.wgsl:1:24 error: unable to parse expression inside []\n"
"fn f() -> void { x = y[^]; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ArrayIndexExprMissingRBracket) {
EXPECT("fn f() -> void { x = y[1; }",
"test.wgsl:1:25 error: expected ']' for array accessor\n"
"fn f() -> void { x = y[1; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, AssignmentStmtMissingAssignment) {
EXPECT("fn f() -> void { a; }",
"test.wgsl:1:19 error: expected '=' for assignment\n"
"fn f() -> void { a; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, AssignmentStmtMissingAssignment2) {
EXPECT("fn f() -> void { a : i32; }",
"test.wgsl:1:18 error: expected 'var' for variable declaration\n"
"fn f() -> void { a : i32; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, AssignmentStmtMissingSemicolon) {
EXPECT("fn f() -> void { a = 1 }",
"test.wgsl:1:24 error: expected ';' for assignment statement\n"
"fn f() -> void { a = 1 }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, AssignmentStmtInvalidRHS) {
EXPECT("fn f() -> void { a = >; }",
"test.wgsl:1:22 error: unable to parse right side of assignment\n"
"fn f() -> void { a = >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, BitcastExprMissingLessThan) {
EXPECT("fn f() -> void { x = bitcast(y); }",
"test.wgsl:1:29 error: expected '<' for bitcast expression\n"
"fn f() -> void { x = bitcast(y); }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, BitcastExprMissingGreaterThan) {
EXPECT("fn f() -> void { x = bitcast<u32(y); }",
"test.wgsl:1:33 error: expected '>' for bitcast expression\n"
"fn f() -> void { x = bitcast<u32(y); }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, BitcastExprMissingType) {
EXPECT("fn f() -> void { x = bitcast<>(y); }",
"test.wgsl:1:30 error: invalid type for bitcast expression\n"
"fn f() -> void { x = bitcast<>(y); }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, BreakStmtMissingSemicolon) {
EXPECT("fn f() -> void { loop { break } }",
"test.wgsl:1:31 error: expected ';' for break statement\n"
"fn f() -> void { loop { break } }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, CallExprMissingRParen) {
EXPECT("fn f() -> void { x = f(1.; }",
"test.wgsl:1:26 error: expected ')' for call expression\n"
"fn f() -> void { x = f(1.; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, CallStmtMissingRParen) {
EXPECT("fn f() -> void { f(1.; }",
"test.wgsl:1:22 error: expected ')' for call statement\n"
"fn f() -> void { f(1.; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, CallStmtInvalidArgument0) {
EXPECT("fn f() -> void { f(<); }",
"test.wgsl:1:20 error: unable to parse argument expression\n"
"fn f() -> void { f(<); }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, CallStmtInvalidArgument1) {
EXPECT(
"fn f() -> void { f(1.0, <); }",
"test.wgsl:1:25 error: unable to parse argument expression after comma\n"
"fn f() -> void { f(1.0, <); }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, CallStmtMissingSemicolon) {
EXPECT("fn f() -> void { f() }",
"test.wgsl:1:22 error: expected ';' for function call\n"
"fn f() -> void { f() }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ConstructorExprMissingLParen) {
EXPECT("fn f() -> void { x = vec2<u32>1,2); }",
"test.wgsl:1:31 error: expected '(' for type constructor\n"
"fn f() -> void { x = vec2<u32>1,2); }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ConstructorExprMissingRParen) {
EXPECT("fn f() -> void { x = vec2<u32>(1,2; }",
"test.wgsl:1:35 error: expected ')' for type constructor\n"
"fn f() -> void { x = vec2<u32>(1,2; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ConstVarStmtInvalid) {
EXPECT("fn f() -> void { const >; }",
"test.wgsl:1:24 error: expected identifier for constant declaration\n"
"fn f() -> void { const >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ConstVarStmtMissingAssignment) {
EXPECT("fn f() -> void { const a : i32; }",
"test.wgsl:1:31 error: expected '=' for constant declaration\n"
"fn f() -> void { const a : i32; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ConstVarStmtMissingConstructor) {
EXPECT("fn f() -> void { const a : i32 = >; }",
"test.wgsl:1:34 error: missing constructor for const declaration\n"
"fn f() -> void { const a : i32 = >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ContinueStmtMissingSemicolon) {
EXPECT("fn f() -> void { loop { continue } }",
"test.wgsl:1:34 error: expected ';' for continue statement\n"
"fn f() -> void { loop { continue } }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, DiscardStmtMissingSemicolon) {
EXPECT("fn f() -> void { discard }",
"test.wgsl:1:26 error: expected ';' for discard statement\n"
"fn f() -> void { discard }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, EqualityInvalidExpr) {
EXPECT("fn f() -> void { return 1 == >; }",
"test.wgsl:1:30 error: unable to parse right side of == expression\n"
"fn f() -> void { return 1 == >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FloatLiteralSuffixedWithF) {
EXPECT("var f : f32 = 1.23f;",
"test.wgsl:1:19 error: float literals must not be suffixed with 'f'\n"
"var f : f32 = 1.23f;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ForLoopInitializerMissingSemicolon) {
EXPECT("fn f() -> void { for (var i : i32 = 0 i < 8; i=i+1) {} }",
"test.wgsl:1:39 error: expected ';' for initializer in for loop\n"
"fn f() -> void { for (var i : i32 = 0 i < 8; i=i+1) {} }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ForLoopInitializerMissingVar) {
EXPECT("fn f() -> void { for (i : i32 = 0; i < 8; i=i+1) {} }",
"test.wgsl:1:23 error: expected 'var' for variable declaration\n"
"fn f() -> void { for (i : i32 = 0; i < 8; i=i+1) {} }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ForLoopConditionMissingSemicolon) {
EXPECT("fn f() -> void { for (var i : i32 = 0; i < 8 i=i+1) {} }",
"test.wgsl:1:46 error: expected ';' for condition in for loop\n"
"fn f() -> void { for (var i : i32 = 0; i < 8 i=i+1) {} }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ForLoopMissingLParen) {
EXPECT("fn f() -> void { for var i : i32 = 0; i < 8; i=i+1) {} }",
"test.wgsl:1:22 error: expected '(' for for loop\n"
"fn f() -> void { for var i : i32 = 0; i < 8; i=i+1) {} }\n"
" ^^^\n");
}
TEST_F(ParserImplErrorTest, ForLoopMissingRParen) {
EXPECT("fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1 {} }",
"test.wgsl:1:53 error: expected ')' for for loop\n"
"fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1 {} }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ForLoopMissingLBrace) {
EXPECT("fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) }",
"test.wgsl:1:54 error: expected '{' for for loop\n"
"fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ForLoopMissingRBrace) {
EXPECT("fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) {",
"test.wgsl:1:55 error: expected '}' for for loop\n"
"fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) {\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclInvalid) {
EXPECT("[[stage(vertex)]] x;",
"test.wgsl:1:19 error: expected declaration after decorations\n"
"[[stage(vertex)]] x;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoMissingEnd) {
EXPECT("[[stage(vertex) fn f() -> void {}",
"test.wgsl:1:17 error: expected ']]' for decoration list\n"
"[[stage(vertex) fn f() -> void {}\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoStageMissingLParen) {
EXPECT("[[stage vertex]] fn f() -> void {}",
"test.wgsl:1:9 error: expected '(' for stage decoration\n"
"[[stage vertex]] fn f() -> void {}\n"
" ^^^^^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoStageMissingRParen) {
EXPECT("[[stage(vertex]] fn f() -> void {}",
"test.wgsl:1:15 error: expected ')' for stage decoration\n"
"[[stage(vertex]] fn f() -> void {}\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoStageInvalid) {
EXPECT("[[stage(x)]] fn f() -> void {}",
"test.wgsl:1:9 error: invalid value for stage decoration\n"
"[[stage(x)]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoStageTypeInvalid) {
EXPECT("[[shader(vertex)]] fn main() -> void {}",
"test.wgsl:1:3 error: expected decoration\n"
"[[shader(vertex)]] fn main() -> void {}\n"
" ^^^^^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeMissingLParen) {
EXPECT("[[workgroup_size 1]] fn f() -> void {}",
"test.wgsl:1:18 error: expected '(' for workgroup_size decoration\n"
"[[workgroup_size 1]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeMissingRParen) {
EXPECT("[[workgroup_size(1]] fn f() -> void {}",
"test.wgsl:1:19 error: expected ')' for workgroup_size decoration\n"
"[[workgroup_size(1]] fn f() -> void {}\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeXInvalid) {
EXPECT("[[workgroup_size(x)]] fn f() -> void {}",
"test.wgsl:1:18 error: expected signed integer literal for "
"workgroup_size x parameter\n"
"[[workgroup_size(x)]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeXNegative) {
EXPECT("[[workgroup_size(-1)]] fn f() -> void {}",
"test.wgsl:1:18 error: workgroup_size x parameter must be greater "
"than 0\n"
"[[workgroup_size(-1)]] fn f() -> void {}\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeXZero) {
EXPECT("[[workgroup_size(0)]] fn f() -> void {}",
"test.wgsl:1:18 error: workgroup_size x parameter must be greater "
"than 0\n"
"[[workgroup_size(0)]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeYInvalid) {
EXPECT("[[workgroup_size(1, x)]] fn f() -> void {}",
"test.wgsl:1:21 error: expected signed integer literal for "
"workgroup_size y parameter\n"
"[[workgroup_size(1, x)]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeYNegative) {
EXPECT("[[workgroup_size(1, -1)]] fn f() -> void {}",
"test.wgsl:1:21 error: workgroup_size y parameter must be greater "
"than 0\n"
"[[workgroup_size(1, -1)]] fn f() -> void {}\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeYZero) {
EXPECT("[[workgroup_size(1, 0)]] fn f() -> void {}",
"test.wgsl:1:21 error: workgroup_size y parameter must be greater "
"than 0\n"
"[[workgroup_size(1, 0)]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeZInvalid) {
EXPECT("[[workgroup_size(1, 2, x)]] fn f() -> void {}",
"test.wgsl:1:24 error: expected signed integer literal for "
"workgroup_size z parameter\n"
"[[workgroup_size(1, 2, x)]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeZNegative) {
EXPECT("[[workgroup_size(1, 2, -1)]] fn f() -> void {}",
"test.wgsl:1:24 error: workgroup_size z parameter must be greater "
"than 0\n"
"[[workgroup_size(1, 2, -1)]] fn f() -> void {}\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclDecoWorkgroupSizeZZero) {
EXPECT("[[workgroup_size(1, 2, 0)]] fn f() -> void {}",
"test.wgsl:1:24 error: workgroup_size z parameter must be greater "
"than 0\n"
"[[workgroup_size(1, 2, 0)]] fn f() -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclMissingIdentifier) {
EXPECT("fn () -> void {}",
"test.wgsl:1:4 error: expected identifier for function declaration\n"
"fn () -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclMissingLParen) {
EXPECT("fn f) -> void {}",
"test.wgsl:1:5 error: expected '(' for function declaration\n"
"fn f) -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclMissingRParen) {
EXPECT("fn f( -> void {}",
"test.wgsl:1:7 error: expected ')' for function declaration\n"
"fn f( -> void {}\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclMissingArrow) {
EXPECT("fn f() void {}",
"test.wgsl:1:8 error: expected '->' for function declaration\n"
"fn f() void {}\n"
" ^^^^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclInvalidReturnType) {
EXPECT("fn f() -> 1 {}",
"test.wgsl:1:11 error: unable to determine function return type\n"
"fn f() -> 1 {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclParamMissingColon) {
EXPECT("fn f(x) -> void {}",
"test.wgsl:1:7 error: expected ':' for parameter\n"
"fn f(x) -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclParamInvalidType) {
EXPECT("fn f(x : 1) -> void {}",
"test.wgsl:1:10 error: invalid type for parameter\n"
"fn f(x : 1) -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclParamMissing) {
EXPECT("fn f(x : i32, ) -> void {}",
"test.wgsl:1:15 error: expected identifier for parameter\n"
"fn f(x : i32, ) -> void {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclMissingLBrace) {
EXPECT("fn f() -> void }",
"test.wgsl:1:16 error: expected '{'\n"
"fn f() -> void }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionDeclMissingRBrace) {
EXPECT("fn f() -> void {",
"test.wgsl:1:17 error: expected '}'\n"
"fn f() -> void {\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, FunctionMissingOpenLine) {
EXPECT(R"(const bar : vec2<f32> = vec2<f32>(1., 2.);
var a : f32 = bar[0];
return;
})",
"test.wgsl:2:17 error: unknown constructed type 'bar'\n"
" var a : f32 = bar[0];\n"
" ^^^\n"
"\n"
"test.wgsl:3:3 error: statement found outside of function body\n"
" return;\n"
" ^^^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstInvalidIdentifier) {
EXPECT("const ^ : i32 = 1;",
"test.wgsl:1:7 error: expected identifier for constant declaration\n"
"const ^ : i32 = 1;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstMissingSemicolon) {
EXPECT("const i : i32 = 1",
"test.wgsl:1:18 error: expected ';' for constant declaration\n"
"const i : i32 = 1\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstMissingLParen) {
EXPECT("const i : vec2<i32> = vec2<i32>;",
"test.wgsl:1:32 error: expected '(' for type constructor\n"
"const i : vec2<i32> = vec2<i32>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstMissingRParen) {
EXPECT("const i : vec2<i32> = vec2<i32>(1., 2.;",
"test.wgsl:1:39 error: expected ')' for type constructor\n"
"const i : vec2<i32> = vec2<i32>(1., 2.;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstMissingAssignment) {
EXPECT("const i : vec2<i32>;",
"test.wgsl:1:20 error: expected '=' for constant declaration\n"
"const i : vec2<i32>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstBadConstLiteral) {
EXPECT("const i : vec2<i32> = vec2<i32>(!);",
"test.wgsl:1:33 error: unable to parse const literal\n"
"const i : vec2<i32> = vec2<i32>(!);\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMaxDepth) {
uint32_t kMaxConstExprDepth = 128;
std::stringstream src;
std::stringstream mkr;
src << "const i : i32 = ";
mkr << " ";
for (size_t i = 0; i < kMaxConstExprDepth + 8; i++) {
src << "f32(";
if (i < kMaxConstExprDepth + 1) {
mkr << " ";
} else if (i == kMaxConstExprDepth + 1) {
mkr << "^^^";
}
}
src << "1.0";
for (size_t i = 0; i < 200; i++) {
src << ")";
}
src << ";";
std::stringstream err;
err << "test.wgsl:1:533 error: max const_expr depth reached\n"
<< src.str() << "\n"
<< mkr.str() << "\n";
EXPECT(src.str().c_str(), err.str().c_str());
}
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMissingLParen) {
EXPECT("const i : vec2<i32> = vec2<i32> 1, 2);",
"test.wgsl:1:33 error: expected '(' for type constructor\n"
"const i : vec2<i32> = vec2<i32> 1, 2);\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclConstExprMissingRParen) {
EXPECT("const i : vec2<i32> = vec2<i32>(1, 2;",
"test.wgsl:1:37 error: expected ')' for type constructor\n"
"const i : vec2<i32> = vec2<i32>(1, 2;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclSampledTextureMissingLessThan) {
EXPECT("var x : texture_1d;",
"test.wgsl:1:19 error: expected '<' for sampled texture type\n"
"var x : texture_1d;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclSampledTextureMissingGreaterThan) {
EXPECT("var x : texture_1d<f32;",
"test.wgsl:1:23 error: expected '>' for sampled texture type\n"
"var x : texture_1d<f32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclSampledTextureInvalidSubtype) {
EXPECT("var x : texture_1d<1>;",
"test.wgsl:1:20 error: invalid type for sampled texture type\n"
"var x : texture_1d<1>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclMultisampledTextureMissingLessThan) {
EXPECT("var x : texture_multisampled_2d;",
"test.wgsl:1:32 error: expected '<' for multisampled texture type\n"
"var x : texture_multisampled_2d;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclMultisampledTextureMissingGreaterThan) {
EXPECT("var x : texture_multisampled_2d<f32;",
"test.wgsl:1:36 error: expected '>' for multisampled texture type\n"
"var x : texture_multisampled_2d<f32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclMultisampledTextureInvalidSubtype) {
EXPECT("var x : texture_multisampled_2d<1>;",
"test.wgsl:1:33 error: invalid type for multisampled texture type\n"
"var x : texture_multisampled_2d<1>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingLessThan) {
EXPECT("var x : [[access(read)]] texture_storage_2d;",
"test.wgsl:1:44 error: expected '<' for storage texture type\n"
"var x : [[access(read)]] texture_storage_2d;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingGreaterThan) {
EXPECT("var x : [[access(read)]] texture_storage_2d<r8uint;",
"test.wgsl:1:51 error: expected '>' for storage texture type\n"
"var x : [[access(read)]] texture_storage_2d<r8uint;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingSubtype) {
EXPECT("var x : [[access(read)]] texture_storage_2d<>;",
"test.wgsl:1:45 error: invalid format for storage texture type\n"
"var x : [[access(read)]] texture_storage_2d<>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingInvalidSubtype) {
EXPECT("var x : [[access(read)]] texture_storage_2d<1>;",
"test.wgsl:1:45 error: invalid format for storage texture type\n"
"var x : [[access(read)]] texture_storage_2d<1>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructDecoMissingStruct) {
EXPECT("[[block]];",
"test.wgsl:1:10 error: expected declaration after decorations\n"
"[[block]];\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructDecoMissingEnd) {
EXPECT("[[block struct {};",
"test.wgsl:1:9 error: expected ']]' for decoration list\n"
"[[block struct {};\n"
" ^^^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructDeclMissingIdentifier) {
EXPECT("struct {};",
"test.wgsl:1:8 error: expected identifier for struct declaration\n"
"struct {};\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructDeclMissingSemicolon) {
EXPECT("struct S {}",
"test.wgsl:1:12 error: expected ';' for struct declaration\n"
"struct S {}\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructDeclMissingLBrace) {
EXPECT("struct S };",
"test.wgsl:1:10 error: expected '{' for struct declaration\n"
"struct S };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructDeclMissingRBrace) {
EXPECT("struct S { i : i32;",
"test.wgsl:1:20 error: expected '}' for struct declaration\n"
"struct S { i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberDecoEmpty) {
EXPECT("struct S { [[]] i : i32; };",
"test.wgsl:1:14 error: empty decoration list\n"
"struct S { [[]] i : i32; };\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberDecoMissingEnd) {
EXPECT("struct S { [[ i : i32; };",
"test.wgsl:1:15 error: expected decoration\n"
"struct S { [[ i : i32; };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberInvalidIdentifier) {
EXPECT("struct S { 1 : i32; };",
"test.wgsl:1:12 error: expected identifier for struct member\n"
"struct S { 1 : i32; };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberMissingSemicolon) {
EXPECT("struct S { i : i32 };",
"test.wgsl:1:20 error: expected ';' for struct member\n"
"struct S { i : i32 };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetMissingLParen) {
EXPECT("struct S { [[offset 1)]] i : i32; };",
"test.wgsl:1:21 error: expected '(' for offset decoration\n"
"struct S { [[offset 1)]] i : i32; };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetMissingRParen) {
EXPECT("struct S { [[offset(1]] i : i32; };",
"test.wgsl:1:22 error: expected ')' for offset decoration\n"
"struct S { [[offset(1]] i : i32; };\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetInvaldValue) {
EXPECT("struct S { [[offset(x)]] i : i32; };",
"test.wgsl:1:21 error: expected signed integer literal for offset "
"decoration\n"
"struct S { [[offset(x)]] i : i32; };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetNegativeValue) {
EXPECT("struct S { [[offset(-2)]] i : i32; };",
"test.wgsl:1:21 error: offset decoration must be positive\n"
"struct S { [[offset(-2)]] i : i32; };\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclTypeAliasMissingIdentifier) {
EXPECT("type 1 = f32;",
"test.wgsl:1:6 error: expected identifier for type alias\n"
"type 1 = f32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclTypeAliasInvalidType) {
EXPECT("type meow = 1;",
"test.wgsl:1:13 error: invalid type alias\n"
"type meow = 1;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclTypeAliasMissingAssignment) {
EXPECT("type meow f32",
"test.wgsl:1:11 error: expected '=' for type alias\n"
"type meow f32\n"
" ^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclTypeAliasMissingSemicolon) {
EXPECT("type meow = f32",
"test.wgsl:1:16 error: expected ';' for type alias\n"
"type meow = f32\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclTypeInvalid) {
EXPECT("var x : fish;",
"test.wgsl:1:9 error: unknown constructed type 'fish'\n"
"var x : fish;\n"
" ^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclTypeDecoInvalid) {
EXPECT("var x : [[]] i32;",
"test.wgsl:1:11 error: empty decoration list\n"
"var x : [[]] i32;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayMissingLessThan) {
EXPECT("var i : array;",
"test.wgsl:1:14 error: expected '<' for array declaration\n"
"var i : array;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayMissingGreaterThan) {
EXPECT("var i : array<u32, 3;",
"test.wgsl:1:21 error: expected '>' for array declaration\n"
"var i : array<u32, 3;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayDecoNotArray) {
EXPECT("var i : [[stride(1)]] i32;",
"test.wgsl:1:11 error: unexpected decorations\n"
"var i : [[stride(1)]] i32;\n"
" ^^^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayDecoMissingEnd) {
EXPECT("var i : [[stride(1) array<i32>;",
"test.wgsl:1:21 error: expected ']]' for decoration list\n"
"var i : [[stride(1) array<i32>;\n"
" ^^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayDecoStrideMissingLParen) {
EXPECT("var i : [[stride 1)]] array<i32>;",
"test.wgsl:1:18 error: expected '(' for stride decoration\n"
"var i : [[stride 1)]] array<i32>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayDecoStrideMissingRParen) {
EXPECT("var i : [[stride(1]] array<i32>;",
"test.wgsl:1:19 error: expected ')' for stride decoration\n"
"var i : [[stride(1]] array<i32>;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayDecoStrideInvalid) {
EXPECT("var i : [[stride(x)]] array<i32>;",
"test.wgsl:1:18 error: expected signed integer literal for stride "
"decoration\n"
"var i : [[stride(x)]] array<i32>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayDecoStrideNegative) {
EXPECT("var i : [[stride(-1)]] array<i32>;",
"test.wgsl:1:18 error: stride decoration must be greater than 0\n"
"var i : [[stride(-1)]] array<i32>;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayMissingType) {
EXPECT("var i : array<1, 3>;",
"test.wgsl:1:15 error: invalid type for array declaration\n"
"var i : array<1, 3>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayInvalidSize) {
EXPECT(
"var i : array<u32, x>;",
"test.wgsl:1:20 error: expected signed integer literal for array size\n"
"var i : array<u32, x>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarArrayNegativeSize) {
EXPECT("var i : array<u32, -3>;",
"test.wgsl:1:20 error: array size must be greater than 0\n"
"var i : array<u32, -3>;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoListEmpty) {
EXPECT("[[]] var i : i32;",
"test.wgsl:1:3 error: empty decoration list\n"
"[[]] var i : i32;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoListInvalid) {
EXPECT("[[location(1), meow]] var i : i32;",
"test.wgsl:1:16 error: expected decoration\n"
"[[location(1), meow]] var i : i32;\n"
" ^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoListMissingComma) {
EXPECT("[[location(1) group(2)]] var i : i32;",
"test.wgsl:1:15 error: expected ',' for decoration list\n"
"[[location(1) group(2)]] var i : i32;\n"
" ^^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoListMissingEnd) {
EXPECT("[[location(1) meow]] var i : i32;",
"test.wgsl:1:15 error: expected ']]' for decoration list\n"
"[[location(1) meow]] var i : i32;\n"
" ^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoLocationMissingLParen) {
EXPECT("[[location 1]] var i : i32;",
"test.wgsl:1:12 error: expected '(' for location decoration\n"
"[[location 1]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoLocationMissingRParen) {
EXPECT("[[location (1]] var i : i32;",
"test.wgsl:1:14 error: expected ')' for location decoration\n"
"[[location (1]] var i : i32;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoLocationInvalidValue) {
EXPECT("[[location(x)]] var i : i32;",
"test.wgsl:1:12 error: expected signed integer literal for location "
"decoration\n"
"[[location(x)]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBuiltinMissingLParen) {
EXPECT("[[builtin position]] var i : i32;",
"test.wgsl:1:11 error: expected '(' for builtin decoration\n"
"[[builtin position]] var i : i32;\n"
" ^^^^^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBuiltinMissingRParen) {
EXPECT("[[builtin(position]] var i : i32;",
"test.wgsl:1:19 error: expected ')' for builtin decoration\n"
"[[builtin(position]] var i : i32;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBuiltinInvalidIdentifer) {
EXPECT("[[builtin(1)]] var i : i32;",
"test.wgsl:1:11 error: expected identifier for builtin\n"
"[[builtin(1)]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBuiltinInvalidValue) {
EXPECT("[[builtin(x)]] var i : i32;",
"test.wgsl:1:11 error: invalid value for builtin decoration\n"
"[[builtin(x)]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBindingMissingLParen) {
EXPECT("[[binding 1]] var i : i32;",
"test.wgsl:1:11 error: expected '(' for binding decoration\n"
"[[binding 1]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBindingMissingRParen) {
EXPECT("[[binding(1]] var i : i32;",
"test.wgsl:1:12 error: expected ')' for binding decoration\n"
"[[binding(1]] var i : i32;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBindingInvalidValue) {
EXPECT("[[binding(x)]] var i : i32;",
"test.wgsl:1:11 error: expected signed integer literal for binding "
"decoration\n"
"[[binding(x)]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoGroupMissingLParen) {
EXPECT("[[group 1]] var i : i32;",
"test.wgsl:1:9 error: expected '(' for group decoration\n"
"[[group 1]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoGroupMissingRParen) {
EXPECT("[[group(1]] var i : i32;",
"test.wgsl:1:10 error: expected ')' for group decoration\n"
"[[group(1]] var i : i32;\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarDecoBindingGroupValue) {
EXPECT("[[group(x)]] var i : i32;",
"test.wgsl:1:9 error: expected signed integer literal for group "
"decoration\n"
"[[group(x)]] var i : i32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarInvalidIdentifier) {
EXPECT("var ^ : mat4x4;",
"test.wgsl:1:5 error: expected identifier for variable declaration\n"
"var ^ : mat4x4;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarMatrixMissingLessThan) {
EXPECT("var i : mat4x4;",
"test.wgsl:1:15 error: expected '<' for matrix\n"
"var i : mat4x4;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarMatrixMissingGreaterThan) {
EXPECT("var i : mat4x4<u32;",
"test.wgsl:1:19 error: expected '>' for matrix\n"
"var i : mat4x4<u32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarMatrixMissingType) {
EXPECT("var i : mat4x4<1>;",
"test.wgsl:1:16 error: invalid type for matrix\n"
"var i : mat4x4<1>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarMissingSemicolon) {
EXPECT("var i : i32",
"test.wgsl:1:12 error: expected ';' for variable declaration\n"
"var i : i32\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarPtrMissingLessThan) {
EXPECT("var i : ptr;",
"test.wgsl:1:12 error: expected '<' for ptr declaration\n"
"var i : ptr;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarPtrMissingGreaterThan) {
EXPECT("var i : ptr<in, u32;",
"test.wgsl:1:20 error: expected '>' for ptr declaration\n"
"var i : ptr<in, u32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarPtrMissingComma) {
EXPECT("var i : ptr<in u32>;",
"test.wgsl:1:16 error: expected ',' for ptr declaration\n"
"var i : ptr<in u32>;\n"
" ^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarPtrMissingStorageClass) {
EXPECT("var i : ptr<meow, u32>;",
"test.wgsl:1:13 error: invalid storage class for ptr declaration\n"
"var i : ptr<meow, u32>;\n"
" ^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarPtrMissingType) {
EXPECT("var i : ptr<in, 1>;",
"test.wgsl:1:17 error: invalid type for ptr declaration\n"
"var i : ptr<in, 1>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarStorageDeclInvalidClass) {
EXPECT("var<fish> i : i32",
"test.wgsl:1:5 error: invalid storage class for variable decoration\n"
"var<fish> i : i32\n"
" ^^^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarStorageDeclMissingGThan) {
EXPECT("var<in i : i32",
"test.wgsl:1:8 error: expected '>' for variable decoration\n"
"var<in i : i32\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarVectorMissingLessThan) {
EXPECT("var i : vec3;",
"test.wgsl:1:13 error: expected '<' for vector\n"
"var i : vec3;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarVectorMissingGreaterThan) {
EXPECT("var i : vec3<u32;",
"test.wgsl:1:17 error: expected '>' for vector\n"
"var i : vec3<u32;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclVarVectorMissingType) {
EXPECT("var i : vec3<1>;",
"test.wgsl:1:14 error: invalid type for vector\n"
"var i : vec3<1>;\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, IfStmtMissingLParen) {
EXPECT("fn f() -> void { if true) {} }",
"test.wgsl:1:21 error: expected '('\n"
"fn f() -> void { if true) {} }\n"
" ^^^^\n");
}
TEST_F(ParserImplErrorTest, IfStmtMissingRParen) {
EXPECT("fn f() -> void { if (true {} }",
"test.wgsl:1:27 error: expected ')'\n"
"fn f() -> void { if (true {} }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, IfStmtInvalidCond) {
EXPECT("fn f() -> void { if (>) {} }",
"test.wgsl:1:22 error: unable to parse expression\n"
"fn f() -> void { if (>) {} }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, LogicalAndInvalidExpr) {
EXPECT("fn f() -> void { return 1 && >; }",
"test.wgsl:1:30 error: unable to parse right side of && expression\n"
"fn f() -> void { return 1 && >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, LogicalOrInvalidExpr) {
EXPECT("fn f() -> void { return 1 || >; }",
"test.wgsl:1:30 error: unable to parse right side of || expression\n"
"fn f() -> void { return 1 || >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, LoopMissingLBrace) {
EXPECT("fn f() -> void { loop }",
"test.wgsl:1:23 error: expected '{' for loop\n"
"fn f() -> void { loop }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, LoopMissingRBrace) {
EXPECT("fn f() -> void { loop {",
"test.wgsl:1:24 error: expected '}' for loop\n"
"fn f() -> void { loop {\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, MaxErrorsReached) {
EXPECT("x; x; x; x; x; x; x; x;",
"test.wgsl:1:1 error: unexpected token\n"
"x; x; x; x; x; x; x; x;\n"
"^\n\n"
"test.wgsl:1:4 error: unexpected token\n"
"x; x; x; x; x; x; x; x;\n"
" ^\n\n"
"test.wgsl:1:7 error: unexpected token\n"
"x; x; x; x; x; x; x; x;\n"
" ^\n\n"
"test.wgsl:1:10 error: unexpected token\n"
"x; x; x; x; x; x; x; x;\n"
" ^\n\n"
"test.wgsl:1:13 error: unexpected token\n"
"x; x; x; x; x; x; x; x;\n"
" ^\n\n"
"test.wgsl error: stopping after 5 errors");
}
TEST_F(ParserImplErrorTest, MemberExprMissingIdentifier) {
EXPECT("fn f() -> void { x = a.; }",
"test.wgsl:1:24 error: expected identifier for member accessor\n"
"fn f() -> void { x = a.; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, MultiplicativeInvalidExpr) {
EXPECT("fn f() -> void { return 1.0 * <; }",
"test.wgsl:1:31 error: unable to parse right side of * expression\n"
"fn f() -> void { return 1.0 * <; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, OrInvalidExpr) {
EXPECT("fn f() -> void { return 1 | >; }",
"test.wgsl:1:29 error: unable to parse right side of | expression\n"
"fn f() -> void { return 1 | >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, RelationalInvalidExpr) {
EXPECT("fn f() -> void { return 1 < >; }",
"test.wgsl:1:29 error: unable to parse right side of < expression\n"
"fn f() -> void { return 1 < >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ReturnStmtMissingSemicolon) {
EXPECT("fn f() -> void { return }",
"test.wgsl:1:25 error: expected ';' for return statement\n"
"fn f() -> void { return }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, ShiftInvalidExpr) {
EXPECT("fn f() -> void { return 1 << >; }",
"test.wgsl:1:30 error: unable to parse right side of << expression\n"
"fn f() -> void { return 1 << >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtMissingLBrace) {
EXPECT("fn f() -> void { switch(1) }",
"test.wgsl:1:28 error: expected '{' for switch statement\n"
"fn f() -> void { switch(1) }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtMissingRBrace) {
EXPECT("fn f() -> void { switch(1) {",
"test.wgsl:1:29 error: expected '}' for switch statement\n"
"fn f() -> void { switch(1) {\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtInvalidCase) {
EXPECT("fn f() -> void { switch(1) { case ^: } }",
"test.wgsl:1:35 error: unable to parse case selectors\n"
"fn f() -> void { switch(1) { case ^: } }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtInvalidCase2) {
EXPECT(
"fn f() -> void { switch(1) { case false: } }",
"test.wgsl:1:35 error: invalid case selector must be an integer value\n"
"fn f() -> void { switch(1) { case false: } }\n"
" ^^^^^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtCaseMissingColon) {
EXPECT("fn f() -> void { switch(1) { case 1 {} } }",
"test.wgsl:1:37 error: expected ':' for case statement\n"
"fn f() -> void { switch(1) { case 1 {} } }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtCaseMissingLBrace) {
EXPECT("fn f() -> void { switch(1) { case 1: } }",
"test.wgsl:1:38 error: expected '{' for case statement\n"
"fn f() -> void { switch(1) { case 1: } }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtCaseMissingRBrace) {
EXPECT("fn f() -> void { switch(1) { case 1: {",
"test.wgsl:1:39 error: expected '}' for case statement\n"
"fn f() -> void { switch(1) { case 1: {\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, SwitchStmtCaseFallthroughMissingSemicolon) {
EXPECT("fn f() -> void { switch(1) { case 1: { fallthrough } case 2: {} } }",
"test.wgsl:1:52 error: expected ';' for fallthrough statement\n"
"fn f() -> void { switch(1) { case 1: { fallthrough } case 2: {} } }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, VarStmtMissingSemicolon) {
EXPECT("fn f() -> void { var a : u32 }",
"test.wgsl:1:30 error: expected ';' for variable declaration\n"
"fn f() -> void { var a : u32 }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, VarStmtInvalidAssignment) {
EXPECT("fn f() -> void { var a : u32 = >; }",
"test.wgsl:1:32 error: missing constructor for variable declaration\n"
"fn f() -> void { var a : u32 = >; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, UnaryInvalidExpr) {
EXPECT("fn f() -> void { return !<; }",
"test.wgsl:1:26 error: unable to parse right side of ! expression\n"
"fn f() -> void { return !<; }\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, UnexpectedToken) {
EXPECT("unexpected",
"test.wgsl:1:1 error: unexpected token\n"
"unexpected\n"
"^^^^^^^^^^\n");
}
TEST_F(ParserImplErrorTest, XorInvalidExpr) {
EXPECT("fn f() -> void { return 1 ^ >; }",
"test.wgsl:1:29 error: unable to parse right side of ^ expression\n"
"fn f() -> void { return 1 ^ >; }\n"
" ^\n");
}
} // namespace
} // namespace wgsl
} // namespace reader
} // namespace tint
| 36.449343 | 80 | 0.534321 | [
"vector"
] |
24adcc510756d52765d48904a12918aa31e60d3a | 1,274 | cc | C++ | cc/hmap/TwoOutOfThree.cc | zihengCat/leetcode-collections | e94d6ee7d17cc72c8f34162d60e8d869164cbd53 | [
"MIT"
] | 4 | 2021-12-08T15:36:36.000Z | 2022-03-23T12:21:06.000Z | cc/hmap/TwoOutOfThree.cc | zihengCat/leetcode-collections | e94d6ee7d17cc72c8f34162d60e8d869164cbd53 | [
"MIT"
] | null | null | null | cc/hmap/TwoOutOfThree.cc | zihengCat/leetcode-collections | e94d6ee7d17cc72c8f34162d60e8d869164cbd53 | [
"MIT"
] | null | null | null | #include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
/**
* LeetCode 2032. Two Out of Three
* https://leetcode.com/problems/two-out-of-three/
*/
class TwoOutOfThree {
public:
vector<int> twoOutOfThree(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3) {
unordered_map<int, int> hmap;
addToMap(nums1, hmap);
addToMap(nums2, hmap);
addToMap(nums3, hmap);
return filterMap(hmap);
}
private:
vector<int> filterMap(unordered_map<int, int>& hmap) {
vector<int> v;
for (unordered_map<int, int>::iterator iter = hmap.begin();
iter != hmap.end();
iter++
) {
if (iter -> second >= 2) {
v.push_back(iter -> first);
}
}
return v;
}
void addToMap(vector<int>& arr, unordered_map<int, int>& hmap) {
unordered_set<int> hset;
for (int i = 0; i < arr.size(); i++) {
hset.insert(arr[i]);
}
for (unordered_set<int>::iterator iter = hset.begin();
iter != hset.end();
iter++
) {
hmap[*iter]++;
}
}
};
int main(int argc, char const *argv[]) {
// ...
return 0;
}
/* EOF */
| 23.592593 | 91 | 0.522763 | [
"vector"
] |
24ae960409141e360720b2ee66e92a6d760a0b2d | 7,249 | cpp | C++ | src/Compucolor.Impl.Keyboard/KeyboardEmulator.cpp | nathanmentley/cc2emulator | 2eccca0ab7a8f306d21a2516106ef687d2b8e065 | [
"MIT"
] | null | null | null | src/Compucolor.Impl.Keyboard/KeyboardEmulator.cpp | nathanmentley/cc2emulator | 2eccca0ab7a8f306d21a2516106ef687d2b8e065 | [
"MIT"
] | null | null | null | src/Compucolor.Impl.Keyboard/KeyboardEmulator.cpp | nathanmentley/cc2emulator | 2eccca0ab7a8f306d21a2516106ef687d2b8e065 | [
"MIT"
] | null | null | null | #include "KeyboardEmulator.h"
Compucolor::Impl::Keyboard::KeyboardEmulator::KeyboardEmulator(
std::shared_ptr<Logger::ILogger> logger
):
_logger(logger),
_kbMatrix(std::vector<uint8_t>(17))
{
}
void Compucolor::Impl::Keyboard::KeyboardEmulator::Start()
{
_logger->LogTrace(
"Starting %s",
"KeyboardEmulator"
);
Reset();
}
void Compucolor::Impl::Keyboard::KeyboardEmulator::Stop()
{
_logger->LogTrace(
"Stopping %s",
"KeyboardEmulator"
);
Reset();
}
uint8_t Compucolor::Impl::Keyboard::KeyboardEmulator::Read(uint8_t port)
{
/*
_logger->LogTrace(
"Reading keyboard byte %d in %s",
port,
"KeyboardEmulator"
);
*/
return _kbMatrix[port];
}
void Compucolor::Impl::Keyboard::KeyboardEmulator::Reset()
{
_logger->LogTrace(
"Resetting in %s",
"KeyboardEmulator"
);
for(uint8_t i = 0; i < 17; i++)
{
_kbMatrix[i] = 0xFF;
}
}
void Compucolor::Impl::Keyboard::KeyboardEmulator::OnKeyUp(Compucolor::Keyboard::CompucolorIIKey key)
{
std::optional<int> row = GetRow(key);
std::optional<int> bit = GetBit(key);
_logger->LogTrace(
"OnKeyUp for %d (%d, %d) in %s",
key,
row,
bit,
"KeyboardEmulator"
);
if(row.has_value() && bit.has_value())
{
_kbMatrix[row.value()] = 0xFF;
}
}
void Compucolor::Impl::Keyboard::KeyboardEmulator::OnKeyDown(Compucolor::Keyboard::CompucolorIIKey key)
{
std::optional<int> row = GetRow(key);
std::optional<int> bit = GetBit(key);
_logger->LogTrace(
"OnKeyDown for %d (%d, %d) in %s",
key,
row,
bit,
"KeyboardEmulator"
);
if(row.has_value() && bit.has_value())
{
_kbMatrix[row.value()] &= (~(1 << bit.value()) & 0xFF);
}
}
std::optional<int> Compucolor::Impl::Keyboard::KeyboardEmulator::GetRow(Compucolor::Keyboard::CompucolorIIKey key)
{
switch (key)
{
case Compucolor::Keyboard::CompucolorIIKey::Zero: return 15;
case Compucolor::Keyboard::CompucolorIIKey::One: return 14;
case Compucolor::Keyboard::CompucolorIIKey::Two: return 13;
case Compucolor::Keyboard::CompucolorIIKey::Three: return 12;
case Compucolor::Keyboard::CompucolorIIKey::Four: return 11;
case Compucolor::Keyboard::CompucolorIIKey::Five: return 10;
case Compucolor::Keyboard::CompucolorIIKey::Six: return 9;
case Compucolor::Keyboard::CompucolorIIKey::Seven: return 8;
case Compucolor::Keyboard::CompucolorIIKey::Eight: return 7;
case Compucolor::Keyboard::CompucolorIIKey::Nine: return 6;
case Compucolor::Keyboard::CompucolorIIKey::A: return 14;
case Compucolor::Keyboard::CompucolorIIKey::B: return 13;
case Compucolor::Keyboard::CompucolorIIKey::C: return 12;
case Compucolor::Keyboard::CompucolorIIKey::D: return 11;
case Compucolor::Keyboard::CompucolorIIKey::E: return 10;
case Compucolor::Keyboard::CompucolorIIKey::F: return 9;
case Compucolor::Keyboard::CompucolorIIKey::G: return 8;
case Compucolor::Keyboard::CompucolorIIKey::H: return 7;
case Compucolor::Keyboard::CompucolorIIKey::I: return 6;
case Compucolor::Keyboard::CompucolorIIKey::J: return 5;
case Compucolor::Keyboard::CompucolorIIKey::K: return 4;
case Compucolor::Keyboard::CompucolorIIKey::L: return 3;
case Compucolor::Keyboard::CompucolorIIKey::M: return 2;
case Compucolor::Keyboard::CompucolorIIKey::N: return 1;
case Compucolor::Keyboard::CompucolorIIKey::O: return 0;
case Compucolor::Keyboard::CompucolorIIKey::P: return 15;
case Compucolor::Keyboard::CompucolorIIKey::Q: return 14;
case Compucolor::Keyboard::CompucolorIIKey::R: return 13;
case Compucolor::Keyboard::CompucolorIIKey::S: return 12;
case Compucolor::Keyboard::CompucolorIIKey::T: return 11;
case Compucolor::Keyboard::CompucolorIIKey::U: return 10;
case Compucolor::Keyboard::CompucolorIIKey::V: return 9;
case Compucolor::Keyboard::CompucolorIIKey::W: return 8;
case Compucolor::Keyboard::CompucolorIIKey::X: return 7;
case Compucolor::Keyboard::CompucolorIIKey::Y: return 6;
case Compucolor::Keyboard::CompucolorIIKey::Z: return 5;
case Compucolor::Keyboard::CompucolorIIKey::Shift: return 16;
case Compucolor::Keyboard::CompucolorIIKey::Break: return 15;
default: return {};
}
}
std::optional<int> Compucolor::Impl::Keyboard::KeyboardEmulator::GetBit(Compucolor::Keyboard::CompucolorIIKey key)
{
switch (key)
{
case Compucolor::Keyboard::CompucolorIIKey::Zero: return 0;
case Compucolor::Keyboard::CompucolorIIKey::One: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Two: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Three: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Four: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Five: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Six: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Seven: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Eight: return 0;
case Compucolor::Keyboard::CompucolorIIKey::Nine: return 0;
case Compucolor::Keyboard::CompucolorIIKey::A: return 1;
case Compucolor::Keyboard::CompucolorIIKey::B: return 1;
case Compucolor::Keyboard::CompucolorIIKey::C: return 1;
case Compucolor::Keyboard::CompucolorIIKey::D: return 1;
case Compucolor::Keyboard::CompucolorIIKey::E: return 1;
case Compucolor::Keyboard::CompucolorIIKey::F: return 1;
case Compucolor::Keyboard::CompucolorIIKey::G: return 1;
case Compucolor::Keyboard::CompucolorIIKey::H: return 1;
case Compucolor::Keyboard::CompucolorIIKey::I: return 1;
case Compucolor::Keyboard::CompucolorIIKey::J: return 1;
case Compucolor::Keyboard::CompucolorIIKey::K: return 1;
case Compucolor::Keyboard::CompucolorIIKey::L: return 1;
case Compucolor::Keyboard::CompucolorIIKey::M: return 1;
case Compucolor::Keyboard::CompucolorIIKey::N: return 1;
case Compucolor::Keyboard::CompucolorIIKey::O: return 1;
case Compucolor::Keyboard::CompucolorIIKey::P: return 2;
case Compucolor::Keyboard::CompucolorIIKey::Q: return 2;
case Compucolor::Keyboard::CompucolorIIKey::R: return 2;
case Compucolor::Keyboard::CompucolorIIKey::S: return 2;
case Compucolor::Keyboard::CompucolorIIKey::T: return 2;
case Compucolor::Keyboard::CompucolorIIKey::U: return 2;
case Compucolor::Keyboard::CompucolorIIKey::V: return 2;
case Compucolor::Keyboard::CompucolorIIKey::W: return 2;
case Compucolor::Keyboard::CompucolorIIKey::X: return 2;
case Compucolor::Keyboard::CompucolorIIKey::Y: return 2;
case Compucolor::Keyboard::CompucolorIIKey::Z: return 2;
case Compucolor::Keyboard::CompucolorIIKey::Shift: return 5;
case Compucolor::Keyboard::CompucolorIIKey::Break: return 4;
default: return {};
}
} | 39.183784 | 115 | 0.666299 | [
"vector"
] |
24bad4645de5ae882621377c0587a11434da47b6 | 6,839 | cc | C++ | src/DetElement.cc | felicepantaleo/helix-fitting | d1540156430f0e4ea85a9fd0e0f08e3447f0ec3f | [
"Apache-2.0"
] | 1 | 2018-06-04T03:44:24.000Z | 2018-06-04T03:44:24.000Z | src/DetElement.cc | felicepantaleo/helix-fitting | d1540156430f0e4ea85a9fd0e0f08e3447f0ec3f | [
"Apache-2.0"
] | null | null | null | src/DetElement.cc | felicepantaleo/helix-fitting | d1540156430f0e4ea85a9fd0e0f08e3447f0ec3f | [
"Apache-2.0"
] | null | null | null | //
// Detector Elements:
// DetElements and Slices
//
#include <CLHEP/config/iostream.h>
#include <CLHEP/config/CLHEP.h>
#include <stdio.h>
#include "DetElement.h"
#include "defines.h"
#include "any2str.h"
#include <assert.h>
#include <string>
#include <vector>
#ifdef GL
#ifdef TEXTURE
#include <Inventor/nodes/SoTexture2.h>
#endif
#include <Inventor/nodes/SoSelection.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoTransform.h>
#include "hepvis/SoG4Tubs.hh"
#endif /* GL */
#ifdef GL
extern void addChild ( SoSelection *root, SoNode *node , string (*info)(int),int , bool );
extern void addChild ( SoSelection *root, SoNode *node );
#endif
vector <DetElement> el_list;
string eltype2str ( eltype tp ) {
char ret[3];
snprintf(ret,5,"%d",tp);
return ret;
};
/// Get the long name of element type 'tp'
string GetElementName(eltype tp) {
switch (tp) {
case CYL:
return "Cyl";
case DIS:
return "Dis";
case UNK:
return "???";
case B:
return "BFd";
case NON:
return "Non";
default:
ERROR ("Element type " + eltype2str(tp) + " unknown");
return "???";
};
};
/// Get element type # for 'ElementName'
eltype GetElementType(string ename) {
int i=UNK;
string name;
while (i<MAX_ELEMENT_TYPES-1 ) { // -1 because the last element is NON
name=GetElementName((eltype) i);
if (name==ename) {
return ((eltype) i);
};
i++;
};
return UNK;
};
string DetElement::SType() const {
char ret[3];
snprintf(ret,5,"%d",Type());
return ret;
};
DetElement::DetElement (const eltype & ityp, const HepDouble & a,
const HepDouble & b , const HepDouble & c, const HepDouble & d) {
typ=ityp; num=0;
_Br=0, _BPhi=0, _Bz=0;
nxt=NULL;
switch (ityp) {
case CYL:
#ifdef DEBUG
assert( a > 0 );
assert( b >= 0 );
assert( c >= 0 );
assert( d >= 0 );
#endif
r = a; sigz = c; sigphi=b/a; z=0; sigr=0;
sigrphi=sigphi * r;
thick = d;
break;
case DIS:
#ifdef DEBUG
assert( a >= 0 );
assert( b >= 0 );
assert( c >= 0 );
assert( d >= 0 );
#endif
z = a; sigr=c; r=0; sigrphi=b ; sigz=0;
sigphi = 0;
thick = d;
break;
case B:
r=a; phi=b; z=c; thick=0;
break;
case NON:
r=a; phi=b; z=c; thick=0;
break;
default:
ERROR("unknown Detector Element " + eltype2str(ityp) );
};
};
DetElement::DetElement () {
// I want a simple way of initializing an array of geometric objects
r = 0; sigz=0; sigphi=0; z=0; num=0; _Br=0, _BPhi=0, _Bz=0; sigrphi=0;
nxt=NULL;
}
HepDouble DetElement::sigRPhi() const {
return sigrphi;
};
HepDouble DetElement::sigPhi() const {
#ifdef DEBUG
if ( Type() == DIS ) ERROR("sigphi undefined");
#endif
return sigphi;
};
void DetElement::setBField( HepDouble tr, HepDouble tPhi, HepDouble tz)
{
_Br=tr; _BPhi=tPhi; _Bz=tz;
};
string DetElement::TypeName () const {
return GetElementName(typ);
};
#ifdef GL
void DetElement::GLdeinitMaterial ( SoSelection *root ) const {
#ifdef TEXTURE
SoTexture2 *texture = new SoTexture2;
texture->filename.setValue("");
root->addChild(texture);
#endif
};
void DetElement::GLinitMaterial ( SoSelection *root ) const {
SoMaterial *myMaterial = new SoMaterial;
if (typ==CYL) {
myMaterial->diffuseColor.setValue(0.03, 0.4, 0.03);
myMaterial->emissiveColor.setValue(0.1, 0.4, 0.1);
myMaterial->transparency=.5;
myMaterial->shininess=1;
} else {
myMaterial->diffuseColor.setValue(0.03, 0.4, 0.03);
myMaterial->emissiveColor.setValue(0.1, 0.4, 0.1);
myMaterial->transparency=.50;
myMaterial->shininess=1;
};
addChild(root,myMaterial);
#ifdef TEXTURE
SoTexture2 *texture = new SoTexture2;
addChild(root,texture);
texture->filename.setValue(ETCDIR"/grey-circuit.rgb");
texture->model=SoTexture2::DECAL;
#endif
};
string DEgetInfo(int a)
{
return el_list[a].getInfo();
};
string DetElement::getInfo () const {
char name[99];
if (typ==CYL) {
snprintf(name,99,"Detector Element.\n"\
" Radius=%.4fm, SigRPhi=%.6f, Sigz=%.8f\n"\
" Thickness=%.4f",R(), sigRPhi(), sigz,thick );
} else {
snprintf(name,99,"Detector Element.\n"\
" z=%.4fm, SigRPhi=%.6f, Sigr=%.8f\n"\
" Thickness=%.4f",Z(), sigRPhi(), sigR(),thick );
};
return name;
};
void DetElement::GLdraw ( SoSelection *root ) const {
SoG4Tubs *newCyl = new SoG4Tubs;
if (typ==CYL) {
newCyl->pRMin = R()-.25 * thick;
newCyl->pRMax = R()+.25 * thick;
newCyl->pDz = 0.08;
} else { // typ==DIS
newCyl->pRMin = 0;
newCyl->pRMax = .05 + Z() / 5;
newCyl->pDz = .1 * thick;
SoTransform *t_a = new SoTransform;
t_a->translation.setValue ( 0 , 0 , Z() );
addChild ( root, t_a );
};
newCyl->smoothDraw=true;
el_list.push_back(*this);
addChild(root,newCyl, (DEgetInfo) , el_list.size()-1 , false );
if ( typ== DIS ) {
SoTransform *t_b = new SoTransform;
t_b->translation.setValue ( 0 , 0 , - Z() );
addChild ( root, t_b );
};
};
#endif
void DetElement::write () const {
switch (Type()) {
case CYL:
cout << TypeName() << " Radius=" << R()
<< " SigPhi=" << sigPhi() << " Sigz=" << sigZ()
<< " Thick=" << Thick() << endl;
break;
case DIS:
cout << TypeName() << " z=" << Z()
<< " SigPhi=" << sigPhi() << " Sigz=" << sigZ()
<< " Thick=" << Thick() << endl;
break;
default:
ERROR("unknown detector element " + SType() );
};
};
// How can we read in detector elements from a file/stdin? ->
// by this kewl operator overloading technique!
#define MLC 255 // MCL Maximum Length for a Configuration line
/// deletes comments from a string|(char *), returning a string.
inline string del_leading_spaces(string line) {
while (line.find_first_of(" ")==0) {
line.erase(0,1); // delete leading spaces and tabs
};
return line;
};
inline eldesc parse_line(string line) {
eldesc el; /*={NON,1,0,0};*/
el.typ=NON;
el.var[0]=1;
el.var[1]=0;
el.var[2]=0;
el.var[3]=0;
int i;
string nxtword,myline;
line=line.substr(0,line.find("#")); // delete comments
line=del_leading_spaces(line);
nxtword=line.substr(0,line.find(" "));
if (!nxtword.size()) { // empty line - jump to the next line
el.typ = NON;
return el;
};
el.typ=GetElementType(nxtword);
for (i=0;i<4;i++) {
line=del_leading_spaces(line);
line.erase(0,line.find_first_of(" ")+1);
line=del_leading_spaces(line);
nxtword=line.substr(0,line.find(" "));
if(!nxtword.size()) {
clog << "Warning: Number of values is wrong in file " <<
" entry #" << i << endl;
};
el.var[i]=atof(nxtword.c_str());
};
return el;
}
istream& operator>> (istream& s, DetElement& el)
{
char word[MLC]; // fixed length strings are ok here.
eldesc eld;
s.getline(word,MLC);
eld=parse_line(word);
if (eld.typ != NON) // ... then the line is not empty
el=DetElement( eld.typ , eld.var[0] , eld.var[1] ,
eld.var[2], eld.var[3] );
return s;
}
| 22.949664 | 90 | 0.62553 | [
"vector",
"model"
] |
24bb55909e3803083893f476cf53bfc251753ff3 | 4,066 | cc | C++ | pytorch/caffe2/operators/experimental/c10/cpu/fc_cpu.cc | raghavnauhria/whatmt | c20483a437c82936cb0fb8080925e37b9c4bba87 | [
"MIT"
] | null | null | null | pytorch/caffe2/operators/experimental/c10/cpu/fc_cpu.cc | raghavnauhria/whatmt | c20483a437c82936cb0fb8080925e37b9c4bba87 | [
"MIT"
] | 1 | 2019-07-22T09:48:46.000Z | 2019-07-22T09:48:46.000Z | pytorch/caffe2/operators/experimental/c10/cpu/fc_cpu.cc | raghavnauhria/whatmt | c20483a437c82936cb0fb8080925e37b9c4bba87 | [
"MIT"
] | null | null | null | #include <ATen/core/op_registration/op_registration.h>
#include "caffe2/core/context.h"
#include "caffe2/core/operator.h"
#include "caffe2/core/export_c10_op_to_caffe2.h"
#include "caffe2/core/tensor.h"
#include "caffe2/utils/conversions.h"
#include "caffe2/utils/math.h"
using caffe2::BaseContext;
using caffe2::Tensor;
namespace caffe2 {
namespace {
template <class DataType, class Context>
class fc_op_cpu final : public c10::OperatorKernel {
public:
void operator()(
const at::Tensor& X_,
const at::Tensor& W_,
const at::Tensor& b_,
const at::Tensor& Y_,
int64_t axis,
int64_t axis_w) {
Tensor X(X_);
Tensor W(W_);
Tensor b(b_);
Tensor Y(Y_);
CPUContext context;
constexpr bool TransposeWeight = true;
CAFFE_ENFORCE(b.dim() == 1, b.dim());
// batch size
const auto canonical_axis = X.canonical_axis_index(axis);
const auto M = X.size_to_dim(canonical_axis);
const auto K = X.size_from_dim(canonical_axis);
const auto canonical_axis_w = W.canonical_axis_index(axis_w);
const int N = TransposeWeight ? W.size_to_dim(canonical_axis_w)
: W.size_from_dim(canonical_axis_w);
auto dimErrorString = [&]() {
return c10::str(
"Dimension mismatch: ",
"X: ",
X.sizes(),
", W: ",
W.sizes(),
", b: ",
b.sizes(),
", axis: ",
axis,
", M: ",
M,
", N: ",
N,
", K: ",
K);
};
// Error checking
CAFFE_ENFORCE(M == X.numel() / K, dimErrorString());
CAFFE_ENFORCE(K == W.numel() / N, dimErrorString());
CAFFE_ENFORCE(N == b.dim32(0), dimErrorString());
CAFFE_ENFORCE(N == b.numel(), dimErrorString());
Y_shape_cache_ = X.sizes().vec();
// This is an invariant of canonical_axis, so we can DCHECK.
DCHECK_LE(canonical_axis + 1, Y_shape_cache_.size());
Y_shape_cache_.resize(canonical_axis + 1);
Y_shape_cache_[canonical_axis] = N;
Y.Resize(Y_shape_cache_);
CAFFE_ENFORCE(M * N == Y.numel(), dimErrorString());
if (X.numel() == 0) {
// skip the rest of the computation if X is empty
Y.template mutable_data<DataType>();
return;
}
// default to FLOAT as math.h does.
caffe2::TensorProto::DataType math_type =
caffe2::TensorProto_DataType_FLOAT;
if (caffe2::fp16_type<DataType>()) {
math_type = caffe2::TensorProto_DataType_FLOAT16;
}
// W * x
caffe2::math::Gemm<DataType, Context, caffe2::DefaultEngine>(
CblasNoTrans,
TransposeWeight ? CblasTrans : CblasNoTrans,
M,
N,
K,
1,
X.template data<DataType>(),
W.template data<DataType>(),
0,
Y.template mutable_data<DataType>(),
static_cast<Context*>(&context),
math_type);
// Add bias term
Tensor bias_multiplier(bias_multiplier_);
ReinitializeTensor(
&bias_multiplier, {M}, at::dtype<DataType>().device(CPU));
caffe2::math::Set<DataType, Context>(
M,
caffe2::convert::To<float, DataType>(1),
bias_multiplier.template mutable_data<DataType>(),
static_cast<Context*>(&context));
caffe2::math::Gemm<DataType, Context, caffe2::DefaultEngine>(
CblasNoTrans,
CblasNoTrans,
M,
N,
1,
1,
bias_multiplier.template data<DataType>(),
b.template data<DataType>(),
1,
Y.template mutable_data<DataType>(),
static_cast<Context*>(&context),
math_type);
}
private:
vector<int64_t> Y_shape_cache_;
at::Tensor bias_multiplier_ = at::Tensor(Tensor());
};
static auto registry = c10::RegisterOperators().op(
"_c10_experimental::FullyConnected",
c10::RegisterOperators::options()
.kernel<fc_op_cpu<float, CPUContext>>(CPUTensorId()));
} // namespace
C10_EXPORT_C10_OP_TO_CAFFE2_CPU(
"_c10_experimental::FullyConnected",
C10FC_DontUseThisOpYet)
} // namespace caffe2
| 28.433566 | 70 | 0.611904 | [
"vector"
] |
24bf6776aa57ef53760955de7fbba9f309e58535 | 14,101 | cpp | C++ | reconstruction/hexclient/communicator.cpp | Brow71189/low-dose-reconstruction | 927d1393f351eba45778e03d12acdde316907ecf | [
"MIT"
] | null | null | null | reconstruction/hexclient/communicator.cpp | Brow71189/low-dose-reconstruction | 927d1393f351eba45778e03d12acdde316907ecf | [
"MIT"
] | null | null | null | reconstruction/hexclient/communicator.cpp | Brow71189/low-dose-reconstruction | 927d1393f351eba45778e03d12acdde316907ecf | [
"MIT"
] | null | null | null |
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "string.h"
#include "stdlib.h"
#include "globals.h"
#include "fast_cache.h"
#include "communicator.hpp"
#include "zippedimg.hpp"
/*
//BigEndian Encoding
short getshortBE()
{
short one = (short)getchar();
short two = (short)getchar();
return ( (one << 8) | (two) );
}
short get16bitint()
{
short first = (short)getchar();
first += ((short)getchar())*256;
return first;
}
unsigned short getushort()
{
unsigned short first = (unsigned short)getchar();
first += ((unsigned short)getchar())*256;
return first;
}
*/
double getdouble(FILE* input) //we have to reverse the byte order from JAVA (at least for linux/gcc)
{
union
{
double dbl;
char byts[sizeof(double)/sizeof(char)];
};
for(size_t i = sizeof(double)/sizeof(char); i > 0u; --i)
{ byts[i-1] = getc(input);}
return dbl;
}
void senddouble(double val) //we have to reverse the byte order for JAVA (at least from linux/gcc)
{
union
{
double dbl;
char byts[sizeof(double)/sizeof(char)];
};
dbl = val;
for(size_t i = sizeof(double)/sizeof(char); i > 0u; --i)
{ putchar(byts[i-1]);}
/*
char *ret = (char*)&val; //quick and dirty
putchar(ret[7]);
putchar(ret[6]);
putchar(ret[5]);
putchar(ret[4]);
putchar(ret[3]);
putchar(ret[2]);
putchar(ret[1]);
putchar(ret[0]);
*/
}
float getfloat(FILE* input) //we have to reverse the byte order from JAVA (at least for linux/gcc)
{
union
{
float flt;
char byts[sizeof(float)/sizeof(char)];
};
for(size_t i = sizeof(float)/sizeof(char); i > 0u; --i)
{ byts[i-1] = getc(input);}
return flt;
}
/* getfloat is broken. solve once we need it.
float getfloat() //we have to reverse the byte order from JAVA (at least for linux/gcc)
{
float ret;
((char*)&ret)[3]=getchar();
((char*)&ret)[2]=getchar();
((char*)&ret)[1]=getchar();
((char*)&ret)[0]=getchar();
return ret;
}
*/
void sendfloat(float val) //we have to reverse the byte order for JAVA (at least from linux/gcc)
{
union
{
float flt;
char byts[sizeof(float)/sizeof(char)];
};
flt = val;
for(size_t i = sizeof(float)/sizeof(char); i > 0u; --i)
{ putchar(byts[i-1]);}
}
ssflt getWeights(FILE* input, ssflt *weight)
{
double weightSum = 0.0;
int modelnum(globalModelNum);
globalCommand->assertCommand(input, "BeginBinary", modelnum * 8 );
for(int q = 0; q < modelnum; ++q )
{
double mw = getdouble(jobfile?jobfile:stdin);
//assert( (mw >= 0.0) && (mw <= 1.0) ); //scaled weights as of 17.09.2015
weight[q] = (ssflt)mw;
weightSum += (double)mw;
}
globalCommand->assertCommand(input, "EndBinary", weightSum );
return weightSum;
}
void sendWeights(ssflt *weight)
{
int modelnum(globalModelNum);
for(int q = 0; q < modelnum; ++q )
{
printf("%lf\n", (double)weight[q]);
}
fflush(stdout);
}
int getModels(FILE* input, unsigned short* Models, int fm, int lm )
{
const int modelarea(globalModelArea);
globalCommand->assertCommand(input, "BeginBinary", 2 * (lm-fm+1) * modelarea );
int checksum = 0;
for (int m = fm; m <= lm; ++m)
{
for (int qr = 0; qr < modelarea; ++qr)
{
unsigned short val = 256 * getc(input);
val += getc(input);
checksum += val;
Models[ m * modelarea + qr] = val;
if(((int)val) >= globalModelval)
{
printf("Error: modelvalue %d excceeds modelval: %d\n", val, globalModelval);
fflush(stdout);
return -1;
}
}
}
globalCommand->assertCommand(input, "EndBinary", checksum );
return checksum;
}
int getBeam(FILE* input, unsigned short* Beam)
{
const int beamarea( globalBeamArea );
globalCommand->assertCommand(input, "BeginBinary", 2 * beamarea );
int checksum(0);
unsigned short beam_min(0);
for (int qr(0); qr < beamarea; ++qr)
{
unsigned short val (256 * getc(input));
val += getc(input);
checksum += val;
Beam[qr] = val;
if( (qr==0) || (val < beam_min) )
{ beam_min = val;}
}
globalCommand->assertCommand(input, "EndBinary", checksum );
for (int qr(0); qr < beamarea; ++qr)
{
Beam[qr] -= beam_min;
}
globalBeamNorm = checksum - beamarea*beam_min;
return checksum;
}
int sendModels(unsigned short* Models, int fm, int lm )
{
int modelsize(globalModelSize);
int modelarea = modelsize * modelsize;
///HMMM maybe we should do some handshakes here. we will see
for (int m = fm; m <= lm; ++m)
{
printf("MODEL\t%d\tPIXELS%d\n", m, modelarea);
fflush(stdout); //make sure master is aware of the awaing pixels
for (int qr = 0; qr < modelarea; ++qr)
{
printf("%d\n", Models[ m * modelarea + qr]);
fflush(stdout);
}
}
fflush(stdout);//should be redundant, but safety first
return 0;
}
int sendEModels(ssflt* EModelsB, ssflt* wghtB,
#ifdef USE_MPFR
ssint* EModelsS, ssint* wghtS,
#endif
bool reporting,
int fm, int lm)
{
const int modelarea( globalModelArea );
for (int m = fm; m <= lm; ++m)
{
#ifdef USE_MPFR
printf("EMODEL\t%d\tPIXELS\t%d\tWGHTB\t%lf\tWGHTS\t%d\n", m, modelarea, wghtB[m], wghtS[m]);
#else
printf("EMODEL\t%d\tPIXELS\t%d\tWGHTB\t%E\n", m, modelarea, wghtB[m]);
#endif
fflush(stdout); //make sure master is aware of the awaing pixels
if(!reporting)
{
int ind( m * modelarea);
for (int qr = 0; qr < modelarea; ++qr)
{
#ifdef USE_MPFR
printf("%lf\t%d\n", EModelsB[ind], EModelsS[ind]);
#else
printf("%E\n", EModelsB[ind]);
#endif
fflush(stdout);
++ind;
}
}
else
{
printf("hidding %d pixels\n",modelarea);
}
}
fflush(stdout);//should be redundant, but safety first
return 0;
}
#ifdef USE_CCTABLE
int getIdata(FILE* input, unsigned short *qImg)
{
const int IdataSize(globalqImgSize);
const int qImgCol(globalqImgCol);
const int subframearea(globalSubFrameArea);
const int subframesize(globalSubFrameSize);
const int subframecount(globalSubFrameCount);
const int datamin(globalDatamin);
const int * const pixpos(pixposG);
globalCommand->assertCommand(input, "BeginBinary", 3 * IdataSize/2 );
int checksum = 0;
int chsum = 0;
pix_non_zero = 0;
for ( int idx = 0; idx < IdataSize; ++idx)
{
int sfC = idx / subframearea;
int ontheframe = idx % subframearea;
if(pixpos[ontheframe] != -1)
{
unsigned short val = 256 * getc(input);
val += getc(input);
chsum += val;
val -= datamin;
const int x = ontheframe % subframesize;
const int y = ontheframe / subframesize;
const int ind = (sfC + x * subframecount + y * qImgCol);
qImg[ind] = val;
checksum += val;
pix_non_zero += (val?1:0);
if(val > globalDatamax)
{
printf("Error datavalue %d exceeds limit: %d\n", val, globalDatamax);
return -1;
}
}
}
globalCommand->assertCommand(input, "EndBinary", chsum );
return checksum;
}
#else //NO_CCTABLE we only need the zipped image
int getIdata(FILE* input, unsigned short *zipImg, long &zipImgUsed)
{
const int IdataSize(globalqImgSize);
const int subframearea(globalSubFrameArea);
//const int subframesize(globalSubFrameSize);
const int subframecount(globalSubFrameCount);
const int datamin(globalDatamin);
const int datamax(globalDatamax);
globalCommand->assertCommand(input, "BeginBinary", 3 * IdataSize / 2 );
int checksum = 0;
int chsum = 0;
pix_non_zero = 0;
unsigned short *zipPtr = zipImg;
unsigned short *sf = new unsigned short[subframearea];
unsigned short *histo = new unsigned short[datamax];
for(int sfC(0); sfC < subframecount; ++sfC)
{
memset(histo,'\0',sizeof(unsigned short)*datamax);
memset(sf,'\0', sizeof(unsigned short)*subframearea);
unsigned short sf_max_val(0);
for(int ind = 0; ind < subframearea; ++ind)
{
if(pixposG[ind]!=-1)
{
unsigned short val = 256 * getc(input);
val += getc(input);
chsum += val;
val -= datamin;
checksum += val;
sf[ ind] = val;
if(val)//skip the zeros
{
++pix_non_zero;
++(histo[val-1]);
sf_max_val = (val > sf_max_val) ? val : sf_max_val;
}
}
}
//assert((int)sf_max_val <= datamax - datamin);
for(int vv(1); vv <= sf_max_val; ++vv)
{
if(histo[vv-1])
{
*(zipPtr++) = vv; //value
*(zipPtr++) = histo[vv-1]; //runlength
//unsigned short chcksum(0);
for(int ind = 0; ind < subframearea; ++ind)
{
if((pixposG[ind] != -1) && (sf[ind] == vv))
{
*(zipPtr++) = pixposG[ind]; //indices
//++chcksum;
}
}
//assert(chcksum == histo[vv-1]);
}
}
*(zipPtr++) = 0; //value
*(zipPtr++) = 0; //runlength
}
//pointer is finally one behind the actual data,-> correct length
zipImgUsed = zipPtr - zipImg;
globalCommand->assertCommand(input, "EndBinary", chsum );
delete[] sf;
delete[] histo;
return checksum;
}
#endif
int getZipIdata(FILE* input, unsigned short *zipImg, long &zipImgUsed)
{
int subframecount(globalSubFrameCount);
int datamin(globalDatamin);
globalCommand->assertCommand(input, "BeginBinary", 2 * zip_img_cap );
int checksum = 0;
int chsum = 0;
long shorts_read = 0;
pix_non_zero = 0;
unsigned short* zipPtr = zipImg;
for(int sfC(0); sfC < subframecount; ++sfC)
{
//printf("FRAME %d of %d\n",sfC, subframecount);
//fflush(stdout);
unsigned short count(0);
unsigned short val0(0);
unsigned short val(0);
unsigned int sf_sum(0);
do
{
val0 = 256 * getc(input);
val0 += getc(input);
chsum += val0;
val = val0;
if(val0 >= datamin)
{ val = val0 - datamin;}
//else
//{ assert(val0 == 0);}
//checksum += val;
count = 256 * getc(input);
count += getc(input);
chsum += count;
//printf("val: %d count: %d\n",val,count);
//fflush(stdout);
shorts_read += 2;
if( (count > 0) && (val > 0) )
{
*(zipPtr++) = val;
*(zipPtr++) = count;
checksum += (val * count);
sf_sum += (val * count);
}
for(unsigned short pos = 0; pos < count; ++pos)
{
unsigned short qr = 256 * getc(input);
qr += getc(input);
//printf("%d ",qr);
//fflush(stdout);
*(zipPtr++) = pixposG[qr];
chsum += qr;
}
shorts_read += count;
//printf("\n");
//printf("remaining %ld\n", zip_img_cap - (zipPtr - zipImg));
fflush(stdout);
}
while( (val > 0) || (count > 0) );
*(zipPtr++) = 0; // 0 times 0 marks the end of a subframe
*(zipPtr++) = 0;
if(sf_sum == 0)
{
printf("getZipIdata: sf_sum == 0 at sfC: %d\n", sfC);
}
}
zipImgUsed = zipPtr - zipImg;
//printf("zipReading %ld of max. %ld\n", zipImgUsed, zip_img_cap);
//fflush(stdout);
//long padcount = 0;
for(long padding = shorts_read; padding < zip_img_cap; ++padding)
{
getc(input);
getc(input);
//++padcount;
}
//printf("zipReading %ld extra shorts totalling %ld\n", padcount, padcount + zipImgUsed);
//fflush(stdout);
globalCommand->assertCommand(input, "EndBinary", chsum );
return checksum;
}
#ifdef MUL_PTBL
ssflt getPtable(FILE* input, ssflt *lPtable, ssflt *mulPtbl, ssflt *Ptbl0)
#else
ssflt getPtable(FILE* input, ssflt *lPtable, ssflt *Ptable, ssflt* InvPtable, ssflt *Ptbl0)
#endif
{
const ssflt InvLn2(1/log(2.0));
double fchecksum(0.0);
const int modelval(globalModelval);
const int ptablewidth(globalPtableWidth);
globalCommand->assertCommand(input, "BeginBinary", 8 * globalPtableSize );
for (int datav = 0; datav < ptablewidth; ++datav)
{
for (int modelv = 0; modelv < modelval; ++modelv)
{
int ind = datav + ptablewidth * modelv;
double pval = getdouble(jobfile?jobfile:stdin);
//assert( isfinite(pval) );
fchecksum += pval;
pval *= pvalscaling;
lPtable[ind] = (ssflt)pval*InvLn2;
#ifndef MUL_PTBL
pval = exp(pval);
Ptable[ind] = (ssflt)pval;
InvPtable[ind] = 1.0/(ssflt)pval;
#endif
}
}
globalCommand->assertCommand(input, "EndBinary", fchecksum );
#ifdef MUL_PTBL
ssflt *mulPtblp( mulPtbl );
//double min_log_jmp;
//double max_log_jmp;
//double sum(0.0); //should be zero in the end again!
//bool first = true;
for(int newv(0); newv < modelval; ++newv )
{
for(int oldv(0); oldv < modelval; ++ oldv)
{
for(int datav(0); datav < ptablewidth; ++datav)
{
//multiplying exps should be more accurate for floating point numbers than exping the difference
*(mulPtblp++) = exp2( lPtable[datav + newv * ptablewidth]) * exp2( -lPtable[datav + oldv * ptablewidth] );
//*mulPtblp = lPtable[datav + newv * ptablewidth] - lPtable[datav + oldv * ptablewidth];
/*sum += *mulPtblp;
if(first || *mulPtblp < min_log_jmp )
{
min_log_jmp = *mulPtblp;
}
if(first || *mulPtblp > max_log_jmp )
{
max_log_jmp = *mulPtblp;
first = false;
}
++mulPtblp;
*/
}
}
}
//printf("log mulPtbl smallest: %lf biggest: %lf sum: %lf\n", min_log_jmp, max_log_jmp, sum);
#endif
ssflt *Ptbl0P(Ptbl0);
for(int datav(0); datav < ptablewidth; ++datav)
{
for(int newv(0); newv < modelval; ++newv )
{
*(Ptbl0P++) = exp2( lPtable[datav + newv * ptablewidth]) * exp2( -lPtable[ /*datav=0*/ newv * ptablewidth] );
//*(Ptbl0P++) = lPtable[datav + newv * ptablewidth] - lPtable[ /*datav=0*/ newv * ptablewidth];
}
}
return fchecksum;
}
int sendHisto(ssflt* histoB,
#ifdef USE_MPFR
ssint* histoS,
#endif
bool reporting
)
{
const int ptableSize ( globalPtableSize );
//make sure master is aware of the awaing data
if(!reporting)
{
#ifdef USE_MPFR
printf("HISTO\tPOINTS\t%d\tBASE\tSHIFT\n", ptableSize);
#else
printf("HISTO\tPOINTS\t%d\tBASE\n", ptableSize);
#endif
fflush(stdout);
for (int ind = 0; ind < ptableSize; ++ind)
{
#ifdef USE_MPFR
printf("%lf\t%d\n", *(histoB++), *(histoS++));
#else
printf("%E\n", *(histoB++));
#endif
fflush(stdout);
}
}
else
{
printf("\nhidding %d histogramm entries\n",ptableSize);
}
fflush(stdout);//should be redundant, but safety first
return 0;
}
| 23.940577 | 112 | 0.61563 | [
"model"
] |
24c476f11f6804edd1a9a13a233a03628ee1cf80 | 5,479 | cpp | C++ | test/_opengl/ShaderPreprocessorTest/src/ShaderPreprocessorTestApp.cpp | nselikoff/Cinder | 54590aabdc3d74b0b078d43590dfad89e50e9c94 | [
"BSD-2-Clause"
] | 3,494 | 2015-01-02T08:42:09.000Z | 2022-03-31T14:16:23.000Z | test/_opengl/ShaderPreprocessorTest/src/ShaderPreprocessorTestApp.cpp | nselikoff/Cinder | 54590aabdc3d74b0b078d43590dfad89e50e9c94 | [
"BSD-2-Clause"
] | 1,284 | 2015-01-02T07:31:47.000Z | 2022-03-30T02:06:43.000Z | test/_opengl/ShaderPreprocessorTest/src/ShaderPreprocessorTestApp.cpp | nselikoff/Cinder | 54590aabdc3d74b0b078d43590dfad89e50e9c94 | [
"BSD-2-Clause"
] | 780 | 2015-01-02T22:14:29.000Z | 2022-03-30T00:16:56.000Z | /*
* [X] check all cases:
*
* [X] version, no defines
* [X] no version, no defines case
* [X] version, with defines case
* [X] no version, with defines case
* [X] version with a comment before it, no defines
* [X] version with comment before it, defines
* [X] no version, with defines and comment before it
* [X] no version, no defines, comment before it
* [X] version, no defines, with include
* [X] version, no defines, with include, comment on top
* [X] no version, no defines, with include
* [X] no version, no defines, with include, comment at top
* [X] version, defines, include
* [X] original more complicated shader
*
* [X] test that the source-string-number is correct here, should go up to 2
* variations:
*
* [X] versions 150 and 330+ handle #lines differently
* [X] check #version 300 es that it is parsed correctly
*/
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "cinder/gl/GlslProg.h"
#include "cinder/gl/ShaderPreprocessor.h"
#include "cinder/Log.h"
#include "cinder/System.h"
#include "cinder/Utilities.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class ShaderPreprocessorTestApp : public App {
void setup() override;
void keyDown( KeyEvent event ) override;
void update() override;
void draw() override;
void reload();
void testGlslProgInclude();
void testSeparateShaderPreprocessor();
void testIncludeHandler();
gl::GlslProgRef mGlslProg;
gl::ShaderPreprocessorRef mPreprocessor;
bool mAddDefineDirective = false;
const std::string mWrongHashDefineDirective = "WRONG_HASH";
};
void ShaderPreprocessorTestApp::setup()
{
mPreprocessor = make_shared<gl::ShaderPreprocessor>();
if( mAddDefineDirective )
mPreprocessor->addDefine( mWrongHashDefineDirective );
reload();
}
void ShaderPreprocessorTestApp::reload()
{
// testGlslProgInclude();
testSeparateShaderPreprocessor();
// testIncludeHandler();
}
void ShaderPreprocessorTestApp::keyDown( KeyEvent event )
{
if( event.getChar() == 'r' ) {
CI_LOG_I( "reload" );
reload();
}
else if( event.getChar() == 'd' ) {
mAddDefineDirective = ! mAddDefineDirective;
CI_LOG_I( "mAddDefineDirectives: " << mAddDefineDirective );
if( mAddDefineDirective ) {
mPreprocessor->addDefine( mWrongHashDefineDirective );
}
else {
mPreprocessor->clearDefines();
}
}
else if( event.getChar() == 'v' ) {
mPreprocessor->setVersion( mPreprocessor->getVersion() == 150 ? 330 : 150 );
CI_LOG_I( "set #version to: " << mPreprocessor->getVersion() );
}
else if( event.getChar() == 'n' ) {
mPreprocessor->setUseFilenameInLineDirectiveEnabled( ! mPreprocessor->isUseFilenameInLineDirectiveEnabled() );
CI_LOG_I( "using filename in #line directive: " << boolalpha << mPreprocessor->isUseFilenameInLineDirectiveEnabled() << dec );
}
}
void ShaderPreprocessorTestApp::testGlslProgInclude()
{
try {
auto format = gl::GlslProg::Format()
.vertex( loadAsset( "passthrough.vert" ) )
.fragment( loadAsset( "shaderWithInclude.frag" ) )
// .define( "COLOR_RED", "vec4( 0, 0, 1, 1 )" )
;
if( mAddDefineDirective ) {
format.define( mWrongHashDefineDirective );
}
mGlslProg = gl::GlslProg::create( format );
}
catch( std::exception &exc ) {
CI_LOG_EXCEPTION( "exception caught.", exc );
}
}
void ShaderPreprocessorTestApp::testSeparateShaderPreprocessor()
{
try {
auto vert = loadAsset( "passthrough.vert" );
const fs::path &fragPath = "simple.frag";
//const fs::path &fragPath = "shaderWithInclude.frag";
string fragSourceRaw = loadString( loadAsset( fragPath ) );
string fragSource = mPreprocessor->parse( fragSourceRaw, fragPath );
// write the preprocessed string out to file within the build folder for comparison
#if defined( CINDER_MAC )
writeString( fs::path( fragPath.stem().string() + "_preprocessed.frag" ), fragSource );
#else
writeString( fs::path( "build" ) / ( fragPath.stem().string() + "_preprocessed.frag" ), fragSource );
#endif
auto format = gl::GlslProg::Format()
.preprocess( false )
.vertex( vert )
.fragment( fragSource )
;
mGlslProg = gl::GlslProg::create( format );
}
catch( std::exception &exc ) {
CI_LOG_EXCEPTION( "exception caught", exc );
}
}
const std::string hashGlsl = R"(
float hash( float n )
{
return 0.5f; // should result in the pattern being solid, no noise
}
)";
void ShaderPreprocessorTestApp::testIncludeHandler()
{
auto includeCustomHash = []( const fs::path &path,std::string *source ) -> bool {
if( path == fs::path( "hash.glsl" ) ) {
*source = hashGlsl;
return true;
}
return false;
};
try {
auto format = gl::GlslProg::Format()
.vertex( loadAsset( "passthrough.vert" ) )
.fragment( loadAsset( "shaderWithInclude.frag" ) )
;
format.getPreprocessor()->getSignalInclude().connect( includeCustomHash );
mGlslProg = gl::GlslProg::create( format );
}
catch( std::exception &exc ) {
CI_LOG_EXCEPTION( "exception caught", exc );
}
}
void ShaderPreprocessorTestApp::update()
{
}
void ShaderPreprocessorTestApp::draw()
{
gl::clear( Color( 0.1, 0.2, 0.1 ) );
if( mGlslProg ) {
gl::ScopedGlslProg glslScope( mGlslProg );
gl::drawSolidRect( getWindowBounds() );
}
}
void prepareSettings( app::App::Settings *settings )
{
if( Display::getDisplays().size() > 1 )
settings->setDisplay( Display::getDisplays()[1] );
}
CINDER_APP( ShaderPreprocessorTestApp, RendererGl, prepareSettings )
| 26.341346 | 128 | 0.693557 | [
"solid"
] |
24c7cedc8321335e5dd0c67eb653d45369a349eb | 15,073 | cpp | C++ | libraries/fc/src/thread/thread.cpp | SophiaTX/SophiaTx-Blockchain | c964691c020962ad1aba8263c0d8a78a9fa27e45 | [
"MIT"
] | 8 | 2018-07-25T20:42:43.000Z | 2019-03-11T03:14:09.000Z | libraries/fc/src/thread/thread.cpp | SophiaTX/SophiaTx-Blockchain | c964691c020962ad1aba8263c0d8a78a9fa27e45 | [
"MIT"
] | 13 | 2018-07-25T17:41:28.000Z | 2019-01-25T13:38:11.000Z | libraries/fc/src/thread/thread.cpp | SophiaTX/SophiaTx-Blockchain | c964691c020962ad1aba8263c0d8a78a9fa27e45 | [
"MIT"
] | 11 | 2018-07-25T14:34:13.000Z | 2019-05-03T13:29:37.000Z | #include <fc/thread/thread.hpp>
#include <fc/io/sstream.hpp>
#include <fc/log/logger.hpp>
#include "thread_d.hpp"
#if defined(_MSC_VER) && !defined(NDEBUG)
# include <windows.h>
const DWORD MS_VC_EXCEPTION=0x406D1388;
#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
#pragma pack(pop)
static void set_thread_name(const char* threadName)
{
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = threadName;
info.dwThreadID = -1;
info.dwFlags = 0;
__try
{
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
#elif defined(__linux__) && !defined(NDEBUG)
# include <pthread.h>
static void set_thread_name(const char* threadName)
{
pthread_setname_np(pthread_self(), threadName);
}
#elif defined(__APPLE__) && !defined(NDEBUG)
# include <pthread.h>
static void set_thread_name(const char* threadName)
{
pthread_setname_np(threadName);
}
#else
static void set_thread_name(const char* threadName)
{
// do nothing in release mode
}
#endif
namespace fc {
const char* thread_name() {
return thread::current().name().c_str();
}
void* thread_ptr() {
return &thread::current();
}
thread*& current_thread() {
#ifdef _MSC_VER
static __declspec(thread) thread* t = NULL;
#else
static __thread thread* t = NULL;
#endif
return t;
}
thread::thread( const std::string& name ) {
promise<void>::ptr p(new promise<void>("thread start"));
boost::thread* t = new boost::thread( [this,p,name]() {
try {
set_thread_name(name.c_str()); // set thread's name for the debugger to display
this->my = new thread_d(*this);
cleanup();
current_thread() = this;
p->set_value();
exec();
} catch ( fc::exception& e ) {
wlog( "unhandled exception" );
p->set_exception( e.dynamic_copy_exception() );
} catch ( ... ) {
wlog( "unhandled exception" );
p->set_exception( std::make_shared<unhandled_exception>( FC_LOG_MESSAGE( warn, "unhandled exception: ${diagnostic}", ("diagnostic",boost::current_exception_diagnostic_information()) ) ) );
//assert( !"unhandled exception" );
//elog( "Caught unhandled exception %s", boost::current_exception_diagnostic_information().c_str() );
}
} );
p->wait();
my->boost_thread = t;
my->name = name;
//wlog("name:${n} tid:${tid}", ("n", name)("tid", (uintptr_t)my->boost_thread->native_handle()) );
}
thread::thread( thread_d* ) {
my = new thread_d(*this);
}
thread::thread( thread&& m ) {
my = m.my;
m.my = 0;
}
thread& thread::operator=(thread&& t ) {
std::swap(t.my,my);
return *this;
}
thread::~thread() {
if( my && is_running())
{
quit();
}
delete my;
}
thread& thread::current() {
if( !current_thread() )
current_thread() = new thread((thread_d*)0);
return *current_thread();
}
void thread::cleanup() {
if ( current_thread() ) {
delete current_thread();
current_thread() = nullptr;
}
}
const std::string& thread::name()const
{
return my->name;
}
void thread::set_name( const std::string& n )
{
if (!is_current())
{
async([=](){ set_name(n); }, "set_name").wait();
return;
}
my->name = n;
set_thread_name(my->name.c_str()); // set thread's name for the debugger to display
}
const char* thread::current_task_desc() const
{
if (my->current && my->current->cur_task)
return my->current->cur_task->get_desc();
return NULL;
}
void thread::debug( const std::string& d ) { /*my->debug(d);*/ }
void thread::quit()
{
//if quitting from a different thread, start quit task on thread.
//If we have and know our attached boost thread, wait for it to finish, then return.
if( !is_current() )
{
auto t = my->boost_thread;
async( [=](){quit();}, "thread::quit" );//.wait();
if( t )
{
t->join();
}
return;
}
my->done = true;
// wlog( "${s}", ("s",name()) );
// We are quiting from our own thread...
// break all promises, thread quit!
while( my->blocked )
{
fc::context* cur = my->blocked;
while( cur )
{
fc::context* n = cur->next;
// this will move the context into the ready list.
//cur->prom->set_exception( boost::copy_exception( error::thread_quit() ) );
//cur->set_exception_on_blocking_promises( thread_quit() );
cur->set_exception_on_blocking_promises( std::make_shared<canceled_exception>(FC_LOG_MESSAGE(error, "cancellation reason: thread quitting")) );
cur = n;
}
if( my->blocked )
{
//wlog( "still blocking... whats up with that?");
debug( "on quit" );
}
}
BOOST_ASSERT( my->blocked == 0 );
//my->blocked = 0;
for (task_base* unstarted_task : my->task_pqueue)
unstarted_task->set_exception(std::make_shared<canceled_exception>(FC_LOG_MESSAGE(error, "cancellation reason: thread quitting")));
my->task_pqueue.clear();
for (task_base* scheduled_task : my->task_sch_queue)
scheduled_task->set_exception(std::make_shared<canceled_exception>(FC_LOG_MESSAGE(error, "cancellation reason: thread quitting")));
my->task_sch_queue.clear();
// move all sleep tasks to ready
for( uint32_t i = 0; i < my->sleep_pqueue.size(); ++i )
my->add_context_to_ready_list( my->sleep_pqueue[i] );
my->sleep_pqueue.clear();
// move all idle tasks to ready
fc::context* cur = my->pt_head;
while( cur )
{
fc::context* n = cur->next;
cur->next = 0;
my->add_context_to_ready_list( cur );
cur = n;
}
// mark all ready tasks (should be everyone)... as canceled
for (fc::context* ready_context : my->ready_heap)
ready_context->canceled = true;
// now that we have poked all fibers... switch to the next one and
// let them all quit.
while (!my->ready_heap.empty())
{
my->start_next_fiber(true);
my->check_for_timeouts();
}
my->clear_free_list();
my->cleanup_thread_specific_data();
}
void thread::exec()
{
if( !my->current )
my->current = new fc::context(&fc::thread::current());
try
{
my->process_tasks();
}
catch( canceled_exception& e )
{
dlog( "thread canceled: ${e}", ("e", e.to_detail_string()) );
}
delete my->current;
my->current = 0;
}
bool thread::is_running()const
{
return !my->done;
}
priority thread::current_priority()const
{
BOOST_ASSERT(my);
if( my->current )
return my->current->prio;
return priority();
}
void thread::yield(bool reschedule)
{
my->check_fiber_exceptions();
my->start_next_fiber(reschedule);
my->check_fiber_exceptions();
}
void thread::sleep_until( const time_point& tp )
{
if( tp <= (time_point::now()+fc::microseconds(10000)) )
yield(true);
my->yield_until( tp, false );
}
int thread::wait_any_until( std::vector<promise_base::ptr>&& p, const time_point& timeout) {
for( size_t i = 0; i < p.size(); ++i )
if( p[i]->ready() )
return i;
if( timeout < time_point::now() )
{
std::stringstream ss;
for( auto i = p.begin(); i != p.end(); ++i )
ss << (*i)->get_desc() << ", ";
FC_THROW_EXCEPTION( timeout_exception, "${task}", ("task",ss.str()) );
}
if( !my->current )
my->current = new fc::context(&fc::thread::current());
for( uint32_t i = 0; i < p.size(); ++i )
my->current->add_blocking_promise(p[i].get(),false);
// if not max timeout, added to sleep pqueue
if( timeout != time_point::maximum() )
{
my->current->resume_time = timeout;
my->sleep_pqueue.push_back(my->current);
std::push_heap( my->sleep_pqueue.begin(),
my->sleep_pqueue.end(),
sleep_priority_less() );
}
my->add_to_blocked( my->current );
my->start_next_fiber();
for( auto i = p.begin(); i != p.end(); ++i )
my->current->remove_blocking_promise(i->get());
my->check_fiber_exceptions();
for( uint32_t i = 0; i < p.size(); ++i )
if( p[i]->ready() )
return i;
//BOOST_THROW_EXCEPTION( wait_any_error() );
return -1;
}
void thread::async_task( task_base* t, const priority& p ) {
async_task( t, p, time_point::min() );
}
void thread::poke() {
boost::unique_lock<boost::mutex> lock(my->task_ready_mutex);
my->task_ready.notify_one();
}
void thread::async_task( task_base* t, const priority& p, const time_point& tp ) {
assert(my);
if ( !is_running() )
{
FC_THROW_EXCEPTION( canceled_exception, "Thread is not running.");
}
t->_when = tp;
// slog( "when %lld", t->_when.time_since_epoch().count() );
// slog( "delay %lld", (tp - fc::time_point::now()).count() );
task_base* stale_head = my->task_in_queue.load(boost::memory_order_relaxed);
do { t->_next = stale_head;
}while( !my->task_in_queue.compare_exchange_weak( stale_head, t, boost::memory_order_release ) );
// Because only one thread can post the 'first task', only that thread will attempt
// to aquire the lock and therefore there should be no contention on this lock except
// when *this thread is about to block on a wait condition.
if( this != ¤t() && !stale_head ) {
boost::unique_lock<boost::mutex> lock(my->task_ready_mutex);
my->task_ready.notify_one();
}
}
void yield() {
thread::current().yield();
}
void usleep( const microseconds& u ) {
thread::current().sleep_until( time_point::now() + u);
}
void sleep_until( const time_point& tp ) {
thread::current().sleep_until(tp);
}
void exec()
{
return thread::current().exec();
}
int wait_any( std::vector<promise_base::ptr>&& v, const microseconds& timeout_us )
{
return thread::current().wait_any_until( std::move(v), time_point::now() + timeout_us );
}
int wait_any_until( std::vector<promise_base::ptr>&& v, const time_point& tp )
{
return thread::current().wait_any_until( std::move(v), tp );
}
void thread::wait_until( promise_base::ptr&& p, const time_point& timeout )
{
if( p->ready() )
return;
if( timeout < time_point::now() )
FC_THROW_EXCEPTION( timeout_exception, "${task}", ("task", p->get_desc()) );
if( !my->current )
my->current = new fc::context(&fc::thread::current());
//slog( " %1% blocking on %2%", my->current, p.get() );
my->current->add_blocking_promise(p.get(), true);
// if not max timeout, added to sleep pqueue
if( timeout != time_point::maximum() )
{
my->current->resume_time = timeout;
my->sleep_pqueue.push_back(my->current);
std::push_heap( my->sleep_pqueue.begin(),
my->sleep_pqueue.end(),
sleep_priority_less() );
}
// elog( "blocking %1%", my->current );
my->add_to_blocked( my->current );
// my->debug("swtiching fibers..." );
my->start_next_fiber();
// slog( "resuming %1%", my->current );
//slog( " %1% unblocking blocking on %2%", my->current, p.get() );
my->current->remove_blocking_promise(p.get());
my->check_fiber_exceptions();
}
void thread::notify( const promise_base::ptr& p )
{
//slog( "this %p my %p", this, my );
BOOST_ASSERT(p->ready());
if( !is_current() )
{
this->async( [=](){ notify(p); }, "notify", priority::max() );
return;
}
// TODO: store a list of blocked contexts with the promise
// to accelerate the lookup.... unless it introduces contention...
// iterate over all blocked contexts
fc::context* cur_blocked = my->blocked;
fc::context* prev_blocked = 0;
while( cur_blocked )
{
// if the blocked context is waiting on this promise
if( cur_blocked->try_unblock( p.get() ) )
{
// remove it from the blocked list.
// remove this context from the sleep queue...
for( uint32_t i = 0; i < my->sleep_pqueue.size(); ++i )
{
if( my->sleep_pqueue[i] == cur_blocked )
{
my->sleep_pqueue[i]->blocking_prom.clear();
my->sleep_pqueue[i] = my->sleep_pqueue.back();
my->sleep_pqueue.pop_back();
std::make_heap( my->sleep_pqueue.begin(),my->sleep_pqueue.end(), sleep_priority_less() );
break;
}
}
auto cur = cur_blocked;
if( prev_blocked )
{
prev_blocked->next_blocked = cur_blocked->next_blocked;
cur_blocked = prev_blocked->next_blocked;
}
else
{
my->blocked = cur_blocked->next_blocked;
cur_blocked = my->blocked;
}
cur->next_blocked = 0;
my->add_context_to_ready_list( cur );
}
else
{ // goto the next blocked task
prev_blocked = cur_blocked;
cur_blocked = cur_blocked->next_blocked;
}
}
}
bool thread::is_current()const
{
return this == ¤t();
}
void thread::notify_task_has_been_canceled()
{
async( [=](){ my->notify_task_has_been_canceled(); }, "notify_task_has_been_canceled", priority::max() );
}
void thread::unblock(fc::context* c)
{
my->unblock(c);
}
#ifdef _MSC_VER
/* support for providing a structured exception handler for async tasks */
namespace detail
{
unhandled_exception_filter_type unhandled_structured_exception_filter = nullptr;
}
void set_unhandled_structured_exception_filter(unhandled_exception_filter_type new_filter)
{
detail::unhandled_structured_exception_filter = new_filter;
}
unhandled_exception_filter_type get_unhandled_structured_exception_filter()
{
return detail::unhandled_structured_exception_filter;
}
#endif // _MSC_VER
} // end namespace fc
| 29.324903 | 200 | 0.574803 | [
"vector"
] |
24c80aab68dcd59e3e1a79e0d764fc02b5859b29 | 3,118 | cpp | C++ | dataset/test/modification/1499_rename/32/transformation_1.cpp | Karina5005/Plagiarism | ce11f72ba21a754ca84a27e5f26a31a19d6cb6fb | [
"MIT"
] | 3 | 2022-02-15T00:29:39.000Z | 2022-03-15T08:36:44.000Z | dataset/test/modification/1499_rename/32/transformation_1.cpp | Kira5005-code/Plagiarism | ce11f72ba21a754ca84a27e5f26a31a19d6cb6fb | [
"MIT"
] | null | null | null | dataset/test/modification/1499_rename/32/transformation_1.cpp | Kira5005-code/Plagiarism | ce11f72ba21a754ca84a27e5f26a31a19d6cb6fb | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("arch=skylake")
#define all(x) x.begin(), x.end()
#define len(x) (int)x.size()
#define rep(x, r) for(int (x) = 0; (x) < (r); (x)++)
#define rrep(x, l, r) for(int (x) = l; (x) < (r); x++)
using namespace std;
using ll = long long;
// Debugging template by livw
// Link: https://codeforces.com/blog/entry/68809
void j(int hc_q) {cerr << hc_q;}
void rul_bd(long be_b) {cerr << be_b;}
void zo(long long mr) {cerr << mr;}
void zfl(unsigned sx) {cerr << sx;}
void c(unsigned long vdj) {cerr << vdj;}
void t(unsigned long long gj_b) {cerr << gj_b;}
void am_gn(float zgs_ngn) {cerr << zgs_ngn;}
void fnc_h(double k_eyw) {cerr << k_eyw;}
void y_jmf(long double fs_r) {cerr << fs_r;}
void xnp(char cs_epa) {cerr << '\'' << cs_epa << '\'';}
void a_xpe(const char *iqo_dmo) {cerr << '\"' << iqo_dmo << '\"';}
void zya(const string &y) {cerr << '\"' << y << '\"';}
void h_qiv(bool uva) {cerr << (uva ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &at) {cerr << '{'; __print(at.first); cerr << ','; __print(at.second); cerr << '}';}
template<typename T>
void __print(const T &pq) {int jz = 0; cerr << '{'; for (auto &ukf: pq) cerr << (jz++ ? "," : ""), __print(ukf); cerr << "}";}
void nuf() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T p, V... cd_g) {__print(p); if (sizeof...(v)) cerr << ", "; _print(cd_g...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#ifdef ONLINE_JUDGE
const bool LOCAL = false;
#else
const bool s = true;
#endif
const int t_eb = 2e7 + 10;
ll zz_xna[t_eb];
void n_xi(int a_kx) {
int t, r_ah, i;
cin >> t >> r_ah >> i;
vector<int> e_y;
for(int qap_qyc = 1; qap_qyc * qap_qyc <= i; qap_qyc++) {
if(qap_qyc * qap_qyc == i)
e_y.push_back(qap_qyc);
else if(i % qap_qyc == 0) {
e_y.push_back(qap_qyc);
e_y.push_back(i / qap_qyc);
}
}
ll vea = 0;
for(auto xh_wr: e_y) {
if(((i / xh_wr) + r_ah) % t == 0) {
vea += zz_xna[((i / xh_wr) + r_ah) / t];
}
}
cout << vea << "\n";
}
int main() {
memset(zz_xna, 0, sizeof zz_xna);
for(int ae = 2; ae < t_eb; ae++)
if(zz_xna[ae] == 0)
for(int jba_k = ae; jba_k < t_eb; jba_k += ae)
zz_xna[jba_k]++;
zz_xna[1] = 1;
for(int i = 2; i < t_eb; i++)
zz_xna[i] = 1ll << zz_xna[i];
bool am = true, a = false, lvv = false;
if(lvv) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
if(!a && !s) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
int agc = 1;
if(am)
cin >> agc;
for(int uep_xjt = 0; uep_xjt < agc; uep_xjt++)
n_xi(uep_xjt + 1);
if(s) {
cout << "Press any key to continue...\n";
string j_j;
cin >> j_j;
}
}
| 29.140187 | 127 | 0.514432 | [
"vector"
] |
24c80e3a443bb0f6e0ede343e40a10bab73bb077 | 2,333 | cpp | C++ | src/core/ConvKernel.cpp | dennisjosesilva/morphotree | 3be4ff7f36de65772ef273a61b0bc5916e2904d9 | [
"MIT"
] | null | null | null | src/core/ConvKernel.cpp | dennisjosesilva/morphotree | 3be4ff7f36de65772ef273a61b0bc5916e2904d9 | [
"MIT"
] | 3 | 2022-03-23T19:16:08.000Z | 2022-03-28T00:40:19.000Z | src/core/ConvKernel.cpp | dennisjosesilva/morphotree | 3be4ff7f36de65772ef273a61b0bc5916e2904d9 | [
"MIT"
] | null | null | null | #include "morphotree/core/convKernel.hpp"
#include <exception>
#include <cmath>
#include <iostream>
namespace morphotree
{
ConvKernel::ConvKernel(uint32 width, uint32 height,
const std::vector<float> &weight)
:weight_{weight}
{
if (width % 2 == 0)
throw std::runtime_error("ConvKernel with even width");
if (height % 2 == 0)
throw std::runtime_error("ConvKernel with even height");
I32Point tl{ - static_cast<int>(width)/2, -static_cast<int>(height)/2 };
domain_ = Box::fromSize(tl, UI32Point{width, height});
if (weight.size() != domain_.numberOfPoints())
throw std::runtime_error("missmatch size of width*height with weight size");
}
ConvKernel ConvKernel::PrewittX()
{
std::vector<float> k = {
-1, 0, 1,
-1, 0, 1,
-1, 0, 1
};
return ConvKernel{3, 3, k};
}
ConvKernel ConvKernel::PrewittY()
{
std::vector<float> k = {
-1, -1, -1,
0, 0, 0,
1, 1, 1
};
return ConvKernel{3, 3, k};
}
ConvKernel ConvKernel::SobelX()
{
std::vector<float> k = {
-1, 0, 1,
-2, 0, 2,
-1, 0, 1
};
return ConvKernel{3, 3, k};
}
ConvKernel ConvKernel::SobelY()
{
std::vector<float> k = {
-1, -2, -1,
0, 0, 0,
1, 2, 1
};
return ConvKernel{3, 3, k};
}
ConvKernel ConvKernel::Laplancian()
{
std::vector<float> k = {
0, 1, 0,
0, -4, 1,
0, 1, 0
};
return ConvKernel{3, 3, k};
}
ConvKernel ConvKernel::Gaussian(unsigned int size, float sigma)
{
if (size % 2 == 0)
size += 1; // make it an odd number.
int sizeOverTwo = size / 2;
std::vector<float> k(size*size, 0.f);
float sigmaTwo = sigma*sigma;
// const float coef = 1.f / (2.0f * M_PI * (sigmaTwo));
float sum = 0.f;
unsigned int idx=0;
for (int u = -sizeOverTwo; u <= sizeOverTwo; u++) {
for (int v = -sizeOverTwo; v <= sizeOverTwo; v++) {
k[idx] = expf(-(u*u + v*v)/(2.f*sigmaTwo));
sum += k[idx];
idx++;
}
}
for (idx = 0; idx < k.size(); idx++)
k[idx] = k[idx] / sum;
return ConvKernel{size, size, k};
}
ConvKernel ConvKernel::Gaussian(float sigma)
{
return Gaussian(static_cast<unsigned int>(6*sigma), sigma);
}
}
| 21.209091 | 82 | 0.540934 | [
"vector"
] |
24cc67e34bc3cde1189e5f6d4664d491ccb86e96 | 31,381 | cpp | C++ | exchange/KLineWidget.cpp | whitexwc15184/WhitecoinLightWallet | cfc458faa1695d90d2210903425377612113c064 | [
"MIT"
] | null | null | null | exchange/KLineWidget.cpp | whitexwc15184/WhitecoinLightWallet | cfc458faa1695d90d2210903425377612113c064 | [
"MIT"
] | 3 | 2020-03-16T05:23:24.000Z | 2020-03-31T03:29:39.000Z | exchange/KLineWidget.cpp | whitexwc15184/WhitecoinLightWallet | cfc458faa1695d90d2210903425377612113c064 | [
"MIT"
] | 1 | 2020-02-16T00:28:39.000Z | 2020-02-16T00:28:39.000Z | #include "KLineWidget.h"
#include "ui_KLineWidget.h"
#include "ExchangePairSelectDialog.h"
#include "AddMyExchangePairsDialog.h"
// 1分钟 5分钟 15分钟 30分钟 1小时 2小时 6小时 12小时 1天 1周 1月
static const QMap<int,int> kLineTypeMap = { {0,60}, {1,300}, {2,900}, {3,1800}, {4,3600}, {5,7200}, {6,21600}, {7,43200}, {8,86400}, {9,604800}, {10,2592000}};
// 不同period 每次查询数据的个数
static const QMap<int,int> kLineQueryCountMap = { {0, 3600 * 36 / 60}, {1,3600 * 24 * 7 / 300}, {2,3600 * 24 * 7 / 900}, {3,3600 * 24 * 7 / 1800}, {4,3600 * 24 * 30 / 3600},
{5,1000}, {6,1000}, {7,1000}, {8,1000}, {9,1000}, {10,1000}};
// 缩放因子
static const QMap<int,double> kLineScaleFactorMap = { {0,0.1}, {1,0.1}, {2,0.2}, {3,0.2}, {4,0.4}, {5,0.4}, {6,0.4}, {7,0.4}, {8,0.4}, {9,0.4}, {10,1}};
KLineWidget::KLineWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::KLineWidget)
{
ui->setupUi(this);
setStyleSheet("QTableView{background-color:rgb(255,255,255);border:none;border-radius:0px;font: 11px \"微软雅黑\";color:rgb(52,37,90);}"
"QScrollBar:vertical{border:none; width:2px;background:transparent;padding:0px 0px 0px 0px;}"
"QScrollBar::handle:vertical{width:2px;background:rgb(202,196,223);border-radius:0px;min-height:14px;}"
"QScrollBar::add-line:vertical{height:0px;}"
"QScrollBar::sub-line:vertical{height:0px;}"
"QScrollBar::sub-page:vertical {background: transparent;}"
"QScrollBar::add-page:vertical {background: transparent;}"
// "QComboBox{background-color:rgb(135,80,179);border:none;color: white;padding-left: 6px;font: 12px \"Microsoft YaHei UI Light\";border-top-left-radius:0px;border-bottom-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;}"
// "QComboBox::drop-down {background:rgb(135,80,179);border:none;}"
// "QComboBox::down-arrow {image: url(:/ui/wallet_ui/downArrow.png);}"
// "QComboBox QAbstractItemView {outline: 0px;}"
// "QComboBox QAbstractItemView{ color:rgb(90,115,227);selection-color: white;background-color: rgb(255,255,255);selection-background-color: rgb(164,77,179);}"
);
ui->closeBtn->setStyleSheet("QToolButton{background-image:url(:/ui/wallet_ui/closeBtn.png);background-repeat: no-repeat;background-position: center;border-style: flat;}"
"QToolButton:hover{background-image:url(:/ui/wallet_ui/closeBtn_hover.png);}");
ui->recentDealsTableWidget->setSelectionMode(QAbstractItemView::NoSelection);
ui->recentDealsTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->recentDealsTableWidget->setFocusPolicy(Qt::NoFocus);
// ui->recentDealsTableWidget->setFrameShape(QFrame::NoFrame);
ui->recentDealsTableWidget->setMouseTracking(true);
ui->recentDealsTableWidget->setShowGrid(false);//隐藏表格线
ui->recentDealsTableWidget->horizontalHeader()->setSectionsClickable(false);
ui->recentDealsTableWidget->horizontalHeader()->setVisible(true);
ui->recentDealsTableWidget->verticalHeader()->setVisible(false);
ui->recentDealsTableWidget->setColumnWidth(0,60);
ui->recentDealsTableWidget->setColumnWidth(1,65);
ui->recentDealsTableWidget->setColumnWidth(2,70);
customPlot = new QCustomPlot(ui->widget);
// customPlot->setGeometry(QRect(60, 110, 480, 354));
customPlot->setGeometry(QRect(0, 34, 480, 310));
customPlot->legend->setVisible(false);
customPlot->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom);
customPlot->axisRects().at(0)->setRangeDrag(Qt::Horizontal);
customPlot->axisRects().at(0)->setRangeZoom(Qt::Horizontal);
customPlot->axisRects().at(0)->setRangeZoomFactor(1.1,1);
// create bottom axis rect for volume bar chart:
volumeAxisRect = new QCPAxisRect(customPlot);
customPlot->plotLayout()->addElement(1, 0, volumeAxisRect);
volumeAxisRect->setMaximumSize(QSize(QWIDGETSIZE_MAX, 100));
volumeAxisRect->axis(QCPAxis::atBottom)->setLayer("axes");
volumeAxisRect->axis(QCPAxis::atBottom)->grid()->setLayer("grid");
// bring bottom and main axis rect closer together:
customPlot->plotLayout()->setRowSpacing(0);
volumeAxisRect->setAutoMargins(QCP::msLeft|QCP::msRight|QCP::msBottom);
volumeAxisRect->setMargins(QMargins(0, 0, 0, 0));
volumeAxisRect->setRangeDrag(Qt::Horizontal);
volumeAxisRect->setRangeZoom(Qt::Horizontal);
QBrush backRole;
backRole.setColor(QColor(255,255,255));
backRole.setStyle(Qt::SolidPattern);
customPlot->setBackground(backRole);
connect(customPlot,&QCustomPlot::mouseMove,this, &KLineWidget::mouseMoveEvent);
customPlot->installEventFilter(this);
tipLabel = new QLabel(this);
tipLabel->raise();
init();
}
KLineWidget::~KLineWidget()
{
delete ui;
}
void KLineWidget::init()
{
connect(&httpManager,SIGNAL(httpReplied(QByteArray,int)),this,SLOT(httpReplied(QByteArray,int)));
ui->periodComboBox->setCurrentIndex(XWCWallet::getInstance()->kLinePeriodIndex);
connect(ui->periodComboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(onPeriodComboBoxCurrentIndexChanged(QString)));
queryKLineData(XWCWallet::getInstance()->kLinePeriodIndex,kLineQueryCountMap.value(ui->periodComboBox->currentIndex()));
queryRecentDeals(20);
ui->currentPairLabel->setText(QString("%1 / %2").arg(revertERCSymbol(XWCWallet::getInstance()->currentExchangePair.first))
.arg(revertERCSymbol(XWCWallet::getInstance()->currentExchangePair.second)));
}
void KLineWidget::onPairChanged(const ExchangePair &_pair)
{
onPairSelected(_pair);
}
void KLineWidget::refresh()
{
refreshCount++;
if(refreshCount % (kLineTypeMap.value(ui->periodComboBox->currentIndex()) / 5) == 0)
{
if( customPlot->xAxis->range().upper >= upper) // 如果用户往前拖动了横坐标 则不刷新
{
// refreshCount = 0;
// queryKLineData(XWCWallet::getInstance()->kLinePeriodIndex,kLineQueryCountMap.value(ui->periodComboBox->currentIndex()));
onPeriodComboBoxCurrentIndexChanged(ui->periodComboBox->currentText());
}
}
queryRecentDeals(20);
}
void KLineWidget::queryRecentDeals(int count)
{
QJsonObject object;
object.insert("jsonrpc","2.0");
object.insert("id","deal");
object.insert("method","xwc.fdxqs.exchange.deal.query");
QJsonObject paramObject;
paramObject.insert("pair", QString("%1/%2").arg(XWCWallet::getInstance()->currentExchangePair.first).arg(XWCWallet::getInstance()->currentExchangePair.second));
paramObject.insert("count", count);
object.insert("params",paramObject);
httpManager.post(MIDDLE_EXCHANGE_URL,QJsonDocument(object).toJson());
}
void KLineWidget::queryKLineData(int type, int count)
{
QJsonObject object;
object.insert("jsonrpc","2.0");
object.insert("id","kline");
object.insert("method","xwc.fdxqs.exchange.kline.query");
QJsonObject paramObject;
paramObject.insert("pair", QString("%1/%2").arg(XWCWallet::getInstance()->currentExchangePair.first).arg(XWCWallet::getInstance()->currentExchangePair.second));
paramObject.insert("type", type);
paramObject.insert("count", count);
object.insert("params",paramObject);
httpManager.post(MIDDLE_EXCHANGE_URL,QJsonDocument(object).toJson());
}
void KLineWidget::drawKLine()
{
QList<uint> keys = kPointMap.keys();
int num = keys.size();
if(num < 1) return;
QVector<double> time(num);
QVector<double> open(num);
QVector<double> high(num);
QVector<double> low(num);
QVector<double> close(num);
// double binSize = 3600 * 12;
double binSize = kLineTypeMap.value( ui->periodComboBox->currentIndex());
const AssetInfo& baseAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.first));
const AssetInfo& quoteAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.second));
int precisionCompensation = qPow(10,baseAssetInfo.precision - quoteAssetInfo.precision);
int offset = QTimeZone::systemTimeZone().standardTimeOffset(QDateTime::currentDateTime());
for(int i = 0; i < num; i++)
{
KPointInfo kPoint = kPointMap.value( keys.at(i));
QDateTime dateTime = QDateTime::fromString( kPoint.dateTime, "yyyy-MM-dd hh:mm:ss");
dateTime.setTimeSpec(Qt::UTC);
time[i] = dateTime.toTime_t() + offset;
open[i] = kPoint.kOpen * precisionCompensation;
high[i] = kPoint.kHigh * precisionCompensation;
low[i] = kPoint.kLow * precisionCompensation;
close[i] = kPoint.kClose * precisionCompensation;
}
lower = time[0];
upper = time[num - 1];
// disconnect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(onXRangeChanged(QCPRange)));
// int num = 500;
// QVector<double> time(num), value(num), value2(num);
// QDateTime start = QDateTime(QDate(2014, 6, 11));
// start.setTimeSpec(Qt::UTC);
// double startTime = start.toTime_t();
// double binSize = 3600*24; // bin data in 1 day intervals
// time[0] = startTime;
// value[0] = 60;
// qsrand(9);
// for (int i=1; i<num; ++i)
// {
// time[i] = startTime + 3600*i;
// value[i] = value[i-1] + (qrand()/(double)RAND_MAX-0.5)*10;
// }
// create candlestick chart:
candlesticks = new QCPFinancial(customPlot->xAxis, customPlot->yAxis);
candlesticks->setName("Candlestick");
candlesticks->setChartStyle(QCPFinancial::csCandlestick);
// candlesticks->data()->set(QCPFinancial::timeSeriesToOhlc(time, value, binSize, time.at(0)));
candlesticks->setData(time,open,high,low,close);
candlesticks->setWidth(binSize*0.9);
candlesticks->setTwoColored(true);
candlesticks->setBrushPositive(QColor(1, 215, 26));
candlesticks->setBrushNegative(QColor(215, 1, 1));
candlesticks->setPenPositive(QPen(QColor(1, 215, 26)));
candlesticks->setPenNegative(QPen(QColor(215, 1, 1)));
customPlot->axisRects().at(0)->axis(QCPAxis::atBottom)->setRange(time[0],time[num - 1]);
volumeAxisRect->axis(QCPAxis::atBottom)->setRange(time[0],time[num - 1]);
// create two bar plottables, for positive (green) and negative (red) volume bars:
customPlot->setAutoAddPlottableToLegend(true);
QCPBars *volumePos = new QCPBars(volumeAxisRect->axis(QCPAxis::atBottom), volumeAxisRect->axis(QCPAxis::atLeft));
QCPBars *volumeNeg = new QCPBars(volumeAxisRect->axis(QCPAxis::atBottom), volumeAxisRect->axis(QCPAxis::atLeft));
for(int i = 0; i < num; i++)
{
KPointInfo kPoint = kPointMap.value( keys.at(i));
AssetInfo assetInfo = XWCWallet::getInstance()->assetInfoMap.value( XWCWallet::getInstance()->getAssetId( XWCWallet::getInstance()->currentExchangePair.first));
double v = getBigNumberString( kPoint.baseAmount, assetInfo.precision).toDouble();
(kPoint.kClose < kPoint.kOpen ? volumeNeg : volumePos)->addData(time.at(i), v); // add data to either volumeNeg or volumePos, depending on sign of v
}
volumePos->setWidth(binSize*0.9);
volumePos->setPen(Qt::NoPen);
volumePos->setBrush(QColor(1, 215, 26));
volumeNeg->setWidth(binSize*0.9);
volumeNeg->setPen(Qt::NoPen);
volumeNeg->setBrush(QColor(215, 1, 1));
// interconnect x axis ranges of main and bottom axis rects:
connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(onXRangeChanged(QCPRange)));
connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), volumeAxisRect->axis(QCPAxis::atBottom), SLOT(setRange(QCPRange)));
connect(volumeAxisRect->axis(QCPAxis::atBottom), SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis, SLOT(setRange(QCPRange)));
// configure axes of both main and bottom axis rect:
QSharedPointer<MyQCPAxisTickerDateTime> dateTimeTicker(new MyQCPAxisTickerDateTime);
dateTimeTicker->setDateTimeSpec(Qt::UTC);
// dateTimeTicker->setDateTimeFormat("dd.MMMM");
// switch (ui->periodComboBox->currentIndex())
// {
// case 0:
// case 1:
// case 2:
// }
dateTimeTicker->setTickTimePointType(MyQCPAxisTickerDateTime::tpDay);
dateTimeTicker->setDateTimeFormat("hh:mm");
volumeAxisRect->axis(QCPAxis::atBottom)->setTicker(dateTimeTicker);
volumeAxisRect->axis(QCPAxis::atBottom)->setTickLabelRotation(0);
customPlot->xAxis->setBasePen(Qt::NoPen);
customPlot->xAxis->setTickLabels(false);
customPlot->xAxis->setTicks(false); // only want vertical grid in main axis rect, so hide xAxis backbone, ticks, and labels
// customPlot->xAxis->setTicker(dateTimeTicker);
customPlot->rescaleAxes();
double factor = kLineScaleFactorMap.value(ui->periodComboBox->currentIndex()) / 10.0;
// double factor = 0.5;
customPlot->xAxis->scaleRange(factor, customPlot->xAxis->range().lower * factor * 0.5 + customPlot->xAxis->range().upper * (1 - factor * 0.5));
double span = kLineTypeMap.value( ui->periodComboBox->currentIndex()) * 40;
// double span = kLineTypeMap.value( ui->periodComboBox->currentIndex()) * kLineQueryCountMap.value( ui->periodComboBox->currentIndex())
// * kLineScaleFactorMap.value( ui->periodComboBox->currentIndex());
customPlot->xAxis->setRangeUpper(upper + span * 0.05);
customPlot->xAxis->setRangeLower(upper - span * 1.05);
if(customPlot->yAxis->range().lower < 0)
{
customPlot->yAxis->setRangeLower(0);
}
customPlot->yAxis->scaleRange(1.1, customPlot->yAxis->range().center());
if(volumeAxisRect->axis(QCPAxis::atLeft)->range().lower < 0)
{
volumeAxisRect->axis(QCPAxis::atLeft)->setRangeLower(0);
}
// 设置两个坐标轴矩形左右对齐
QCPMarginGroup *group = new QCPMarginGroup(customPlot);
customPlot->axisRect()->setMarginGroup(QCP::msLeft|QCP::msRight, group);
volumeAxisRect->setMarginGroup(QCP::msLeft|QCP::msRight, group);
customPlot->replot();
}
void KLineWidget::showRecentDeals()
{
ui->recentDealsTableWidget->setRowCount(0);
ui->recentDealsTableWidget->setRowCount(deals.size());
for(int i = 0; i < deals.size(); i++)
{
ui->recentDealsTableWidget->setRowHeight(i, 22);
ExchangeDeal deal = deals.at(i);
QDateTime utcDateTime = QDateTime::fromString(deal.dateTime, "yyyy-MM-dd hh:mm:ss");
utcDateTime.setTimeSpec(Qt::UTC);
QString str = utcDateTime.toLocalTime().toString("hh:mm:ss");
ui->recentDealsTableWidget->setItem( i, 0, new QTableWidgetItem(str));
const AssetInfo& baseAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.first));
const AssetInfo& quoteAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.second));
unsigned long long baseAmount = deal.baseAmount;
unsigned long long quoteAmount = deal.quoteAmount;
double price = double(quoteAmount) / qPow(10,quoteAssetInfo.precision) / baseAmount * qPow(10,baseAssetInfo.precision);
QString priceStr = QString::number(price,'f', XWCWallet::getInstance()->getExchangePairPrecision(XWCWallet::getInstance()->currentExchangePair));
ui->recentDealsTableWidget->setItem( i, 1, new QTableWidgetItem(priceStr));
ui->recentDealsTableWidget->item(i,1)->setTextColor( (deal.type == "buy") ? QColor(1,215,26) : QColor(215,1,1));
double amount = roundDown( getBigNumberString(baseAmount, baseAssetInfo.precision).toDouble(), XWCWallet::getInstance()->getExchangeAmountPrecision(XWCWallet::getInstance()->currentExchangePair.first));
QString amountStr = QString::number( amount, 'f', XWCWallet::getInstance()->getExchangeAmountPrecision(XWCWallet::getInstance()->currentExchangePair.first));
ui->recentDealsTableWidget->setItem( i, 2, new QTableWidgetItem( amountStr));
for(int j : {0,1,2})
{
ui->recentDealsTableWidget->item(i,j)->setTextAlignment(Qt::AlignCenter);
}
// 显示最新价格
if(i == 0)
{
ui->priceLabel->setText(priceStr);
ui->priceLabel->adjustSize();
ui->priceLabel->setGeometry(ui->priceLabel->x(), ui->priceLabel->y(), ui->priceLabel->width(), 20);
ui->infoLabel->move(ui->priceLabel->x() + ui->priceLabel->width() + 10, ui->infoLabel->y());
}
}
}
void KLineWidget::rescaleYAxis()
{
if (candlesticks)
{
QSharedPointer<QCPFinancialDataContainer> data = candlesticks->data();
double dHigh = 0;
double dLow = 99999999;
unsigned long long volumeHigh = 0;
int count = 0;
QCPRange range = customPlot->xAxis->range();
for (int i = 0; i < data->size(); ++i)
{
QCPFinancialDataContainer::const_iterator it = data->at(i);
if(range.contains(it->key))
{
if (it->high > dHigh) dHigh = it->high;
if (it->low < dLow && it->low > 0) dLow = it->low;
const KPointInfo& kPoint = kPointMap.value( uint(it->key) - 3600 * 8);
count++;
if(kPoint.baseAmount > volumeHigh) volumeHigh = kPoint.baseAmount;
}
}
customPlot->yAxis->setRange(dLow / 1.5, dHigh * 1.5);
const AssetInfo& baseAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.first));
volumeAxisRect->axis(QCPAxis::atLeft)->setRange(0, getBigNumberString(volumeHigh, baseAssetInfo.precision).toDouble() * 1.5);
}
}
uint KLineWidget::getTimeLeftValue(uint time_t, uint interval)
{
QVector<uint> keys = QVector<uint>::fromList( kPointMap.keys());
uint left = 0;
if(time_t % interval > interval / 2)
{
left = time_t - time_t % interval + interval;
}
else
{
left = time_t - time_t % interval;
}
return left;
}
void KLineWidget::showLatestInfo()
{
if(kPointMap.size() < 1)
{
ui->infoLabel->clear();
return;
}
const KPointInfo kpInfo = kPointMap.last();
const AssetInfo& baseAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.first));
const AssetInfo& quoteAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.second));
double precisionCompensation = qPow(10,baseAssetInfo.precision - quoteAssetInfo.precision);
int showPrecision = XWCWallet::getInstance()->getExchangePairPrecision(XWCWallet::getInstance()->currentExchangePair);
double changeRate = (kpInfo.kOpen < 1e-9) ? 0 : (kpInfo.kClose - kpInfo.kOpen) / kpInfo.kOpen;
double amount = roundDown( getBigNumberString(kpInfo.baseAmount, baseAssetInfo.precision).toDouble(), XWCWallet::getInstance()->getExchangeAmountPrecision(XWCWallet::getInstance()->currentExchangePair.first));
QString amountStr = QString::number( amount, 'f', XWCWallet::getInstance()->getExchangeAmountPrecision(XWCWallet::getInstance()->currentExchangePair.first));
QString str = tr("<html><head/><body><p><span style=\" font-size:10px; color:%7;\">CHANGE: %1% </span><span style=\" font-size:10px; color:#261932;\">O:%2 H:%3 L:%4 C:%5 V:%6</span></p></body></html>").arg( QString::number(changeRate * 100, 'f', 2))
.arg( QString::number(kpInfo.kOpen * precisionCompensation,'f',showPrecision)).arg(QString::number(kpInfo.kHigh * precisionCompensation,'f',showPrecision))
.arg(QString::number(kpInfo.kLow * precisionCompensation,'f',showPrecision)).arg(QString::number(kpInfo.kClose * precisionCompensation,'f',showPrecision))
.arg( amountStr)
.arg( (changeRate > 0) ? "rgb(1,215,26)" : "rgb(215,1,1)" );
ui->infoLabel->setText(str);
}
void KLineWidget::onXRangeChanged(const QCPRange &range)
{
// if(lower < 1.5e+9 || upper < 1.5e+9) return;
// QCPRange boundedRange = range;
// if(range.lower < lower)
// {
// boundedRange.lower = lower;
// }
// if(range.upper > upper)
// {
// boundedRange.upper = upper;
// }
// customPlot->xAxis->setRange(boundedRange);
if(kPointMap.size() < 1) return;
rescaleYAxis();
}
void KLineWidget::mouseMoveEvent(QMouseEvent *event)
{
if(kPointMap.size() < 1) return;
// if(customPlot->graphCount() < 4) return;
QVector<double> vx,vy;
uint x = uint( customPlot->xAxis->pixelToCoord(event->pos().x()));
double y = customPlot->yAxis->pixelToCoord(event->pos().y());
double y2 = volumeAxisRect->axis(QCPAxis::atLeft)->pixelToCoord(event->pos().y());
int offset = QTimeZone::systemTimeZone().standardTimeOffset(QDateTime::currentDateTime());
uint left = getTimeLeftValue(x - offset, uint(kLineTypeMap.value(ui->periodComboBox->currentIndex())));
const KPointInfo kpInfo = kPointMap.value(left);
const AssetInfo& baseAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.first));
const AssetInfo& quoteAssetInfo = XWCWallet::getInstance()->assetInfoMap.value(XWCWallet::getInstance()->getAssetId(XWCWallet::getInstance()->currentExchangePair.second));
double precisionCompensation = qPow(10,baseAssetInfo.precision - quoteAssetInfo.precision);
int showPrecision = XWCWallet::getInstance()->getExchangePairPrecision(XWCWallet::getInstance()->currentExchangePair);
double changeRate = (kpInfo.kOpen < 1e-9) ? 0 : (kpInfo.kClose - kpInfo.kOpen) / kpInfo.kOpen;
double amount = roundDown( getBigNumberString(kpInfo.baseAmount, baseAssetInfo.precision).toDouble(), XWCWallet::getInstance()->getExchangeAmountPrecision(XWCWallet::getInstance()->currentExchangePair.first));
QString amountStr = QString::number( amount, 'f', XWCWallet::getInstance()->getExchangeAmountPrecision(XWCWallet::getInstance()->currentExchangePair.first));
QString str = tr("<html><head/><body><p><span style=\" font-size:10px; color:%7;\">CHANGE: %1% </span><span style=\" font-size:10px; color:#261932;\">O:%2 H:%3 L:%4 C:%5 V:%6</span></p></body></html>").arg( QString::number(changeRate * 100, 'f', 2))
.arg( QString::number(kpInfo.kOpen * precisionCompensation,'f',showPrecision)).arg(QString::number(kpInfo.kHigh * precisionCompensation,'f',showPrecision))
.arg(QString::number(kpInfo.kLow * precisionCompensation,'f',showPrecision)).arg(QString::number(kpInfo.kClose * precisionCompensation,'f',showPrecision))
.arg( amountStr)
.arg( (changeRate > 0) ? "rgb(1,215,26)" : "rgb(215,1,1)" );
ui->infoLabel->setText(str);
// customPlot->graph(0)->data().data()->clear();
customPlot->clearGraphs();
customPlot->addGraph();
customPlot->addGraph();
if(event->pos().y() < volumeAxisRect->top())
{
// 如果鼠标在上面的图
vx << 0 << x << customPlot->xAxis->range().maxRange;
vy << y << y << y;
customPlot->graph(0)->setData(vx,vy);
customPlot->graph(0)->setPen(QPen(Qt::blue));
vx.clear();
vy.clear();
vx << x << x << x;
vy << 0 << y << customPlot->yAxis->range().maxRange;
customPlot->graph(1)->setData(vx,vy);
customPlot->graph(1)->setPen(QPen(Qt::blue));
customPlot->replot();
tipLabel->move( customPlot->mapTo(this, event->pos() + QPoint(12,5)));
QString timeStr = QDateTime::fromTime_t(left).toString("hh:mm");
tipLabel->setText(QString("(%1 , %2)").arg(timeStr).arg(y));
tipLabel->adjustSize();
tipLabel->show();
}
else
{
// 如果鼠标在volume图
QCPGraph *volumeGraphH = new QCPGraph(volumeAxisRect->axis(QCPAxis::atBottom), volumeAxisRect->axis(QCPAxis::atLeft));
QCPGraph *volumeGraphV = new QCPGraph(volumeAxisRect->axis(QCPAxis::atBottom), volumeAxisRect->axis(QCPAxis::atLeft));
vx << 0 << x << volumeAxisRect->axis(QCPAxis::atBottom)->range().maxRange;
vy << y2 << y2 << y2;
volumeGraphH->setData(vx,vy);
volumeGraphH->setPen(QPen(Qt::blue));
// customPlot->graph(2)->setData(vx,vy);
// customPlot->graph(2)->setPen(QPen(Qt::blue));
vx.clear();
vy.clear();
vx << x << x << x;
vy << 0 << y2 << volumeAxisRect->axis(QCPAxis::atLeft)->range().maxRange;
volumeGraphV->setData(vx,vy);
volumeGraphV->setPen(QPen(Qt::blue));
// customPlot->graph(3)->setData(vx,vy);
// customPlot->graph(3)->setPen(QPen(Qt::blue));
customPlot->replot();
tipLabel->move( customPlot->mapTo(this, event->pos() + QPoint(12,5)));
QString timeStr = QDateTime::fromTime_t(left).toString("hh:mm");
tipLabel->setText(QString("(%1 , %2)").arg(timeStr).arg(y2));
tipLabel->adjustSize();
tipLabel->show();
}
}
bool KLineWidget::eventFilter(QObject *watched, QEvent *e)
{
if(watched == customPlot)
{
if(e->type() == QEvent::Enter)
{
if(customPlot->graphCount() == 0)
{
// customPlot->addGraph();
// customPlot->addGraph();
// if(volumeAxisRect)
// {
// customPlot->addGraph(volumeAxisRect->axis(QCPAxis::atBottom,QCPAxis::atLeft));
// customPlot->addGraph(volumeAxisRect->axis(QCPAxis::atBottom,QCPAxis::atLeft));
// }
// tipLabel->show();
}
}
else if(e->type() == QEvent::Leave)
{
if(customPlot->graphCount() >= 2)
{
customPlot->clearGraphs();
customPlot->replot();
tipLabel->hide();
showLatestInfo();
}
}
}
return QWidget::eventFilter(watched,e);
}
void KLineWidget::httpReplied(QByteArray _data, int _status)
{
QJsonObject object = QJsonDocument::fromJson(_data).object();
QString id = object.value("id").toString();
if(id == "deal")
{
QJsonObject resultObject = object.value("result").toObject();
QJsonArray array = resultObject.value("data").toArray();
deals.clear();
for( QJsonValue v : array)
{
QJsonObject dealObject = v.toObject();
ExchangeDeal deal;
deal.address = dealObject.value("addr").toString();
deal.baseAmount = jsonValueToULL( dealObject.value("base_amount"));
deal.quoteAmount = jsonValueToULL( dealObject.value("quote_amount"));
deal.pairStr = dealObject.value("pair").toString();
deal.blockNum = dealObject.value("block_num").toInt();
deal.type = dealObject.value("ex_type").toString();
deal.dateTime = dealObject.value("timestamp").toString();
deals << deal;
}
showRecentDeals();
}
else if(id == "kline")
{
QJsonObject resultObject = object.value("result").toObject();
QJsonArray array = resultObject.value("data").toArray();
kPointMap.clear();
for( QJsonValue v : array)
{
QJsonObject kObject = v.toObject();
KPointInfo info;
info.baseAmount = jsonValueToULL( kObject.value("base_amount"));
info.quoteAmount = jsonValueToULL( kObject.value("quote_amount"));
info.blockNum = kObject.value("block_num").toInt();
info.pairStr = kObject.value("ex_pair").toString();
info.kOpen = kObject.value("k_open").toDouble();
info.kClose = kObject.value("k_close").toDouble();
info.kHigh = kObject.value("k_high").toDouble();
info.kLow = kObject.value("k_low").toDouble();
info.dateTime = kObject.value("timestamp").toString();
QDateTime dateTime = QDateTime::fromString( kObject.value("timestamp").toString(), "yyyy-MM-dd hh:mm:ss");
dateTime.setTimeSpec(Qt::UTC);
uint time_t = dateTime.toTime_t();
kPointMap.insert(time_t, info);
}
drawKLine();
showLatestInfo();
}
}
void KLineWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(QPen(QColor(239,242,245),Qt::SolidLine));
painter.setBrush(QBrush(QColor(239,242,245),Qt::SolidPattern));
painter.drawRect(rect());
}
void KLineWidget::on_favoriteMarketBtn_clicked()
{
ExchangePairSelectDialog dialog("");
connect(&dialog, &ExchangePairSelectDialog::pairSelected, this, &KLineWidget::onPairSelected);
connect(&dialog, &ExchangePairSelectDialog::pairSelected, this, &KLineWidget::pairChanged);
connect(&dialog, &ExchangePairSelectDialog::addFavoriteClicked, this, &KLineWidget::onAddFavoriteClicked);
dialog.move(ui->favoriteMarketBtn->mapToGlobal( QPoint(ui->favoriteMarketBtn->width() / 2 - dialog.width() / 2,ui->favoriteMarketBtn->height())));
dialog.exec();
}
void KLineWidget::on_marketBtn1_clicked()
{
ExchangePairSelectDialog dialog("XWC");
connect(&dialog, &ExchangePairSelectDialog::pairSelected, this, &KLineWidget::onPairSelected);
connect(&dialog, &ExchangePairSelectDialog::pairSelected, this, &KLineWidget::pairChanged);
dialog.move(ui->marketBtn1->mapToGlobal( QPoint(ui->marketBtn1->width() / 2 - dialog.width() / 2,ui->marketBtn1->height())));
dialog.exec();
}
void KLineWidget::on_marketBtn3_clicked()
{
ExchangePairSelectDialog dialog("ERCPAX");
connect(&dialog, &ExchangePairSelectDialog::pairSelected, this, &KLineWidget::onPairSelected);
connect(&dialog, &ExchangePairSelectDialog::pairSelected, this, &KLineWidget::pairChanged);
dialog.move(ui->marketBtn3->mapToGlobal( QPoint(ui->marketBtn3->width() / 2 - dialog.width() / 2,ui->marketBtn3->height())));
dialog.exec();
}
void KLineWidget::onPairSelected(const ExchangePair &_pair)
{
XWCWallet::getInstance()->currentExchangePair = _pair;
ui->currentPairLabel->setText( QString("%1 / %2").arg(revertERCSymbol(_pair.first)).arg(revertERCSymbol(_pair.second)));
ui->priceLabel->clear();
ui->infoLabel->clear();
tipLabel->hide();
customPlot->clearPlottables();
customPlot->replot();
kPointMap.clear();
queryKLineData(XWCWallet::getInstance()->kLinePeriodIndex, kLineQueryCountMap.value(ui->periodComboBox->currentIndex()));
queryRecentDeals(20);
}
void KLineWidget::onAddFavoriteClicked()
{
AddMyExchangePairsDialog dialog;
dialog.pop();
}
void KLineWidget::onPeriodComboBoxCurrentIndexChanged(const QString &arg1)
{
refreshCount = 0;
XWCWallet::getInstance()->kLinePeriodIndex = ui->periodComboBox->currentIndex();
ui->infoLabel->clear();
tipLabel->hide();
customPlot->clearPlottables();
kPointMap.clear();
queryKLineData(XWCWallet::getInstance()->kLinePeriodIndex, kLineQueryCountMap.value(ui->periodComboBox->currentIndex()));
}
void KLineWidget::on_closeBtn_clicked()
{
Q_EMIT onClose();
}
| 44.638691 | 265 | 0.663554 | [
"object"
] |
24ccc43a572d9eca100df2b9b1ce4494219a3bfc | 346 | cpp | C++ | leetcode/contest-223/5649. Decode XORed Array.cpp | upupming/algorithm | 44edcffe886eaf4ce8c7b27a8db50d7ed5d29ef1 | [
"MIT"
] | 107 | 2019-10-25T07:46:59.000Z | 2022-03-29T11:10:56.000Z | leetcode/contest-223/5649. Decode XORed Array.cpp | upupming/algorithm | 44edcffe886eaf4ce8c7b27a8db50d7ed5d29ef1 | [
"MIT"
] | 1 | 2021-08-13T05:42:27.000Z | 2021-08-13T05:42:27.000Z | leetcode/contest-223/5649. Decode XORed Array.cpp | upupming/algorithm | 44edcffe886eaf4ce8c7b27a8db50d7ed5d29ef1 | [
"MIT"
] | 18 | 2020-12-09T14:24:22.000Z | 2022-03-30T06:56:01.000Z | #include <bits/stdc++.h>
using namespace std;
class Solution {
public:
vector<int> decode(vector<int>& encoded, int first) {
int n = encoded.size() + 1;
vector<int> ans(n);
ans[0] = first;
for (int i = 1; i < n; i++) {
ans[i] = ans[i - 1] ^ encoded[i - 1];
}
return ans;
}
}; | 24.714286 | 57 | 0.482659 | [
"vector"
] |
24cd41b05b126a119f066ad7cacf927efa86979d | 1,519 | cpp | C++ | testsuite/probes/max.cpp | sehe/cpp-sort | ddcadeb2d8a3dec220f5e23cc17e0b05e555d665 | [
"MIT"
] | null | null | null | testsuite/probes/max.cpp | sehe/cpp-sort | ddcadeb2d8a3dec220f5e23cc17e0b05e555d665 | [
"MIT"
] | null | null | null | testsuite/probes/max.cpp | sehe/cpp-sort | ddcadeb2d8a3dec220f5e23cc17e0b05e555d665 | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2016-2021 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <forward_list>
#include <iterator>
#include <vector>
#include <catch2/catch.hpp>
#include <cpp-sort/probes/max.h>
#include <cpp-sort/utility/size.h>
#include <testing-tools/distributions.h>
#include <testing-tools/internal_compare.h>
TEST_CASE( "presortedness measure: max", "[probe][max]" )
{
using cppsort::probe::max;
SECTION( "simple test" )
{
std::forward_list<int> li = { 12, 28, 17, 59, 13, 10, 39, 21, 31, 30 };
CHECK( (max)(li) == 6 );
CHECK( (max)(li.begin(), li.end()) == 6 );
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
CHECK( (max)(tricky, &internal_compare<int>::compare_to) == 6 );
}
SECTION( "upper bound" )
{
// The upper bound should correspond to the size of
// the input sequence minus one
std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
auto max_n = (max).max_for_size(cppsort::utility::size(li));
CHECK( max_n == 10 );
CHECK( (max)(li) == max_n );
CHECK( (max)(li.begin(), li.end()) == max_n );
}
SECTION( "regressions" )
{
std::vector<int> collection;
collection.reserve(100);
auto distribution = dist::ascending_sawtooth{};
distribution(std::back_inserter(collection), 100);
std::sort(collection.begin(), collection.end());
CHECK( (max)(collection) == 0 );
}
}
| 29.211538 | 79 | 0.587887 | [
"vector"
] |
24ce30adc8eb46e071e78989a0b6067cce8f2758 | 15,268 | hpp | C++ | lung/test/ventilation/TestDynamicVentilation.hpp | stu-l/Chaste | 8efa8b440660553af66804067639f237c855f557 | [
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null | lung/test/ventilation/TestDynamicVentilation.hpp | stu-l/Chaste | 8efa8b440660553af66804067639f237c855f557 | [
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null | lung/test/ventilation/TestDynamicVentilation.hpp | stu-l/Chaste | 8efa8b440660553af66804067639f237c855f557 | [
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null | /*
Copyright (c) 2005-2022, University of Oxford.
All rights reserved.
University of Oxford means the Chancellor, Masters and Scholars of the
University of Oxford, having an administrative office at Wellington
Square, Oxford OX1 2JD, UK.
This file is part of Chaste.
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 the University of Oxford 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.
*/
#ifndef TESTDYNAMICVENTILATION_HPP_
#define TESTDYNAMICVENTILATION_HPP_
#include <cxxtest/TestSuite.h>
#include "AirwayPropertiesCalculator.hpp"
#include "AirwayRemesher.hpp"
#include "DynamicVentilationProblem.hpp"
#include "MatrixVentilationProblem.hpp"
#include "MutableMesh.hpp"
#include "OutputFileHandler.hpp"
#include "ProgressReporter.hpp"
#include "TetrahedralMesh.hpp"
#include "FileFinder.hpp"
#include "SimpleBalloonAcinarUnit.hpp"
#include "SimpleBalloonExplicitAcinarUnit.hpp"
#include "boost/numeric/ublas/io.hpp"
#include <set>
#include <map>
#include "DynamicVentilationProblem.hpp"
#include "CommandLineArguments.hpp"
#include "PetscSetupAndFinalize.hpp"
template <typename ACINAR_UNIT = SimpleBalloonAcinarUnit> class SimpleAcinarUnitFactory : public AbstractAcinarUnitFactory
{
public:
SimpleAcinarUnitFactory(double acinarCompliance,
double pleuralPressureAmplitude,
double frequency = 0.5) : mAcinarCompliance(acinarCompliance),
mPleuralPressureAmplitude(pleuralPressureAmplitude),
mFrequency(frequency)
{}
virtual AbstractAcinarUnit* CreateAcinarUnitForNode(Node<3>* pNode)
{
ACINAR_UNIT* p_acinus = new ACINAR_UNIT;
p_acinus->SetCompliance(mAcinarCompliance);
return p_acinus;
}
virtual double GetPleuralPressureForNode(double time, Node<3>* pNode)
{
return -mPleuralPressureAmplitude*sin(2*M_PI*mFrequency*time);
}
private:
double mAcinarCompliance;
double mPleuralPressureAmplitude;
double mFrequency;
};
class TestDynamicVentilation : public CxxTest::TestSuite
{
public:
void TestColemanDynamicVentilationSingleAirway()
{
#if defined(LUNG_USE_UMFPACK) || defined(LUNG_USE_KLU)
FileFinder mesh_finder("lung/test/data/single_branch", RelativeTo::ChasteSourceRoot);
double compliance = 0.1/98.0665/1e3; //in m^3 / pa. Converted from 0.1 L/cmH2O per lung.
SimpleAcinarUnitFactory<> factory(compliance, 2400.0);
double viscosity = 1.92e-5; //Pa s
double terminal_airway_radius = 0.0005; //m
double terminal_airway_length = 0.005; //m
double terminal_airway_resistance = 8*viscosity*terminal_airway_length/(M_PI*SmallPow(terminal_airway_radius, 4));
double ode_volume = 0.0;
DynamicVentilationProblem problem(&factory, mesh_finder.GetAbsolutePath(), 0u);
problem.rGetMatrixVentilationProblem().SetMeshInMilliMetres();
problem.rGetMatrixVentilationProblem().SetOutflowPressure(0.0);
problem.SetTimeStep(0.01);
TimeStepper time_stepper(0.0, 1.0, 0.01);
while (!time_stepper.IsTimeAtEnd())
{
//Solve corresponding backward Euler problem for testing
double pleural_pressure = factory.GetPleuralPressureForNode(time_stepper.GetNextTime(), NULL);
double dt = time_stepper.GetNextTimeStep();
ode_volume = (ode_volume - dt*pleural_pressure/terminal_airway_resistance)/(1 + dt/(terminal_airway_resistance*compliance));
//Solve using DynamicVentilationProblem
problem.SetEndTime(time_stepper.GetNextTime());
problem.Solve();
std::map<unsigned, AbstractAcinarUnit*>& r_acinar_map = problem.rGetAcinarUnitMap();
TS_ASSERT_DELTA(ode_volume, r_acinar_map[5]->GetVolume(), 1e-6);
time_stepper.AdvanceOneTimeStep();
}
// Coverage
TS_ASSERT_THROWS_NOTHING(factory.GetMesh());
#else
std::cout << "Warning: This test needs a direct solver (UMFPACK or KLU) to execute correctly." << std::endl;
#endif
}
void TestColemanDynamicVentilationThreeBifurcations()
{
FileFinder mesh_finder("lung/test/data/three_bifurcations", RelativeTo::ChasteSourceRoot);
//The three bifurcation mesh defines a fully symmetric three bifurcation airway tree.
//The composite ventilation problem is then equivalent to a trumpet problem connected
//to an acinus with compliance equal to the total compliance of all the acini.
double total_compliance = 0.1/98.0665/1e3; //in m^3 / pa. Converted from 0.1 L/cmH2O per lung to four acinar compartments
double acinar_compliance = total_compliance/4.0;
SimpleAcinarUnitFactory<> factory(acinar_compliance, 2400.0);
TS_ASSERT_THROWS_CONTAINS(factory.GetMesh(), "The mesh object has not been set in the acinar unit factory");
double viscosity = 1.92e-5; //Pa s
double terminal_airway_radius = 0.00005; //m
double resistance_per_unit_length = 8*viscosity/(M_PI*SmallPow(terminal_airway_radius, 4));
//All airways in the mesh have radius 0.05 mm. The first branch is 3mm long, the others are 5mm.
double total_airway_resistance = (0.003 + 0.005/2 + 0.005/4)*resistance_per_unit_length;
double ode_volume = 0.0;
//Setup a simulation iterating between the flow solver and the acinar balloon.
DynamicVentilationProblem problem(&factory, mesh_finder.GetAbsolutePath(), 0u);
problem.rGetMatrixVentilationProblem().SetOutflowPressure(0.0);
problem.rGetMatrixVentilationProblem().SetMeshInMilliMetres();
problem.SetTimeStep(0.01);
factory.GetNumberOfAcini();
TimeStepper time_stepper(0.0, 1.0, 0.01);
while (!time_stepper.IsTimeAtEnd())
{
//Solve corresponding backward Euler problem for testing
double pleural_pressure = factory.GetPleuralPressureForNode(time_stepper.GetNextTime(), NULL);
double dt = time_stepper.GetNextTimeStep();
ode_volume = (ode_volume - dt*pleural_pressure/total_airway_resistance)/(1 + dt/(total_airway_resistance*total_compliance));
//Solve using DynamicVentilationProblem
problem.SetEndTime(time_stepper.GetNextTime());
problem.Solve();
std::map<unsigned, AbstractAcinarUnit*>& r_acinar_map = problem.rGetAcinarUnitMap();
TS_ASSERT_DELTA(ode_volume, r_acinar_map[5]->GetVolume(), 1e-6);
time_stepper.AdvanceOneTimeStep();
}
//Solve for longer and write output to VTK
problem.SetSamplingTimeStepMultiple(10u);
problem.SetOutputDirectory("TestDynamicVentilation");
problem.SetOutputFilenamePrefix("three_bifurcations");
problem.SetWriteVtkOutput();
problem.SetEndTime(1.5);
problem.Solve();
#ifdef CHASTE_VTK
std::string filepath = OutputFileHandler::GetChasteTestOutputDirectory() + "TestDynamicVentilation/";
std::string basename = filepath + "three_bifurcations";
FileFinder vtu_file(basename + ".vtu", RelativeTo::Absolute);
TS_ASSERT(vtu_file.Exists());
#endif
}
void TestColemanDynamicVentilationOtisBifurcations()
{
#if defined(LUNG_USE_UMFPACK) || defined(LUNG_USE_KLU)
FileFinder mesh_finder("lung/test/data/otis_bifurcation", RelativeTo::ChasteSourceRoot);
//The otis bifurcation mesh defines two branches of unequal radii leading to two acini
//Analytical results for this system can be found in Otis et al. Journal of Applied Physiology 1956
double total_compliance = 0.1/98.0665/1e3; //in m^3 / pa. Converted from 0.1 L/cmH2O per lung to four acinar compartments
double viscosity = 1.92e-5; //Pa s
double radius_zero = 0.002; //m
double radius_one = 0.0002; //m
double radius_two = 0.001; //m
double length = 0.001; //m
double R0 = 8*length*viscosity/(M_PI*SmallPow(radius_zero, 4));
double R1 = 8*length*viscosity/(M_PI*SmallPow(radius_one, 4));
double R2 = 8*length*viscosity/(M_PI*SmallPow(radius_two, 4));
double C1 = total_compliance/2.0;
double C2 = total_compliance/2.0;
double T1 = C1*R1;
double T2 = C2*R2;
double frequency = 2; //Hz
double omega = 2*M_PI*frequency;
double effective_compliance = (SmallPow(omega, 2)*SmallPow(T2*C1 + T1*C2, 2) + SmallPow(C1 + C2, 2)) /
(SmallPow(omega, 2)*(SmallPow(T1,2)*C2 + SmallPow(T2,2)*C2) + C1 + C2);
double effective_resistance = R0 +
(SmallPow(omega,2)*T1*T2*(T2*C1 + T1*C2) + (T1*C1 + T2*C2)) /
(SmallPow(omega,2)*SmallPow(T2*C1 + T1*C2,2) + SmallPow(C1 + C2, 2));
double theta = std::atan(1/(omega*effective_resistance*effective_compliance));
double delta_p = 500;
SimpleAcinarUnitFactory<> factory(C1, delta_p/2.0, frequency);
DynamicVentilationProblem problem(&factory, mesh_finder.GetAbsolutePath(), 0u);
problem.rGetMatrixVentilationProblem().SetMeshInMilliMetres();
problem.rGetMatrixVentilationProblem().SetRadiusOnEdge();
problem.rGetMatrixVentilationProblem().SetOutflowPressure(0.0);
double expected_tidal_volume = effective_compliance*delta_p*std::sin(theta);
//Setup a simulation iterating between the flow solver and the acinar balloon.
problem.SetTimeStep(0.0005);
problem.SetEndTime(16.0);
problem.Solve(); //Solve to 16s to allow the problem to equilibriate
double min_total_volume = 0.0;
double max_total_volume = 0.0;
//Now solve the last four seconds recording the tidal volume.
TimeStepper time_stepper(16.0, 20.0, 0.0005);
while (!time_stepper.IsTimeAtEnd())
{
problem.SetEndTime(time_stepper.GetNextTime());
problem.Solve();
std::map<unsigned, AbstractAcinarUnit*>& r_acinar_map = problem.rGetAcinarUnitMap();
double total_volume = r_acinar_map[2]->GetVolume() + r_acinar_map[3]->GetVolume();
if (min_total_volume > total_volume)
{
min_total_volume = total_volume;
}
if (max_total_volume < total_volume)
{
max_total_volume = total_volume;
}
time_stepper.AdvanceOneTimeStep();
}
TS_ASSERT_DELTA(expected_tidal_volume, max_total_volume - min_total_volume, 1e-7);
#else
std::cout << "Warning: This test needs a direct solver (UMFPACK or KLU) to execute correctly." << std::endl;
#endif
}
void TestColemanVsExplicitWithPedley()
{
#if defined(LUNG_USE_UMFPACK) || defined(LUNG_USE_KLU)
//This test compares an acinar unit using an explicit coupling scheme against an
//acinar unit using the Coleman coupling scheme. Both use dynamic (Pedley) airway
//resistance. Compliance & resistance are chosen to obtain similar dt bounds for
//the explicit scheme as commonly found for full simulations
FileFinder mesh_finder("lung/test/data/single_branch_no_intermediate", RelativeTo::ChasteSourceRoot);
double compliance = 0.1/98.0665/1e3/30000; //in m^3 / pa. Converted from 0.1 L/cmH2O per lung.
//Theory says that dt < 2*R*C gives stability in the explicit scheme when using Poiseuille flow.
//As R_poiseuille < R_pedley, this acts as a lower bound for stability here.
//Nb, we use radius = 2 mm, which results in a very tight dt bound, to ensure that Pedley resistance is
//used.
double dt = 1e-6;
double end_time = 0.15;
double viscosity = 1.92e-5; //Pa s
double terminal_airway_radius = 0.002; //m
double terminal_airway_length = 0.005; //m
double terminal_airway_resistance = 8*viscosity*terminal_airway_length/(M_PI*SmallPow(terminal_airway_radius, 4));
TS_ASSERT_LESS_THAN(dt, 2*terminal_airway_resistance*compliance);
double coleman_end_volume;
double explicit_end_volume;
{
SimpleAcinarUnitFactory<SimpleBalloonExplicitAcinarUnit> factory(compliance, 2400.0);
DynamicVentilationProblem problem(&factory, mesh_finder.GetAbsolutePath(), 0u);
problem.rGetMatrixVentilationProblem().SetOutflowPressure(0.0);
problem.rGetMatrixVentilationProblem().SetMeshInMilliMetres();
problem.rGetMatrixVentilationProblem().SetDynamicResistance();
problem.SetTimeStep(dt);
problem.SetEndTime(end_time);
problem.Solve();
std::map<unsigned, AbstractAcinarUnit*>& r_acinar_map = problem.rGetAcinarUnitMap();
explicit_end_volume = r_acinar_map[1]->GetVolume();
}
{
SimpleAcinarUnitFactory<> factory(compliance, 2400.0);
DynamicVentilationProblem problem(&factory, mesh_finder.GetAbsolutePath(), 0u);
problem.rGetMatrixVentilationProblem().SetOutflowPressure(0.0);
problem.rGetMatrixVentilationProblem().SetMeshInMilliMetres();
problem.rGetMatrixVentilationProblem().SetDynamicResistance();
problem.SetTimeStep(dt);
problem.SetEndTime(end_time);
problem.Solve();
std::map<unsigned, AbstractAcinarUnit*>& r_acinar_map = problem.rGetAcinarUnitMap();
coleman_end_volume = r_acinar_map[1]->GetVolume();
}
TS_ASSERT_DELTA(explicit_end_volume, coleman_end_volume, 1e-12);
#else
std::cout << "Warning: This test needs a direct solver (UMFPACK or KLU) to execute correctly." << std::endl;
#endif
}
};
#endif /* TESTDYNAMICVENTILATION_HPP_ */
| 42.176796 | 136 | 0.68804 | [
"mesh",
"object"
] |
24d5948aae4745d5a2e025cdab471eb4c1fd59fa | 7,595 | cpp | C++ | samples_framework/src/SampleData.cpp | rubric4b/cegui-0.8.4-tizen | 13456d7a07d697dc276fdc8663e4ca365829aa3a | [
"MIT"
] | 5 | 2016-04-18T23:12:51.000Z | 2022-03-06T05:12:07.000Z | samples_framework/src/SampleData.cpp | rubric4b/cegui-0.8.4-tizen | 13456d7a07d697dc276fdc8663e4ca365829aa3a | [
"MIT"
] | 2 | 2015-10-09T19:13:25.000Z | 2018-12-25T17:16:54.000Z | samples_framework/src/SampleData.cpp | rubric4b/cegui-0.8.4-tizen | 13456d7a07d697dc276fdc8663e4ca365829aa3a | [
"MIT"
] | 15 | 2015-02-23T16:35:28.000Z | 2022-03-25T13:40:33.000Z | /***********************************************************************
created: 4/6/2012
author: Lukas E Meindl
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#include "SampleData.h"
#include "Sample.h"
#include "Samples_xmlHandler.h"
#include "CEGUI/DynamicModule.h"
#include "CEGUI/Version.h"
#include "CEGUI/Exceptions.h"
#include "CEGUI/System.h"
#include "CEGUI/TextureTarget.h"
#include "CEGUI/BasicImage.h"
#include "CEGUI/GUIContext.h"
#include "CEGUI/Texture.h"
#include "CEGUI/ImageManager.h"
#include "CEGUI/Window.h"
#include "CEGUI/Vector.h"
using namespace CEGUI;
#define S_(X) #X
#define STRINGIZE(X) S_(X)
typedef Sample& (*getSampleInstance)();
#define GetSampleInstanceFuncName "getSampleInstance"
SampleData::SampleData(CEGUI::String sampleName,
CEGUI::String summary,
CEGUI::String description,
SampleType sampleTypeEnum,
CEGUI::String credits)
: d_name(sampleName)
, d_summary(summary)
, d_description(description)
, d_type(sampleTypeEnum)
, d_usedFilesString("")
, d_credits(credits)
, d_sampleWindow(0)
, d_guiContext(0)
, d_textureTarget(0)
, d_textureTargetImage(0)
{
}
SampleData::~SampleData()
{
}
CEGUI::String SampleData::getName()
{
return d_name;
}
CEGUI::String SampleData::getSummary()
{
return "Summary:\n" + d_summary;
}
CEGUI::String SampleData::getCredits()
{
return "Credits:\n" + d_credits;
}
CEGUI::String SampleData::getSampleTypeString()
{
switch(d_type)
{
case ST_Module:
return SampleDataHandler::SampleTypeCppModule;
break;
case ST_Lua:
return SampleDataHandler::SampleTypeLua;
break;
case ST_Python:
return SampleDataHandler::SampleTypePython;
default:
return "";
}
}
CEGUI::String SampleData::getDescription()
{
return "Description:\n" + d_description;
}
CEGUI::String SampleData::getUsedFilesString()
{
return "Used files:\n" + d_usedFilesString;
}
void SampleData::setSampleWindow(CEGUI::Window* sampleWindow)
{
d_sampleWindow = sampleWindow;
}
CEGUI::Window* SampleData::getSampleWindow()
{
return d_sampleWindow;
}
void SampleData::initialise(int width, int height)
{
CEGUI::System& system(System::getSingleton());
CEGUI::Sizef size(static_cast<float>(width), static_cast<float>(height));
d_textureTarget = system.getRenderer()->createTextureTarget();
d_guiContext = &system.createGUIContext((RenderTarget&)*d_textureTarget);
d_textureTarget->declareRenderSize(size);
CEGUI::String imageName(d_textureTarget->getTexture().getName());
d_textureTargetImage = static_cast<CEGUI::BasicImage*>(&CEGUI::ImageManager::getSingleton().create("BasicImage", "SampleBrowser/" + imageName));
d_textureTargetImage->setTexture(&d_textureTarget->getTexture());
setTextureTargetImageArea(static_cast<float>(height), static_cast<float>(width));
}
void SampleData::deinitialise()
{
CEGUI::System& system(System::getSingleton());
if(d_guiContext)
{
system.destroyGUIContext(*d_guiContext);
d_guiContext = 0;
}
if(d_textureTarget)
{
system.getRenderer()->destroyTextureTarget(d_textureTarget);
d_textureTarget = 0;
}
if(d_textureTargetImage)
{
CEGUI::ImageManager::getSingleton().destroy(*d_textureTargetImage);
d_textureTargetImage = 0;
}
}
GUIContext* SampleData::getGuiContext()
{
return d_guiContext;
}
void SampleData::handleNewWindowSize(float width, float height)
{
setTextureTargetImageArea(height, width);
CEGUI::Sizef windowSize(width, height);
if(d_textureTarget)
{
d_textureTarget->declareRenderSize(windowSize);
d_sampleWindow->getRenderingSurface()->invalidate();
}
}
CEGUI::Image& SampleData::getRTTImage()
{
return *d_textureTargetImage;
}
void SampleData::setGUIContextRTT()
{
d_guiContext->setRenderTarget(*d_textureTarget);
}
void SampleData::clearRTTTexture()
{
d_textureTarget->clear();
}
void SampleData::setTextureTargetImageArea(float height, float width)
{
if(d_textureTarget)
{
bool isTextureTargetVerticallyFlipped = d_textureTarget->isRenderingInverted();
CEGUI::Rectf renderArea;
if(isTextureTargetVerticallyFlipped)
renderArea = CEGUI::Rectf(0.0f, height, width, 0.0f);
else
renderArea = CEGUI::Rectf(0.0f, 0.0f, width, height);
if(d_textureTargetImage)
d_textureTargetImage->setArea(renderArea);
}
}
//----------------------------------------------------------------------------//
SampleDataModule::SampleDataModule(CEGUI::String sampleName,
CEGUI::String summary,
CEGUI::String description,
SampleType sampleTypeEnum,
CEGUI::String credits)
: SampleData(sampleName, summary, description, sampleTypeEnum, credits)
, d_sample(0)
, d_dynamicModule(0)
{
}
SampleDataModule::~SampleDataModule()
{
}
void SampleDataModule::initialise(int width, int height)
{
SampleData::initialise(width, height);
getSampleInstanceFromDLL();
d_sample->initialise(d_guiContext);
d_usedFilesString = d_sample->getUsedFilesString();
}
void SampleDataModule::deinitialise()
{
if(d_sample)
d_sample->deinitialise();
SampleData::deinitialise();
}
void SampleDataModule::getSampleInstanceFromDLL()
{
CEGUI::DynamicModule* sampleModule = new CEGUI::DynamicModule(d_name);
getSampleInstance functionPointerGetSample = (getSampleInstance)sampleModule->getSymbolAddress(CEGUI::String(GetSampleInstanceFuncName));
if(functionPointerGetSample == 0)
{
CEGUI::String errorMessage = "The sample creation function is not defined in the dynamic library of " + d_name;
CEGUI_THROW(CEGUI::InvalidRequestException(errorMessage.c_str()));
}
d_sample = &(functionPointerGetSample());
}
void SampleDataModule::onEnteringSample()
{
d_sample->onEnteringSample();
}
void SampleDataModule::update(float timeSinceLastUpdate)
{
d_sample->update(timeSinceLastUpdate);
} | 27.820513 | 148 | 0.661883 | [
"vector"
] |
24e01470f7dc433d6d87e5be1a0ff5ecbafc7534 | 17,009 | cpp | C++ | patch/Torus/dsp/string_synth_part.cpp | maasijam/DaisyExamples | d982852292c16ccd6884f5f1313223c4bd66daeb | [
"MIT"
] | 180 | 2020-05-28T01:34:57.000Z | 2022-03-29T17:50:27.000Z | patch/Torus/dsp/string_synth_part.cpp | maasijam/DaisyExamples | d982852292c16ccd6884f5f1313223c4bd66daeb | [
"MIT"
] | 132 | 2020-05-28T02:49:28.000Z | 2022-03-04T16:30:46.000Z | patch/Torus/dsp/string_synth_part.cpp | maasijam/DaisyExamples | d982852292c16ccd6884f5f1313223c4bd66daeb | [
"MIT"
] | 107 | 2020-06-03T03:22:49.000Z | 2022-02-28T15:46:47.000Z | // Copyright 2015 Emilie Gillet.
//
// Author: Emilie Gillet (emilie.o.gillet@gmail.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// See http://creativecommons.org/licenses/MIT/ for more information.
//
// -----------------------------------------------------------------------------
//
// String synth part.
#include "dsp/string_synth_part.h"
#include "dsp/dsp.h"
namespace torus
{
using namespace std;
using namespace stmlib;
void StringSynthPart::Init(uint16_t* reverb_buffer)
{
active_group_ = 0;
acquisition_delay_ = 0;
polyphony_ = 1;
fx_type_ = FX_ENSEMBLE;
for(int32_t i = 0; i < kStringSynthVoices; ++i)
{
voice_[i].Init();
}
for(int32_t i = 0; i < kMaxStringSynthPolyphony; ++i)
{
group_[i].tonic = 0.0f;
group_[i].envelope.Init();
}
for(int32_t i = 0; i < kNumFormants; ++i)
{
formant_filter_[i].Init();
}
limiter_.Init();
reverb_.Init(reverb_buffer);
chorus_.Init(reverb_buffer);
ensemble_.Init(reverb_buffer);
note_filter_.Init(
kSampleRate / kMaxBlockSize,
0.001f, // Lag time with a sharp edge on the V/Oct input or trigger.
0.005f, // Lag time after the trigger has been received.
0.050f, // Time to transition from reactive to filtered.
0.004f); // Prevent a sharp edge to partly leak on the previous voice.
}
const int32_t kRegistrationTableSize = 11;
const float registrations[kRegistrationTableSize][kNumHarmonics * 2] = {
{1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
{1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
{1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
{1.0f, 0.1f, 0.0f, 0.0f, 1.0f, 0.0f},
{1.0f, 0.5f, 1.0f, 0.0f, 1.0f, 0.0f},
{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
{0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f},
{0.0f, 0.5f, 1.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
};
void StringSynthPart::ComputeRegistration(float gain,
float registration,
float* amplitudes)
{
registration *= (kRegistrationTableSize - 1.001f);
MAKE_INTEGRAL_FRACTIONAL(registration);
float total = 0.0f;
for(int32_t i = 0; i < kNumHarmonics * 2; ++i)
{
float a = registrations[registration_integral][i];
float b = registrations[registration_integral + 1][i];
amplitudes[i] = a + (b - a) * registration_fractional;
total += amplitudes[i];
}
for(int32_t i = 0; i < kNumHarmonics * 2; ++i)
{
amplitudes[i] = gain * amplitudes[i] / total;
}
}
#ifdef BRYAN_CHORDS
// Chord table by Bryan Noll:
// - more compact, leaving room for a bass
// - more frequent note changes between adjacent chords.
// - dropped fifth.
const float chords[kMaxStringSynthPolyphony][kNumChords][kMaxChordSize]
= {{
{-12.0f, -0.01f, 0.0f, 0.01f, 0.02f, 11.99f, 12.0f, 24.0f}, // OCT
{-12.0f, -5.01f, -5.0f, 0.0f, 7.0f, 12.0f, 19.0f, 24.0f}, // 5
{-12.0f, -5.0f, 0.0f, 5.0f, 7.0f, 12.0f, 17.0f, 24.0f}, // sus4
{-12.0f, -5.0f, 0.0f, 0.01f, 3.0f, 12.0f, 19.0f, 24.0f}, // m
{-12.0f, -5.01f, -5.0f, 0.0f, 3.0f, 10.0f, 19.0f, 24.0f}, // m7
{-12.0f, -5.0f, 0.0f, 3.0f, 10.0f, 14.0f, 19.0f, 24.0f}, // m9
{-12.0f, -5.01f, -5.0f, 0.0f, 3.0f, 10.0f, 17.0f, 24.0f}, // m11
{-12.0f, -5.0f, 0.0f, 2.0f, 9.0f, 16.0f, 19.0f, 24.0f}, // 69
{-12.0f, -5.0f, 0.0f, 4.0f, 11.0f, 14.0f, 19.0f, 24.0f}, // M9
{-12.0f, -5.0f, 0.0f, 4.0f, 7.0f, 11.0f, 19.0f, 24.0f}, // M7
{-12.0f, -5.0f, 0.0f, 4.0f, 7.0f, 12.0f, 19.0f, 24.0f}, // M
},
{
{-12.0f, -0.01f, 0.0f, 0.01f, 12.0f, 12.01f}, // OCT
{-12.0f, -5.01f, -5.0f, 0.0f, 7.0f, 12.0f}, // 5
{-12.0f, -5.0f, 0.0f, 5.0f, 7.0f, 12.0f}, // sus4
{-12.0f, -5.0f, 0.0f, 0.01f, 3.0f, 12.0f}, // m
{-12.0f, -5.01f, -5.0f, 0.0f, 3.0f, 10.0f}, // m7
{-12.0f, -5.0f, 0.0f, 3.0f, 10.0f, 14.0f}, // m9
{-12.0f, -5.0f, 0.0f, 3.0f, 10.0f, 17.0f}, // m11
{-12.0f, -5.0f, 0.0f, 2.0f, 9.0f, 16.0f}, // 69
{-12.0f, -5.0f, 0.0f, 4.0f, 11.0f, 14.0f}, // M9
{-12.0f, -5.0f, 0.0f, 4.0f, 7.0f, 11.0f}, // M7
{-12.0f, -5.0f, 0.0f, 4.0f, 7.0f, 12.0f}, // M
},
{
{-12.0f, 0.0f, 0.01f, 12.0f}, // OCT
{-12.0f, 6.99f, 7.0f, 12.0f}, // 5
{-12.0f, 5.0f, 7.0f, 12.0f}, // sus4
{-12.0f, 3.0f, 11.99f, 12.0f}, // m
{-12.0f, 3.0f, 9.99f, 10.0f}, // m7
{-12.0f, 3.0f, 10.0f, 14.0f}, // m9
{-12.0f, 3.0f, 10.0f, 17.0f}, // m11
{-12.0f, 2.0f, 9.0f, 16.0f}, // 69
{-12.0f, 4.0f, 11.0f, 14.0f}, // M9
{-12.0f, 4.0f, 7.0f, 11.0f}, // M7
{-12.0f, 4.0f, 7.0f, 12.0f}, // M
},
{
{0.0f, 0.01f, 12.0f}, // OCT
{0.0f, 7.0f, 12.0f}, // 5
{5.0f, 7.0f, 12.0f}, // sus4
{0.0f, 3.0f, 12.0f}, // m
{0.0f, 3.0f, 10.0f}, // m7
{3.0f, 10.0f, 14.0f}, // m9
{3.0f, 10.0f, 17.0f}, // m11
{2.0f, 9.0f, 16.0f}, // 69
{4.0f, 11.0f, 14.0f}, // M9
{4.0f, 7.0f, 11.0f}, // M7
{4.0f, 7.0f, 12.0f}, // M
}};
#else
// Original chord table:
// - wider, occupies more room in the spectrum.
// - minimum number of note changes between adjacent chords.
// - consistant with the chord table used for the sympathetic strings model.
const float chords[kMaxStringSynthPolyphony][kNumChords][kMaxChordSize]
= {{
{-24.0f, -12.0f, 0.0f, 0.01f, 0.02f, 11.99f, 12.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 3.0f, 7.0f, 10.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 3.0f, 7.0f, 12.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 3.0f, 7.0f, 14.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 3.0f, 7.0f, 17.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 6.99f, 7.0f, 18.99f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 4.0f, 7.0f, 17.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 4.0f, 7.0f, 14.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 4.0f, 7.0f, 12.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 4.0f, 7.0f, 11.0f, 19.0f, 24.0f},
{-24.0f, -12.0f, 0.0f, 5.0f, 7.0f, 12.0f, 17.0f, 24.0f},
},
{
{-24.0f, -12.0f, 0.0f, 0.01f, 12.0f, 12.01f},
{-24.0f, -12.0f, 0.0f, 3.00f, 7.0f, 10.0f},
{-24.0f, -12.0f, 0.0f, 3.00f, 7.0f, 12.0f},
{-24.0f, -12.0f, 0.0f, 3.00f, 7.0f, 14.0f},
{-24.0f, -12.0f, 0.0f, 3.00f, 7.0f, 17.0f},
{-24.0f, -12.0f, 0.0f, 6.99f, 12.0f, 19.0f},
{-24.0f, -12.0f, 0.0f, 4.00f, 7.0f, 17.0f},
{-24.0f, -12.0f, 0.0f, 4.00f, 7.0f, 14.0f},
{-24.0f, -12.0f, 0.0f, 4.00f, 7.0f, 12.0f},
{-24.0f, -12.0f, 0.0f, 4.00f, 7.0f, 11.0f},
{-24.0f, -12.0f, 0.0f, 5.00f, 7.0f, 12.0f},
},
{
{-12.0f, 0.0f, 0.01f, 12.0f},
{-12.0f, 3.0f, 7.0f, 10.0f},
{-12.0f, 3.0f, 7.0f, 12.0f},
{-12.0f, 3.0f, 7.0f, 14.0f},
{-12.0f, 3.0f, 7.0f, 17.0f},
{-12.0f, 7.0f, 12.0f, 19.0f},
{-12.0f, 4.0f, 7.0f, 17.0f},
{-12.0f, 4.0f, 7.0f, 14.0f},
{-12.0f, 4.0f, 7.0f, 12.0f},
{-12.0f, 4.0f, 7.0f, 11.0f},
{-12.0f, 5.0f, 7.0f, 12.0f},
},
{
{0.0f, 0.01f, 12.0f},
{0.0f, 3.0f, 10.0f},
{0.0f, 3.0f, 7.0f},
{0.0f, 3.0f, 14.0f},
{0.0f, 3.0f, 17.0f},
{0.0f, 7.0f, 19.0f},
{0.0f, 4.0f, 17.0f},
{0.0f, 4.0f, 14.0f},
{0.0f, 4.0f, 7.0f},
{0.0f, 4.0f, 11.0f},
{0.0f, 5.0f, 7.0f},
}};
#endif // BRYAN_CHORDS
void StringSynthPart::ProcessEnvelopes(float shape,
uint8_t* flags,
float* values)
{
float decay = shape;
float attack = 0.0f;
if(shape < 0.5f)
{
attack = 0.0f;
}
else
{
attack = (shape - 0.5f) * 2.0f;
}
// Convert the arbitrary values to actual units.
float period = kSampleRate / kMaxBlockSize;
float attack_time = SemitonesToRatio(attack * 96.0f) * 0.005f * period;
// float decay_time = SemitonesToRatio(decay * 96.0f) * 0.125f * period;
float decay_time = SemitonesToRatio(decay * 84.0f) * 0.180f * period;
float attack_rate = 1.0f / attack_time;
float decay_rate = 1.0f / decay_time;
for(int32_t i = 0; i < polyphony_; ++i)
{
float drone = shape < 0.98f ? 0.0f : (shape - 0.98f) * 55.0f;
if(drone >= 1.0f)
drone = 1.0f;
group_[i].envelope.set_ad(attack_rate, decay_rate);
float value = group_[i].envelope.Process(flags[i]);
values[i] = value + (1.0f - value) * drone;
}
}
const int32_t kFormantTableSize = 5;
const float formants[kFormantTableSize][kNumFormants] = {
{700, 1100, 2400},
{500, 1300, 1700},
{400, 2000, 2500},
{600, 800, 2400},
{300, 900, 2200},
};
void StringSynthPart::ProcessFormantFilter(float vowel,
float shift,
float resonance,
float* out,
float* aux,
size_t size)
{
for(size_t i = 0; i < size; ++i)
{
filter_in_buffer_[i] = out[i] + aux[i];
}
fill(&out[0], &out[size], 0.0f);
fill(&aux[0], &aux[size], 0.0f);
vowel *= (kFormantTableSize - 1.001f);
MAKE_INTEGRAL_FRACTIONAL(vowel);
for(int32_t i = 0; i < kNumFormants; ++i)
{
float a = formants[vowel_integral][i];
float b = formants[vowel_integral + 1][i];
float f = a + (b - a) * vowel_fractional;
f *= shift;
formant_filter_[i].set_f_q<FREQUENCY_DIRTY>(f / kSampleRate, resonance);
formant_filter_[i].Process<FILTER_MODE_BAND_PASS>(
filter_in_buffer_, filter_out_buffer_, size);
const float pan = i * 0.3f + 0.2f;
for(size_t j = 0; j < size; ++j)
{
out[j] += filter_out_buffer_[j] * pan * 0.5f;
aux[j] += filter_out_buffer_[j] * (1.0f - pan) * 0.5f;
}
}
}
struct ChordNote
{
float note;
float amplitude;
};
void StringSynthPart::Process(const PerformanceState& performance_state,
const Patch& patch,
const float* in,
float* out,
float* aux,
size_t size)
{
// Assign note to a voice.
uint8_t envelope_flags[kMaxStringSynthPolyphony];
fill(&envelope_flags[0], &envelope_flags[polyphony_], 0);
note_filter_.Process(performance_state.note, performance_state.strum);
if(performance_state.strum)
{
group_[active_group_].tonic = note_filter_.stable_note();
envelope_flags[active_group_] = ENVELOPE_FLAG_FALLING_EDGE;
active_group_ = (active_group_ + 1) % polyphony_;
envelope_flags[active_group_] = ENVELOPE_FLAG_RISING_EDGE;
acquisition_delay_ = 3;
}
if(acquisition_delay_)
{
--acquisition_delay_;
}
else
{
group_[active_group_].tonic = note_filter_.note();
group_[active_group_].chord = performance_state.chord;
group_[active_group_].structure = patch.structure;
envelope_flags[active_group_] |= ENVELOPE_FLAG_GATE;
}
// Process envelopes.
float envelope_values[kMaxStringSynthPolyphony];
ProcessEnvelopes(patch.damping, envelope_flags, envelope_values);
copy(&in[0], &in[size], &aux[0]);
copy(&in[0], &in[size], &out[0]);
int32_t chord_size = min(kStringSynthVoices / polyphony_, kMaxChordSize);
for(int32_t group = 0; group < polyphony_; ++group)
{
ChordNote notes[kMaxChordSize];
float harmonics[kNumHarmonics * 2];
ComputeRegistration(
envelope_values[group] * 0.25f, patch.brightness, harmonics);
// Note enough polyphony for smooth transition between chords.
for(int32_t i = 0; i < chord_size; ++i)
{
float n = chords[polyphony_ - 1][group_[group].chord][i];
notes[i].note = n;
notes[i].amplitude = n >= 0.0f && n <= 17.0f ? 1.0f : 0.7f;
}
for(int32_t chord_note = 0; chord_note < chord_size; ++chord_note)
{
float note = 0.0f;
note += group_[group].tonic;
note += performance_state.tonic;
note += performance_state.fm;
note += notes[chord_note].note;
float amplitudes[kNumHarmonics * 2];
for(int32_t i = 0; i < kNumHarmonics * 2; ++i)
{
amplitudes[i] = notes[chord_note].amplitude * harmonics[i];
}
// Fold truncated harmonics.
size_t num_harmonics = polyphony_ >= 2 && chord_note < 2
? kNumHarmonics - 1
: kNumHarmonics;
for(int32_t i = num_harmonics; i < kNumHarmonics; ++i)
{
amplitudes[2 * (num_harmonics - 1)] += amplitudes[2 * i];
amplitudes[2 * (num_harmonics - 1) + 1]
+= amplitudes[2 * i + 1];
}
float frequency = SemitonesToRatio(note - 69.0f) * a3;
voice_[group * chord_size + chord_note].Render(
frequency,
amplitudes,
num_harmonics,
(group + chord_note) & 1 ? out : aux,
size);
}
}
if(clear_fx_)
{
reverb_.Clear();
clear_fx_ = false;
}
switch(fx_type_)
{
case FX_FORMANT:
case FX_FORMANT_2:
ProcessFormantFilter(patch.position,
fx_type_ == FX_FORMANT ? 1.0f : 1.1f,
fx_type_ == FX_FORMANT ? 25.0f : 10.0f,
out,
aux,
size);
break;
case FX_CHORUS:
chorus_.set_amount(patch.position);
chorus_.set_depth(0.15f + 0.5f * patch.position);
chorus_.Process(out, aux, size);
break;
case FX_ENSEMBLE:
ensemble_.set_amount(patch.position * (2.0f - patch.position));
ensemble_.set_depth(0.2f + 0.8f * patch.position * patch.position);
ensemble_.Process(out, aux, size);
break;
case FX_REVERB:
case FX_REVERB_2:
reverb_.set_amount(patch.position * 0.5f);
reverb_.set_diffusion(0.625f);
reverb_.set_time(fx_type_ == FX_REVERB
? (0.5f + 0.49f * patch.position)
: (0.3f + 0.6f * patch.position));
reverb_.set_input_gain(0.2f);
reverb_.set_lp(fx_type_ == FX_REVERB ? 0.3f : 0.6f);
reverb_.Process(out, aux, size);
break;
default: break;
}
// Prevent main signal cancellation when EVEN gets summed with ODD through
// normalization.
for(size_t i = 0; i < size; ++i)
{
aux[i] = -aux[i];
}
limiter_.Process(out, aux, size, 1.0f);
}
} // namespace torus | 36.816017 | 80 | 0.502264 | [
"render",
"shape",
"model"
] |
24e074d50adf21fe5b0800485afc3133872520b8 | 5,093 | cc | C++ | src/io.cc | cb-geo/mpm-point-generator | 5ee7fc1655a405c20960ce2fc28551ee7d66e5a0 | [
"MIT"
] | null | null | null | src/io.cc | cb-geo/mpm-point-generator | 5ee7fc1655a405c20960ce2fc28551ee7d66e5a0 | [
"MIT"
] | 71 | 2017-05-24T18:53:39.000Z | 2020-03-19T04:06:04.000Z | src/io.cc | cb-geo/mpm-point-generator | 5ee7fc1655a405c20960ce2fc28551ee7d66e5a0 | [
"MIT"
] | 4 | 2017-05-24T18:37:55.000Z | 2020-02-26T18:08:10.000Z | #include "io.h"
//! Constructor with argc and argv
//! \param[in] argc Number of input arguments
//! \param[in] argv Array of input arguments
IO::IO(int argc, char** argv) {
// Set title
TCLAP::CmdLine cmd("Material Point Generator (CB-Geo)", ' ', "0.0.1");
// Define dimension
// TCLAP::ValueArg<unsigned int> dim_arg(
// "d", "dimension", "Problem dimension", true, 3, "Dimension");
// cmd.add(dim_arg);
// Define working directory
TCLAP::ValueArg<std::string> cwd_arg(
"f", "working_dir", "Current working folder", true, "", "Working_folder");
cmd.add(cwd_arg);
// Define input file
TCLAP::ValueArg<std::string> input_arg("i", "input_file",
"Input JSON file [cube.json]", false,
"cube.json", "input_file");
cmd.add(input_arg);
// Parse arguments
cmd.parse(argc, argv);
//! Set working directory
working_dir_ = cwd_arg.getValue();
//! Set input file if the optional argument is not empty
const auto input_file = input_arg.getValue();
const auto json_filename = working_dir_ + input_file;
//! Check if json file is present
std::ifstream inputFile(json_filename);
try {
if (!inputFile.is_open())
throw std::runtime_error(
std::string("Input file not found in specified location: ") +
json_filename);
} catch (const std::runtime_error& except) {
std::cerr << "Exception opening/reading json file";
}
//! Store json object as private variable
//! Read json file and store to private variables
json_ = json::parse(inputFile);
}
//! \brief Return user-specified mesh file name
std::string IO::mesh_file_name() const {
std::string mesh_file_name;
//! Check if mesh file is present
mesh_file_name =
working_dir_ + json_["mesh_file"].template get<std::string>();
std::ifstream meshfile;
meshfile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try {
meshfile.open(mesh_file_name);
} catch (const std::ifstream::failure& except) {
std::cerr << "Exception opening/reading mesh file";
}
meshfile.close();
return mesh_file_name;
}
//! \brief Return user-specified material propertes
std::vector<Json> IO::material_properties() const {
std::vector<Json> json_material_properties;
// Store json object for material properties
// IO handles null json object by making empty json object
// MaterialProperties class could handle empty json object
for (unsigned i = 0; i < json_["material_properties"].size(); i++) {
if (!json_["material_properties"].is_null()) {
json_material_properties.emplace_back(json_["material_properties"].at(i));
} else {
std::cout << "No material properties specified, using default\n";
json_material_properties.clear();
}
}
return json_material_properties;
}
//! \brief Return user-specified gauss points
unsigned IO::ngauss_points() const {
unsigned ngauss_points{0};
//! Read and pass the
//! If not specified, set default value of 1
try {
if (json_.at("ngauss_points").size())
ngauss_points = json_["ngauss_points"].template get<unsigned>();
} catch (json::out_of_range& out_of_range) {
std::cerr << out_of_range.what() << '\n';
std::cout << "ngauss_points not specified. Using a default value of 1\n";
ngauss_points = 1;
}
return ngauss_points;
}
//! \brief Return user-specified dimension
unsigned IO::dimension() const {
unsigned dimension{0};
//! Read and pass the
//! If not specified, set default value of 1
try {
if (json_.at("dimension").size())
dimension = json_["dimension"].template get<unsigned>();
} catch (json::out_of_range& out_of_range) {
std::cerr << out_of_range.what() << '\n';
std::cout << "dimension not specified. Using a default value of 2\n";
dimension = 2;
}
return dimension;
}
//! \brief Write output file names and store them in private member
//! \param[in] attribute Attribute being written (eg., material_points / stress)
//! \param[in] file_extension File Extension (*.txt)
boost::filesystem::path IO::output_file(const std::string& attribute,
const std::string& file_extension) {
std::stringstream file_name;
std::string path{"results/"};
try {
auto results = json_.at("results_path");
if (!results.empty()) path = results;
} catch (std::exception& except) {
std::cerr << except.what() << '\n';
// console_->error("Output file creation: {}", except.what());
// console_->warn("Using default path: {}", path);
}
//! Make the file_name
file_name.str(std::string());
file_name << attribute << file_extension;
//! Include path
if (!path.empty()) path = working_dir_ + path;
//! Create results folder if not present
boost::filesystem::path dir(path);
if (!boost::filesystem::exists(dir)) boost::filesystem::create_directory(dir);
//! Create full path with working directory path and file name
boost::filesystem::path file_path(path + file_name.str().c_str());
return file_path;
} | 30.680723 | 80 | 0.660122 | [
"mesh",
"object",
"vector"
] |
24e0883296f3deb0a11e6daab154779dd1b0b1d9 | 7,443 | hpp | C++ | thrill/core/fold_by_hash_post_phase.hpp | SDEagle/thrill | f0e5aa2326a55af3c9a92fc418f8eb8e3cf8c5fa | [
"BSD-2-Clause"
] | 1 | 2020-08-04T19:16:16.000Z | 2020-08-04T19:16:16.000Z | thrill/core/fold_by_hash_post_phase.hpp | tim3z/thrill | f0e5aa2326a55af3c9a92fc418f8eb8e3cf8c5fa | [
"BSD-2-Clause"
] | null | null | null | thrill/core/fold_by_hash_post_phase.hpp | tim3z/thrill | f0e5aa2326a55af3c9a92fc418f8eb8e3cf8c5fa | [
"BSD-2-Clause"
] | null | null | null | /*******************************************************************************
* thrill/core/reduce_by_hash_post_phase.hpp
*
* Hash table with support for reduce.
*
* Part of Project Thrill - http://project-thrill.org
*
* Copyright (C) 2015 Matthias Stumpp <mstumpp@gmail.com>
* Copyright (C) 2015 Alexander Noe <aleexnoe@gmail.com>
* Copyright (C) 2015-2016 Timo Bingmann <tb@panthema.net>
*
* All rights reserved. Published under the BSD-2 license in the LICENSE file.
******************************************************************************/
#pragma once
#ifndef THRILL_CORE_FOLD_BY_HASH_POST_PHASE_HEADER
#define THRILL_CORE_FOLD_BY_HASH_POST_PHASE_HEADER
#include <thrill/api/context.hpp>
#include <thrill/common/logger.hpp>
#include <thrill/core/fold_functional.hpp>
#include <thrill/core/fold_probing_hash_table.hpp>
#include <thrill/data/file.hpp>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <string>
#include <utility>
#include <vector>
namespace thrill {
namespace core {
template <typename ValueOut, typename ValueIn, typename Key,
typename KeyExtractor, typename FoldFunction, typename Emitter,
typename FoldConfig_ = DefaultFoldConfig,
typename IndexFunction = ReduceByHash<Key>,
typename KeyEqualFunction = std::equal_to<Key> >
class FoldByHashPostPhase
{
static constexpr bool debug = false;
public:
using FoldConfig = FoldConfig_;
using PhaseEmitter = FoldPostPhaseEmitter<
ValueOut, ValueIn, Emitter>;
using Table = typename FoldTableSelect<
FoldConfig::table_impl_,
ValueOut, Key, ValueIn,
KeyExtractor, FoldFunction, PhaseEmitter,
FoldConfig, IndexFunction, KeyEqualFunction>::type;
/*!
* A data structure which takes an arbitrary value and extracts a key using
* a key extractor function from that value. Afterwards, the value is hashed
* based on the key into some slot.
*/
FoldByHashPostPhase(
Context& ctx, size_t dia_id,
const KeyExtractor& key_extractor,
const FoldFunction& fold_function,
const Emitter& emit,
const FoldConfig& config = FoldConfig(),
const IndexFunction& index_function = IndexFunction(),
const KeyEqualFunction& key_equal_function = KeyEqualFunction())
: config_(config),
emitter_(emit),
table_(ctx, dia_id,
key_extractor, fold_function, emitter_,
/* num_partitions */ 32, /* TODO(tb): parameterize */
config, /* immediate_flush */ false,
index_function, key_equal_function),
spilling_file_(ctx.GetFile(dia_id)) { }
//! non-copyable: delete copy-constructor
FoldByHashPostPhase(const FoldByHashPostPhase&) = delete;
//! non-copyable: delete assignment operator
FoldByHashPostPhase& operator = (const FoldByHashPostPhase&) = delete;
void Initialize(size_t limit_memory_bytes) {
table_.Initialize(limit_memory_bytes);
spilling_writer_ = spilling_file_.GetWriter();
}
void Insert(const ValueIn& value) {
if (!table_.Insert(value)) {
spilling_writer_.Put(value);
}
}
//! Flushes all items in the whole table.
template <bool DoCache>
void Flush(bool consume, data::File::Writer* writer = nullptr) {
LOG << "Flushing items";
// read primary hash table, since ReduceByHash delivers items in any
// order, we can just emit items from fully reduced partitions.
table_.FlushAll(consume, /* grow */ false,
[this, writer](const size_t& partition_id, const ValueOut& p) {
if (DoCache) writer->Put(p);
emitter_.Emit(partition_id, p);
});
if (spilling_file_.num_items() == 0) {
LOG << "Flushed items directly.";
return;
}
table_.Dispose();
assert(consume && "Items were spilled hence Flushing must consume");
// if partially reduce files remain, create new hash tables to process
// them iteratively.
data::File remaining_items = std::move(spilling_file_);
size_t iteration = 0;
while (remaining_items.num_items() > 0)
{
data::File next_spill = table_.ctx().GetFile(table_.dia_id());
data::File::Writer next_writer = next_spill.GetWriter();
Table subtable(
table_.ctx(), table_.dia_id(),
table_.key_extractor(), table_.fold_function(), emitter_,
/* num_partitions */ 32, config_, /* immediate_flush */ false,
IndexFunction(iteration, table_.index_function()),
table_.key_equal_function());
subtable.Initialize(table_.limit_memory_bytes());
auto reader = remaining_items.GetConsumeReader();
while (reader.HasNext()) {
const ValueIn& value = reader.template Next<ValueIn>();
if (!subtable.Insert(value)) {
next_writer.Put(value);
}
}
subtable.FlushAll(consume, /* grow */ false,
[this, writer](const size_t& partition_id, const ValueOut& p) {
if (DoCache) writer->Put(p);
emitter_.Emit(partition_id, p);
});
subtable.Dispose();
next_writer.Close();
remaining_items = std::move(next_spill);
++iteration;
}
LOG << "Flushed items";
}
//! Push data into emitter
void PushData(bool consume = false) {
spilling_writer_.Close();
if (!cache_)
{
if (spilling_file_.num_items() == 0) {
// all items did fit into the table
Flush</* DoCache */ false>(consume);
}
else {
// we have items left over
cache_ = table_.ctx().GetFilePtr(table_.dia_id());
data::File::Writer writer = cache_->GetWriter();
Flush</* DoCache */ true>(true, &writer);
}
}
else
{
// previous PushData() has stored data in cache_
data::File::Reader reader = cache_->GetReader(consume);
while (reader.HasNext())
emitter_.Emit(reader.Next<ValueOut>());
}
}
void Dispose() {
table_.Dispose();
if (cache_) cache_.reset();
}
//! \name Accessors
//! \{
//! Returns mutable reference to first table_
Table& table() { return table_; }
//! Returns the total num of items in the table.
size_t num_items() const { return table_.num_items(); }
//! \}
private:
//! Stored reduce config to initialize the subtable.
FoldConfig config_;
//! Emitters used to parameterize hash table for output to next DIA node.
PhaseEmitter emitter_;
//! the first-level hash table implementation
Table table_;
//! File for storing data in-case we need multiple re-reduce levels.
data::FilePtr cache_;
data::File spilling_file_;
data::File::Writer spilling_writer_;
};
} // namespace core
} // namespace thrill
#endif // !THRILL_CORE_REDUCE_BY_HASH_POST_PHASE_HEADER
/******************************************************************************/
| 32.644737 | 80 | 0.592369 | [
"vector"
] |
24e0e2e4e543f24864f29e4985a65732fec88893 | 4,480 | hpp | C++ | src/tbs_game.hpp | sweetkristas/anura | 5e8cbcfc7b761c5c01e5c5509a0fb159b8fb60cd | [
"CC0-1.0"
] | null | null | null | src/tbs_game.hpp | sweetkristas/anura | 5e8cbcfc7b761c5c01e5c5509a0fb159b8fb60cd | [
"CC0-1.0"
] | null | null | null | src/tbs_game.hpp | sweetkristas/anura | 5e8cbcfc7b761c5c01e5c5509a0fb159b8fb60cd | [
"CC0-1.0"
] | null | null | null | /*
Copyright (C) 2003-2013 by David White <davewx7@gmail.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.
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/>.
*/
#ifndef GAME_HPP_INCLUDED
#define GAME_HPP_INCLUDED
#include <boost/intrusive_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <deque>
#include <set>
#include "db_client.hpp"
#include "tbs_ai_player.hpp"
#include "tbs_bot.hpp"
#include "formula_callable.hpp"
#include "variant.hpp"
namespace tbs {
struct game_type;
class game : public game_logic::formula_callable
{
public:
struct error {
error(const std::string& m);
std::string msg;
};
static void reload_game_types();
static boost::intrusive_ptr<game> create(const variant& v);
static game* current();
explicit game(const game_type& type);
explicit game(const variant& v);
game(const std::string& game_type, const variant& doc);
virtual ~game();
void cancel_game();
virtual variant write(int nplayer=-1, int processing_ms=-1) const;
virtual void handle_message(int nplayer, const variant& msg);
int game_id() const { return game_id_; }
struct message {
std::vector<int> recipients;
std::string contents;
};
void swap_outgoing_messages(std::vector<message>& msg);
bool started() const { return started_; }
virtual bool full() const { return players_.size() == 2; }
virtual void add_player(const std::string& name);
virtual void add_ai_player(const std::string& name, const variant& info);
std::vector<std::string> get_ai_players() const;
virtual void remove_player(const std::string& name);
struct player {
player();
std::string name;
int side;
bool is_human;
int confirmed_state_id;
mutable variant state_sent;
mutable int state_id_sent;
bool allow_deltas;
};
int get_player_index(const std::string& nick) const;
std::vector<player>& players() { return players_; }
const std::vector<player>& players() const { return players_; }
void queue_message(const std::string& msg, int nplayer=-1);
void queue_message(const char* msg, int nplayer=-1);
void queue_message(const variant& msg, int nplayer=-1);
virtual void setup_game();
virtual void set_as_current_game(bool set) {}
void process();
int state_id() const { return state_id_; }
void player_disconnect(int nplayer);
void player_reconnect(int nplayer);
void player_disconnected_for(int nplayer, int time_ms);
protected:
void start_game();
virtual void send_game_state(int nplayer=-1, int processing_ms=-1);
void ai_play();
void send_notify(const std::string& msg, int nplayer=-1);
void send_error(const std::string& msg, int nplayer=-1);
void set_message(const std::string& msg);
private:
virtual variant get_value(const std::string& key) const;
virtual void set_value(const std::string& key, const variant& value);
virtual ai_player* create_ai() const { return NULL; }
const game_type& type_;
int game_id_;
bool started_;
int state_id_; //upward counting integer keeping track of the game state.
int rng_seed_;
int cycle_;
int tick_rate_;
//a message which explains the reason for the last game state change.
std::string current_message_;
std::vector<player> players_;
std::vector<int> players_disconnected_;
std::vector<message> outgoing_messages_;
std::vector<std::string> log_;
enum GAME_STATE { STATE_SETUP, STATE_PLAYING };
GAME_STATE state_;
std::vector<boost::shared_ptr<ai_player> > ai_;
variant doc_;
game_logic::formula_callable* backup_callable_;
std::vector<boost::intrusive_ptr<tbs::bot> > bots_;
void handle_event(const std::string& name, game_logic::formula_callable* variables=NULL);
void execute_command(variant cmd);
mutable db_client_ptr db_client_;
};
class game_context {
game* old_game_;
public:
explicit game_context(game* g);
void set(game* g);
~game_context();
};
typedef boost::intrusive_ptr<game> game_ptr;
typedef boost::intrusive_ptr<const game> const_game_ptr;
}
#endif
| 24.347826 | 90 | 0.740625 | [
"vector"
] |
24e2349d8046e8e8a5e3f7135a920329877864b8 | 1,698 | cc | C++ | lib/sk/rt/logger/StableHeadCycler.cc | stemkit-collection/stemkit-cpp | dfa77d831f49916ba6d134f407a4dcd0983328f6 | [
"MIT"
] | 4 | 2019-02-19T16:48:41.000Z | 2022-01-31T07:57:54.000Z | lib/sk/rt/logger/StableHeadCycler.cc | stemkit-collection/stemkit-cpp | dfa77d831f49916ba6d134f407a4dcd0983328f6 | [
"MIT"
] | 1 | 2019-01-30T04:48:35.000Z | 2019-01-30T04:48:35.000Z | lib/sk/rt/logger/StableHeadCycler.cc | stemkit-collection/stemkit-cpp | dfa77d831f49916ba6d134f407a4dcd0983328f6 | [
"MIT"
] | null | null | null | /* vim: set sw=2:
* Copyright (c) 2008, Gennady Bystritsky <bystr@mac.com>
*
* Distributed under the MIT Licence.
* This is free software. See 'LICENSE' for details.
* You must read and accept the license prior to use.
*
* Author: Gennady Bystritsky
*/
#include <sk/util/Class.h>
#include <sk/util/String.h>
#include <sk/util/SystemException.h>
#include "StableHeadCycler.h"
#include <unistd.h>
sk::rt::logger::StableHeadCycler::
StableHeadCycler(const sk::util::Pathname& pathname)
: AbstractCycler(pathname), _nextChunk(0)
{
}
sk::rt::logger::StableHeadCycler::
~StableHeadCycler()
{
}
bool
sk::rt::logger::StableHeadCycler::
scanFile()
{
return readMarker(getPath(), _nextChunk);
}
void
sk::rt::logger::StableHeadCycler::
initFile()
{
writeMarker(getPath(), _nextChunk);
}
void
sk::rt::logger::StableHeadCycler::
cycleFile()
{
sk::util::String backup = makeChunkPath(_nextChunk);
unlink(backup.getChars());
if(rename(getPath().getChars(), backup.getChars()) < 0) {
throw sk::util::SystemException(sk::util::String("rename():") + getPath());
}
_nextChunk += 1;
int chunks = getChunks();
if(chunks > 0) {
if(_nextChunk >= chunks) {
_nextChunk = 0;
}
}
}
const sk::util::String
sk::rt::logger::StableHeadCycler::
getPath() const
{
return getPathname().toString();
}
const sk::util::Pathname&
sk::rt::logger::StableHeadCycler::
getPathname() const
{
return getMasterPathname();
}
sk::util::Object*
sk::rt::logger::StableHeadCycler::
clone() const
{
return new StableHeadCycler(*this);
}
const sk::util::Class
sk::rt::logger::StableHeadCycler::
getClass() const
{
return sk::util::Class("sk::rt::logger::StableHeadCycler");
}
| 18.866667 | 79 | 0.684923 | [
"object"
] |
008d7a550011fff68328ca55340a29eb915c9a93 | 2,768 | cc | C++ | test/fuzzers/congestion_controller_feedback_fuzzer.cc | bebo/webrtc | 61ab9c5200ffb1281d038978465543cc52598e16 | [
"DOC",
"BSD-3-Clause"
] | null | null | null | test/fuzzers/congestion_controller_feedback_fuzzer.cc | bebo/webrtc | 61ab9c5200ffb1281d038978465543cc52598e16 | [
"DOC",
"BSD-3-Clause"
] | null | null | null | test/fuzzers/congestion_controller_feedback_fuzzer.cc | bebo/webrtc | 61ab9c5200ffb1281d038978465543cc52598e16 | [
"DOC",
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
namespace webrtc {
class NullBitrateObserver : public CongestionController::Observer,
public RemoteBitrateObserver {
public:
~NullBitrateObserver() override {}
// TODO(minyue): remove this when old OnNetworkChanged is deprecated. See
// https://bugs.chromium.org/p/webrtc/issues/detail?id=6796
using CongestionController::Observer::OnNetworkChanged;
void OnNetworkChanged(uint32_t bitrate_bps,
uint8_t fraction_loss,
int64_t rtt_ms,
int64_t bwe_period_ms) override {}
void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
uint32_t bitrate) override {}
};
void FuzzOneInput(const uint8_t* data, size_t size) {
size_t i = 0;
if (size < sizeof(int64_t) + sizeof(uint8_t) + sizeof(uint32_t))
return;
SimulatedClock clock(data[i++]);
NullBitrateObserver observer;
RtcEventLogNullImpl event_log;
PacketRouter packet_router;
CongestionController cc(&clock, &observer, &observer, &event_log,
&packet_router);
RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true);
RTPHeader header;
header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]);
i += sizeof(uint32_t);
header.extension.hasTransportSequenceNumber = true;
int64_t arrival_time_ms =
std::max<int64_t>(ByteReader<int64_t>::ReadBigEndian(&data[i]), 0);
i += sizeof(int64_t);
const size_t kMinPacketSize =
sizeof(size_t) + sizeof(uint16_t) + sizeof(uint8_t);
while (i + kMinPacketSize < size) {
size_t payload_size = ByteReader<size_t>::ReadBigEndian(&data[i]) % 1500;
i += sizeof(size_t);
header.extension.transportSequenceNumber =
ByteReader<uint16_t>::ReadBigEndian(&data[i]);
i += sizeof(uint16_t);
rbe->IncomingPacket(arrival_time_ms, payload_size, header);
clock.AdvanceTimeMilliseconds(5);
arrival_time_ms += ByteReader<uint8_t>::ReadBigEndian(&data[i]);
arrival_time_ms += sizeof(uint8_t);
}
rbe->Process();
}
} // namespace webrtc
| 40.115942 | 85 | 0.708454 | [
"vector"
] |
00949df1a7e2af90b9b5f3edb8ccb1f7a7ef619f | 11,322 | cpp | C++ | Solution/PhoenixTests/Source/Tests/ECS/ECSTest.cpp | rohunb/PhoenixEngine | 4d21f9000c2e0c553c398785e8cebff1bc190a8c | [
"MIT"
] | 2 | 2017-11-09T20:05:36.000Z | 2018-07-05T00:55:01.000Z | Solution/PhoenixTests/Source/Tests/ECS/ECSTest.cpp | rohunb/PhoenixEngine | 4d21f9000c2e0c553c398785e8cebff1bc190a8c | [
"MIT"
] | null | null | null | Solution/PhoenixTests/Source/Tests/ECS/ECSTest.cpp | rohunb/PhoenixEngine | 4d21f9000c2e0c553c398785e8cebff1bc190a8c | [
"MIT"
] | null | null | null | #include "Tests/ECS/ECSTest.h"
#include "ECS/ComponentManager.h"
#include "ECS/ComponentManagerConfig.h"
#include "ECS/RequirementBitArrayStorage.h"
#include "Math/Vector3D.h"
#include "Utility/Debug/Assert.h"
#include "Utility/MetaProgramming/TypeList.h"
#include <iostream>
using namespace Phoenix;
namespace ECSTestStructs
{
struct Comp0 {};
struct Comp1 {};
struct Comp2 {};
using ComponentList = TTypeList<Comp0, Comp1, Comp2>;
struct Tag0 {};
struct Tag1 {};
using TagList = TTypeList<Tag0, Tag1>;
using Requirement0 = TTypeList<>;
using Requirement1 = TTypeList<Tag0, Comp0, Comp2>;
using Requirement2 = TTypeList<Tag1, Comp2, Comp1>;
using Requirement3 = TTypeList<Comp0, Comp1>;
using RequirementList = TTypeList<Requirement0, Requirement1, Requirement2, Requirement3>;
template<typename TRequirement>
struct TSystem0 {};
using System0 = TSystem0<Requirement1>;
using SystemList = TTypeList<System0>;
using Config = TComponentManagerConfig<ComponentList, TagList, RequirementList, SystemList>;
}
void FECSTest::RunTests() const
{
TestRequirementBitArrays();
TestComponentManager();
}
void FECSTest::TestRequirementBitArrays() const
{
using namespace ECSTestStructs;
TRequirementBitArrayStorage<Config> RequirementBitArrays;
const auto& RequirementBitArray0 = RequirementBitArrays.GetRequirementBitArray<Requirement0>();
const auto& RequirementBitArray1 = RequirementBitArrays.GetRequirementBitArray<Requirement1>();
const auto& RequirementBitArray2 = RequirementBitArrays.GetRequirementBitArray<Requirement2>();
const auto& RequirementBitArray3 = RequirementBitArrays.GetRequirementBitArray<Requirement3>();
//BitArray Arrangement: {Tag1, Tag0, Comp2, Comp1, Comp0}
using BitArray = Config::ComponentsBitArray;
F_AssertEqual(RequirementBitArray0, BitArray { "00000" }, "Requirement Bit Array is Incorrect");
F_AssertEqual(RequirementBitArray1, BitArray { "01101" }, "Requirement Bit Array is Incorrect");
F_AssertEqual(RequirementBitArray2, BitArray { "10110" }, "Requirement Bit Array is Incorrect");
F_AssertEqual(RequirementBitArray3, BitArray { "00011" }, "Requirement Bit Array is Incorrect");
}
void FECSTest::TestComponentManager() const
{
ManagerBasicTests();
ManagerKillTests();
ManagerComponentTests();
}
void FECSTest::ManagerBasicTests() const
{
using namespace ECSTestStructs;
TComponentManager<Config> ComponentManager;
std::cout << "Component Manager Initialized...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 0, "Component Manager incorrect state");
using EntityID = TComponentManager<Config>::EntityID;
EntityID Entity0 = ComponentManager.CreateEntity();
std::cout << "First Entity Created...\n";
ComponentManager.PrintState();
EntityID Entity1 = ComponentManager.CreateEntity();
std::cout << "Second Entity Created...\n";
ComponentManager.PrintState();
F_AssertFalse(ComponentManager.HasTag<Tag0>(Entity0), "Tag error");
ComponentManager.AddTag<Tag0>(Entity0);
F_Assert(ComponentManager.HasTag<Tag0>(Entity0), "Tag error");
F_AssertFalse(ComponentManager.HasTag<Tag1>(Entity1), "Tag error");
ComponentManager.AddTag<Tag1>(Entity1);
F_Assert(ComponentManager.HasTag<Tag1>(Entity1), "Tag error");
F_Assert(ComponentManager.HasTag<Tag0>(Entity0), "Tag error");
ComponentManager.RemoveTag<Tag0>(Entity0);
F_AssertFalse(ComponentManager.HasTag<Tag0>(Entity0), "Tag error");
F_AssertFalse(ComponentManager.HasComponent<Comp0>(Entity0), "Component error");
ComponentManager.AddComponent<Comp0>(Entity0);
F_Assert(ComponentManager.HasComponent<Comp0>(Entity0), "Component error");
F_AssertFalse(ComponentManager.HasComponent<Comp1>(Entity1), "Component error");
ComponentManager.AddComponent<Comp1>(Entity1);
F_Assert(ComponentManager.HasComponent<Comp1>(Entity1), "Component error");
F_Assert(ComponentManager.HasComponent<Comp0>(Entity0), "Component error");
ComponentManager.RemoveComponent<Comp0>(Entity0);
F_AssertFalse(ComponentManager.HasComponent<Comp0>(Entity0), "Component error");
F_AssertEqual(ComponentManager.GetEntityCount(), 0, "Entity count should remain at 0 until Refreshed");
ComponentManager.Refresh();
std::cout << "After Refresh...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 2, "Entity count should be updated after Refresh");
F_AssertFalse(ComponentManager.HasTag<Tag0>(Entity0), "Tag error");
F_Assert(ComponentManager.HasTag<Tag1>(Entity1), "Tag error");
F_AssertFalse(ComponentManager.HasComponent<Comp0>(Entity0), "Component error");
F_Assert(ComponentManager.HasComponent<Comp1>(Entity1), "Component error");
ComponentManager.Clear();
std::cout << "After Clear...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 0, "Entity count be 0 after Clear");
}
void FECSTest::ManagerKillTests() const
{
using namespace ECSTestStructs;
TComponentManager<Config> ComponentManager;
using EntityID = TComponentManager<Config>::EntityID;
//Fill up...assuming 10 initial size
const SizeT StartingSize = 10;
F_AssertEqual(TComponentManager<Config>::StartingSize, StartingSize, "Update starting size");
for (SizeT I = 0; I < StartingSize; ++I)
{
ComponentManager.CreateEntity();
}
F_AssertEqual(ComponentManager.GetEntityCount(), 0, "Entity Count incorrect");
std::cout << "Filled starting entities...\n";
ComponentManager.PrintState();
ComponentManager.Refresh();
std::cout << "Refreshed...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 10, "Entity Count incorrect");
EntityID Entity10 = ComponentManager.CreateEntity();
F_AssertEqual(ComponentManager.GetEntityCount(), 10, "Entity Count incorrect");
std::cout << "11th entity...\n";
ComponentManager.PrintState();
ComponentManager.Refresh();
std::cout << "Refreshed...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 11, "Entity Count incorrect");
F_AssertEqual(ComponentManager.GetCapacity(), 20, "Capacity incorrect");
ComponentManager.Destroy(Entity10);
F_AssertEqual(ComponentManager.GetEntityCount(), 11, "Entity Count incorrect");
std::cout << "11th entity killed...\n";
ComponentManager.PrintState();
ComponentManager.Refresh();
std::cout << "Refreshed...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 10, "Entity Count incorrect");
F_AssertEqual(ComponentManager.GetCapacity(), 20, "Capacity incorrect");
Entity10 = ComponentManager.CreateEntity();
EntityID Entity11 = ComponentManager.CreateEntity();
F_AssertEqual(ComponentManager.GetEntityCount(), 10, "Entity Count incorrect");
std::cout << "12th entity...\n";
ComponentManager.PrintState();
ComponentManager.Refresh();
std::cout << "Refreshed...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 12, "Entity Count incorrect");
ComponentManager.Destroy(0);
F_AssertEqual(ComponentManager.GetEntityCount(), 12, "Entity Count incorrect");
std::cout << "0th entity killed...\n";
ComponentManager.PrintState();
ComponentManager.Refresh();
std::cout << "Refreshed...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 11, "Entity Count incorrect");
ComponentManager.Destroy(5);
F_AssertEqual(ComponentManager.GetEntityCount(), 11, "Entity Count incorrect");
std::cout << "5th entity killed...\n";
ComponentManager.PrintState();
ComponentManager.Refresh();
std::cout << "Refreshed...\n";
ComponentManager.PrintState();
F_AssertEqual(ComponentManager.GetEntityCount(), 10, "Entity Count incorrect");
ComponentManager.ForEntities([&ComponentManager](EntityID ID)
{
const auto& Entity = ComponentManager.GetEntityByID(ID);
const auto& BitArray = Entity.BitArray;
std::cout << BitArray << std::endl;
});
}
void FECSTest::ManagerComponentTests() const
{
struct CTransform
{
FVector3D Position;
CTransform() = default;
CTransform(const FVector3D& Position)
: Position(Position)
{}
};
struct CRigidBody
{
FVector3D Velocity;
CRigidBody() = default;
CRigidBody(const FVector3D& Velocity)
: Velocity(Velocity)
{}
};
using ComponentList = TTypeList<CTransform, CRigidBody>;
using TagList = TTypeList<>;
using RequirementList = TTypeList<>;
using SystemList = TTypeList<>;
using Config = TComponentManagerConfig<ComponentList, TagList, RequirementList, SystemList>;
TComponentManager<Config> ComponentManager;
typedef TComponentManager<Config>::EntityID EntityID;
EntityID Entity0 = ComponentManager.CreateEntity();
ComponentManager.Refresh();
FVector3D Position { 1.0f, 1.0f, 1.0f };
ComponentManager.AddComponent<CTransform>(Entity0, Position);
F_Assert(ComponentManager.HasComponent<CTransform>(Entity0), "Add Component failed");
CTransform& Transform = ComponentManager.GetComponent<CTransform>(Entity0);
F_AssertEqual(Transform.Position, Position, "Component data incorrect");
FVector3D DefaultVector;
FVector3D HighVelocity { 10.0f, 20.0f, 30.0f };
ComponentManager.AddComponent<CRigidBody>(Entity0);
F_Assert(ComponentManager.HasComponent<CRigidBody>(Entity0), "Add Component failed");
CRigidBody& Rigidbody = ComponentManager.GetComponent<CRigidBody>(Entity0);
F_AssertEqual(Rigidbody.Velocity, DefaultVector, "Component data incorrect");
ComponentManager.RemoveComponent<CRigidBody>(Entity0);
F_AssertFalse(ComponentManager.HasComponent<CRigidBody>(Entity0), "Remove Component failed");
ComponentManager.AddComponent<CRigidBody>(Entity0, HighVelocity);
F_Assert(ComponentManager.HasComponent<CRigidBody>(Entity0), "Add Component failed");
CRigidBody& NewRigidbody = ComponentManager.GetComponent<CRigidBody>(Entity0);
F_AssertEqual(NewRigidbody.Velocity, HighVelocity, "Component data incorrect");
EntityID Entity1 = ComponentManager.CreateEntity();
ComponentManager.AddComponent<CTransform>(Entity1, FVector3D(2.0f, 2.0f, 2.0f));
ComponentManager.AddComponent<CRigidBody>(Entity1, FVector3D(2.0f, 2.0f, 2.0f));
EntityID Entity2 = ComponentManager.CreateEntity();
ComponentManager.AddComponent<CTransform>(Entity2, FVector3D(4.0f, 4.0f, 4.0f));
ComponentManager.AddComponent<CRigidBody>(Entity2, FVector3D(4.0f, 4.0f, 4.0f));
ComponentManager.Refresh();
CTransform& Transform1 = ComponentManager.GetComponent<CTransform>(Entity1);
F_AssertEqual(Transform1.Position, FVector3D(2.0f,2.0f,2.0f), "Component data incorrect");
CRigidBody& Rigidbody1 = ComponentManager.GetComponent<CRigidBody>(Entity1);
F_AssertEqual(Rigidbody1.Velocity, FVector3D(2.0f, 2.0f, 2.0f), "Component data incorrect");
ComponentManager.Destroy(Entity1);
ComponentManager.Refresh();
EntityID Entity3 = ComponentManager.CreateEntity();
ComponentManager.AddComponent<CTransform>(Entity3, FVector3D(3.0f, 3.0f, 3.0f));
ComponentManager.AddComponent<CRigidBody>(Entity3, FVector3D(3.0f, 3.0f, 3.0f));
ComponentManager.Refresh();
CTransform& Transform2 = ComponentManager.GetComponent<CTransform>(Entity3);
F_AssertEqual(Transform2.Position, FVector3D(3.0f, 3.0f, 3.0f), "Component data incorrect");
CRigidBody& Rigidbody2 = ComponentManager.GetComponent<CRigidBody>(Entity3);
F_AssertEqual(Rigidbody2.Velocity, FVector3D(3.0f, 3.0f, 3.0f), "Component data incorrect");
}
| 34.309091 | 104 | 0.772125 | [
"transform"
] |
00a1584384eb17ec19e0b96e8dd1cdfe831593d6 | 5,970 | cpp | C++ | test/forward_dnn/forward_dnn/ocl_device.cpp | mintaka33/fast-dnn | eba7bfa926d1840a0f528d18766b9a7f8dee463b | [
"Apache-2.0"
] | 1 | 2019-03-15T05:31:53.000Z | 2019-03-15T05:31:53.000Z | test/forward_dnn/forward_dnn/ocl_device.cpp | neptune46/fast-dnn | 409cafa97d658625b8a7b6453cacd6387546d955 | [
"Apache-2.0"
] | null | null | null | test/forward_dnn/forward_dnn/ocl_device.cpp | neptune46/fast-dnn | 409cafa97d658625b8a7b6453cacd6387546d955 | [
"Apache-2.0"
] | null | null | null | #include "pch.h"
#include "ocl_device.h"
#include <vector>
#include <stdio.h>
#define OPENCL_VERSION_1_2 1.2f
#define OPENCL_VERSION_2_0 2.0f
OclEngine::OclEngine()
{
}
OclEngine::~OclEngine()
{
}
bool OclEngine::checkPlatform(cl_platform_id platform, const char* preferredPlatform)
{
size_t stringLength = 0;
cl_int err = CL_SUCCESS;
bool match = false;
err = clGetPlatformInfo(platform, CL_PLATFORM_NAME, 0, NULL, &stringLength);
if (CL_SUCCESS != err)
{
printf("Error: clGetPlatformInfo() to get CL_PLATFORM_NAME length returned '%d'.\n", err);
return false;
}
std::vector<char> platformName(stringLength);
err = clGetPlatformInfo(platform, CL_PLATFORM_NAME, stringLength, &platformName[0], NULL);
if (CL_SUCCESS != err)
{
printf("Error: clGetplatform_ids() to get CL_PLATFORM_NAME returned %d.\n", err);
return false;
}
if (strstr(&platformName[0], preferredPlatform) != 0)
{
match = true;
}
return match;
}
cl_platform_id OclEngine::findPlatform(cl_device_type deviceType, const char* preferredPlatform)
{
cl_uint numPlatforms = 0;
cl_int ret = CL_SUCCESS;
ret = clGetPlatformIDs(0, NULL, &numPlatforms);
if (CL_SUCCESS != ret)
{
printf("ERROR: failed to call clGetPlatformIDs\n");
return nullptr;
}
if (numPlatforms <= 0)
{
printf("ERROR: no platform found\n");
return nullptr;
}
std::vector<cl_platform_id> platforms(numPlatforms);
ret = clGetPlatformIDs(numPlatforms, &platforms[0], NULL);
if (CL_SUCCESS != ret)
{
printf("ERROR: failed to call clGetPlatformIDs\n");
return nullptr;
}
for (cl_uint i = 0; i < numPlatforms; i++)
{
bool match = true;
cl_uint numDevices = 0;
match = checkPlatform(platforms[i], preferredPlatform);
if (match)
{
ret = clGetDeviceIDs(platforms[i], deviceType, 0, NULL, &numDevices);
if (CL_SUCCESS != ret)
{
printf("ERROR: clGetDeviceIDs() returned %d.\n", ret);
}
if (0 != numDevices)
{
return platforms[i];
}
}
}
return nullptr;
}
int OclEngine::getVersions()
{
cl_int err = CL_SUCCESS;
size_t stringLength = 0;
err = clGetPlatformInfo(platform_, CL_PLATFORM_VERSION, 0, NULL, &stringLength);
if (CL_SUCCESS != err)
{
printf("Error: clGetPlatformInfo() to get CL_PLATFORM_VERSION length returned '%d'.\n", err);
return err;
}
std::vector<char> platformVersion(stringLength);
err = clGetPlatformInfo(platform_, CL_PLATFORM_VERSION, stringLength, &platformVersion[0], NULL);
if (CL_SUCCESS != err)
{
printf("Error: clGetplatform_ids() to get CL_PLATFORM_VERSION returned %d.\n", err);
return err;
}
if (strstr(&platformVersion[0], "OpenCL 2.0") != NULL)
{
platformVersion_ = OPENCL_VERSION_2_0;
}
err = clGetDeviceInfo(device_, CL_DEVICE_VERSION, 0, NULL, &stringLength);
if (CL_SUCCESS != err)
{
printf("Error: clGetDeviceInfo() to get CL_DEVICE_VERSION length returned '%d'.\n", err);
return err;
}
std::vector<char> deviceVersion(stringLength);
err = clGetDeviceInfo(device_, CL_DEVICE_VERSION, stringLength, &deviceVersion[0], NULL);
if (CL_SUCCESS != err)
{
printf("Error: clGetDeviceInfo() to get CL_DEVICE_VERSION returned %d.\n", err);
return err;
}
if (strstr(&deviceVersion[0], "OpenCL 2.0") != NULL)
{
deviceVersion_ = OPENCL_VERSION_2_0;
}
err = clGetDeviceInfo(device_, CL_DEVICE_OPENCL_C_VERSION, 0, NULL, &stringLength);
if (CL_SUCCESS != err)
{
printf("Error: clGetDeviceInfo() to get CL_DEVICE_OPENCL_C_VERSION length returned '%d'.\n", err);
return err;
}
std::vector<char> compilerVersion(stringLength);
err = clGetDeviceInfo(device_, CL_DEVICE_OPENCL_C_VERSION, stringLength, &compilerVersion[0], NULL);
if (CL_SUCCESS != err)
{
printf("Error: clGetDeviceInfo() to get CL_DEVICE_OPENCL_C_VERSION returned %d.\n", err);
return err;
}
else if (strstr(&compilerVersion[0], "OpenCL C 2.0") != NULL)
{
compilerVersion_ = OPENCL_VERSION_2_0;
}
return err;
}
int OclEngine::create(cl_device_type deviceType, const char* platformName)
{
cl_int ret = CL_SUCCESS;
platform_ = findPlatform(deviceType, platformName);
if (platform_ == nullptr)
{
printf("ERROR: Failed to find OpenCL platform.\n");
return -1;
}
// Create context with device of specified type.
cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform_, 0 };
context_ = clCreateContextFromType(contextProperties, deviceType, NULL, NULL, &ret);
if ((CL_SUCCESS != ret) || (nullptr == context_))
{
printf("Couldn't create a context, clCreateContextFromType() returned %d.\n", ret);
return ret;
}
// Query for OpenCL device which was used for context creation
ret = clGetContextInfo(context_, CL_CONTEXT_DEVICES, sizeof(cl_device_id), &device_, NULL);
if (CL_SUCCESS != ret)
{
printf("Error: clGetContextInfo() to get list of devices returned %d.\n", ret);
return ret;
}
getVersions();
if (OPENCL_VERSION_2_0 != deviceVersion_)
{
printf("ERROR: device doesn't support OpenCL 2.0\n");
return -1;
}
const cl_command_queue_properties properties[] = { CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0 };
commandQueue_ = clCreateCommandQueueWithProperties(context_, device_, properties, &ret);
if (CL_SUCCESS != ret)
{
printf("Error: clCreateCommandQueue() returned %d.\n", ret);
return ret;
}
return 0;
}
void OclEngine::destroy()
{
}
| 27.511521 | 109 | 0.636181 | [
"vector"
] |
00a294b8d18e80d783b61f5692d329971cbd09ac | 5,132 | cpp | C++ | Algorithms/Implementation/two-kings/two-kings.cpp | CodeLogist/hackerrank-solutions | faecc4c9563a017eb61e83f0025aa9eb78fd33a1 | [
"MIT"
] | 73 | 2016-09-14T18:20:41.000Z | 2022-02-05T14:58:04.000Z | Algorithms/Implementation/two-kings/two-kings.cpp | A-STAR0/hackerrank-solutions-1 | 518cdd9049477d70c499ba4f51f06ac99178f0ab | [
"MIT"
] | 3 | 2017-03-03T01:12:31.000Z | 2020-04-18T16:51:59.000Z | Algorithms/Implementation/two-kings/two-kings.cpp | A-STAR0/hackerrank-solutions-1 | 518cdd9049477d70c499ba4f51f06ac99178f0ab | [
"MIT"
] | 69 | 2017-03-02T19:03:54.000Z | 2022-03-29T12:35:38.000Z | #include <bits/stdc++.h>
typedef std::pair<int,int> ipair;
const int BOARD_LEN = 8;
std::vector<ipair> best;
std::vector<ipair> curr; // for `go`
std::vector<std::vector<char>> board(BOARD_LEN);
std::vector<ipair> pos; // all possible positions.
static inline bool valid_point(const ipair& p) {
return p.first >= 0 && p.first < BOARD_LEN && p.second >= 0 && p.second < BOARD_LEN;
}
static inline bool valid(const ipair& p) {
return valid_point(p) && board[p.first][p.second] == '*';
}
/*
checks to see if kings are in checkmate,
assumes `curr` is being checked.
*/
static bool check(const ipair& king, const ipair& other) {
static std::vector<std::vector<char>> can_move;
can_move.assign(BOARD_LEN, std::vector<char>(BOARD_LEN, true));
board[other.first][other.second] = 'k';
can_move[other.first][other.second] = false; /* cant sit on the other king */
for (const auto& queen : curr)
board[queen.first][queen.second] = 'q';
// fill out queen strike zones
for (const auto& queen : curr) {
// down
for (int i = queen.first+1; i < BOARD_LEN; ++i) {
can_move[i][queen.second] = false;
if (board[i][queen.second] != '*')
break;
}
// up
for (int i = queen.first-1; i >= 0; --i) {
can_move[i][queen.second] = false;
if (board[i][queen.second] != '*')
break;
}
// right
for (int j = queen.second+1; j < BOARD_LEN; ++j) {
can_move[queen.first][j] = false;
if (board[queen.first][j] != '*')
break;
}
// left
for (int j = queen.second-1; j >= 0; --j) {
can_move[queen.first][j] = false;
if (board[queen.first][j] != '*')
break;
}
// down and right
for (int i = 1; i+queen.first < BOARD_LEN && i+queen.second < BOARD_LEN; ++i) {
can_move[queen.first+i][queen.second+i] = false;
if (board[queen.first+i][queen.second+i] != '*')
break;
}
// up and right
for (int i = 1; queen.first - i >= 0 && i+queen.second < BOARD_LEN; ++i) {
can_move[queen.first-i][queen.second+i] = false;
if (board[queen.first-i][queen.second+i] != '*')
break;
}
// down and left
for (int i = 1; queen.first - i >= 0 && i-queen.second >= 0; ++i) {
can_move[queen.first-i][queen.second-i] = false;
if (board[queen.first-i][queen.second-i] != '*')
break;
}
// up and left
for (int i = 1; queen.first + i < BOARD_LEN && i-queen.second >= 0; ++i) {
can_move[queen.first+i][queen.second-i] = false;
if (board[queen.first+i][queen.second-i] != '*')
break;
}
}
bool good = true;
for (int i = -1; i <= 1 && good; ++i) {
for (int j = -1; j <= 1 && good; ++j) {
if (valid_point({king.first+i,king.second+j})) {
good = good && !can_move[king.first+i][king.second+j];
}
}
}
board[other.first][other.second] = '*';
for (const auto& queen : curr)
board[queen.first][queen.second] = '*';
return good;
}
static void one_case(const int& case_num) {
std::vector<ipair> kings(2);
for (auto& k : kings) {
std::scanf("%d %d",&k.first,&k.second);
}
best.resize(10);
curr.resize(2);
for (int i = 0; i < pos.size(); ++i) {
curr[0] = pos[i];
if (!valid(curr[0]) || curr[0] == kings.front() || curr[0] == kings.back()) continue;
for (int j = i+1; j < pos.size(); ++j) {
curr[1] = pos[j];
if (!valid(curr[1]) || curr[1] == kings.front() || curr[1] == kings.back()) continue;
if (check(kings.front(),kings.back()) && check(kings.back(),kings.front()) && curr.size() < best.size()) {
best = curr;
}
curr.push_back({0,0});
for (int k = j+1; k < pos.size(); ++k) {
curr[2] = pos[k];
if (!valid(curr[2]) || curr[2] == kings.front() || curr[2] == kings.back()) continue;
if (check(kings.front(),kings.back()) && check(kings.back(),kings.front()) && curr.size() < best.size()) {
best = curr;
}
}
curr.pop_back();
}
}
// std::printf("tc #%d: %d %d %d %d\n", case_num, kings.front().first,kings.front().second,kings.back().first,kings.back().second);
std::printf("%d\n", static_cast<int>(best.size()));
for (const auto& q : best) {
std::printf("Q %d %d\n", q.first,q.second);
board[q.first][q.second] = 'q';
}
// for (const auto& k : kings) {
// board[k.first][k.second] = 'k';
// }
// for (const auto& r : board) {
// for (const auto& c : r) {
// std::putchar(c);
// }
// std::putchar('\n');
// }
for (const auto& k : kings) {
board[k.first][k.second] = '*';
}
}
int main(void) {
board.assign(BOARD_LEN, std::vector<char>(BOARD_LEN, '*'));
for (int i = 0; i < BOARD_LEN; ++i) {
for (int j = 0; j < BOARD_LEN; ++j) {
pos.push_back({i,j});
}
}
int n;
std::scanf("%d",&n);
for (int i = 1; i <= n; ++i) one_case(i);
return 0;
}
| 27.297872 | 132 | 0.517927 | [
"vector"
] |
00a53e1ee138f86c29beeb3a25d7afd57b886868 | 2,651 | hpp | C++ | Library/Private/Galleon/Galleon/CargoDeck.hpp | KonstantinTomashevich/Emergence | 83b1d52bb62bf619f9402e3081dd9de6b0cb232c | [
"Apache-2.0"
] | 3 | 2021-06-02T05:06:48.000Z | 2022-01-26T09:39:44.000Z | Library/Private/Galleon/Galleon/CargoDeck.hpp | KonstantinTomashevich/Emergence | 83b1d52bb62bf619f9402e3081dd9de6b0cb232c | [
"Apache-2.0"
] | null | null | null | Library/Private/Galleon/Galleon/CargoDeck.hpp | KonstantinTomashevich/Emergence | 83b1d52bb62bf619f9402e3081dd9de6b0cb232c | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <string>
#include <vector>
#include <Galleon/LongTermContainer.hpp>
#include <Galleon/ShortTermContainer.hpp>
#include <Galleon/SingletonContainer.hpp>
#include <Handling/Handle.hpp>
#include <StandardLayout/Mapping.hpp>
namespace Emergence::Galleon
{
class CargoDeck final
{
public:
CargoDeck (std::string _name) noexcept;
/// CargoDeck manages lots of storages with lots of objects, therefore it's not optimal to copy it.
CargoDeck (const CargoDeck &_other) = delete;
/// Move constructor could be useful, but we don't implement it
/// because it's useless for Warehouse implementation.
CargoDeck (CargoDeck &&_other) = delete;
/// \invariant There is no handles to any container and no prepared queries, that belong this deck.
~CargoDeck () noexcept;
Handling::Handle<SingletonContainer> AcquireSingletonContainer (const StandardLayout::Mapping &_typeMapping);
Handling::Handle<ShortTermContainer> AcquireShortTermContainer (const StandardLayout::Mapping &_typeMapping);
Handling::Handle<LongTermContainer> AcquireLongTermContainer (const StandardLayout::Mapping &_typeMapping);
[[nodiscard]] bool IsSingletonContainerAllocated (const StandardLayout::Mapping &_typeMapping) const noexcept;
[[nodiscard]] bool IsShortTermContainerAllocated (const StandardLayout::Mapping &_typeMapping) const noexcept;
[[nodiscard]] bool IsLongTermContainerAllocated (const StandardLayout::Mapping &_typeMapping) const noexcept;
[[nodiscard]] const std::string &GetName () const noexcept;
/// CargoDeck manages lots of storages with lots of objects, therefore it's not optimal to copy assign it.
CargoDeck &operator= (const CargoDeck &_other) = delete;
/// Move assign could be useful, but we don't implement it
/// because it's useless for Warehouse implementation.
CargoDeck &operator= (CargoDeck &&_other) = delete;
private:
friend class SingletonContainer;
friend class ShortTermContainer;
friend class LongTermContainer;
/// VisualizationDriver for Warehouse service should be able to directly access containers.
friend class VisualizationDriver;
void DetachContainer (SingletonContainer *_container) noexcept;
void DetachContainer (ShortTermContainer *_container) noexcept;
void DetachContainer (LongTermContainer *_container) noexcept;
std::string name;
struct
{
std::vector<SingletonContainer *> singleton {};
std::vector<ShortTermContainer *> shortTerm {};
std::vector<LongTermContainer *> longTerm {};
} containers {};
};
} // namespace Emergence::Galleon
| 33.987179 | 114 | 0.746888 | [
"vector"
] |
00a749a00eff1f86001bbd2996a9ab2a1de8cce1 | 2,721 | cxx | C++ | src/mod/pub/tst/storage-dir-tst/mod-storage-dir-tst.cxx | indigoabstract/appplex | 83c3b903db6c6ea83690ccffbd533ff6ab01d246 | [
"MIT"
] | 1 | 2017-12-26T14:29:37.000Z | 2017-12-26T14:29:37.000Z | src/mod/pub/tst/storage-dir-tst/mod-storage-dir-tst.cxx | indigoabstract/appplex | 83c3b903db6c6ea83690ccffbd533ff6ab01d246 | [
"MIT"
] | null | null | null | src/mod/pub/tst/storage-dir-tst/mod-storage-dir-tst.cxx | indigoabstract/appplex | 83c3b903db6c6ea83690ccffbd533ff6ab01d246 | [
"MIT"
] | null | null | null | #include "stdafx.hxx"
#include "mod-storage-dir-tst.hxx"
#include "pfm.hxx"
mod_storage_dir_tst::mod_storage_dir_tst() : mws_mod(mws_stringify(MOD_STORAGE_DIR_TST)) {}
mws_sp<mod_storage_dir_tst> mod_storage_dir_tst::nwi()
{
return mws_sp<mod_storage_dir_tst>(new mod_storage_dir_tst());
}
void mod_storage_dir_tst::init()
{
mws_log::set_enabled(true);
mws_log::i()->push("mod_storage_dir_tst::init()");
mws_path test_path_0("path_0/path_1/path_2");
mws_path test_parent_path_0 = test_path_0.parent_path();
mws_path test_path_1("path_0/path_1/path_2/");
mws_path test_parent_path_1 = test_path_1.parent_path();
mws_path prv_path(storage.prv_dir());
mws_path res_path(storage.res_dir());
mws_path tmp_path(storage.tmp_dir());
mws_path parent_path = prv_path.parent_path();
const unicode_string& app_path_wstr = mws::args::get_unicode_path();
std::string app_path_str = mws_str::unicode_string_to_string(app_path_wstr);
mws_path app_path(app_path_str);
std::string sample = storage.load_as_string("sample.txt");
mws_println_all_builds("test_path_0 [ %s ]", test_path_0.string().c_str());
mws_println_all_builds("test_parent_path_0 [ %s ]", test_parent_path_0.string().c_str());
mws_println_all_builds("test_path_1 [ %s ]", test_path_1.string().c_str());
mws_println_all_builds("test_parent_path_1 [ %s ]", test_parent_path_1.string().c_str());
mws_println_all_builds("prv_path [ %s ]", prv_path.string().c_str());
mws_println_all_builds("private_path_parent [ %s ]", parent_path.string().c_str());
mws_println_all_builds("res_path [ %s ]", res_path.string().c_str());
mws_println_all_builds("tmp_path [ %s ]", tmp_path.string().c_str());
mws_println_all_builds("app_path [ %s ]", app_path.parent_path().string().c_str());
mws_println_all_builds("crt_path [ %s ]", mws_path::current_path().c_str());
std::vector<mws_sp<mws_file>> prv_files = prv_path.list_directory(true);
std::vector<mws_sp<mws_file>> res_files = res_path.list_directory(true);
std::vector<mws_sp<mws_file>> tmp_files = tmp_path.list_directory(true);
mws_println_all_builds("\n[ %d ] prv_files", prv_files.size());
for (auto& e : prv_files)
{
mws_println_all_builds("[ %s ]", e->string_path().c_str());
}
mws_println_all_builds("\n[ %d ] res_files", res_files.size());
for (auto& e : res_files)
{
mws_println_all_builds("[ %s ]", e->string_path().c_str());
}
mws_println_all_builds("\n[ %d ] tmp_files", tmp_files.size());
for (auto& e : tmp_files)
{
mws_println_all_builds("[ %s ]", e->string_path().c_str());
}
if (!sample.empty()) { mws_println_all_builds("\nsample-text [ %s ]", sample.c_str()); }
}
| 41.227273 | 92 | 0.709666 | [
"vector"
] |
00b95ac96d3799d4f7541c5fd7da332e48de4c91 | 296 | hpp | C++ | include/ecalc/types.hpp | strikles/libecalc | afa0e240ffd88d568903acd80bd7429cc5273064 | [
"MIT"
] | null | null | null | include/ecalc/types.hpp | strikles/libecalc | afa0e240ffd88d568903acd80bd7429cc5273064 | [
"MIT"
] | null | null | null | include/ecalc/types.hpp | strikles/libecalc | afa0e240ffd88d568903acd80bd7429cc5273064 | [
"MIT"
] | null | null | null | #ifndef ECALC_TYPES_H
#define ECALC_TYPES_H
#include <vector>
#include <stdint.h>
#include "result.hpp"
namespace ecalc {
typedef unsigned int card;
typedef uint64_t bitset;
typedef uint64_t combination;
typedef std::vector<card> cards;
typedef std::vector<Result> result_collection;
}
#endif
| 17.411765 | 46 | 0.787162 | [
"vector"
] |
00be058d4226ab51c793b81962d699e112cd28b9 | 23,507 | cc | C++ | tkrzw_dbm_async_test.cc | Passw/estraier-tkrzw-btree | e149ffc0229f91014fb5de6f25fc1dbe4c35142a | [
"Apache-2.0"
] | null | null | null | tkrzw_dbm_async_test.cc | Passw/estraier-tkrzw-btree | e149ffc0229f91014fb5de6f25fc1dbe4c35142a | [
"Apache-2.0"
] | null | null | null | tkrzw_dbm_async_test.cc | Passw/estraier-tkrzw-btree | e149ffc0229f91014fb5de6f25fc1dbe4c35142a | [
"Apache-2.0"
] | null | null | null | /*************************************************************************************************
* Tests for tkrzw_dbm_async.h
*
* Copyright 2020 Google LLC
* 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
* https://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.
*************************************************************************************************/
#include "tkrzw_sys_config.h"
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "tkrzw_dbm.h"
#include "tkrzw_dbm_async.h"
#include "tkrzw_dbm_poly.h"
#include "tkrzw_file_poly.h"
#include "tkrzw_file_util.h"
#include "tkrzw_lib_common.h"
#include "tkrzw_str_util.h"
using namespace testing;
// Main routine
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
TEST(AsyncDBMTest, Empty) {
tkrzw::TemporaryDirectory tmp_dir(true, "tkrzw-");
std::string file_path = tmp_dir.MakeUniquePath("casket-", ".tkh");
std::string copy_path = tmp_dir.MakeUniquePath("casket-copy-", ".tkh");
tkrzw::PolyDBM dbm;
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.OpenAdvanced(
file_path, true, tkrzw::File::OPEN_TRUNCATE, {{"num_buckets", "100"}}));
{
tkrzw::AsyncDBM async(&dbm, 4);
}
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.Close());
}
TEST(AsyncDBMTest, Basic) {
tkrzw::TemporaryDirectory tmp_dir(true, "tkrzw-");
std::string file_path = tmp_dir.MakeUniquePath("casket-", ".tkh");
std::string copy_path = tmp_dir.MakeUniquePath("casket-copy-", ".tkh");
tkrzw::PolyDBM dbm;
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.OpenAdvanced(
file_path, true, tkrzw::File::OPEN_TRUNCATE, {{"num_buckets", "100"}}));
std::vector<std::future<std::pair<tkrzw::Status, std::string>>> get_results;
std::map<std::string, int32_t> status_counter;
std::mutex postproc_mutex;
auto postproc = [&](const char* name, const tkrzw::Status& status) {
std::lock_guard lock(postproc_mutex);
status_counter[tkrzw::StrCat(
name, ":", tkrzw::Status::CodeName(status.GetCode()))]++;
};
{
tkrzw::AsyncDBM async(&dbm, 4);
async.SetCommonPostprocessor(postproc);
for (int32_t i = 1; i <= 100; i++) {
const std::string key = tkrzw::ToString(i);
const std::string value = tkrzw::ToString(i * i);
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Set(key, value, false).get());
const auto& get_result = async.Get(key).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, get_result.first);
EXPECT_EQ(value, get_result.second);
EXPECT_EQ(tkrzw::Status::DUPLICATION_ERROR, async.Set(key, value, false).get());
if (i % 2 == 0) {
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Remove(key).get());
EXPECT_EQ(tkrzw::Status::NOT_FOUND_ERROR, async.Remove(key).get());
}
}
EXPECT_EQ(50, dbm.CountSimple());
for (int32_t i = 1; i <= 100; i++) {
const std::string key = tkrzw::ToString(i);
const std::string value = tkrzw::ToString(i * i);
async.Set(key, value, false);
}
for (int32_t i = 1; i <= 100; i++) {
const std::string key = tkrzw::ToString(i);
async.Append(key, "0", ":").wait();
}
for (int32_t i = 1; i <= 100; i++) {
const std::string key = tkrzw::ToString(i);
get_results.emplace_back(async.Get(key));
}
}
{
std::lock_guard lock(postproc_mutex);
EXPECT_EQ(150, status_counter["Set:SUCCESS"]);
EXPECT_EQ(150, status_counter["Set:DUPLICATION_ERROR"]);
EXPECT_EQ(200, status_counter["Get:SUCCESS"]);
EXPECT_EQ(50, status_counter["Remove:SUCCESS"]);
EXPECT_EQ(50, status_counter["Remove:NOT_FOUND_ERROR"]);
EXPECT_EQ(100, status_counter["Append:SUCCESS"]);
status_counter.clear();
}
EXPECT_EQ(100, dbm.CountSimple());
ASSERT_EQ(100, get_results.size());
for (int32_t i = 1; i <= 100; i++) {
const std::string value = tkrzw::ToString(i * i) + ":0";
const auto& rv = get_results[i-1].get();
EXPECT_EQ(tkrzw::Status::SUCCESS, rv.first);
EXPECT_EQ(value, rv.second);
}
{
tkrzw::AsyncDBM async(&dbm, 4);
async.SetCommonPostprocessor(postproc);
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Synchronize(false).get());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Rebuild().get());
EXPECT_EQ(100, dbm.CountSimple());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CopyFileData(copy_path).get());
{
tkrzw::PolyDBM copy_dbm;
EXPECT_EQ(tkrzw::Status::SUCCESS, copy_dbm.OpenAdvanced(
copy_path, true, tkrzw::File::OPEN_DEFAULT, {{"num_buckets", "100"}}));
EXPECT_EQ(100, copy_dbm.CountSimple());
EXPECT_EQ(tkrzw::Status::SUCCESS, copy_dbm.Clear());
EXPECT_EQ(0, copy_dbm.CountSimple());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Export(©_dbm).get());
EXPECT_EQ(100, copy_dbm.CountSimple());
EXPECT_EQ(tkrzw::Status::SUCCESS, copy_dbm.Close());
}
{
tkrzw::PolyFile copy_file;
EXPECT_EQ(tkrzw::Status::SUCCESS, copy_file.Open(
copy_path, true, tkrzw::File::OPEN_TRUNCATE));
EXPECT_EQ(tkrzw::Status::SUCCESS, async.ExportToFlatRecords(©_file).get());
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.Clear());
EXPECT_EQ(0, dbm.CountSimple());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.ImportFromFlatRecords(©_file).get());
EXPECT_EQ(100, dbm.CountSimple());
EXPECT_EQ(tkrzw::Status::SUCCESS, copy_file.Close());
}
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Clear().get());
EXPECT_EQ(0, dbm.CountSimple());
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.CompareExchange("a", std::string_view(), "123").get());
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.CompareExchange("a", "123", "4567").get());
EXPECT_EQ("4567", async.Get("a").get().second);
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.CompareExchange("a", "4567", std::string_view()).get());
EXPECT_EQ(tkrzw::Status::INFEASIBLE_ERROR,
async.CompareExchange("a", tkrzw::DBM::ANY_DATA, "abc").get());
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.CompareExchange("a", std::string_view(), "abc").get());
EXPECT_EQ("abc", dbm.GetSimple("a"));
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.CompareExchange("a", tkrzw::DBM::ANY_DATA, "def").get());
EXPECT_EQ("def", dbm.GetSimple("a"));
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.CompareExchange("a", tkrzw::DBM::ANY_DATA, tkrzw::DBM::ANY_DATA).get());
EXPECT_EQ("def", dbm.GetSimple("a"));
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.CompareExchange("a", tkrzw::DBM::ANY_DATA, std::string_view()).get());
EXPECT_EQ("", dbm.GetSimple("a"));
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Increment("b", 2, 100).get().first);
EXPECT_EQ(105, async.Increment("b", 3, 100).get().second);
const std::map<std::string_view, std::string_view> records = {{"a", "A"}, {"b", "BB"}};
EXPECT_EQ(tkrzw::Status::SUCCESS, async.SetMulti(records, true).get());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.AppendMulti(records, ":").get());
const std::vector<std::string_view> get_keys = {"a", "b", "c", "d"};
auto get_results = async.GetMulti(get_keys).get();
EXPECT_EQ(2, get_results.second.size());
EXPECT_EQ("A:A", get_results.second["a"]);
EXPECT_EQ("BB:BB", get_results.second["b"]);
const std::vector<std::string_view> remove_keys = {"a", "b"};
EXPECT_EQ(tkrzw::Status::SUCCESS, async.RemoveMulti(remove_keys).get());
async.Set("1", "10");
async.Set("2", "20");
async.Set("3", "30");
typedef std::vector<std::pair<std::string_view, std::string_view>> kv_list;
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CompareExchangeMulti(
kv_list({{"1", "10"}, {"2", "20"}}), kv_list({{"1", "100"}, {"2", "200"}})).get());
EXPECT_EQ(tkrzw::Status::INFEASIBLE_ERROR, async.CompareExchangeMulti(
kv_list({{"1", "10"}, {"2", "20"}}), kv_list({{"1", "xxx"}, {"2", "yyy"}})).get());
EXPECT_EQ("100", dbm.GetSimple("1"));
EXPECT_EQ("200", dbm.GetSimple("2"));
EXPECT_EQ(tkrzw::Status::INFEASIBLE_ERROR, async.CompareExchangeMulti(
kv_list({{"1", "100"}, {"2", std::string_view()}}),
kv_list({{"1", "xx"}, {"2", "yyy"}})).get());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CompareExchangeMulti(
kv_list({{"1", "100"}, {"2", "200"}}),
kv_list({{"1", "xx"}, {"2", std::string_view()}})).get());
EXPECT_EQ("xx", dbm.GetSimple("1"));
EXPECT_EQ(tkrzw::Status::NOT_FOUND_ERROR, dbm.Get("2"));
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CompareExchangeMulti(
kv_list({{"1", "xx"}, {"3", "30"}}),
kv_list({{"1", std::string_view()}, {"3", std::string_view()}, {"4", "hello"}})).get());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CompareExchangeMulti(
kv_list({{"4", "hello"}}), kv_list({{"4", std::string_view()}})).get());
EXPECT_EQ(tkrzw::Status::INFEASIBLE_ERROR, async.CompareExchangeMulti(
kv_list({{"xyz", tkrzw::DBM::ANY_DATA}}), kv_list({{"xyz", "abc"}})).get());
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CompareExchangeMulti(
kv_list({{"xyz", std::string_view()}}), kv_list({{"xyz", "abc"}})).get());
EXPECT_EQ("abc", async.Get("xyz").get().second);
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CompareExchangeMulti(
kv_list({{"xyz", tkrzw::DBM::ANY_DATA}}), kv_list({{"xyz", "def"}})).get());
EXPECT_EQ("def", async.Get("xyz").get().second);
EXPECT_EQ(tkrzw::Status::SUCCESS, async.CompareExchangeMulti(
kv_list({{"xyz", tkrzw::DBM::ANY_DATA}}), kv_list({{"xyz", std::string_view()}})).get());
EXPECT_EQ("", async.Get("xyz").get().second);
}
{
std::lock_guard lock(postproc_mutex);
EXPECT_EQ(1, status_counter["Synchronize:SUCCESS"]);
EXPECT_EQ(1, status_counter["Rebuild:SUCCESS"]);
EXPECT_EQ(1, status_counter["Clear:SUCCESS"]);
EXPECT_EQ(1, status_counter["GetMulti:NOT_FOUND_ERROR"]);
EXPECT_EQ(1, status_counter["SetMulti:SUCCESS"]);
EXPECT_EQ(1, status_counter["AppendMulti:SUCCESS"]);
EXPECT_EQ(1, status_counter["RemoveMulti:SUCCESS"]);
status_counter.clear();
}
{
tkrzw::AsyncDBM async(&dbm, 4);
async.SetCommonPostprocessor(postproc);
for (int32_t i = 1; i <= 100; i++) {
const std::string old_key = tkrzw::StrCat("foo:", i);
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Set(old_key, old_key).get());
const std::string new_key = tkrzw::StrCat("bar:", i);
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Rekey(old_key, new_key, false, false).get());
EXPECT_EQ(old_key, async.Get(new_key).get().second);
}
}
{
std::lock_guard lock(postproc_mutex);
EXPECT_EQ(100, status_counter["Set:SUCCESS"]);
EXPECT_EQ(100, status_counter["Rekey:SUCCESS"]);
EXPECT_EQ(100, status_counter["Get:SUCCESS"]);
}
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.Close());
}
TEST(AsyncDBMTest, Process) {
tkrzw::TemporaryDirectory tmp_dir(true, "tkrzw-");
std::string file_path = tmp_dir.MakeUniquePath("casket-", ".tkt");
tkrzw::PolyDBM dbm;
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.OpenAdvanced(
file_path, true, tkrzw::File::OPEN_TRUNCATE, {{"num_buckets", "100"}}));
{
tkrzw::AsyncDBM async(&dbm, 4);
class Setter : public tkrzw::AsyncDBM::RecordProcessor {
public:
Setter(std::string_view new_value) : new_value_(new_value), old_value_() {}
std::string_view ProcessFull(std::string_view key, std::string_view value) override {
old_value_ = value;
return new_value_;
}
std::string_view ProcessEmpty(std::string_view key) override {
return new_value_;
}
const std::string& GetOldValue() const {
return old_value_;
}
private:
std::string new_value_;
std::string old_value_;
};
auto r1 = async.Process("a", std::make_unique<Setter>("one"), true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r1.first);
EXPECT_EQ("", r1.second->GetOldValue());
auto r2 = async.Process("a", std::make_unique<Setter>("two"), true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r2.first);
EXPECT_EQ("one", r2.second->GetOldValue());
std::string old_value;
auto r3 = async.Process("b", [&](std::string_view key, std::string_view value) {
if (value.data() != tkrzw::DBM::RecordProcessor::NOOP.data()) {
old_value = value;
}
return "uno";
}, true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r3);
EXPECT_EQ("", old_value);
auto r4 = async.Process("b", [&](std::string_view key, std::string_view value) {
if (value.data() != tkrzw::DBM::RecordProcessor::NOOP.data()) {
old_value = value;
}
return "dos";
}, true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r4);
EXPECT_EQ("uno", old_value);
class Bracketter : public tkrzw::AsyncDBM::RecordProcessor {
public:
Bracketter() {}
std::string_view ProcessFull(std::string_view key, std::string_view value) override {
if (value.data() == tkrzw::DBM::RecordProcessor::NOOP.data()) {
return tkrzw::DBM::RecordProcessor::NOOP;
}
new_value_ = tkrzw::StrCat("[", value, "]");
return new_value_;
}
private:
std::string new_value_;
};
auto r5 = async.ProcessEach(std::make_unique<Bracketter>(), true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r5.first);
std::string new_value;
auto r6 = async.ProcessEach([&](
std::string_view key, std::string_view value) -> std::string_view {
if (value.data() == tkrzw::DBM::RecordProcessor::NOOP.data()) {
return tkrzw::DBM::RecordProcessor::NOOP;
}
new_value = tkrzw::StrCat("(", value, ")");
return new_value;
}, true).get();
EXPECT_EQ("([two])", dbm.GetSimple("a"));
EXPECT_EQ("([dos])", dbm.GetSimple("b"));
std::vector<std::pair<std::string_view, std::shared_ptr<Setter>>> key_proc_pairs;
key_proc_pairs.emplace_back(std::make_pair("a", std::make_unique<Setter>("three")));
key_proc_pairs.emplace_back(std::make_pair("b", std::make_unique<Setter>("tres")));
auto r7 = async.ProcessMulti(key_proc_pairs, true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r7.first);
EXPECT_EQ("three", dbm.GetSimple("a"));
EXPECT_EQ("tres", dbm.GetSimple("b"));
ASSERT_EQ(2, r7.second.size());
EXPECT_EQ("([two])", r7.second[0]->GetOldValue());
EXPECT_EQ("([dos])", r7.second[1]->GetOldValue());
std::vector<std::pair<std::string_view, tkrzw::DBM::RecordLambdaType>> key_lambda_pairs;
key_lambda_pairs.emplace_back(std::make_pair(
"a", [&](std::string_view key, std::string_view value) { return "four"; }));
key_lambda_pairs.emplace_back(std::make_pair(
"b", [&](std::string_view key, std::string_view value) { return "cuatro"; }));
auto r8 = async.ProcessMulti(key_lambda_pairs, true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r8);
EXPECT_EQ("four", dbm.GetSimple("a"));
EXPECT_EQ("cuatro", dbm.GetSimple("b"));
EXPECT_EQ(tkrzw::Status::SUCCESS, async.Set("!!", "foo", false).get());
EXPECT_EQ(tkrzw::Status::SUCCESS,
async.ProcessFirst(std::make_unique<Bracketter>(), true).get().first);
std::string first_key, first_value;
auto r9 = async.ProcessFirst([&](
std::string_view key, std::string_view value) -> std::string_view {
first_key = key;
first_value = value;
return tkrzw::DBM::RecordProcessor::NOOP;
}, true).get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r9);
EXPECT_EQ("!!", first_key);
EXPECT_EQ("[foo]", first_value);
auto r10 = async.PopFirst().get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r10.first);
EXPECT_EQ("!!", r10.second.first);
EXPECT_EQ("[foo]", r10.second.second);
EXPECT_EQ(tkrzw::Status::SUCCESS, async.PushLast("bar", 0).get());
auto r11 = async.PopFirst().get();
EXPECT_EQ(tkrzw::Status::SUCCESS, r11.first);
EXPECT_EQ(std::string("\0\0\0\0\0\0\0\0", 8), r11.second.first);
EXPECT_EQ("bar", r11.second.second);
}
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.Close());
}
TEST(AsyncDBMTest, SearchModal) {
tkrzw::TemporaryDirectory tmp_dir(true, "tkrzw-");
std::string file_path = tmp_dir.MakeUniquePath("casket-", ".tkt");
tkrzw::PolyDBM dbm;
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.OpenAdvanced(
file_path, true, tkrzw::File::OPEN_TRUNCATE, {{"num_buckets", "100"}}));
{
tkrzw::AsyncDBM async(&dbm, 4);
std::vector<std::future<tkrzw::Status>> set_results;
for (int32_t i = 1; i <= 50; i++) {
const std::string key = tkrzw::SPrintF("%04d", i);
const std::string value = tkrzw::ToString(i * i);
set_results.emplace_back(async.Set(key, value, true));
}
for (auto& set_result : set_results) {
EXPECT_EQ(tkrzw::Status::SUCCESS, set_result.get());
}
std::map<std::string, std::string> records;
for (int32_t i = 51; i <= 100; i++) {
std::string key = tkrzw::SPrintF("%04d", i);
std::string value = tkrzw::ToString(i * i);
records.emplace(std::make_pair(std::move(key), std::move(value)));
}
EXPECT_EQ(tkrzw::Status::SUCCESS, async.SetMulti(records, false).get());
EXPECT_EQ(100, dbm.CountSimple());
std::map<std::string, std::string> all_records;
std::string last_key = "";
while (true) {
auto [search_status, keys] = async.SearchModal("upper", last_key, 10).get();
if (search_status != tkrzw::Status::SUCCESS || keys.empty()) {
break;
}
const auto [get_status, records] = async.GetMulti(keys).get();
for (const auto& record : records) {
all_records.emplace(record);
}
last_key = keys.back();
}
EXPECT_EQ(100, all_records.size());
}
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.Close());
}
TEST(AsyncDBMTest, StatusFeature) {
tkrzw::TemporaryDirectory tmp_dir(true, "tkrzw-");
std::string file_path = tmp_dir.MakeUniquePath("casket-", ".tkh");
tkrzw::PolyDBM dbm;
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.OpenAdvanced(
file_path, true, tkrzw::File::OPEN_TRUNCATE, {{"num_buckets", "100"}}));
{
tkrzw::AsyncDBM async(&dbm, 4);
for (int32_t i = 1; i <= 100; i++) {
const std::string key = tkrzw::SPrintF("%04d", i);
const std::string value = tkrzw::ToString(i * i);
tkrzw::StatusFuture set_future(async.Set(key, value));
EXPECT_EQ(typeid(tkrzw::Status), set_future.GetExtraType());
if (i % 3 == 0) {
EXPECT_TRUE(set_future.Wait());
}
const auto& set_result = set_future.Get();
EXPECT_EQ(tkrzw::Status::SUCCESS, set_result);
tkrzw::StatusFuture get_future(async.Get(key));
tkrzw::StatusFuture get_future_move(std::move(get_future));
EXPECT_EQ(typeid(std::pair<tkrzw::Status, std::string>), get_future.GetExtraType());
if (i % 3 == 0) {
EXPECT_TRUE(get_future_move.Wait());
}
const auto& get_result = get_future_move.GetString();
EXPECT_EQ(tkrzw::Status::SUCCESS, get_result.first);
EXPECT_EQ(value, get_result.second);
if (i % 2 == 0) {
tkrzw::StatusFuture remove_future(async.Remove(key));
EXPECT_EQ(typeid(tkrzw::Status), remove_future.GetExtraType());
if (i % 3 == 0) {
EXPECT_TRUE(remove_future.Wait());
}
const auto& remove_result = remove_future.Get();
EXPECT_EQ(tkrzw::Status::SUCCESS, remove_result);
tkrzw::StatusFuture incr_future(async.Increment(key, 1, 100));
if (i % 3 == 0) {
EXPECT_TRUE(incr_future.Wait());
}
const auto& incr_result = incr_future.GetInteger();
EXPECT_EQ(tkrzw::Status::SUCCESS, incr_result.first);
EXPECT_EQ(101, incr_result.second);
}
}
EXPECT_EQ(100, dbm.CountSimple());
{
tkrzw::StatusFuture search_future(async.SearchModal("regex", "[123]7", 0));
EXPECT_EQ(typeid(std::pair<tkrzw::Status, std::vector<std::string>>),
search_future.GetExtraType());
search_future.Wait(0);
EXPECT_TRUE(search_future.Wait());
const auto& search_result = search_future.GetStringVector();
EXPECT_EQ(tkrzw::Status::SUCCESS, search_result.first);
EXPECT_THAT(search_result.second, UnorderedElementsAre("0017", "0027", "0037"));
}
for (int32_t i = 0; i < 10; i++) {
std::map<std::string, std::string> records;
std::vector<std::string> keys;
for (int32_t j = 1; j <= 10; j++) {
const int32_t num = i * 10 + j;
const std::string key = tkrzw::SPrintF("%04d", num);
const std::string value = tkrzw::ToString(num * num);
records.emplace(key, value);
keys.emplace_back(key);
}
tkrzw::StatusFuture set_future(async.SetMulti(records));
EXPECT_EQ(typeid(tkrzw::Status), set_future.GetExtraType());
if (i % 3 == 0) {
EXPECT_TRUE(set_future.Wait());
}
const auto& set_result = set_future.Get();
EXPECT_EQ(tkrzw::Status::SUCCESS, set_result);
tkrzw::StatusFuture get_future(async.GetMulti(keys));
if (i % 3 == 0) {
EXPECT_TRUE(get_future.Wait());
}
const auto& get_result = get_future.GetStringMap();
EXPECT_EQ(typeid(std::pair<tkrzw::Status, std::map<std::string, std::string>>),
get_future.GetExtraType());
EXPECT_EQ(tkrzw::Status::SUCCESS, get_result.first);
EXPECT_EQ(10, get_result.second.size());
for (const auto& key : keys) {
EXPECT_NE(get_result.second.end(), get_result.second.find(key));
}
if (i == 0) {
tkrzw::StatusFuture remove_future(async.RemoveMulti(keys));
EXPECT_EQ(typeid(tkrzw::Status), remove_future.GetExtraType());
if (i % 3 == 0) {
EXPECT_TRUE(remove_future.Wait());
}
const auto& remove_result = remove_future.Get();
EXPECT_EQ(tkrzw::Status::SUCCESS, remove_result);
}
}
tkrzw::StatusFuture clear_future(async.Clear());
EXPECT_EQ(tkrzw::Status::SUCCESS, clear_future.Get());
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.Set("aa", "AAA"));
tkrzw::StatusFuture rekey_future(async.Rekey("aa", "bb"));
EXPECT_EQ(tkrzw::Status::SUCCESS, rekey_future.Get());
tkrzw::StatusFuture pop_future(async.PopFirst());
const auto& pop_result = pop_future.GetStringPair();
EXPECT_EQ(tkrzw::Status::SUCCESS, pop_result.first);
EXPECT_EQ("bb", pop_result.second.first);
EXPECT_EQ("AAA", pop_result.second.second);
}
EXPECT_EQ(tkrzw::Status::SUCCESS, dbm.Close());
}
// END OF FILE
| 45.822612 | 99 | 0.61454 | [
"vector"
] |
00c5a19d9d449673bbeab57b50d5ffe97a89c93e | 85,729 | hpp | C++ | modules/calib/include/opencv2/calib.hpp | Gabrielreisribeiro/opencv | 39df6d2f035ca6822494fe4234e163895828b23b | [
"Apache-2.0"
] | null | null | null | modules/calib/include/opencv2/calib.hpp | Gabrielreisribeiro/opencv | 39df6d2f035ca6822494fe4234e163895828b23b | [
"Apache-2.0"
] | null | null | null | modules/calib/include/opencv2/calib.hpp | Gabrielreisribeiro/opencv | 39df6d2f035ca6822494fe4234e163895828b23b | [
"Apache-2.0"
] | 1 | 2021-04-30T18:00:41.000Z | 2021-04-30T18:00:41.000Z | // This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
#ifndef OPENCV_CALIB_HPP
#define OPENCV_CALIB_HPP
#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/core/affine.hpp"
/**
@defgroup calib Camera Calibration
The functions in this section use a so-called pinhole camera model. The view of a scene
is obtained by projecting a scene's 3D point \f$P_w\f$ into the image plane using a perspective
transformation which forms the corresponding pixel \f$p\f$. Both \f$P_w\f$ and \f$p\f$ are
represented in homogeneous coordinates, i.e. as 3D and 2D homogeneous vector respectively. You will
find a brief introduction to projective geometry, homogeneous vectors and homogeneous
transformations at the end of this section's introduction. For more succinct notation, we often drop
the 'homogeneous' and say vector instead of homogeneous vector.
The distortion-free projective transformation given by a pinhole camera model is shown below.
\f[s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w,\f]
where \f$P_w\f$ is a 3D point expressed with respect to the world coordinate system,
\f$p\f$ is a 2D pixel in the image plane, \f$A\f$ is the camera intrinsic matrix,
\f$R\f$ and \f$t\f$ are the rotation and translation that describe the change of coordinates from
world to camera coordinate systems (or camera frame) and \f$s\f$ is the projective transformation's
arbitrary scaling and not part of the camera model.
The camera intrinsic matrix \f$A\f$ (notation used as in @cite Zhang2000 and also generally notated
as \f$K\f$) projects 3D points given in the camera coordinate system to 2D pixel coordinates, i.e.
\f[p = A P_c.\f]
The camera intrinsic matrix \f$A\f$ is composed of the focal lengths \f$f_x\f$ and \f$f_y\f$, which are
expressed in pixel units, and the principal point \f$(c_x, c_y)\f$, that is usually close to the
image center:
\f[A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1},\f]
and thus
\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1} \vecthree{X_c}{Y_c}{Z_c}.\f]
The matrix of intrinsic parameters does not depend on the scene viewed. So, once estimated, it can
be re-used as long as the focal length is fixed (in case of a zoom lens). Thus, if an image from the
camera is scaled by a factor, all of these parameters need to be scaled (multiplied/divided,
respectively) by the same factor.
The joint rotation-translation matrix \f$[R|t]\f$ is the matrix product of a projective
transformation and a homogeneous transformation. The 3-by-4 projective transformation maps 3D points
represented in camera coordinates to 2D points in the image plane and represented in normalized
camera coordinates \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$:
\f[Z_c \begin{bmatrix}
x' \\
y' \\
1
\end{bmatrix} = \begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0
\end{bmatrix}
\begin{bmatrix}
X_c \\
Y_c \\
Z_c \\
1
\end{bmatrix}.\f]
The homogeneous transformation is encoded by the extrinsic parameters \f$R\f$ and \f$t\f$ and
represents the change of basis from world coordinate system \f$w\f$ to the camera coordinate sytem
\f$c\f$. Thus, given the representation of the point \f$P\f$ in world coordinates, \f$P_w\f$, we
obtain \f$P\f$'s representation in the camera coordinate system, \f$P_c\f$, by
\f[P_c = \begin{bmatrix}
R & t \\
0 & 1
\end{bmatrix} P_w,\f]
This homogeneous transformation is composed out of \f$R\f$, a 3-by-3 rotation matrix, and \f$t\f$, a
3-by-1 translation vector:
\f[\begin{bmatrix}
R & t \\
0 & 1
\end{bmatrix} = \begin{bmatrix}
r_{11} & r_{12} & r_{13} & t_x \\
r_{21} & r_{22} & r_{23} & t_y \\
r_{31} & r_{32} & r_{33} & t_z \\
0 & 0 & 0 & 1
\end{bmatrix},
\f]
and therefore
\f[\begin{bmatrix}
X_c \\
Y_c \\
Z_c \\
1
\end{bmatrix} = \begin{bmatrix}
r_{11} & r_{12} & r_{13} & t_x \\
r_{21} & r_{22} & r_{23} & t_y \\
r_{31} & r_{32} & r_{33} & t_z \\
0 & 0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
X_w \\
Y_w \\
Z_w \\
1
\end{bmatrix}.\f]
Combining the projective transformation and the homogeneous transformation, we obtain the projective
transformation that maps 3D points in world coordinates into 2D points in the image plane and in
normalized camera coordinates:
\f[Z_c \begin{bmatrix}
x' \\
y' \\
1
\end{bmatrix} = \begin{bmatrix} R|t \end{bmatrix} \begin{bmatrix}
X_w \\
Y_w \\
Z_w \\
1
\end{bmatrix} = \begin{bmatrix}
r_{11} & r_{12} & r_{13} & t_x \\
r_{21} & r_{22} & r_{23} & t_y \\
r_{31} & r_{32} & r_{33} & t_z
\end{bmatrix}
\begin{bmatrix}
X_w \\
Y_w \\
Z_w \\
1
\end{bmatrix},\f]
with \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$. Putting the equations for instrincs and extrinsics together, we can write out
\f$s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w\f$ as
\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}
\begin{bmatrix}
r_{11} & r_{12} & r_{13} & t_x \\
r_{21} & r_{22} & r_{23} & t_y \\
r_{31} & r_{32} & r_{33} & t_z
\end{bmatrix}
\begin{bmatrix}
X_w \\
Y_w \\
Z_w \\
1
\end{bmatrix}.\f]
If \f$Z_c \ne 0\f$, the transformation above is equivalent to the following,
\f[\begin{bmatrix}
u \\
v
\end{bmatrix} = \begin{bmatrix}
f_x X_c/Z_c + c_x \\
f_y Y_c/Z_c + c_y
\end{bmatrix}\f]
with
\f[\vecthree{X_c}{Y_c}{Z_c} = \begin{bmatrix}
R|t
\end{bmatrix} \begin{bmatrix}
X_w \\
Y_w \\
Z_w \\
1
\end{bmatrix}.\f]
The following figure illustrates the pinhole camera model.

Real lenses usually have some distortion, mostly radial distortion, and slight tangential distortion.
So, the above model is extended as:
\f[\begin{bmatrix}
u \\
v
\end{bmatrix} = \begin{bmatrix}
f_x x'' + c_x \\
f_y y'' + c_y
\end{bmatrix}\f]
where
\f[\begin{bmatrix}
x'' \\
y''
\end{bmatrix} = \begin{bmatrix}
x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + 2 p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4 \\
y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\
\end{bmatrix}\f]
with
\f[r^2 = x'^2 + y'^2\f]
and
\f[\begin{bmatrix}
x'\\
y'
\end{bmatrix} = \begin{bmatrix}
X_c/Z_c \\
Y_c/Z_c
\end{bmatrix},\f]
if \f$Z_c \ne 0\f$.
The distortion parameters are the radial coefficients \f$k_1\f$, \f$k_2\f$, \f$k_3\f$, \f$k_4\f$, \f$k_5\f$, and \f$k_6\f$
,\f$p_1\f$ and \f$p_2\f$ are the tangential distortion coefficients, and \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$,
are the thin prism distortion coefficients. Higher-order coefficients are not considered in OpenCV.
The next figures show two common types of radial distortion: barrel distortion
(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
Radial distortion is always monotonic for real lenses,
and if the estimator produces a non-monotonic result,
this should be considered a calibration failure.
More generally, radial distortion must be monotonic and the distortion function must be bijective.
A failed estimation result may look deceptively good near the image center
but will work poorly in e.g. AR/SFM applications.
The optimization method used in OpenCV camera calibration does not include these constraints as
the framework does not support the required integer programming and polynomial inequalities.
See [issue #15992](https://github.com/opencv/opencv/issues/15992) for additional information.


In some cases, the image sensor may be tilted in order to focus an oblique plane in front of the
camera (Scheimpflug principle). This can be useful for particle image velocimetry (PIV) or
triangulation with a laser fan. The tilt causes a perspective distortion of \f$x''\f$ and
\f$y''\f$. This distortion can be modeled in the following way, see e.g. @cite Louhichi07.
\f[\begin{bmatrix}
u \\
v
\end{bmatrix} = \begin{bmatrix}
f_x x''' + c_x \\
f_y y''' + c_y
\end{bmatrix},\f]
where
\f[s\vecthree{x'''}{y'''}{1} =
\vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}(\tau_x, \tau_y)}
{0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)}
{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\f]
and the matrix \f$R(\tau_x, \tau_y)\f$ is defined by two rotations with angular parameter
\f$\tau_x\f$ and \f$\tau_y\f$, respectively,
\f[
R(\tau_x, \tau_y) =
\vecthreethree{\cos(\tau_y)}{0}{-\sin(\tau_y)}{0}{1}{0}{\sin(\tau_y)}{0}{\cos(\tau_y)}
\vecthreethree{1}{0}{0}{0}{\cos(\tau_x)}{\sin(\tau_x)}{0}{-\sin(\tau_x)}{\cos(\tau_x)} =
\vecthreethree{\cos(\tau_y)}{\sin(\tau_y)\sin(\tau_x)}{-\sin(\tau_y)\cos(\tau_x)}
{0}{\cos(\tau_x)}{\sin(\tau_x)}
{\sin(\tau_y)}{-\cos(\tau_y)\sin(\tau_x)}{\cos(\tau_y)\cos(\tau_x)}.
\f]
In the functions below the coefficients are passed or returned as
\f[(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f]
vector. That is, if the vector contains four elements, it means that \f$k_3=0\f$ . The distortion
coefficients do not depend on the scene viewed. Thus, they also belong to the intrinsic camera
parameters. And they remain the same regardless of the captured image resolution. If, for example, a
camera has been calibrated on images of 320 x 240 resolution, absolutely the same distortion
coefficients can be used for 640 x 480 images from the same camera while \f$f_x\f$, \f$f_y\f$,
\f$c_x\f$, and \f$c_y\f$ need to be scaled appropriately.
The functions below use the above model to do the following:
- Project 3D points to the image plane given intrinsic and extrinsic parameters.
- Compute extrinsic parameters given intrinsic parameters, a few 3D points, and their
projections.
- Estimate intrinsic and extrinsic camera parameters from several views of a known calibration
pattern (every view is described by several 3D-2D point correspondences).
- Estimate the relative position and orientation of the stereo camera "heads" and compute the
*rectification* transformation that makes the camera optical axes parallel.
<B> Homogeneous Coordinates </B><br>
Homogeneous Coordinates are a system of coordinates that are used in projective geometry. Their use
allows to represent points at infinity by finite coordinates and simplifies formulas when compared
to the cartesian counterparts, e.g. they have the advantage that affine transformations can be
expressed as linear homogeneous transformation.
One obtains the homogeneous vector \f$P_h\f$ by appending a 1 along an n-dimensional cartesian
vector \f$P\f$ e.g. for a 3D cartesian vector the mapping \f$P \rightarrow P_h\f$ is:
\f[\begin{bmatrix}
X \\
Y \\
Z
\end{bmatrix} \rightarrow \begin{bmatrix}
X \\
Y \\
Z \\
1
\end{bmatrix}.\f]
For the inverse mapping \f$P_h \rightarrow P\f$, one divides all elements of the homogeneous vector
by its last element, e.g. for a 3D homogeneous vector one gets its 2D cartesian counterpart by:
\f[\begin{bmatrix}
X \\
Y \\
W
\end{bmatrix} \rightarrow \begin{bmatrix}
X / W \\
Y / W
\end{bmatrix},\f]
if \f$W \ne 0\f$.
Due to this mapping, all multiples \f$k P_h\f$, for \f$k \ne 0\f$, of a homogeneous point represent
the same point \f$P_h\f$. An intuitive understanding of this property is that under a projective
transformation, all multiples of \f$P_h\f$ are mapped to the same point. This is the physical
observation one does for pinhole cameras, as all points along a ray through the camera's pinhole are
projected to the same image point, e.g. all points along the red ray in the image of the pinhole
camera model above would be mapped to the same image coordinate. This property is also the source
for the scale ambiguity s in the equation of the pinhole camera model.
As mentioned, by using homogeneous coordinates we can express any change of basis parameterized by
\f$R\f$ and \f$t\f$ as a linear transformation, e.g. for the change of basis from coordinate system
0 to coordinate system 1 becomes:
\f[P_1 = R P_0 + t \rightarrow P_{h_1} = \begin{bmatrix}
R & t \\
0 & 1
\end{bmatrix} P_{h_0}.\f]
@note
- Many functions in this module take a camera intrinsic matrix as an input parameter. Although all
functions assume the same structure of this parameter, they may name it differently. The
parameter's description, however, will be clear in that a camera intrinsic matrix with the structure
shown above is required.
- A calibration sample for 3 cameras in a horizontal position can be found at
opencv_source_code/samples/cpp/3calibration.cpp
- A calibration sample based on a sequence of images can be found at
opencv_source_code/samples/cpp/calibration.cpp
- A calibration sample in order to do 3D reconstruction can be found at
opencv_source_code/samples/cpp/build3dmodel.cpp
- A calibration example on stereo calibration can be found at
opencv_source_code/samples/cpp/stereo_calib.cpp
- A calibration example on stereo matching can be found at
opencv_source_code/samples/cpp/stereo_match.cpp
- (Python) A camera calibration sample can be found at
opencv_source_code/samples/python/calibrate.py
@{
@defgroup calib3d_fisheye Fisheye camera model
Definitions: Let P be a point in 3D of coordinates X in the world reference frame (stored in the
matrix X) The coordinate vector of P in the camera reference frame is:
\f[Xc = R X + T\f]
where R is the rotation matrix corresponding to the rotation vector om: R = rodrigues(om); call x, y
and z the 3 coordinates of Xc:
\f[x = Xc_1 \\ y = Xc_2 \\ z = Xc_3\f]
The pinhole projection coordinates of P is [a; b] where
\f[a = x / z \ and \ b = y / z \\ r^2 = a^2 + b^2 \\ \theta = atan(r)\f]
Fisheye distortion:
\f[\theta_d = \theta (1 + k_1 \theta^2 + k_2 \theta^4 + k_3 \theta^6 + k_4 \theta^8)\f]
The distorted point coordinates are [x'; y'] where
\f[x' = (\theta_d / r) a \\ y' = (\theta_d / r) b \f]
Finally, conversion into pixel coordinates: The final pixel coordinates vector [u; v] where:
\f[u = f_x (x' + \alpha y') + c_x \\
v = f_y y' + c_y\f]
@defgroup calib3d_c C API
@}
*/
namespace cv {
//! @addtogroup calib
//! @{
enum { CALIB_CB_ADAPTIVE_THRESH = 1,
CALIB_CB_NORMALIZE_IMAGE = 2,
CALIB_CB_FILTER_QUADS = 4,
CALIB_CB_FAST_CHECK = 8,
CALIB_CB_EXHAUSTIVE = 16,
CALIB_CB_ACCURACY = 32,
CALIB_CB_LARGER = 64,
CALIB_CB_MARKER = 128
};
enum { CALIB_CB_SYMMETRIC_GRID = 1,
CALIB_CB_ASYMMETRIC_GRID = 2,
CALIB_CB_CLUSTERING = 4
};
enum { CALIB_NINTRINSIC = 18,
CALIB_USE_INTRINSIC_GUESS = 0x00001,
CALIB_FIX_ASPECT_RATIO = 0x00002,
CALIB_FIX_PRINCIPAL_POINT = 0x00004,
CALIB_ZERO_TANGENT_DIST = 0x00008,
CALIB_FIX_FOCAL_LENGTH = 0x00010,
CALIB_FIX_K1 = 0x00020,
CALIB_FIX_K2 = 0x00040,
CALIB_FIX_K3 = 0x00080,
CALIB_FIX_K4 = 0x00800,
CALIB_FIX_K5 = 0x01000,
CALIB_FIX_K6 = 0x02000,
CALIB_RATIONAL_MODEL = 0x04000,
CALIB_THIN_PRISM_MODEL = 0x08000,
CALIB_FIX_S1_S2_S3_S4 = 0x10000,
CALIB_TILTED_MODEL = 0x40000,
CALIB_FIX_TAUX_TAUY = 0x80000,
CALIB_USE_QR = 0x100000, //!< use QR instead of SVD decomposition for solving. Faster but potentially less precise
CALIB_FIX_TANGENT_DIST = 0x200000,
// only for stereo
CALIB_FIX_INTRINSIC = 0x00100,
CALIB_SAME_FOCAL_LENGTH = 0x00200,
// for stereo rectification
CALIB_ZERO_DISPARITY = 0x00400,
CALIB_USE_LU = (1 << 17), //!< use LU instead of SVD decomposition for solving. much faster but potentially less precise
CALIB_USE_EXTRINSIC_GUESS = (1 << 22) //!< for stereoCalibrate
};
enum HandEyeCalibrationMethod
{
CALIB_HAND_EYE_TSAI = 0, //!< A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/Eye Calibration @cite Tsai89
CALIB_HAND_EYE_PARK = 1, //!< Robot Sensor Calibration: Solving AX = XB on the Euclidean Group @cite Park94
CALIB_HAND_EYE_HORAUD = 2, //!< Hand-eye Calibration @cite Horaud95
CALIB_HAND_EYE_ANDREFF = 3, //!< On-line Hand-Eye Calibration @cite Andreff99
CALIB_HAND_EYE_DANIILIDIS = 4 //!< Hand-Eye Calibration Using Dual Quaternions @cite Daniilidis98
};
enum RobotWorldHandEyeCalibrationMethod
{
CALIB_ROBOT_WORLD_HAND_EYE_SHAH = 0, //!< Solving the robot-world/hand-eye calibration problem using the kronecker product @cite Shah2013SolvingTR
CALIB_ROBOT_WORLD_HAND_EYE_LI = 1 //!< Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product @cite Li2010SimultaneousRA
};
/** @brief Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
@param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern
coordinate space. In the old interface all the per-view vectors are concatenated. See
#calibrateCamera for details.
@param imagePoints Vector of vectors of the projections of the calibration pattern points. In the
old interface all the per-view vectors are concatenated.
@param imageSize Image size in pixels used to initialize the principal point.
@param aspectRatio If it is zero or negative, both \f$f_x\f$ and \f$f_y\f$ are estimated independently.
Otherwise, \f$f_x = f_y * \texttt{aspectRatio}\f$ .
The function estimates and returns an initial camera intrinsic matrix for the camera calibration process.
Currently, the function only supports planar calibration patterns, which are patterns where each
object point has z-coordinate =0.
*/
CV_EXPORTS_W Mat initCameraMatrix2D( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints,
Size imageSize, double aspectRatio = 1.0 );
/** @brief Finds the positions of internal corners of the chessboard.
@param image Source chessboard view. It must be an 8-bit grayscale or color image.
@param patternSize Number of inner corners per a chessboard row and column
( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
@param corners Output array of detected corners.
@param flags Various operation flags that can be zero or a combination of the following values:
- @ref CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
and white, rather than a fixed threshold level (computed from the average image brightness).
- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before
applying fixed or adaptive thresholding.
- @ref CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
square-like shape) to filter out false quads extracted at the contour retrieval stage.
- @ref CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
and shortcut the call if none is found. This can drastically speed up the call in the
degenerate condition when no chessboard is observed.
The function attempts to determine whether the input image is a view of the chessboard pattern and
locate the internal chessboard corners. The function returns a non-zero value if all of the corners
are found and they are placed in a certain order (row by row, left to right in every row).
Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example,
a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black
squares touch each other. The detected coordinates are approximate, and to determine their positions
more accurately, the function calls cornerSubPix. You also may use the function cornerSubPix with
different parameters if returned coordinates are not accurate enough.
Sample usage of detecting and drawing chessboard corners: :
@code
Size patternsize(8,6); //interior number of corners
Mat gray = ....; //source image
vector<Point2f> corners; //this will be filled by the detected corners
//CALIB_CB_FAST_CHECK saves a lot of time on images
//that do not contain any chessboard corners
bool patternfound = findChessboardCorners(gray, patternsize, corners,
CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
+ CALIB_CB_FAST_CHECK);
if(patternfound)
cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
@endcode
@note The function requires white space (like a square-thick border, the wider the better) around
the board to make the detection more robust in various environments. Otherwise, if there is no
border and the background is dark, the outer black squares cannot be segmented properly and so the
square grouping and ordering algorithm fails.
Use gen_pattern.py (@ref tutorial_camera_calibration_pattern) to create checkerboard.
*/
CV_EXPORTS_W bool findChessboardCorners( InputArray image, Size patternSize, OutputArray corners,
int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE );
/*
Checks whether the image contains chessboard of the specific size or not.
If yes, nonzero value is returned.
*/
CV_EXPORTS_W bool checkChessboard(InputArray img, Size size);
/** @brief Finds the positions of internal corners of the chessboard using a sector based approach.
@param image Source chessboard view. It must be an 8-bit grayscale or color image.
@param patternSize Number of inner corners per a chessboard row and column
( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
@param corners Output array of detected corners.
@param flags Various operation flags that can be zero or a combination of the following values:
- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection.
- @ref CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate.
- @ref CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects.
- @ref CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description).
- @ref CALIB_CB_MARKER The detected pattern must have a marker (see description).
This should be used if an accurate camera calibration is required.
@param meta Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)).
Each entry stands for one corner of the pattern and can have one of the following values:
- 0 = no meta data attached
- 1 = left-top corner of a black cell
- 2 = left-top corner of a white cell
- 3 = left-top corner of a black cell with a white marker dot
- 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner)
The function is analog to #findChessboardCorners but uses a localized radon
transformation approximated by box filters being more robust to all sort of
noise, faster on larger images and is able to directly return the sub-pixel
position of the internal chessboard corners. The Method is based on the paper
@cite duda2018 "Accurate Detection and Localization of Checkerboard Corners for
Calibration" demonstrating that the returned sub-pixel positions are more
accurate than the one returned by cornerSubPix allowing a precise camera
calibration for demanding applications.
In the case, the flags @ref CALIB_CB_LARGER or @ref CALIB_CB_MARKER are given,
the result can be recovered from the optional meta array. Both flags are
helpful to use calibration patterns exceeding the field of view of the camera.
These oversized patterns allow more accurate calibrations as corners can be
utilized, which are as close as possible to the image borders. For a
consistent coordinate system across all images, the optional marker (see image
below) can be used to move the origin of the board to the location where the
black circle is located.
@note The function requires a white boarder with roughly the same width as one
of the checkerboard fields around the whole board to improve the detection in
various environments. In addition, because of the localized radon
transformation it is beneficial to use round corners for the field corners
which are located on the outside of the board. The following figure illustrates
a sample checkerboard optimized for the detection. However, any other checkerboard
can be used as well.
Use gen_pattern.py (@ref tutorial_camera_calibration_pattern) to create checkerboard.

*/
CV_EXPORTS_AS(findChessboardCornersSBWithMeta)
bool findChessboardCornersSB(InputArray image,Size patternSize, OutputArray corners,
int flags,OutputArray meta);
/** @overload */
CV_EXPORTS_W inline
bool findChessboardCornersSB(InputArray image, Size patternSize, OutputArray corners,
int flags = 0)
{
return findChessboardCornersSB(image, patternSize, corners, flags, noArray());
}
/** @brief Estimates the sharpness of a detected chessboard.
Image sharpness, as well as brightness, are a critical parameter for accuracte
camera calibration. For accessing these parameters for filtering out
problematic calibraiton images, this method calculates edge profiles by traveling from
black to white chessboard cell centers. Based on this, the number of pixels is
calculated required to transit from black to white. This width of the
transition area is a good indication of how sharp the chessboard is imaged
and should be below ~3.0 pixels.
@param image Gray image used to find chessboard corners
@param patternSize Size of a found chessboard pattern
@param corners Corners found by #findChessboardCornersSB
@param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
@param vertical By default edge responses for horizontal lines are calculated
@param sharpness Optional output array with a sharpness value for calculated edge responses (see description)
The optional sharpness array is of type CV_32FC1 and has for each calculated
profile one row with the following five entries:
* 0 = x coordinate of the underlying edge in the image
* 1 = y coordinate of the underlying edge in the image
* 2 = width of the transition area (sharpness)
* 3 = signal strength in the black cell (min brightness)
* 4 = signal strength in the white cell (max brightness)
@return Scalar(average sharpness, average min brightness, average max brightness,0)
*/
CV_EXPORTS_W Scalar estimateChessboardSharpness(InputArray image, Size patternSize, InputArray corners,
float rise_distance=0.8F,bool vertical=false,
OutputArray sharpness=noArray());
//! finds subpixel-accurate positions of the chessboard corners
CV_EXPORTS_W bool find4QuadCornerSubpix( InputArray img, InputOutputArray corners, Size region_size );
/** @brief Renders the detected chessboard corners.
@param image Destination image. It must be an 8-bit color image.
@param patternSize Number of inner corners per a chessboard row and column
(patternSize = cv::Size(points_per_row,points_per_column)).
@param corners Array of detected corners, the output of #findChessboardCorners.
@param patternWasFound Parameter indicating whether the complete board was found or not. The
return value of #findChessboardCorners should be passed here.
The function draws individual chessboard corners detected either as red circles if the board was not
found, or as colored corners connected with lines if the board was found.
*/
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
InputArray corners, bool patternWasFound );
struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
{
CV_WRAP CirclesGridFinderParameters();
CV_PROP_RW cv::Size2f densityNeighborhoodSize;
CV_PROP_RW float minDensity;
CV_PROP_RW int kmeansAttempts;
CV_PROP_RW int minDistanceToAddKeypoint;
CV_PROP_RW int keypointScale;
CV_PROP_RW float minGraphConfidence;
CV_PROP_RW float vertexGain;
CV_PROP_RW float vertexPenalty;
CV_PROP_RW float existingVertexGain;
CV_PROP_RW float edgeGain;
CV_PROP_RW float edgePenalty;
CV_PROP_RW float convexHullFactor;
CV_PROP_RW float minRNGEdgeSwitchDist;
enum GridType
{
SYMMETRIC_GRID, ASYMMETRIC_GRID
};
GridType gridType;
CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING.
CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from prediction. Used by CALIB_CB_CLUSTERING.
};
#ifndef DISABLE_OPENCV_3_COMPATIBILITY
typedef CirclesGridFinderParameters CirclesGridFinderParameters2;
#endif
/** @brief Finds centers in the grid of circles.
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
@param patternSize number of circles per row and column
( patternSize = Size(points_per_row, points_per_colum) ).
@param centers output array of detected centers.
@param flags various operation flags that can be one of the following values:
- @ref CALIB_CB_SYMMETRIC_GRID uses symmetric pattern of circles.
- @ref CALIB_CB_ASYMMETRIC_GRID uses asymmetric pattern of circles.
- @ref CALIB_CB_CLUSTERING uses a special algorithm for grid detection. It is more robust to
perspective distortions but much more sensitive to background clutter.
@param blobDetector feature detector that finds blobs like dark circles on light background.
If `blobDetector` is NULL then `image` represents Point2f array of candidates.
@param parameters struct for finding circles in a grid pattern.
The function attempts to determine whether the input image contains a grid of circles. If it is, the
function locates centers of the circles. The function returns a non-zero value if all of the centers
have been found and they have been placed in a certain order (row by row, left to right in every
row). Otherwise, if the function fails to find all the corners or reorder them, it returns 0.
Sample usage of detecting and drawing the centers of circles: :
@code
Size patternsize(7,7); //number of centers
Mat gray = ...; //source image
vector<Point2f> centers; //this will be filled by the detected centers
bool patternfound = findCirclesGrid(gray, patternsize, centers);
drawChessboardCorners(img, patternsize, Mat(centers), patternfound);
@endcode
@note The function requires white space (like a square-thick border, the wider the better) around
the board to make the detection more robust in various environments.
*/
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
OutputArray centers, int flags,
const Ptr<FeatureDetector> &blobDetector,
const CirclesGridFinderParameters& parameters);
/** @overload */
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
const Ptr<FeatureDetector> &blobDetector = SimpleBlobDetector::create());
/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration
pattern.
@param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer
vector contains as many elements as the number of pattern views. If the same calibration pattern
is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
possible to use partially occluded patterns or even different patterns in different views. Then,
the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
In the old interface all the vectors of object points from different views are concatenated
together.
@param imagePoints In the new interface it is a vector of vectors of the projections of calibration
pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and
objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
respectively. In the old interface all the vectors of object points from different views are
concatenated together.
@param imageSize Size of the image used only to initialize the camera intrinsic matrix.
@param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
\f$\cameramatrix{A}\f$ . If @ref CALIB_USE_INTRINSIC_GUESS
and/or @ref CALIB_FIX_ASPECT_RATIO, @ref CALIB_FIX_PRINCIPAL_POINT or @ref CALIB_FIX_FOCAL_LENGTH
are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
@param distCoeffs Input/output vector of distortion coefficients
\f$\distcoeffs\f$.
@param rvecs Output vector of rotation vectors (@ref Rodrigues ) estimated for each pattern view
(e.g. std::vector<cv::Mat>>). That is, each i-th rotation vector together with the corresponding
i-th translation vector (see the next output parameter description) brings the calibration pattern
from the object coordinate space (in which object points are specified) to the camera coordinate
space. In more technical terms, the tuple of the i-th rotation and translation vector performs
a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
space.
@param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
describtion above.
@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
parameters. Order of deviations values:
\f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic
parameters. Order of deviations values: \f$(R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\f$ where M is
the number of pattern views. \f$R_i, T_i\f$ are concatenated 1x3 vectors.
@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
@param flags Different flags that may be zero or a combination of the following values:
- @ref CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
center ( imageSize is used), and focal distances are computed in a least-squares fashion.
Note, that if intrinsic parameters are known, there is no need to use this function just to
estimate extrinsic parameters. Use @ref solvePnP instead.
- @ref CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
optimization. It stays at the center or at a different location specified when
@ref CALIB_USE_INTRINSIC_GUESS is set too.
- @ref CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
ratio fx/fy stays the same as in the input cameraMatrix . When
@ref CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
ignored, only their ratio is computed and used further.
- @ref CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
to zeros and stay zero.
- @ref CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if
@ref CALIB_USE_INTRINSIC_GUESS is set.
- @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 The corresponding radial distortion
coefficient is not changed during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is
set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- @ref CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the rational model and return 8 coefficients or more.
- @ref CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the thin prism model and return 12 coefficients or more.
- @ref CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- @ref CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the tilted sensor model and return 14 coefficients.
- @ref CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
@param criteria Termination criteria for the iterative optimization algorithm.
@return the overall RMS re-projection error.
The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
views. The algorithm is based on @cite Zhang2000 and @cite BouguetMCT . The coordinates of 3D object
points and their corresponding 2D projections in each view must be specified. That may be achieved
by using an object with known geometry and easily detectable feature points. Such an object is
called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
a calibration rig (see @ref findChessboardCorners). Currently, initialization of intrinsic
parameters (when @ref CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
be used as long as initial cameraMatrix is provided.
The algorithm performs the following steps:
- Compute the initial intrinsic parameters (the option only available for planar calibration
patterns) or read them from the input parameters. The distortion coefficients are all set to
zeros initially unless some of CALIB_FIX_K? are specified.
- Estimate the initial camera pose as if the intrinsic parameters have been already known. This is
done using @ref solvePnP .
- Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error,
that is, the total sum of squared distances between the observed feature points imagePoints and
the projected (using the current estimates for camera parameters and the poses) object points
objectPoints. See @ref projectPoints for details.
@note
If you use a non-square (i.e. non-N-by-N) grid and @ref findChessboardCorners for calibration,
and @ref calibrateCamera returns bad values (zero distortion coefficients, \f$c_x\f$ and
\f$c_y\f$ very far from the image center, and/or large differences between \f$f_x\f$ and
\f$f_y\f$ (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
instead of using patternSize=cvSize(cols,rows) in @ref findChessboardCorners.
@sa
calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
undistort
*/
CV_EXPORTS_AS(calibrateCameraExtended) double calibrateCamera( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints, Size imageSize,
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
OutputArray stdDeviationsIntrinsics,
OutputArray stdDeviationsExtrinsics,
OutputArray perViewErrors,
int flags = 0, TermCriteria criteria = TermCriteria(
TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON) );
/** @overload */
CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints, Size imageSize,
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
int flags = 0, TermCriteria criteria = TermCriteria(
TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON) );
/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
This function is an extension of #calibrateCamera with the method of releasing object which was
proposed in @cite strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
targets (calibration plates), this method can dramatically improve the precision of the estimated
camera parameters. Both the object-releasing method and standard method are supported by this
function. Use the parameter **iFixedPoint** for method selection. In the internal implementation,
#calibrateCamera is a wrapper for this function.
@param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
the identical calibration board must be used in each view and it must be fully visible, and all
objectPoints[i] must be the same and all points should be roughly close to a plane. **The calibration
target has to be rigid, or at least static if the camera (rather than the calibration target) is
shifted for grabbing images.**
@param imagePoints Vector of vectors of the projections of calibration pattern points. See
#calibrateCamera for details.
@param imageSize Size of the image used only to initialize the intrinsic camera matrix.
@param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
a switch for calibration method selection. If object-releasing method to be used, pass in the
parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
make standard calibration method selected. Usually the top-right corner point of the calibration
board grid is recommended to be fixed when object-releasing method being utilized. According to
\cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
@param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
@param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details.
@param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
for details.
@param tvecs Output vector of translation vectors estimated for each pattern view.
@param newObjPoints The updated output vector of calibration pattern points. The coordinates might
be scaled based on three fixed points. The returned coordinates are accurate only if the above
mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
is ignored with standard calibration method.
@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
See #calibrateCamera for details.
@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
See #calibrateCamera for details.
@param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
parameter is ignored with standard calibration method.
@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
@param flags Different flags that may be zero or a combination of some predefined values. See
#calibrateCamera for details. If the method of releasing object is used, the calibration time may
be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
less precise and less stable in some rare cases.
@param criteria Termination criteria for the iterative optimization algorithm.
@return the overall RMS re-projection error.
The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
views. The algorithm is based on @cite Zhang2000, @cite BouguetMCT and @cite strobl2011iccv. See
#calibrateCamera for other detailed explanations.
@sa
calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
*/
CV_EXPORTS_AS(calibrateCameraROExtended) double calibrateCameraRO( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint,
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
OutputArray newObjPoints,
OutputArray stdDeviationsIntrinsics,
OutputArray stdDeviationsExtrinsics,
OutputArray stdDeviationsObjPoints,
OutputArray perViewErrors,
int flags = 0, TermCriteria criteria = TermCriteria(
TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON) );
/** @overload */
CV_EXPORTS_W double calibrateCameraRO( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint,
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
OutputArray newObjPoints,
int flags = 0, TermCriteria criteria = TermCriteria(
TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON) );
/** @brief Computes useful camera characteristics from the camera intrinsic matrix.
@param cameraMatrix Input camera intrinsic matrix that can be estimated by #calibrateCamera or
#stereoCalibrate .
@param imageSize Input image size in pixels.
@param apertureWidth Physical width in mm of the sensor.
@param apertureHeight Physical height in mm of the sensor.
@param fovx Output field of view in degrees along the horizontal sensor axis.
@param fovy Output field of view in degrees along the vertical sensor axis.
@param focalLength Focal length of the lens in mm.
@param principalPoint Principal point in mm.
@param aspectRatio \f$f_y/f_x\f$
The function computes various useful camera characteristics from the previously estimated camera
matrix.
@note
Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for
the chessboard pitch (it can thus be any value).
*/
CV_EXPORTS_W void calibrationMatrixValues( InputArray cameraMatrix, Size imageSize,
double apertureWidth, double apertureHeight,
CV_OUT double& fovx, CV_OUT double& fovy,
CV_OUT double& focalLength, CV_OUT Point2d& principalPoint,
CV_OUT double& aspectRatio );
/** @brief Calibrates a stereo camera set up. This function finds the intrinsic parameters
for each of the two cameras and the extrinsic parameters between the two cameras.
@param objectPoints Vector of vectors of the calibration pattern points. The same structure as
in @ref calibrateCamera. For each pattern view, both cameras need to see the same object
points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
be equal for each i.
@param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
observed by the first camera. The same structure as in @ref calibrateCamera.
@param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
observed by the second camera. The same structure as in @ref calibrateCamera.
@param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in
@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
@param distCoeffs1 Input/output vector of distortion coefficients, the same as in
@ref calibrateCamera.
@param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for
cameraMatrix1.
@param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
description for distCoeffs1.
@param imageSize Size of the image used only to initialize the camera intrinsic matrices.
@param R Output rotation matrix. Together with the translation vector T, this matrix brings
points given in the first camera's coordinate system to points in the second camera's
coordinate system. In more technical terms, the tuple of R and T performs a change of basis
from the first camera's coordinate system to the second camera's coordinate system. Due to its
duality, this tuple is equivalent to the position of the first camera with respect to the
second camera coordinate system.
@param T Output translation vector, see description above.
@param E Output essential matrix.
@param F Output fundamental matrix.
@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
@param flags Different flags that may be zero or a combination of the following values:
- @ref CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
matrices are estimated.
- @ref CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
according to the specified flags. Initial values are provided by the user.
- @ref CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
- @ref CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
- @ref CALIB_FIX_FOCAL_LENGTH Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ .
- @ref CALIB_FIX_ASPECT_RATIO Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$
.
- @ref CALIB_SAME_FOCAL_LENGTH Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ .
- @ref CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
zeros and fix there.
- @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 Do not change the corresponding radial
distortion coefficient during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set,
the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- @ref CALIB_RATIONAL_MODEL Enable coefficients k4, k5, and k6. To provide the backward
compatibility, this extra flag should be explicitly specified to make the calibration
function use the rational model and return 8 coefficients. If the flag is not set, the
function computes and returns only 5 distortion coefficients.
- @ref CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the thin prism model and return 12 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- @ref CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- @ref CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- @ref CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
@param criteria Termination criteria for the iterative optimization algorithm.
The function estimates the transformation between two cameras making a stereo pair. If one computes
the poses of an object relative to the first camera and to the second camera,
( \f$R_1\f$,\f$T_1\f$ ) and (\f$R_2\f$,\f$T_2\f$), respectively, for a stereo camera where the
relative position and orientation between the two cameras are fixed, then those poses definitely
relate to each other. This means, if the relative position and orientation (\f$R\f$,\f$T\f$) of the
two cameras is known, it is possible to compute (\f$R_2\f$,\f$T_2\f$) when (\f$R_1\f$,\f$T_1\f$) is
given. This is what the described function does. It computes (\f$R\f$,\f$T\f$) such that:
\f[R_2=R R_1\f]
\f[T_2=R T_1 + T.\f]
Therefore, one can compute the coordinate representation of a 3D point for the second camera's
coordinate system when given the point's coordinate representation in the first camera's coordinate
system:
\f[\begin{bmatrix}
X_2 \\
Y_2 \\
Z_2 \\
1
\end{bmatrix} = \begin{bmatrix}
R & T \\
0 & 1
\end{bmatrix} \begin{bmatrix}
X_1 \\
Y_1 \\
Z_1 \\
1
\end{bmatrix}.\f]
Optionally, it computes the essential matrix E:
\f[E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\f]
where \f$T_i\f$ are components of the translation vector \f$T\f$ : \f$T=[T_0, T_1, T_2]^T\f$ .
And the function can also compute the fundamental matrix F:
\f[F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\f]
Besides the stereo-related information, the function can also perform a full calibration of each of
the two cameras. However, due to the high dimensionality of the parameter space and noise in the
input data, the function can diverge from the correct solution. If the intrinsic parameters can be
estimated with high accuracy for each of the cameras individually (for example, using
#calibrateCamera ), you are recommended to do so and then pass @ref CALIB_FIX_INTRINSIC flag to the
function along with the computed intrinsic parameters. Otherwise, if all the parameters are
estimated at once, it makes sense to restrict some parameters, for example, pass
@ref CALIB_SAME_FOCAL_LENGTH and @ref CALIB_ZERO_TANGENT_DIST flags, which is usually a
reasonable assumption.
Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
points in all the available views from both cameras. The function returns the final value of the
re-projection error.
*/
CV_EXPORTS_AS(stereoCalibrateExtended) double stereoCalibrate( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1,
InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2,
Size imageSize, InputOutputArray R,InputOutputArray T, OutputArray E, OutputArray F,
OutputArray perViewErrors, int flags = CALIB_FIX_INTRINSIC,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 100, 1e-6) );
/// @overload
CV_EXPORTS_W double stereoCalibrate( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1,
InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2,
Size imageSize, OutputArray R,OutputArray T, OutputArray E, OutputArray F,
int flags = CALIB_FIX_INTRINSIC,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 100, 1e-6) );
/** @brief Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$
@param[in] R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point
expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$).
This is a vector (`vector<Mat>`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors,
for all the transformations from gripper frame to robot base frame.
@param[in] t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point
expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$).
This is a vector (`vector<Mat>`) that contains the `(3x1)` translation vectors for all the transformations
from gripper frame to robot base frame.
@param[in] R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$).
This is a vector (`vector<Mat>`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors,
for all the transformations from calibration target frame to camera frame.
@param[in] t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$).
This is a vector (`vector<Mat>`) that contains the `(3x1)` translation vectors for all the transformations
from calibration target frame to camera frame.
@param[out] R_cam2gripper Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point
expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).
@param[out] t_cam2gripper Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point
expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).
@param[in] method One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod
The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
rotation then the translation (separable solutions) and the following methods are implemented:
- R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
- F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
- R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
with the following implemented methods:
- N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
- K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand.
The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot
end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting
the suitable transformations to the function, see below.

The calibration procedure is the following:
- a static calibration pattern is used to estimate the transformation between the target frame
and the camera frame
- the robot gripper is moved in order to acquire several poses
- for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
instance the robot kinematics
\f[
\begin{bmatrix}
X_b\\
Y_b\\
Z_b\\
1
\end{bmatrix}
=
\begin{bmatrix}
_{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\
0_{1 \times 3} & 1
\end{bmatrix}
\begin{bmatrix}
X_g\\
Y_g\\
Z_g\\
1
\end{bmatrix}
\f]
- for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
for instance a pose estimation method (PnP) from 2D-3D point correspondences
\f[
\begin{bmatrix}
X_c\\
Y_c\\
Z_c\\
1
\end{bmatrix}
=
\begin{bmatrix}
_{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\
0_{1 \times 3} & 1
\end{bmatrix}
\begin{bmatrix}
X_t\\
Y_t\\
Z_t\\
1
\end{bmatrix}
\f]
The Hand-Eye calibration procedure returns the following homogeneous transformation
\f[
\begin{bmatrix}
X_g\\
Y_g\\
Z_g\\
1
\end{bmatrix}
=
\begin{bmatrix}
_{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\
0_{1 \times 3} & 1
\end{bmatrix}
\begin{bmatrix}
X_c\\
Y_c\\
Z_c\\
1
\end{bmatrix}
\f]
This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\f$ equation:
- for an eye-in-hand configuration
\f[
\begin{align*}
^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &=
\hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\
(^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &=
\hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
\textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\
\end{align*}
\f]
- for an eye-to-hand configuration
\f[
\begin{align*}
^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &=
\hspace{0.1em} ^{g}{\textrm{T}_b}^{(2)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\
(^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &=
\hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
\textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\
\end{align*}
\f]
\note
Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
\note
A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
So at least 3 different poses are required, but it is strongly recommended to use many more poses.
*/
CV_EXPORTS void calibrateHandEye( InputArrayOfArrays R_gripper2base, InputArrayOfArrays t_gripper2base,
InputArrayOfArrays R_target2cam, InputArrayOfArrays t_target2cam,
OutputArray R_cam2gripper, OutputArray t_cam2gripper,
HandEyeCalibrationMethod method=CALIB_HAND_EYE_TSAI );
/** @brief Computes Robot-World/Hand-Eye calibration: \f$_{}^{w}\textrm{T}_b\f$ and \f$_{}^{c}\textrm{T}_g\f$
@param[in] R_world2cam Rotation part extracted from the homogeneous matrix that transforms a point
expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$).
This is a vector (`vector<Mat>`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors,
for all the transformations from world frame to the camera frame.
@param[in] t_world2cam Translation part extracted from the homogeneous matrix that transforms a point
expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$).
This is a vector (`vector<Mat>`) that contains the `(3x1)` translation vectors for all the transformations
from world frame to the camera frame.
@param[in] R_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$).
This is a vector (`vector<Mat>`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors,
for all the transformations from robot base frame to the gripper frame.
@param[in] t_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$).
This is a vector (`vector<Mat>`) that contains the `(3x1)` translation vectors for all the transformations
from robot base frame to the gripper frame.
@param[out] R_base2world Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point
expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$).
@param[out] t_base2world Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point
expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$).
@param[out] R_gripper2cam Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point
expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$).
@param[out] t_gripper2cam Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point
expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$).
@param[in] method One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod
The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the
rotation then the translation (separable solutions):
- M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR
Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
with the following implemented method:
- A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA
The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame
and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated.

The calibration procedure is the following:
- a static calibration pattern is used to estimate the transformation between the target frame
and the camera frame
- the robot gripper is moved in order to acquire several poses
- for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
instance the robot kinematics
\f[
\begin{bmatrix}
X_g\\
Y_g\\
Z_g\\
1
\end{bmatrix}
=
\begin{bmatrix}
_{}^{g}\textrm{R}_b & _{}^{g}\textrm{t}_b \\
0_{1 \times 3} & 1
\end{bmatrix}
\begin{bmatrix}
X_b\\
Y_b\\
Z_b\\
1
\end{bmatrix}
\f]
- for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using
for instance a pose estimation method (PnP) from 2D-3D point correspondences
\f[
\begin{bmatrix}
X_c\\
Y_c\\
Z_c\\
1
\end{bmatrix}
=
\begin{bmatrix}
_{}^{c}\textrm{R}_w & _{}^{c}\textrm{t}_w \\
0_{1 \times 3} & 1
\end{bmatrix}
\begin{bmatrix}
X_w\\
Y_w\\
Z_w\\
1
\end{bmatrix}
\f]
The Robot-World/Hand-Eye calibration procedure returns the following homogeneous transformations
\f[
\begin{bmatrix}
X_w\\
Y_w\\
Z_w\\
1
\end{bmatrix}
=
\begin{bmatrix}
_{}^{w}\textrm{R}_b & _{}^{w}\textrm{t}_b \\
0_{1 \times 3} & 1
\end{bmatrix}
\begin{bmatrix}
X_b\\
Y_b\\
Z_b\\
1
\end{bmatrix}
\f]
\f[
\begin{bmatrix}
X_c\\
Y_c\\
Z_c\\
1
\end{bmatrix}
=
\begin{bmatrix}
_{}^{c}\textrm{R}_g & _{}^{c}\textrm{t}_g \\
0_{1 \times 3} & 1
\end{bmatrix}
\begin{bmatrix}
X_g\\
Y_g\\
Z_g\\
1
\end{bmatrix}
\f]
This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{Z}\mathbf{B}\f$ equation, with:
- \f$\mathbf{A} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_w\f$
- \f$\mathbf{X} \Leftrightarrow \hspace{0.1em} _{}^{w}\textrm{T}_b\f$
- \f$\mathbf{Z} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_g\f$
- \f$\mathbf{B} \Leftrightarrow \hspace{0.1em} _{}^{g}\textrm{T}_b\f$
\note
At least 3 measurements are required (input vectors size must be greater or equal to 3).
*/
CV_EXPORTS void calibrateRobotWorldHandEye( InputArrayOfArrays R_world2cam, InputArrayOfArrays t_world2cam,
InputArrayOfArrays R_base2gripper, InputArrayOfArrays t_base2gripper,
OutputArray R_base2world, OutputArray t_base2world,
OutputArray R_gripper2cam, OutputArray t_gripper2cam,
RobotWorldHandEyeCalibrationMethod method=CALIB_ROBOT_WORLD_HAND_EYE_SHAH );
/** @brief The methods in this namespace use a so-called fisheye camera model.
@ingroup calib3d_fisheye
*/
namespace fisheye
{
//! @addtogroup calib3d_fisheye
//! @{
enum{
CALIB_USE_INTRINSIC_GUESS = 1 << 0,
CALIB_RECOMPUTE_EXTRINSIC = 1 << 1,
CALIB_CHECK_COND = 1 << 2,
CALIB_FIX_SKEW = 1 << 3,
CALIB_FIX_K1 = 1 << 4,
CALIB_FIX_K2 = 1 << 5,
CALIB_FIX_K3 = 1 << 6,
CALIB_FIX_K4 = 1 << 7,
CALIB_FIX_INTRINSIC = 1 << 8,
CALIB_FIX_PRINCIPAL_POINT = 1 << 9,
CALIB_ZERO_DISPARITY = 1 << 10,
CALIB_FIX_FOCAL_LENGTH = 1 << 11
};
/** @brief Projects points using fisheye model
@param objectPoints Array of object points, 1xN/Nx1 3-channel (or vector\<Point3f\> ), where N is
the number of points in the view.
@param imagePoints Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or
vector\<Point2f\>.
@param affine
@param K Camera intrinsic matrix \f$cameramatrix{K}\f$.
@param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$.
@param alpha The skew coefficient.
@param jacobian Optional output 2Nx15 jacobian matrix of derivatives of image points with respect
to components of the focal lengths, coordinates of the principal point, distortion coefficients,
rotation vector, translation vector, and the skew. In the old interface different components of
the jacobian are returned via different output parameters.
The function computes projections of 3D points to the image plane given intrinsic and extrinsic
camera parameters. Optionally, the function computes Jacobians - matrices of partial derivatives of
image points coordinates (as functions of all the input parameters) with respect to the particular
parameters, intrinsic and/or extrinsic.
*/
CV_EXPORTS void projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine,
InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray());
/** @overload */
CV_EXPORTS_W void projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec,
InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray());
/** @brief Distorts 2D points using fisheye model.
@param undistorted Array of object points, 1xN/Nx1 2-channel (or vector\<Point2f\> ), where N is
the number of points in the view.
@param K Camera intrinsic matrix \f$cameramatrix{K}\f$.
@param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$.
@param alpha The skew coefficient.
@param distorted Output array of image points, 1xN/Nx1 2-channel, or vector\<Point2f\> .
Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity.
This means if you want to transform back points undistorted with undistortPoints() you have to
multiply them with \f$P^{-1}\f$.
*/
CV_EXPORTS_W void distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0);
/** @brief Undistorts 2D points using fisheye model
@param distorted Array of object points, 1xN/Nx1 2-channel (or vector\<Point2f\> ), where N is the
number of points in the view.
@param K Camera intrinsic matrix \f$cameramatrix{K}\f$.
@param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$.
@param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
1-channel or 1x1 3-channel
@param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
@param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector\<Point2f\> .
*/
CV_EXPORTS_W void undistortPoints(InputArray distorted, OutputArray undistorted,
InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray());
/** @brief Computes undistortion and rectification maps for image transform by cv::remap(). If D is empty zero
distortion is used, if R or P is empty identity matrixes are used.
@param K Camera intrinsic matrix \f$cameramatrix{K}\f$.
@param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$.
@param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
1-channel or 1x1 3-channel
@param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
@param size Undistorted image size.
@param m1type Type of the first output map that can be CV_32FC1 or CV_16SC2 . See convertMaps()
for details.
@param map1 The first output map.
@param map2 The second output map.
*/
CV_EXPORTS_W void initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P,
const cv::Size& size, int m1type, OutputArray map1, OutputArray map2);
/** @brief Transforms an image to compensate for fisheye lens distortion.
@param distorted image with fisheye lens distortion.
@param undistorted Output image with compensated fisheye lens distortion.
@param K Camera intrinsic matrix \f$cameramatrix{K}\f$.
@param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$.
@param Knew Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you
may additionally scale and shift the result by using a different matrix.
@param new_size the new size
The function transforms an image to compensate radial and tangential lens distortion.
The function is simply a combination of fisheye::initUndistortRectifyMap (with unity R ) and remap
(with bilinear interpolation). See the former function for details of the transformation being
performed.
See below the results of undistortImage.
- a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
k_4, k_5, k_6) of distortion were optimized under calibration)
- b\) result of fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
k_3, k_4) of fisheye distortion were optimized under calibration)
- c\) original image was captured with fisheye lens
Pictures a) and b) almost the same. But if we consider points of image located far from the center
of image, we can notice that on image a) these points are distorted.

*/
CV_EXPORTS_W void undistortImage(InputArray distorted, OutputArray undistorted,
InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size());
/** @brief Estimates new camera intrinsic matrix for undistortion or rectification.
@param K Camera intrinsic matrix \f$cameramatrix{K}\f$.
@param image_size Size of the image
@param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$.
@param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
1-channel or 1x1 3-channel
@param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
@param balance Sets the new focal length in range between the min focal length and the max focal
length. Balance is in range of [0, 1].
@param new_size the new size
@param fov_scale Divisor for new focal length.
*/
CV_EXPORTS_W void estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R,
OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0);
/** @brief Performs camera calibaration
@param objectPoints vector of vectors of calibration pattern points in the calibration pattern
coordinate space.
@param imagePoints vector of vectors of the projections of calibration pattern points.
imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
objectPoints[i].size() for each i.
@param image_size Size of the image used only to initialize the camera intrinsic matrix.
@param K Output 3x3 floating-point camera intrinsic matrix
\f$\cameramatrix{A}\f$ . If
@ref fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
initialized before calling the function.
@param D Output vector of distortion coefficients \f$\distcoeffsfisheye\f$.
@param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
That is, each k-th rotation vector together with the corresponding k-th translation vector (see
the next output parameter description) brings the calibration pattern from the model coordinate
space (in which object points are specified) to the world coordinate space, that is, a real
position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
@param tvecs Output vector of translation vectors estimated for each pattern view.
@param flags Different flags that may be zero or a combination of the following values:
- @ref fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
center ( imageSize is used), and focal distances are computed in a least-squares fashion.
- @ref fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
of intrinsic optimization.
- @ref fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
- @ref fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
- @ref fisheye::CALIB_FIX_K1,..., @ref fisheye::CALIB_FIX_K4 Selected distortion coefficients
are set to zeros and stay zero.
- @ref fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
optimization. It stays at the center or at a different location specified when @ref fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
- @ref fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
optimization. It is the \f$max(width,height)/\pi\f$ or the provided \f$f_x\f$, \f$f_y\f$ when @ref fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
@param criteria Termination criteria for the iterative optimization algorithm.
*/
CV_EXPORTS_W double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size,
InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON));
/** @brief Stereo rectification for fisheye camera model
@param K1 First camera intrinsic matrix.
@param D1 First camera distortion parameters.
@param K2 Second camera intrinsic matrix.
@param D2 Second camera distortion parameters.
@param imageSize Size of the image used for stereo calibration.
@param R Rotation matrix between the coordinate systems of the first and the second
cameras.
@param tvec Translation vector between coordinate systems of the cameras.
@param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
@param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
@param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
camera.
@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
camera.
@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ).
@param flags Operation flags that may be zero or @ref fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
the function makes the principal points of each camera have the same pixel coordinates in the
rectified views. And if the flag is not set, the function may still shift the images in the
horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
useful image area.
@param newImageSize New image resolution after rectification. The same size should be passed to
initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
is passed (default), it is set to the original imageSize . Setting it to larger value can help you
preserve details in the original image, especially when there is a big radial distortion.
@param balance Sets the new focal length in range between the min focal length and the max focal
length. Balance is in range of [0, 1].
@param fov_scale Divisor for new focal length.
*/
CV_EXPORTS_W void stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec,
OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(),
double balance = 0.0, double fov_scale = 1.0);
/** @brief Performs stereo calibration
@param objectPoints Vector of vectors of the calibration pattern points.
@param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
observed by the first camera.
@param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
observed by the second camera.
@param K1 Input/output first camera intrinsic matrix:
\f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If
any of @ref fisheye::CALIB_USE_INTRINSIC_GUESS , @ref fisheye::CALIB_FIX_INTRINSIC are specified,
some or all of the matrix components must be initialized.
@param D1 Input/output vector of distortion coefficients \f$\distcoeffsfisheye\f$ of 4 elements.
@param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 .
@param D2 Input/output lens distortion coefficients for the second camera. The parameter is
similar to D1 .
@param imageSize Size of the image used only to initialize camera intrinsic matrix.
@param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
@param T Output translation vector between the coordinate systems of the cameras.
@param flags Different flags that may be zero or a combination of the following values:
- @ref fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
are estimated.
- @ref fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
center (imageSize is used), and focal distances are computed in a least-squares fashion.
- @ref fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
of intrinsic optimization.
- @ref fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
- @ref fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
- @ref fisheye::CALIB_FIX_K1,..., @ref fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
zero.
@param criteria Termination criteria for the iterative optimization algorithm.
*/
CV_EXPORTS_W double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize,
OutputArray R, OutputArray T, int flags = fisheye::CALIB_FIX_INTRINSIC,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON));
//! @} calib3d_fisheye
} //end namespace fisheye
} //end namespace cv
#endif
| 51.76872 | 167 | 0.738152 | [
"geometry",
"object",
"shape",
"vector",
"model",
"transform",
"3d"
] |
00c5c9e3160637c2c0114a13ada160036811cef6 | 2,005 | cpp | C++ | wms/Png.cpp | fmidev/smartmet-plugin-wms | 908027c3dbe604c2e220718fd4926aa03673a8d6 | [
"MIT"
] | null | null | null | wms/Png.cpp | fmidev/smartmet-plugin-wms | 908027c3dbe604c2e220718fd4926aa03673a8d6 | [
"MIT"
] | 6 | 2017-01-05T07:19:43.000Z | 2019-10-23T06:21:48.000Z | wms/Png.cpp | fmidev/smartmet-plugin-wms | 908027c3dbe604c2e220718fd4926aa03673a8d6 | [
"MIT"
] | 1 | 2016-12-30T11:10:58.000Z | 2016-12-30T11:10:58.000Z | #include "Png.h"
#include "Hash.h"
#include <boost/numeric/conversion/cast.hpp>
#include <macgyver/Exception.h>
#include <stdexcept>
namespace SmartMet
{
namespace Plugin
{
namespace Dali
{
// ----------------------------------------------------------------------
/*!
* \brief Initialize from JSON
*/
// ----------------------------------------------------------------------
void Png::init(const Json::Value& theJson, const Config& /* theConfig */)
{
try
{
if (!theJson.isObject())
throw Fmi::Exception(BCP, "Png JSON is not a JSON object");
// Iterate through all the members
const auto members = theJson.getMemberNames();
for (const auto& name : members)
{
const Json::Value& json = theJson[name];
if (name == "quality")
options.quality = json.asDouble();
else if (name == "errorfactor")
options.errorfactor = json.asDouble();
else if (name == "maxcolors")
options.maxcolors = json.asInt();
else if (name == "truecolor")
options.truecolor = json.asBool();
else
throw Fmi::Exception(BCP, "Png does not have a setting named '" + name + "'");
}
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
// ----------------------------------------------------------------------
/*!
* \brief Hash value for the layer
*/
// ----------------------------------------------------------------------
std::size_t Png::hash_value(const State& /* theState */) const
{
try
{
auto hash = Fmi::hash_value(options.quality);
Fmi::hash_combine(hash, Fmi::hash_value(options.errorfactor));
Fmi::hash_combine(hash, Fmi::hash_value(options.errorfactor));
Fmi::hash_combine(hash, Fmi::hash_value(options.maxcolors));
Fmi::hash_combine(hash, Fmi::hash_value(options.truecolor));
return hash;
}
catch (...)
{
throw Fmi::Exception::Trace(BCP, "Operation failed!");
}
}
} // namespace Dali
} // namespace Plugin
} // namespace SmartMet
| 25.705128 | 86 | 0.539651 | [
"object"
] |
00c5e13f64ea36fe5c9abd25c0e4222800ba460a | 2,394 | cpp | C++ | src/Image.cpp | Jomiri/raytracer | 27c42254c72737d64a8487fb62fb842c7c423259 | [
"BSL-1.0",
"MIT"
] | 4 | 2019-10-22T19:27:13.000Z | 2020-12-14T22:04:06.000Z | src/Image.cpp | Jomiri/raytracer | 27c42254c72737d64a8487fb62fb842c7c423259 | [
"BSL-1.0",
"MIT"
] | null | null | null | src/Image.cpp | Jomiri/raytracer | 27c42254c72737d64a8487fb62fb842c7c423259 | [
"BSL-1.0",
"MIT"
] | 3 | 2020-03-19T07:14:16.000Z | 2022-02-20T00:40:49.000Z | //
// Created by Joona on 13/10/2018.
//
#include <fstream>
#include "Common.h"
#include "Image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define STBI_MSC_SECURE_CRT
#include "stb_image/stb_image_write.h"
Image::Image(int width, int height) {
this->width = width;
this->height = height;
pixels = std::vector<vec3>(width * height);
}
int Image::get_height() const {
return height;
}
int Image::get_width() const {
return width;
}
void Image::set_pixel_at(int x, int y, vec3 pixel) {
pixels.at(x + y*width) = pixel;
}
vec3 Image::get_pixel_at(int x, int y) const {
return pixels.at(x + y*width);
}
void Image::to_ppm(const std::string &file_name) const {
std::ofstream os {file_name};
os << "P3" << std::endl;
os << width << " " << height << std::endl;
os << "255" << std::endl;
for (const auto& p : pixels) {
auto ir = static_cast<int>(255.99 * p.x);
auto ig = static_cast<int>(255.99 * p.y);
auto ib = static_cast<int>(255.99 * p.z);
os << ir << " " << ig << " " << ib << std::endl;
}
}
void Image::to_png(const std::string& file_name) const {
std::vector<unsigned char> data;
constexpr int num_channels = 4;
data.reserve(num_channels*width*height);
for (const auto& p : pixels) {
data.push_back(static_cast<unsigned char>(255.99 * p.x)); // red
data.push_back(static_cast<unsigned char>(255.99 * p.y)); // green
data.push_back(static_cast<unsigned char>(255.99 * p.z)); // blue
data.push_back(255); // alpha
}
stbi_write_png(file_name.c_str(), width, height, 4, data.data(), 4*width);
}
void Image::gamma_correct() {
for (auto& px : pixels) {
px = vec3(sqrt(px.x), sqrt(px.y), sqrt(px.z));
}
}
/* After this operation, "out" contains the average of "images"
* Inefficient, but that does not matter here.
*/
void average_images(const std::vector<Image> &images, Image &out) {
const size_t n_images = images.size();
const int width = out.get_width();
const int height = out.get_height();
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
vec3 col {0, 0, 0};
for (int k = 0; k < n_images; k++) {
col += images[k].get_pixel_at(i, j);
}
col /= Float(n_images);
out.set_pixel_at(i, j, col);
}
}
}
| 27.517241 | 78 | 0.588137 | [
"vector"
] |
00c8c67ebc94dfa74903fae47ab6b29c816e42aa | 3,263 | cc | C++ | test/refine2x.cc | cwsmith/core | 840fbf6ec49a63aeaa3945f11ddb224f6055ac9f | [
"BSD-3-Clause"
] | 1 | 2021-12-02T09:25:32.000Z | 2021-12-02T09:25:32.000Z | test/refine2x.cc | cwsmith/core | 840fbf6ec49a63aeaa3945f11ddb224f6055ac9f | [
"BSD-3-Clause"
] | null | null | null | test/refine2x.cc | cwsmith/core | 840fbf6ec49a63aeaa3945f11ddb224f6055ac9f | [
"BSD-3-Clause"
] | null | null | null | #include <ma.h>
#include <apf.h>
#include <gmi_mesh.h>
#include <apfMDS.h>
#include <PCU.h>
#include <apfNumbering.h>
#include <apfShape.h>
#ifdef HAVE_SIMMETRIX
#include <gmi_sim.h>
#include <SimUtil.h>
#include <MeshSim.h>
#include <SimModel.h>
#endif
#include <pcu_util.h>
#include <cstdlib>
#include <iostream>
class AnisotropicX: public ma::AnisotropicFunction {
public:
AnisotropicX(ma::Mesh* mesh, int splitDir) {
m = mesh;
dir = splitDir;
PCU_ALWAYS_ASSERT(dir>=0 && dir<3);
isf = new ma::IdentitySizeField(m);
fLen = createFieldOn(m, "incidentEdgeLength", apf::SCALAR);
fCnt = createFieldOn(m, "incidentEdgeCount", apf::SCALAR);
getVtxSize();
}
~AnisotropicX() {
apf::destroyField(fLen);
apf::destroyField(fCnt);
delete isf;
}
void getValue(ma::Entity* v, ma::Matrix& r, ma::Vector& h) {
r = ma::Matrix(1,0,0,
0,1,0,
0,0,1);
int cnt = static_cast<int>(apf::getScalar(fCnt, v, 0));
double l = apf::getScalar(fLen, v, 0) / cnt;
const double f = 1.8;
double sz[3] = {l,l,l};
for(int i=0; i<3; i++)
if( i == dir )
sz[i] /= f;
h = ma::Vector(sz);
}
private:
ma::Mesh* m;
int dir;
ma::SizeField* isf;
apf::Field* fLen;
apf::Field* fCnt;
void getVtxSize() {
double len;
int cnt;
ma::Entity* vtx;
apf::MeshIterator* itr = m->begin(0);
while( (vtx = m->iterate(itr)) ) {
getEdgeLenAndCnt(vtx, len, cnt);
apf::setScalar(fLen, vtx, 0, len);
apf::setScalar(fCnt, vtx, 0, cnt);
}
m->end(itr);
apf::accumulate(fLen);
apf::accumulate(fCnt);
apf::synchronize(fLen);
apf::synchronize(fCnt);
}
void getEdgeLenAndCnt(ma::Entity* v, double& len, int& cnt) {
len = 0;
cnt = 0;
apf::Up edges;
m->getUp(v, edges);
for(int eIdx=0; eIdx < edges.n; eIdx++) {
if( m->isOwned(edges.e[eIdx])) {
cnt++;
len += isf->measure(edges.e[eIdx]);
}
}
}
};
int main(int argc, char** argv)
{
MPI_Init(&argc,&argv);
PCU_Comm_Init();
if (argc != 5) {
if(0==PCU_Comm_Self())
std::cerr << "usage: " << argv[0]
<< " <model file> <in mesh> <split direction=[0-2]> <out mesh> \n";
return EXIT_FAILURE;
}
#ifdef HAVE_SIMMETRIX
MS_init();
SimModel_start();
Sim_readLicenseFile(NULL);
gmi_sim_start();
gmi_register_sim();
#endif
gmi_register_mesh();
ma::Mesh* m = apf::loadMdsMesh(argv[1],argv[2]);
AnisotropicX* ansx = new AnisotropicX(m, atoi(argv[3]));
ma::Input* in = ma::configure(m, ansx);
in->shouldRunPreZoltanRib = true;
in->shouldRunPreParma = true;
in->shouldRunMidParma = true;
in->shouldRunPostParma = true;
in->maximumIterations = 10;
if (in->shouldSnap) {
in->shouldSnap = false;
PCU_ALWAYS_ASSERT(in->shouldTransferParametric);
}
in->shouldFixShape = false;
ma::adapt(in);
m->verify();
delete ansx;
m->writeNative(argv[4]);
m->destroyNative();
apf::destroyMesh(m);
#ifdef HAVE_SIMMETRIX
gmi_sim_stop();
Sim_unregisterAllKeys();
SimModel_stop();
MS_exit();
#endif
PCU_Comm_Free();
MPI_Finalize();
}
| 25.1 | 75 | 0.581673 | [
"mesh",
"vector",
"model"
] |
00dc0456d051d9655138a9d33676100db9d6ab19 | 803 | cpp | C++ | 112A.cpp | felikjunvianto/kfile-codeforces-submissions | 1b53da27a294a12063b0912e12ad32efe24af678 | [
"MIT"
] | null | null | null | 112A.cpp | felikjunvianto/kfile-codeforces-submissions | 1b53da27a294a12063b0912e12ad32efe24af678 | [
"MIT"
] | null | null | null | 112A.cpp | felikjunvianto/kfile-codeforces-submissions | 1b53da27a294a12063b0912e12ad32efe24af678 | [
"MIT"
] | null | null | null | #include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pi 2*acos(0.0)
#define eps 1e-9
#define PII pair<int,int>
#define PDD pair<double,double>
#define LL long long
#define INF 1000000000
using namespace std;
char msk[111];
string a,b;
int x;
int main()
{
scanf("%s",msk);a=msk;
scanf("%s",msk);b=msk;
for(x=0;x<a.size();x++) if((a[x]>='A')&&(a[x]<='Z')) a[x]^=32;
for(x=0;x<b.size();x++) if((b[x]>='A')&&(b[x]<='Z')) b[x]^=32;
if(a==b) printf("0\n"); else
if(a>b) printf("1\n"); else printf("-1\n");
return 0;
}
| 18.674419 | 64 | 0.595268 | [
"vector"
] |
00ecdacb7c326d8996110ed94b39d2e8470332e6 | 5,034 | cpp | C++ | KMatrix/KMatrixHelpers.cpp | Mos-Fett/KMatrix | 8146ca84ab6be8d6d974613940ae689084c247c2 | [
"MIT"
] | null | null | null | KMatrix/KMatrixHelpers.cpp | Mos-Fett/KMatrix | 8146ca84ab6be8d6d974613940ae689084c247c2 | [
"MIT"
] | null | null | null | KMatrix/KMatrixHelpers.cpp | Mos-Fett/KMatrix | 8146ca84ab6be8d6d974613940ae689084c247c2 | [
"MIT"
] | null | null | null | //
// KMatrixHelpers.cpp
// KMatrix
//
// Created by Grant Giesbrecht on 4/14/18.
// Copyright © 2018 IEGA. All rights reserved.
//
#include "KMatrixHelpers.hpp"
#include <vector>
#include <IEGA/stdutil.hpp>
#include <IEGA/string_manip.hpp>
const char* matrix_bounds_excep::what() const throw(){
return "Attempted to access element out of bounds";
}
const char* matrix_multiplication_exception::what() const throw(){
return "Attempted to multiply matricies of the wrong size";
}
/*
Creates a 2D vector of int from a string. The result is saved to 'out'.
input - string interpreted as a matrix
out - 2D vector in which result is saved
Returns true if creating vector was successful
*/
bool matrixFromString(std::string input, std::vector<std::vector<int> >& out){
std::vector<std::vector<double> > temp;
bool ret = matrixFromString(input, temp);
out.clear();
std::vector<int> temp_int;
for (int i = 0 ; i < temp.size() ; i++){
temp_int.clear();
for (int j = 0 ; j < temp[i].size() ; j++){
temp_int.push_back((int)temp[i][j]);
}
out.push_back(temp_int);
}
return ret;
}
/*
Creates a 2D vector of doubles from a string. The result is saved to 'out'.
input - string interpreted as a matrix
out - 2D vector in which result is saved
Returns true if creating vector was successful
*/
bool matrixFromString(std::string input, std::vector<std::vector<double> >& out){
int c = -1;
int r = 0;
std::vector<double> values;
ensure_whitespace(input, ",;");
std::vector<std::string> tokens = parse(input, " ");
int ticker = 0;
bool add_line = false;
bool req_commas = false;
char phase = 'b';
for (int i = 0 ; i < tokens.size() ; i++){
if (isnum(tokens[i])){
if (req_commas && phase != 'c' && phase != 'n'){
std::cout << "ERROR: Failed to create matrix from string - missing comma before token " << i << ", '" << tokens[i] << "'. String:\n\t'" << input << "'" << std::endl;
return false;
}
values.push_back(strtod(tokens[i]));
ticker++;
add_line = true;
phase = 'v'; //var added
}else if(tokens[i] == ";"){
if (phase == 'c'){
std::cout << "ERROR: Failed to create matrix from string - semicolon can not follow a comma. String:\n\t'" << input << "'" << std::endl;
return false;
}else if(phase == 'b'){
std::cout << "ERROR: Failed to create matrix from string - semicolon can not be first symbol. String:\n\t'" << input << "'" << std::endl;
return false;
}
if (c == -1){
c = ticker;
}else if(c != ticker){
std::cout << "ERROR: Failed to create matrix from string:\n\t'" << input << "'" << std::endl;
return false;
}
phase = 'n'; //new row
add_line = false;
r++;
ticker = 0;
}else if(tokens[i] == ","){
if ( r == 0 && ticker == 1){ //begin
req_commas = true;
phase = 'c';
}else if(req_commas && 'v'){
phase = 'c'; //Ready for next var
}else{
std::cout << "ERROR: Failed to create matrix from string due to invalid comma. String:\n\t'" << input << "'" << std::endl;
return false;
}
}else{
}
}
if (add_line){
c = ticker;
r++;
}
if (r < 0 || c < 0) return false;
//Resize and fill array
out.clear();
for (int rr = 0 ; rr < r ; rr++){
std::vector<double> temp;
for (int cc = 0 ; cc < c ; cc++){
temp.push_back(values[rr*c + cc]);
// out[rr][cc] = ;
}
out.push_back(temp);
}
return true;
}
std::string limited_template_to_string(int x){
return std::to_string(x);
}
//std::string limited_template_to_string(long int x){
// return std::to_string(x);
//}
//
//std::string limited_template_to_string(long long int x){
// return std::to_string(x);
//}
//
//std::string limited_template_to_string(unsigned int x){
// return std::to_string(x);
//}
//
//std::string limited_template_to_string(unsigned long int x){
// return std::to_string(x);
//}
//
//std::string limited_template_to_string(unsigned long long int x){
// return std::to_string(x);
//}
std::string limited_template_to_string(std::string x){
return x;
}
//std::string limited_template_to_string(float x){
// return std::to_string(x);
//}
std::string limited_template_to_string(double x){
return std::to_string(x);
}
std::string limited_template_to_string(bool x){
return bool_to_str(x);
}
std::string limited_template_to_string(char x){
return std::to_string((int)(x));
}
| 28.122905 | 181 | 0.545491 | [
"vector"
] |
00f55d7e8fb3be8970741c7cf05f92d09d709aa8 | 13,899 | cc | C++ | src/shrpx_log.cc | max-weller/nghttpd-mptcp | 3788e09726c949d8b2d91358b448167d4a5d46d7 | [
"MIT"
] | 7 | 2018-08-29T00:47:21.000Z | 2019-05-28T16:52:00.000Z | src/shrpx_log.cc | max-weller/nghttpd-mptcp | 3788e09726c949d8b2d91358b448167d4a5d46d7 | [
"MIT"
] | null | null | null | src/shrpx_log.cc | max-weller/nghttpd-mptcp | 3788e09726c949d8b2d91358b448167d4a5d46d7 | [
"MIT"
] | 1 | 2018-09-21T06:34:05.000Z | 2018-09-21T06:34:05.000Z | /*
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2012 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "shrpx_log.h"
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif // HAVE_SYSLOG_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif // HAVE_UNISTD_H
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif // HAVE_INTTYPES_H
#include <sys/wait.h>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iomanip>
#include "shrpx_config.h"
#include "shrpx_downstream.h"
#include "shrpx_worker.h"
#include "util.h"
#include "template.h"
using namespace nghttp2;
namespace shrpx {
namespace {
const StringRef SEVERITY_STR[] = {
StringRef::from_lit("INFO"), StringRef::from_lit("NOTICE"),
StringRef::from_lit("WARN"), StringRef::from_lit("ERROR"),
StringRef::from_lit("FATAL")};
} // namespace
namespace {
const char *SEVERITY_COLOR[] = {
"\033[1;32m", // INFO
"\033[1;36m", // NOTICE
"\033[1;33m", // WARN
"\033[1;31m", // ERROR
"\033[1;35m", // FATAL
};
} // namespace
int Log::severity_thres_ = NOTICE;
void Log::set_severity_level(int severity) { severity_thres_ = severity; }
int Log::set_severity_level_by_name(const StringRef &name) {
for (size_t i = 0, max = array_size(SEVERITY_STR); i < max; ++i) {
if (name == SEVERITY_STR[i]) {
severity_thres_ = i;
return 0;
}
}
return -1;
}
int severity_to_syslog_level(int severity) {
switch (severity) {
case (INFO):
return LOG_INFO;
case (NOTICE):
return LOG_NOTICE;
case (WARN):
return LOG_WARNING;
case (ERROR):
return LOG_ERR;
case (FATAL):
return LOG_CRIT;
default:
return -1;
}
}
Log::Log(int severity, const char *filename, int linenum)
: filename_(filename), severity_(severity), linenum_(linenum) {}
Log::~Log() {
int rv;
auto config = get_config();
if (!config) {
return;
}
auto lgconf = log_config();
auto &errorconf = config->logging.error;
if (!log_enabled(severity_) ||
(lgconf->errorlog_fd == -1 && !errorconf.syslog)) {
return;
}
if (errorconf.syslog) {
if (severity_ == NOTICE) {
syslog(severity_to_syslog_level(severity_), "[%s] %s",
SEVERITY_STR[severity_].c_str(), stream_.str().c_str());
} else {
syslog(severity_to_syslog_level(severity_), "[%s] %s (%s:%d)",
SEVERITY_STR[severity_].c_str(), stream_.str().c_str(), filename_,
linenum_);
}
return;
}
char buf[4_k];
auto tty = lgconf->errorlog_tty;
lgconf->update_tstamp(std::chrono::system_clock::now());
auto &time_local = lgconf->time_local;
if (severity_ == NOTICE) {
rv =
snprintf(buf, sizeof(buf), "%s PID%d [%s%s%s] %s\n", time_local.c_str(),
config->pid, tty ? SEVERITY_COLOR[severity_] : "",
SEVERITY_STR[severity_].c_str(), tty ? "\033[0m" : "",
stream_.str().c_str());
} else {
rv = snprintf(buf, sizeof(buf), "%s PID%d [%s%s%s] %s%s:%d%s %s\n",
time_local.c_str(), config->pid,
tty ? SEVERITY_COLOR[severity_] : "",
SEVERITY_STR[severity_].c_str(), tty ? "\033[0m" : "",
tty ? "\033[1;30m" : "", filename_, linenum_,
tty ? "\033[0m" : "", stream_.str().c_str());
}
if (rv < 0) {
return;
}
auto nwrite = std::min(static_cast<size_t>(rv), sizeof(buf) - 1);
while (write(lgconf->errorlog_fd, buf, nwrite) == -1 && errno == EINTR)
;
}
namespace {
template <typename OutputIterator>
std::pair<OutputIterator, size_t> copy(const char *src, size_t srclen,
size_t avail, OutputIterator oitr) {
auto nwrite = std::min(srclen, avail);
auto noitr = std::copy_n(src, nwrite, oitr);
return std::make_pair(noitr, avail - nwrite);
}
} // namespace
namespace {
template <typename OutputIterator>
std::pair<OutputIterator, size_t> copy(const char *src, size_t avail,
OutputIterator oitr) {
return copy(src, strlen(src), avail, oitr);
}
} // namespace
namespace {
template <typename OutputIterator>
std::pair<OutputIterator, size_t> copy(const std::string &src, size_t avail,
OutputIterator oitr) {
return copy(src.c_str(), src.size(), avail, oitr);
}
} // namespace
namespace {
template <typename OutputIterator>
std::pair<OutputIterator, size_t> copy(const StringRef &src, size_t avail,
OutputIterator oitr) {
return copy(src.c_str(), src.size(), avail, oitr);
}
} // namespace
namespace {
template <typename OutputIterator>
std::pair<OutputIterator, size_t> copy(const ImmutableString &src, size_t avail,
OutputIterator oitr) {
return copy(src.c_str(), src.size(), avail, oitr);
}
} // namespace
namespace {
template <size_t N, typename OutputIterator>
std::pair<OutputIterator, size_t> copy_l(const char (&src)[N], size_t avail,
OutputIterator oitr) {
return copy(src, N - 1, avail, oitr);
}
} // namespace
namespace {
const char LOWER_XDIGITS[] = "0123456789abcdef";
} // namespace
namespace {
template <typename OutputIterator>
std::pair<OutputIterator, size_t> copy_hex_low(const uint8_t *src,
size_t srclen, size_t avail,
OutputIterator oitr) {
auto nwrite = std::min(srclen * 2, avail) / 2;
for (auto i = 0u; i < nwrite; ++i) {
*oitr++ = LOWER_XDIGITS[src[i] >> 4];
*oitr++ = LOWER_XDIGITS[src[i] & 0xf];
}
return std::make_pair(oitr, avail - nwrite);
}
} // namespace
void upstream_accesslog(const std::vector<LogFragment> &lfv,
const LogSpec &lgsp) {
auto lgconf = log_config();
auto &accessconf = get_config()->logging.access;
if (lgconf->accesslog_fd == -1 && !accessconf.syslog) {
return;
}
char buf[4_k];
auto downstream = lgsp.downstream;
const Request *req = nullptr;
if (downstream) {
req = &downstream->request();
}
auto p = buf;
auto avail = sizeof(buf) - 2;
lgconf->update_tstamp(lgsp.time_now);
auto &time_local = lgconf->time_local;
auto &time_iso8601 = lgconf->time_iso8601;
for (auto &lf : lfv) {
switch (lf.type) {
case SHRPX_LOGF_LITERAL:
std::tie(p, avail) = copy(lf.value, avail, p);
break;
case SHRPX_LOGF_REMOTE_ADDR:
std::tie(p, avail) = copy(lgsp.remote_addr, avail, p);
break;
case SHRPX_LOGF_TIME_LOCAL:
std::tie(p, avail) = copy(time_local, avail, p);
break;
case SHRPX_LOGF_TIME_ISO8601:
std::tie(p, avail) = copy(time_iso8601, avail, p);
break;
case SHRPX_LOGF_REQUEST:
std::tie(p, avail) = copy(lgsp.method, avail, p);
std::tie(p, avail) = copy_l(" ", avail, p);
std::tie(p, avail) = copy(lgsp.path, avail, p);
std::tie(p, avail) = copy_l(" HTTP/", avail, p);
std::tie(p, avail) = copy(util::utos(lgsp.major), avail, p);
if (lgsp.major < 2) {
std::tie(p, avail) = copy_l(".", avail, p);
std::tie(p, avail) = copy(util::utos(lgsp.minor), avail, p);
}
break;
case SHRPX_LOGF_STATUS:
std::tie(p, avail) = copy(util::utos(lgsp.status), avail, p);
break;
case SHRPX_LOGF_BODY_BYTES_SENT:
std::tie(p, avail) = copy(util::utos(lgsp.body_bytes_sent), avail, p);
break;
case SHRPX_LOGF_HTTP:
if (req) {
auto hd = req->fs.header(lf.value);
if (hd) {
std::tie(p, avail) = copy((*hd).value, avail, p);
break;
}
}
std::tie(p, avail) = copy_l("-", avail, p);
break;
case SHRPX_LOGF_AUTHORITY:
if (req) {
if (!req->authority.empty()) {
std::tie(p, avail) = copy(req->authority, avail, p);
break;
}
}
std::tie(p, avail) = copy_l("-", avail, p);
break;
case SHRPX_LOGF_REMOTE_PORT:
std::tie(p, avail) = copy(lgsp.remote_port, avail, p);
break;
case SHRPX_LOGF_SERVER_PORT:
std::tie(p, avail) = copy(util::utos(lgsp.server_port), avail, p);
break;
case SHRPX_LOGF_REQUEST_TIME: {
auto t = std::chrono::duration_cast<std::chrono::milliseconds>(
lgsp.request_end_time - lgsp.request_start_time)
.count();
auto frac = util::utos(t % 1000);
auto sec = util::utos(t / 1000);
if (frac.size() < 3) {
frac = std::string(3 - frac.size(), '0') + frac;
}
sec += '.';
sec += frac;
std::tie(p, avail) = copy(sec, avail, p);
} break;
case SHRPX_LOGF_PID:
std::tie(p, avail) = copy(util::utos(lgsp.pid), avail, p);
break;
case SHRPX_LOGF_ALPN:
std::tie(p, avail) = copy(lgsp.alpn, avail, p);
break;
case SHRPX_LOGF_SSL_CIPHER:
if (!lgsp.tls_info) {
std::tie(p, avail) = copy_l("-", avail, p);
break;
}
std::tie(p, avail) = copy(lgsp.tls_info->cipher, avail, p);
break;
case SHRPX_LOGF_SSL_PROTOCOL:
if (!lgsp.tls_info) {
std::tie(p, avail) = copy_l("-", avail, p);
break;
}
std::tie(p, avail) = copy(lgsp.tls_info->protocol, avail, p);
break;
case SHRPX_LOGF_SSL_SESSION_ID:
if (!lgsp.tls_info || lgsp.tls_info->session_id_length == 0) {
std::tie(p, avail) = copy_l("-", avail, p);
break;
}
std::tie(p, avail) =
copy_hex_low(lgsp.tls_info->session_id,
lgsp.tls_info->session_id_length, avail, p);
break;
case SHRPX_LOGF_SSL_SESSION_REUSED:
if (!lgsp.tls_info) {
std::tie(p, avail) = copy_l("-", avail, p);
break;
}
std::tie(p, avail) =
copy_l(lgsp.tls_info->session_reused ? "r" : ".", avail, p);
break;
case SHRPX_LOGF_BACKEND_HOST:
if (!lgsp.downstream_addr) {
std::tie(p, avail) = copy_l("-", avail, p);
break;
}
std::tie(p, avail) = copy(lgsp.downstream_addr->host, avail, p);
break;
case SHRPX_LOGF_BACKEND_PORT:
if (!lgsp.downstream_addr) {
std::tie(p, avail) = copy_l("-", avail, p);
break;
}
std::tie(p, avail) =
copy(util::utos(lgsp.downstream_addr->port), avail, p);
break;
case SHRPX_LOGF_NONE:
break;
default:
break;
}
}
*p = '\0';
if (accessconf.syslog) {
syslog(LOG_INFO, "%s", buf);
return;
}
*p++ = '\n';
auto nwrite = p - buf;
while (write(lgconf->accesslog_fd, buf, nwrite) == -1 && errno == EINTR)
;
}
int reopen_log_files() {
int res = 0;
int new_accesslog_fd = -1;
int new_errorlog_fd = -1;
auto lgconf = log_config();
auto config = get_config();
auto &accessconf = config->logging.access;
auto &errorconf = config->logging.error;
if (!accessconf.syslog && !accessconf.file.empty()) {
new_accesslog_fd = util::open_log_file(accessconf.file.c_str());
if (new_accesslog_fd == -1) {
LOG(ERROR) << "Failed to open accesslog file " << accessconf.file;
res = -1;
}
}
if (!errorconf.syslog && !errorconf.file.empty()) {
new_errorlog_fd = util::open_log_file(errorconf.file.c_str());
if (new_errorlog_fd == -1) {
if (lgconf->errorlog_fd != -1) {
LOG(ERROR) << "Failed to open errorlog file " << errorconf.file;
} else {
std::cerr << "Failed to open errorlog file " << errorconf.file
<< std::endl;
}
res = -1;
}
}
util::close_log_file(lgconf->accesslog_fd);
util::close_log_file(lgconf->errorlog_fd);
lgconf->accesslog_fd = new_accesslog_fd;
lgconf->errorlog_fd = new_errorlog_fd;
lgconf->errorlog_tty =
(new_errorlog_fd == -1) ? false : isatty(new_errorlog_fd);
return res;
}
void log_chld(pid_t pid, int rstatus, const char *msg) {
std::string signalstr;
if (WIFSIGNALED(rstatus)) {
signalstr += "; signal ";
auto sig = WTERMSIG(rstatus);
auto s = strsignal(sig);
if (s) {
signalstr += s;
signalstr += '(';
} else {
signalstr += "UNKNOWN(";
}
signalstr += util::utos(sig);
signalstr += ')';
}
LOG(NOTICE) << msg << ": [" << pid << "] exited "
<< (WIFEXITED(rstatus) ? "normally" : "abnormally")
<< " with status " << std::hex << rstatus << std::oct
<< "; exit status " << WEXITSTATUS(rstatus)
<< (signalstr.empty() ? "" : signalstr.c_str());
}
void redirect_stderr_to_errorlog() {
auto lgconf = log_config();
auto &errorconf = get_config()->logging.error;
if (errorconf.syslog || lgconf->errorlog_fd == -1) {
return;
}
dup2(lgconf->errorlog_fd, STDERR_FILENO);
}
} // namespace shrpx
| 28.365306 | 80 | 0.598029 | [
"vector"
] |
00fbb876696b2d588ccc68a4ce3eeb96c702bf72 | 13,323 | cc | C++ | 3rdparty/pytorch/caffe2/quantization/server/fully_connected_rowwise_dnnlowp_op.cc | WoodoLee/TorchCraft | 999f68aab9e7d50ed3ae138297226dc95fefc458 | [
"MIT"
] | null | null | null | 3rdparty/pytorch/caffe2/quantization/server/fully_connected_rowwise_dnnlowp_op.cc | WoodoLee/TorchCraft | 999f68aab9e7d50ed3ae138297226dc95fefc458 | [
"MIT"
] | null | null | null | 3rdparty/pytorch/caffe2/quantization/server/fully_connected_rowwise_dnnlowp_op.cc | WoodoLee/TorchCraft | 999f68aab9e7d50ed3ae138297226dc95fefc458 | [
"MIT"
] | null | null | null | #include "fully_connected_rowwise_dnnlowp_op.h"
#include <fbgemm/src/RefImplementations.h>
#include <chrono>
#include "fbgemm_pack_op.h"
namespace caffe2 {
using namespace std;
template <typename T>
FullyConnectedRowWiseDNNLowPOp<T>::FullyConnectedRowWiseDNNLowPOp(
const OperatorDef& operator_def,
Workspace* ws)
: BaseType(operator_def, ws),
axis_(OperatorBase::GetSingleArgument<int32_t>("axis", 1)),
axis_w_(OperatorBase::GetSingleArgument<int32_t>("axis_w", 1)),
b_quantized_(make_shared<vector<int32_t>>()),
column_offsets_(make_shared<vector<int32_t>>()),
is_weight_constant_(
OperatorBase::GetSingleArgument<bool>("constant_weight", true)) {
using namespace dnnlowp;
LOG(INFO) << "Using Rowwise Quantization!";
if (!is_weight_constant_) {
LOG(INFO) << operator_def.output(0) << " is_weight_constant "
<< is_weight_constant_;
LOG(FATAL) << "rowwise quantization doesn't support nonconstant weights";
}
}
template <typename T>
bool FullyConnectedRowWiseDNNLowPOp<T>::RunOnDevice() {
using namespace std;
using namespace dnnlowp;
this->ParseDNNLowPOperatorArguments_();
chrono::time_point<chrono::system_clock> t_very_begin, t_begin, t_end;
if (VLOG_IS_ON(3)) {
t_begin = chrono::system_clock::now();
t_very_begin = t_begin;
}
// Get quantization parameters
if (!GetQuantizationParameters_()) {
return false;
}
if (VLOG_IS_ON(3)) {
t_end = chrono::system_clock::now();
double dt = chrono::duration<double>(t_end - t_begin).count();
VLOG(3) << "@PERF this=" << this << " get_quant_params: " << dt * 1e3
<< " ms";
}
const auto& X = InputTensorCPU_(0);
const auto& W = InputTensorCPU_(1);
auto* Y = OutputTensorCPU_(0);
const auto canonical_axis = X.canonical_axis_index(axis_);
const auto M = X.size_to_dim(canonical_axis);
const auto K = X.size_from_dim(canonical_axis);
const auto canonical_axis_w = W.canonical_axis_index(axis_w_);
const int N = W.size_to_dim(canonical_axis_w);
const auto& b = InputTensorCPU_(2);
Y_shape_cache_ = X.sizes().vec();
Y_shape_cache_.resize(canonical_axis + 1);
Y_shape_cache_[canonical_axis] = N;
Y->Resize(Y_shape_cache_);
Y_int32_.resize(Y->size());
// Quantize X
vector<T> X_temp;
if (VLOG_IS_ON(3)) {
t_begin = chrono::system_clock::now();
}
const T* Xdata = QuantizeInputIfNeeded<T>(this, 0, in_qparams_[0], X_temp);
if (VLOG_IS_ON(3)) {
t_end = chrono::system_clock::now();
double dt = chrono::duration<double>(t_end - t_begin).count();
VLOG(3) << "@PERF this=" << this << " input quantization: " << dt * 1e3
<< " ms";
}
const T_signed* Wdata = W_quantized_.data();
if (VLOG_IS_ON(3)) {
t_begin = chrono::system_clock::now();
}
if (Wq_packed_) {
// fast path using fbgemm
using namespace fbgemm;
int row_offset_size_per_thread = M;
int x_pack_buf_size_per_thread = PackAMatrix<uint8_t>::packedBufferSize();
row_offsets_.resize(row_offset_size_per_thread);
X_pack_buf_.resize(x_pack_buf_size_per_thread);
DoNothing<int32_t, int32_t> doNothingObj{};
memCopy<> memCopyObj(doNothingObj);
PackAMatrix<uint8_t> packA(
matrix_op_t::NoTranspose,
M,
K,
reinterpret_cast<const uint8_t*>(Xdata),
K,
X_pack_buf_.data(),
1); // group
fbgemmPacked(
packA,
*Wq_packed_,
Y_int32_.data(),
Y_int32_.data(),
N,
memCopyObj,
0, // thread_id
1); // num_threads
if (VLOG_IS_ON(3)) {
t_end = chrono::system_clock::now();
double dt = chrono::duration<double>(t_end - t_begin).count();
VLOG(3) << "@PERF this=" << this << " gemm: " << dt * 1e3 << " ms";
t_begin = chrono::system_clock::now();
}
row_offsets_u8acc32_ref(
M, K, K, reinterpret_cast<const uint8_t*>(Xdata), row_offsets_.data());
// Requantization
// TODO: implement row-wise requantization output pipeline
if (dequantize_output_) {
const float* b_data = b.template data<float>();
float* Ydata = OutputTensorCPU_(0)->template mutable_data<float>();
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N; ++j) {
Y_int32_[i * N + j] -=
in_qparams_[0].zero_point * (*column_offsets_)[j] +
rowwise_qparams_[j].zero_point * row_offsets_[i];
Y_int32_[i * N + j] += (*b_quantized_)[j];
Ydata[i * N + j] = Y_int32_[i * N + j] * rowwise_qparams_[j].scale *
in_qparams_[0].scale +
b_data[j];
}
}
} else {
T* Ydata = GetQuantizedOutputData_();
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N; ++j) {
Y_int32_[i * N + j] -=
in_qparams_[0].zero_point * (*column_offsets_)[j] +
rowwise_qparams_[j].zero_point * row_offsets_[i];
Y_int32_[i * N + j] += (*b_quantized_)[j];
Ydata[i * N + j] = Requantize<T>(
Y_int32_[i * N + j], rowwise_requantization_params_[j]);
}
}
}
} else {
// slow path
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N; ++j) {
int32_t sum = 0;
for (int k = 0; k < K; ++k) {
int w = (int)Wdata[j * K + k];
sum += Xdata[i * K + k] * w;
}
Y_int32_[i * N + j] = sum;
} // for each column
} // for each row
if (VLOG_IS_ON(3)) {
t_end = chrono::system_clock::now();
double dt = chrono::duration<double>(t_end - t_begin).count();
VLOG(3) << "@PERF this=" << this << " gemm: " << dt * 1e3 << " ms";
t_begin = chrono::system_clock::now();
}
// Requantization
if (dequantize_output_) {
const float* b_data = b.template data<float>();
float* Ydata = OutputTensorCPU_(0)->template mutable_data<float>();
for (int i = 0; i < M; ++i) {
int32_t row_offset = 0;
for (int k = 0; k < K; ++k) {
row_offset += (int)Xdata[i * K + k];
}
for (int j = 0; j < N; ++j) {
Y_int32_[i * N + j] -=
in_qparams_[0].zero_point * (*column_offsets_)[j] +
rowwise_qparams_[j].zero_point * row_offset;
Ydata[i * N + j] = Y_int32_[i * N + j] * rowwise_qparams_[j].scale *
in_qparams_[0].scale +
b_data[j];
}
}
} else {
T* Ydata = GetQuantizedOutputData_();
for (int i = 0; i < M; ++i) {
int32_t row_offset = 0;
for (int k = 0; k < K; ++k) {
row_offset += (int)Xdata[i * K + k];
}
for (int j = 0; j < N; ++j) {
Y_int32_[i * N + j] -=
in_qparams_[0].zero_point * (*column_offsets_)[j] +
rowwise_qparams_[j].zero_point * row_offset;
Y_int32_[i * N + j] += (*b_quantized_)[j];
Ydata[i * N + j] = fbgemm::Requantize<T>(
Y_int32_[i * N + j], rowwise_requantization_params_[j]);
}
}
}
}
if (!dequantize_output_) {
RunOnDeviceEpilogue_();
} else {
this->MeasureQuantizationError_();
}
if (VLOG_IS_ON(3)) {
t_end = chrono::system_clock::now();
double dt = chrono::duration<double>(t_end - t_begin).count();
VLOG(3) << "@PERF this=" << this
<< " bias-offset-requantization: " << dt * 1e3 << " ms";
t_end = chrono::system_clock::now();
double ops = 2. * M * N * K;
dt = chrono::duration<double>(t_end - t_very_begin).count();
double gops = ops / dt / 1e9;
VLOG(3) << "@PERF this=" << this
<< " output=" << OperatorBase::debug_def().output(0) << " " << M
<< "x" << N << "x" << K << ": " << dt * 1e3 << " ms " << gops
<< " gops";
}
return true;
}
template <typename T>
bool FullyConnectedRowWiseDNNLowPOp<T>::GetQuantizationParameters_() {
using namespace dnnlowp;
in_qparams_[0] = GetInputTensorQuantizationParamsOf(this, 0, qfactory_.get());
const auto& W = InputTensorCPU_(1);
const auto canonical_axis_w = W.canonical_axis_index(axis_w_);
const auto N = W.size_to_dim(canonical_axis_w);
const auto K = W.size_from_dim(canonical_axis_w);
bool fast_path = is_same<T, uint8_t>::value && GetCpuId().avx2();
if (is_weight_constant_) {
if ((fast_path && !Wq_packed_) || (!fast_path && W_quantized_.empty())) {
LOG(INFO) << "Choose rowwise quantization params";
if (rowwise_qparams_.empty()) {
if (this->template InputIsType<Int8FCDNNLowPPackedWeightBlob>(1)) {
const auto& packed_filter =
this->template Input<Int8FCDNNLowPPackedWeightBlob>(1);
CAFFE_ENFORCE_EQ(packed_filter.qparams.size(), N);
// TODO: optimize the overhead of copy
rowwise_qparams_ = packed_filter.qparams;
} else {
// choose rowwise quantization params
if (this->template InputIsType<int8::Int8TensorCPU>(1)) {
static int log_occurences = 0;
if (log_occurences < 32) {
++log_occurences;
LOG(WARNING) << "Cannot do row-wise quantization for "
"pre-quantized weight "
<< this->debug_def().input(1);
}
}
rowwise_qparams_.resize(N);
QuantizeWeight<T>(
InputBlob(1),
K,
N,
rowwise_qparams_,
W_quantized_,
qfactory_.get());
}
}
if (fast_path) {
// fast path using fbgemm
LOG(INFO)
<< "Using fast path with int8 fbgemm and generating Wq_packed_";
if (this->template InputIsType<Int8FCDNNLowPPackedWeightBlob>(1)) {
const auto& packed_filter =
this->template Input<Int8FCDNNLowPPackedWeightBlob>(1);
Wq_packed_ = packed_filter.W;
} else {
Wq_packed_.reset(new fbgemm::PackBMatrix<int8_t>(
fbgemm::matrix_op_t::Transpose,
K,
N,
reinterpret_cast<const int8_t*>(W_quantized_.data()),
K, // ld
nullptr, // pmat
1)); // groups
}
} else {
LOG(WARNING)
<< "Falling back to slow path because fbgemm doesn't support "
"this type or shape";
}
}
} else {
// !is_weigtht_constant
LOG(WARNING) << "Not supporting nonconstant weights";
in_qparams_[1] =
GetInputTensorQuantizationParamsOf(this, 1, qfactory_.get());
fbgemm::Quantize<T_signed>(
W.template data<float>(),
W_quantized_.data(),
W_quantized_.size(),
in_qparams_[1]);
if (rowwise_qparams_.empty()) {
rowwise_qparams_.resize(N);
for (int i = 0; i < N; ++i) {
rowwise_qparams_[i] = in_qparams_[1];
}
}
}
if (!is_weight_constant_ || column_offsets_->empty()) {
if (this->template InputIsType<Int8FCDNNLowPPackedWeightBlob>(1)) {
const auto& packed_filter =
this->template Input<Int8FCDNNLowPPackedWeightBlob>(1);
column_offsets_ = packed_filter.column_offsets;
} else {
ComputeColumnOffsets<T_signed>(
K, N, W_quantized_.data(), rowwise_qparams_, *column_offsets_);
}
}
if (Wq_packed_) {
vector<T_signed>().swap(W_quantized_);
}
if (!is_weight_constant_ || b_quantized_->empty()) {
// Quantize bias
if (this->template InputIsType<Int8FCDNNLowPPackedWeightBlob>(2) &&
this->template Input<Int8FCDNNLowPPackedWeightBlob>(2).bias.get()) {
const auto& packed_filter =
this->template Input<Int8FCDNNLowPPackedWeightBlob>(2);
CAFFE_ENFORCE(!dequantize_output_);
b_quantized_ = packed_filter.bias;
} else {
b_quantized_->resize(N);
const auto& b = InputTensorCPU_(2);
const float* b_data = b.template data<float>();
for (int j = 0; j < N; ++j) {
(*b_quantized_)[j] = fbgemm::Quantize<int32_t>(
b_data[j], 0, in_qparams_[0].scale * rowwise_qparams_[j].scale, 32);
}
}
}
if (!dequantize_output_) {
GetOutputQuantizationParams_();
if (rowwise_requantization_params_.empty()) {
// Choose requantization params
rowwise_requantization_params_.resize(N);
for (int i = 0; i < N; ++i) {
float real_multiplier = in_qparams_[0].scale *
rowwise_qparams_[i].scale / out_qparams_.scale;
rowwise_requantization_params_[i] =
qfactory_->ChooseRequantizationMultiplier(
real_multiplier, out_qparams_);
}
}
} else {
if (measure_quantization_error_) {
// to measure quantization error, run ref impl.
Fp32Op_()->DequantizeInput();
Fp32Op_()->Get()->RunOnDevice();
}
}
return true;
}
REGISTER_CPU_OPERATOR_WITH_ENGINE(
FC,
DNNLOWP_ROWWISE,
FullyConnectedRowWiseDNNLowPOp<uint8_t>);
REGISTER_CPU_OPERATOR_WITH_ENGINE(
FC,
DNNLOWP_ROWWISE_16,
FullyConnectedRowWiseDNNLowPOp<uint16_t>);
REGISTER_CPU_OPERATOR_WITH_ENGINE(
Int8FC,
DNNLOWP_ROWWISE,
FullyConnectedRowWiseDNNLowPOp<uint8_t>);
REGISTER_CPU_OPERATOR_WITH_ENGINE(
Int8FCRowWise,
DNNLOWP,
FullyConnectedRowWiseDNNLowPOp<uint8_t>);
} // namespace caffe2
| 33.059553 | 80 | 0.591158 | [
"shape",
"vector"
] |
00fc566df0ef76ab6293018f4c9f20783ec78ca6 | 7,778 | cc | C++ | device/u2f/u2f_message_unittest.cc | google-ar/chromium | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 777 | 2017-08-29T15:15:32.000Z | 2022-03-21T05:29:41.000Z | device/u2f/u2f_message_unittest.cc | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 66 | 2017-08-30T18:31:18.000Z | 2021-08-02T10:59:35.000Z | device/u2f/u2f_message_unittest.cc | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 123 | 2017-08-30T01:19:34.000Z | 2022-03-17T22:55:31.000Z | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/u2f/u2f_message.h"
#include "net/base/io_buffer.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
class U2fMessageTest : public testing::Test {};
// Packets should be 64 bytes + 1 report ID byte
TEST_F(U2fMessageTest, TestPacketSize) {
uint32_t channel_id = 0x05060708;
std::vector<uint8_t> data;
scoped_refptr<U2fPacket> init_packet(
new U2fInitPacket(channel_id, 0, data, data.size()));
EXPECT_EQ(65, init_packet->GetSerializedBuffer()->size());
scoped_refptr<U2fPacket> continuation_packet(
new U2fContinuationPacket(channel_id, 0, data));
EXPECT_EQ(65, continuation_packet->GetSerializedBuffer()->size());
}
/*
* U2f Init Packets are of the format:
* Byte 0: 0
* Byte 1-4: Channel ID
* Byte 5: Command byte
* Byte 6-7: Big Endian size of data
* Byte 8-n: Data block
*
* Remaining buffer is padded with 0
*/
TEST_F(U2fMessageTest, TestPacketData) {
uint32_t channel_id = 0xF5060708;
std::vector<uint8_t> data{10, 11};
uint8_t cmd = static_cast<uint8_t>(U2fMessage::Type::CMD_WINK);
scoped_refptr<U2fPacket> init_packet(
new U2fInitPacket(channel_id, cmd, data, data.size()));
int index = 0;
EXPECT_EQ(0, init_packet->GetSerializedBuffer()->data()[index++]);
EXPECT_EQ((channel_id >> 24) & 0xff,
static_cast<uint8_t>(
init_packet->GetSerializedBuffer()->data()[index++]));
EXPECT_EQ((channel_id >> 16) & 0xff,
static_cast<uint8_t>(
init_packet->GetSerializedBuffer()->data()[index++]));
EXPECT_EQ((channel_id >> 8) & 0xff,
static_cast<uint8_t>(
init_packet->GetSerializedBuffer()->data()[index++]));
EXPECT_EQ(channel_id & 0xff,
static_cast<uint8_t>(
init_packet->GetSerializedBuffer()->data()[index++]));
EXPECT_EQ(cmd, static_cast<uint8_t>(
init_packet->GetSerializedBuffer()->data()[index++]));
EXPECT_EQ(data.size() >> 8,
static_cast<uint8_t>(
init_packet->GetSerializedBuffer()->data()[index++]));
EXPECT_EQ(data.size() & 0xff,
static_cast<uint8_t>(
init_packet->GetSerializedBuffer()->data()[index++]));
EXPECT_EQ(data.at(0), init_packet->GetSerializedBuffer()->data()[index++]);
EXPECT_EQ(data.at(1), init_packet->GetSerializedBuffer()->data()[index++]);
for (; index < init_packet->GetSerializedBuffer()->size(); index++) {
EXPECT_EQ(0, init_packet->GetSerializedBuffer()->data()[index])
<< "mismatch at index " << index;
}
}
TEST_F(U2fMessageTest, TestPacketConstructors) {
uint32_t channel_id = 0x05060708;
std::vector<uint8_t> data{10, 11};
uint8_t cmd = static_cast<uint8_t>(U2fMessage::Type::CMD_WINK);
scoped_refptr<U2fInitPacket> orig_packet(
new U2fInitPacket(channel_id, cmd, data, data.size()));
size_t payload_length = static_cast<size_t>(orig_packet->payload_length());
scoped_refptr<U2fInitPacket> reconstructed_packet =
U2fInitPacket::CreateFromSerializedData(
orig_packet->GetSerializedBuffer(), &payload_length);
EXPECT_EQ(orig_packet->command(), reconstructed_packet->command());
EXPECT_EQ(orig_packet->payload_length(),
reconstructed_packet->payload_length());
EXPECT_THAT(orig_packet->GetPacketPayload(),
testing::ContainerEq(reconstructed_packet->GetPacketPayload()));
EXPECT_EQ(channel_id, reconstructed_packet->channel_id());
ASSERT_EQ(orig_packet->GetSerializedBuffer()->size(),
reconstructed_packet->GetSerializedBuffer()->size());
for (size_t i = 0;
i < static_cast<size_t>(orig_packet->GetSerializedBuffer()->size());
++i) {
EXPECT_EQ(orig_packet->GetSerializedBuffer()->data()[i],
reconstructed_packet->GetSerializedBuffer()->data()[i]);
}
}
TEST_F(U2fMessageTest, TestMaxLengthPacketConstructors) {
uint32_t channel_id = 0xAAABACAD;
std::vector<uint8_t> data;
for (size_t i = 0; i < U2fMessage::kMaxMessageSize; ++i)
data.push_back(static_cast<uint8_t>(i % 0xff));
U2fMessage::Type cmd = U2fMessage::Type::CMD_MSG;
scoped_refptr<U2fMessage> orig_msg =
U2fMessage::Create(channel_id, cmd, data);
auto it = orig_msg->begin();
scoped_refptr<U2fMessage> new_msg =
U2fMessage::CreateFromSerializedData((*it)->GetSerializedBuffer());
it++;
for (; it != orig_msg->end(); ++it)
new_msg->AddContinuationPacket((*it)->GetSerializedBuffer());
auto orig_it = orig_msg->begin();
auto new_it = new_msg->begin();
for (; orig_it != orig_msg->end() && new_it != new_msg->end();
++orig_it, ++new_it) {
EXPECT_THAT((*orig_it)->GetPacketPayload(),
testing::ContainerEq((*new_it)->GetPacketPayload()));
EXPECT_EQ((*orig_it)->channel_id(), (*new_it)->channel_id());
ASSERT_EQ((*orig_it)->GetSerializedBuffer()->size(),
(*new_it)->GetSerializedBuffer()->size());
for (size_t i = 0;
i < static_cast<size_t>((*new_it)->GetSerializedBuffer()->size());
++i) {
EXPECT_EQ((*orig_it)->GetSerializedBuffer()->data()[i],
(*new_it)->GetSerializedBuffer()->data()[i]);
}
}
}
TEST_F(U2fMessageTest, TestMessagePartitoning) {
uint32_t channel_id = 0x01010203;
std::vector<uint8_t> data(U2fMessage::kInitPacketDataSize + 1);
scoped_refptr<U2fMessage> two_packet_message =
U2fMessage::Create(channel_id, U2fMessage::Type::CMD_PING, data);
EXPECT_EQ(2U, two_packet_message->NumPackets());
data.resize(U2fMessage::kInitPacketDataSize);
scoped_refptr<U2fMessage> one_packet_message =
U2fMessage::Create(channel_id, U2fMessage::Type::CMD_PING, data);
EXPECT_EQ(1U, one_packet_message->NumPackets());
data.resize(U2fMessage::kInitPacketDataSize +
U2fMessage::kContinuationPacketDataSize + 1);
scoped_refptr<U2fMessage> three_packet_message =
U2fMessage::Create(channel_id, U2fMessage::Type::CMD_PING, data);
EXPECT_EQ(3U, three_packet_message->NumPackets());
}
TEST_F(U2fMessageTest, TestMaxSize) {
uint32_t channel_id = 0x00010203;
std::vector<uint8_t> data(U2fMessage::kMaxMessageSize + 1);
scoped_refptr<U2fMessage> oversize_message =
U2fMessage::Create(channel_id, U2fMessage::Type::CMD_PING, data);
EXPECT_EQ(nullptr, oversize_message);
}
TEST_F(U2fMessageTest, TestDeconstruct) {
uint32_t channel_id = 0x0A0B0C0D;
std::vector<uint8_t> data(U2fMessage::kMaxMessageSize, 0x7F);
scoped_refptr<U2fMessage> filled_message =
U2fMessage::Create(channel_id, U2fMessage::Type::CMD_PING, data);
EXPECT_THAT(data, testing::ContainerEq(filled_message->GetMessagePayload()));
}
TEST_F(U2fMessageTest, TestDeserialize) {
uint32_t channel_id = 0x0A0B0C0D;
std::vector<uint8_t> data(U2fMessage::kMaxMessageSize);
scoped_refptr<U2fMessage> orig_message =
U2fMessage::Create(channel_id, U2fMessage::Type::CMD_PING, data);
std::list<scoped_refptr<net::IOBufferWithSize>> orig_list;
scoped_refptr<net::IOBufferWithSize> buf = orig_message->PopNextPacket();
orig_list.push_back(buf);
scoped_refptr<U2fMessage> new_message =
U2fMessage::CreateFromSerializedData(buf);
while (!new_message->MessageComplete()) {
buf = orig_message->PopNextPacket();
orig_list.push_back(buf);
new_message->AddContinuationPacket(buf);
}
while ((buf = new_message->PopNextPacket())) {
ASSERT_EQ(buf->size(), orig_list.front()->size());
EXPECT_EQ(0, memcmp(buf->data(), orig_list.front()->data(), buf->size()));
orig_list.pop_front();
}
}
} // namespace device
| 38.127451 | 79 | 0.694009 | [
"vector"
] |
2e0164d9469faeeee9ba26b85deea9805fa73e5f | 43,266 | cpp | C++ | src/grid/grid.cpp | vanreeslab/murphy | 01c9c56171fcee33cb3c1c93c25617ccf7b8ff83 | [
"BSD-3-Clause"
] | 1 | 2021-12-01T22:12:56.000Z | 2021-12-01T22:12:56.000Z | src/grid/grid.cpp | vanreeslab/murphy | 01c9c56171fcee33cb3c1c93c25617ccf7b8ff83 | [
"BSD-3-Clause"
] | null | null | null | src/grid/grid.cpp | vanreeslab/murphy | 01c9c56171fcee33cb3c1c93c25617ccf7b8ff83 | [
"BSD-3-Clause"
] | null | null | null | #include "grid.hpp"
#include <omp.h>
#include <p8est_extended.h>
#include "partitioner.hpp"
#include "wavelet/interpolating_wavelet.hpp"
using std::list;
using std::string;
/**
* @brief Construct a new Grid which is empty, only the Wavelets have been associated
*
*/
Grid::Grid() : ForestGrid(), prof_(nullptr), ghost_(nullptr), interp_(nullptr){};
/**
* @brief Construct a new Grid as a uniform grid, distributed among the cpus
*
* Initialize the ForestGrid, the Wavelet, the profiler, the ghosts and the grid blocks.
* The grid is defined as a set of l[0]xl[1]xl[2] octrees, each of them refined up to level ilvl.
*
* @param ilvl the starting initialization level
* @param isper defines the periodicity of the dimension (cannot be changed afterwards)
* @param l the aspect ratio of the domain (integers), defining how many trees are used in each direction
* @param comm the MPI communicator used
* @param prof the profiler pointer if any (can be nullptr)
*/
Grid::Grid(const level_t ilvl, const bool isper[3], const lid_t l[3], BlockDataType block_type, MPI_Comm comm, Prof* const prof)
: ForestGrid(ilvl, isper, l, block_type, comm) {
m_begin;
m_assert(IsCompatibleBlockType(M_GRIDBLOCK, block_type), "You can not instantiate a Grid with Blocks which don't have ghosting capabilities");
//-------------------------------------------------------------------------
// profiler
prof_ = prof;
// create a default Wavelet -> default is M_WAVELET_N and M_WAVELET_NT
interp_ = new InterpolatingWavelet();
// create the associated blocks
p8est_iter_volume_t callback_create = get_cback_CreateBlock(block_type);
p8est_iterate(p4est_forest_, nullptr, nullptr, callback_create, nullptr, nullptr, nullptr);
// partition the grid to have compatible grid
Partitioner part = Partitioner(&fields_, this, true);
#ifdef M_MPI_AGGRESSIVE
part.SendRecv(&fields_, M_FORWARD);
#else
part.Start(&fields_, M_FORWARD);
part.End(&fields_, M_FORWARD);
#endif
// setup the ghost stuctures as the mesh will not change anymore
SetupMeshGhost();
//--------------------------------------------------------------------------
const p4est_gloidx_t n_quad_global = p4est_forest_->global_num_quadrants;
const size_t n_tree_global = p4est_forest_->trees->elem_count;
const rank_t comm_size = p4est_forest_->mpisize;
const rank_t nthread = omp_get_max_threads();
m_log("uniform grid created with %ld blocks on %ld trees using %d ranks and %d threads", n_quad_global, n_tree_global, comm_size, nthread);
m_end;
}
/**
* @brief Destroy the Grid, frees all the blocks and the fields contained (if not done)
*
* @warning if we are a copy of another grid, we cannot know which block has been allocated by us,
* so we do not free the blocks!!
*
*/
Grid::~Grid() {
m_begin;
//--------------------------------------------------------------------------
m_profStart(prof_,"grid cleanup");
// destroy the Wavelet and the details they are mine
if (interp_ != nullptr) {
m_verb("dealloc the interp");
delete (interp_);
}
// destroy the ghosts, they are mine as well
DestroyMeshGhost();
// destroy the remaining blocks
if (is_connect_owned_) {
p8est_iter_volume_t callback_destroy = get_cback_DestroyBlock(this->block_type());
p8est_iterate(p4est_forest_, nullptr, nullptr, callback_destroy, nullptr, nullptr, nullptr);
}
m_profStop(prof_,"grid cleanup");
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief update the min and max level taken into account for the next refinement (does not change the current state of the grid to match the new requirements!)
*
* the function fails if the existing levels on the grid do not fit into the new bounds (it avoid blocks blocked at a given level).
*
*/
void Grid::level_limit(const level_t min, const level_t max) {
m_assert(min <= max, "the levels must be %d <= %d", min, max);
m_assert(this->MinLevel() >= min, "trying to impose a min level = %d while blocks exist on a lower one = %d", min, this->MinLevel());
m_assert(this->MaxLevel() <= max, "trying to impose a max level = %d while blocks exist on a higher one = %d", max, this->MaxLevel());
//--------------------------------------------------------------------------
level_limit_min_ = min;
level_limit_max_ = max;
m_verb("limit leves are now %d to %d ", min, max);
//--------------------------------------------------------------------------
};
/**
* @brief setup the Ghost structure when the mesh is not going to change anymore
*
* @warning this function cannot be called on on existing structure
*
*/
void Grid::SetupMeshGhost() {
m_begin;
m_assert(ghost_ == nullptr, "cannot create something that already exists");
//--------------------------------------------------------------------------
// create the forestGrid part
this->SetupP4estMeshAndGhost();
// create the ghosts structure
m_verb("starting the Ghost construction");
ghost_ = new Ghost(this, level_limit_min_, level_limit_max_, interp_, prof_);
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief destroys the Ghost structure of both the ForestGrid and the grid
*
*/
void Grid::DestroyMeshGhost() {
m_begin;
//--------------------------------------------------------------------------
if (ghost_ != nullptr) {
m_verb("dealloc the ghost");
delete ghost_;
ghost_ = nullptr;
}
this->DestroyP4estMeshAndGhost();
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief returns the local memory size (in Byte) of the grid, including every field contained in it
*
* @return size_t
*/
size_t Grid::LocalMemSize() const {
m_begin;
//--------------------------------------------------------------------------
size_t memsize = 0;
memsize += sizeof(fields_);
memsize += sizeof(prof_);
for (const auto fid : fields_) {
memsize += p4est_forest_->local_num_quadrants * (M_N * M_N * M_N) * fid.second->lda() * sizeof(real_t);
}
//--------------------------------------------------------------------------
m_end;
return memsize;
}
/**
* @brief returns the number of local number of degree of freedom for one field containing one dimension
*
* @return size_t
*/
size_t Grid::LocalNumDof() const {
return p4est_forest_->local_num_quadrants * (M_N * M_N * M_N);
}
/**
* @brief returns the number of global number of degree of freedom for one field containing one dimension
*
* @return size_t
*/
size_t Grid::GlobalNumDof() const {
return p4est_forest_->global_num_quadrants * (M_N * M_N * M_N);
}
bool Grid::IsAField(const Field* const field) const {
std::string key = field->name();
return (fields_.find(key) != fields_.end());
}
/**
* @brief register a field in the current grid
*
* It loops on the blocks to allocate the needed memory
*
* @param field
*/
void Grid::AddField(Field* field) {
m_begin;
m_assert(!field->is_expr(), "The field must be stored in memory here");
//--------------------------------------------------------------------------
if (!IsAField(field)) {
// add the field
fields_[field->name()] = field;
// allocate the field on every block
DoOpTree(nullptr, &GridBlock::AddField, this, field);
m_verb("field %s has been added to the grid", field->name().c_str());
} else {
m_verb("field %s is already in the grid", field->name().c_str());
}
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief Store an analytical expression on the field (by copy!)
*
* @param field the pointer of the field associated with the expression
* @param expr the expression ot be set
*/
void Grid::SetExpr(Field* field, const lambda_expr_t expr) {
m_begin;
m_assert(field->is_expr(), "The field must be an expression here");
//--------------------------------------------------------------------------
// the field might be existing but we need to overwrite it (if after adapt)
// add the field
expr_[field->name()] = expr; // copy the expression
fields_[field->name()] = field; // copy the pointer to the field
// allocate the field on every block
DoOpTree(nullptr, &GridBlock::SetExpr, this, field, expr);
m_verb("field %s has been added to the grid", field->name().c_str());
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief unregister a field in the current grid and free the associated memory on each block
*
* @param field
*/
void Grid::DeleteField(const Field* field) {
m_begin;
m_assert(!field->is_expr(), "The field must be stored in memory here");
//--------------------------------------------------------------------------
if (IsAField(field)) {
// remove the field to everyblock
DoOpTree(nullptr, &GridBlock::DeleteField, this, field);
// remove the field
fields_.erase(field->name());
} else {
m_verb("field %s is not in the grid", field->name().c_str());
}
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief reset the fields_ list to the given list of new fields
*
* @warning if mis-used, this function will break the whole run...
*
* @param fields
*/
void Grid::ResetFields(const std::map<string, Field*>* fields) {
m_begin;
//--------------------------------------------------------------------------
// clear the current map
fields_.clear();
// copy the new one
for (auto fid : *fields) {
fields_[fid.first] = fid.second;
// check if we satisfy the requirements on the key
m_assert(fid.first == fid.second->name(), "the key of the map must be the name of the field");
}
//--------------------------------------------------------------------------
m_end;
}
void Grid::GhostPull_SetLength(const Field* field, bidx_t ghost_len[2]) const {
m_begin;
m_assert(!(field == nullptr), "the source field cannot be empty");
m_assert(IsAField(field), "the field does not belong to this grid");
m_assert(ghost_ != nullptr, "The ghost structure is not valid, unable to use it");
//--------------------------------------------------------------------------
const bool ghost_status = field->ghost_status(ghost_len);
m_log("ghost check: field <%s> is %s (requested %d %d, provided %d %d)", field->name().c_str(), ghost_status ? ("OK") : ("to be computed"), ghost_len[0], ghost_len[1], field->get_ghost_len(0), field->get_ghost_len(1));
if (!ghost_status) {
ghost_->SetLength(ghost_len);
}
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief Pull the ghost points (take values from neighbors to fill my ghost points) - start the comm
*
* @param field the considered field
* @param ida the dimension of the field which has to be send
*/
void Grid::GhostPull_Post(const Field* field, const sid_t ida, const bidx_t ghost_len[2]) const {
m_begin;
m_assert(0 <= ida && ida < field->lda(), "the ida is not within the field's limit");
m_assert(!(field == nullptr), "the source field cannot be empty");
m_assert(IsAField(field), "the field does not belong to this grid");
m_assert(ghost_ != nullptr, "The ghost structure is not valid, unable to use it");
//--------------------------------------------------------------------------
if (!field->ghost_status(ghost_len)) {
ghost_->PullGhost_Post(field, ida);
}
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief Pull the ghost points (take values from neighbors to fill my ghost points) - end the comm
*
* @param field the considered field
* @param ida the received dimension
*/
void Grid::GhostPull_Wait(const Field* field, const sid_t ida, const bidx_t ghost_len[2]) const {
m_begin;
m_assert(0 <= ida && ida < field->lda(), "the ida is not within the field's limit");
m_assert(!(field == nullptr), "the source field cannot be empty");
m_assert(IsAField(field), "the field does not belong to this grid");
m_assert(ghost_ != nullptr, "The ghost structure is not valid, unable to use it");
//--------------------------------------------------------------------------
if (!field->ghost_status(ghost_len)) {
ghost_->PullGhost_Wait(field, ida);
}
//--------------------------------------------------------------------------
m_end;
}
void Grid::GhostPull(Field* field, const BlockOperator* op) const {
m_begin;
//--------------------------------------------------------------------------
bidx_t ghost_len[2];
op->GhostLengthNeed(ghost_len);
GhostPull(field, ghost_len);
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief Pull the ghost points (take the values from the neighbors): after this function, the ghost status of the field is set as up-to-date
*
* @param field the field which requires the ghost
*/
void Grid::GhostPull(Field* field, const bidx_t ghost_len_usr[2]) const {
m_begin;
m_assert(!(field == nullptr), "the source field cannot be empty");
m_assert(ghost_ != nullptr, "The ghost structure is not valid, unable to use it");
//--------------------------------------------------------------------------
// get the real ghost length
bidx_t ghost_len[2] = {ghost_len_usr[0], ghost_len_usr[1]};
GhostPull_SetLength(field, ghost_len);
// start the send in the first dimension
m_profStart(prof_, "pull ghost");
for (lda_t ida = 0; ida < field->lda(); ++ida) {
m_verb("ghosting post field <%s> in dir %d", field->name().c_str(), ida);
GhostPull_Post(field, ida, ghost_len);
m_verb("ghosting wait field <%s> in dir %d", field->name().c_str(), ida);
GhostPull_Wait(field, ida, ghost_len);
}
m_profStop(prof_, "pull ghost");
// set that everything is ready for the field
const bidx_t ghost_len_actual[2] = {m_max(ghost_len[0], field->get_ghost_len(0)),
m_max(ghost_len[1], field->get_ghost_len(1))};
field->ghost_len(ghost_len_actual);
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief sets the refinement tolerance for grid adaptation (see @ref Adapt)
*
* the actual coarsening tolerance might not be the given one:
* - if coarsen tol < epsilon machine, we keep epsilon
* - if refine tol / coarsen tol < 2^M_WAVELET_N we keep coarsen = refine tol / (1<<M_WAVELET_N)
*
* @param refine_tol we refine if criterion > refine_tol
* @param coarsen_tol we coarsen if criterion < coarsen_tol
*/
void Grid::SetTol(const real_t refine_tol, const real_t coarsen_tol) {
m_begin;
m_assert(refine_tol > coarsen_tol, "the refinement tolerance must be > the coarsening tolerance");
m_assert(refine_tol > 0.0, "The refinement tolerance = %e must be > 0.0", refine_tol);
m_assert(coarsen_tol >= 0.0, "The coarsening tolerance = %e must be >= 0.0", coarsen_tol);
//--------------------------------------------------------------------------
// if ctol is smaller than epsilon, just remember epsilon
// also, having a coarsening tolerance too close to the refinement one makes no sense.
// so we need to make sure the tolerances are wide enough.
// as detail = C * h^N (N = wavelet N), we must have that refine_tol/coarsen_tol
ctol_ = m_max(m_min(coarsen_tol, refine_tol / (1 << M_WAVELET_N)), std::numeric_limits<real_t>::epsilon());
rtol_ = refine_tol;
m_log("reset the tolerances to rtol = %e and ctol = %e -> ratio = %.0f", rtol_, ctol_, rtol_ / ctol_);
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief Refine the grid if the criterion says so on the field
*
* Interpolate the field (which are not temporary) to match the new mesh structure
*
* @param field the field to use for the criterion computation
*/
void Grid::Refine(Field* field, const SetValue* expr) {
m_begin;
m_assert(IsAField(field), "the field must already exist on the grid!");
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
if (expr == nullptr) {
AdaptMagic(field, nullptr, nullptr, &cback_StatusCheck, nullptr, &cback_UpdateDependency, nullptr);
// AdaptMagic(field, nullptr, &cback_StatusCheck, &cback_StatusCheck, nullptr, &cback_UpdateDependency, nullptr);
} else {
// apply the operator to get the starting value
(*expr)(this, field);
// adapt given the value, have to remove the cast to allow the cas in void* (only possible way, sorry)
void* my_expr = static_cast<void*>(const_cast<SetValue*>(expr));
AdaptMagic(field, nullptr, nullptr, &cback_StatusCheck, static_cast<void*>(field), &cback_ValueFill, my_expr);
// AdaptMagic(field, nullptr, &cback_StatusCheck, &cback_StatusCheck, static_cast<void*>(field), &cback_ValueFill, my_expr);
}
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief Coarsen the grid if the criterion says so on the field
*
* Interpolate the field (which are not temporary) to match the new mesh structure
*
* @param field the field to use for the criterion computation
*/
void Grid::Coarsen(Field* field, const SetValue* expr) {
m_begin;
m_assert(IsAField(field), "the field must already exist on the grid!");
//--------------------------------------------------------------------------
if (expr == nullptr) {
AdaptMagic(field, nullptr, &cback_StatusCheck, nullptr, nullptr, &cback_UpdateDependency, nullptr);
// AdaptMagic(field, nullptr, &cback_StatusCheck, &cback_StatusCheck, nullptr, &cback_UpdateDependency, nullptr);
} else {
// apply the operator to get the starting value
(*expr)(this, field);
// adapt given the value, have to remove the cast to allow the cas in void* (only possible way, sorry)
void* my_expr = static_cast<void*>(const_cast<SetValue*>(expr));
AdaptMagic(field, nullptr, &cback_StatusCheck, nullptr, static_cast<void*>(field), &cback_ValueFill, my_expr);
// AdaptMagic(field, nullptr, &cback_StatusCheck, &cback_StatusCheck, static_cast<void*>(field), &cback_ValueFill, my_expr);
}
//--------------------------------------------------------------------------
m_end;
}
/**a
* @brief Adapt the grid using a given field for the details.
*
* The (optional) anaylical expression is used before the adaptation and then is used everytime a new block is created.
* Other fields than field might be garbage
*
* Notes:
* - The adaptation can be recursive
* - if the ghost provided by the SetValue are not sufficient, the ghosts will be recomputed
*
* @param field the field to adapt
* @param expr the analytical expression to use as a SetValue object, might be null
*/
void Grid::Adapt(Field* field, const SetValue* expr) {
m_begin;
m_assert(IsAField(field), "the field must already exist on the grid!");
//--------------------------------------------------------------------------
if (expr == nullptr) {
AdaptMagic(field, nullptr, &cback_StatusCheck, &cback_StatusCheck, nullptr, &cback_UpdateDependency, nullptr);
} else {
// apply the operator to get the starting value
(*expr)(this, field);
// adapt given the value, have to remove the cast to allow the cas in void* (only possible way, sorry)
void* my_expr = static_cast<void*>(const_cast<SetValue*>(expr));
AdaptMagic(field, nullptr, &cback_StatusCheck, &cback_StatusCheck, static_cast<void*>(field), &cback_ValueFill, my_expr);
}
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief adapt = (refine or coarsen) each block recursivelly to reach the criterion imposed in the patch list.
*
* @warning no interpolation will be performed, i.e. every existing field will be reset to 0 during its execution
*
* A block is refined/coarsened if one part of it belongs to the patch. Simply touching the patch does not count as belonging (i.e.
* the comparison is done using strict operators `<` and `>` ), see @ref cback_Patch().
*
* @param patches the list of patch to match
*/
void Grid::Adapt(list<Patch>* patches) {
m_begin;
//--------------------------------------------------------------------------
if (patches->empty()) {
return;
}
AdaptMagic(nullptr, patches, &cback_StatusCheck, &cback_StatusCheck, nullptr, &cback_UpdateDependency, nullptr);
//--------------------------------------------------------------------------
m_end;
}
/**
* @brief Adapt the grid, this function performs the actual adaptation for all the others
*
* @warning This function is a "do all the magic function" and therefore should be changed carefully.
*
* @param field_detail if not empty, the field used to computer the details on the blocks
* @param patches if not empty, a list of patches to dictate the grid layout
* @param coarsen_cback p4est callback function for deciding on coarsening
* @param refine_cback p4est callback function for deciding on refinement
* @param coarseref_cback_ptr pointer to data used in these refine/coarsen p4est callback functions
* @param interpolate_fct p4est callback function for interpolation: do the actual refinement/coarsening
* @param interpolate_ptr pointer to data used in the interpolate callback function
* @param max_detail stores the value of the max_detail per dimension of the field, if not nullptr
*/
void Grid::AdaptMagic(/* criterion */ Field* field_detail, list<Patch>* patches,
/* p4est coarsen/refine */ cback_coarsen_citerion_t coarsen_cback, cback_refine_criterion_t refine_cback, void* coarseref_cback_ptr,
/* p4est interpolate */ cback_interpolate_t interpolate_fct, void* interpolate_ptr) {
m_begin;
m_assert(interpolate_fct != nullptr, "the interpolation function cannot be a nullptr");
m_assert(cback_criterion_ptr_ == nullptr, "the pointer `cback_criterion_ptr` must be nullptr");
m_assert(cback_interpolate_ptr_ == nullptr, "the pointer `cback_interpolate_ptr` must be nullptr");
m_assert(p4est_forest_->user_pointer == nullptr, "we must reset the user_pointer to nullptr");
m_assert((field_detail == nullptr) || (patches == nullptr), "you cannot give both a field for detail computation and a patch list");
//--------------------------------------------------------------------------
m_profStart(prof_, "adaptation");
//..........................................................................
string msg = "grid";
if (coarsen_cback != nullptr && refine_cback != nullptr) {
msg += " adaptation";
} else if (coarsen_cback != nullptr) {
msg += " coarsening";
} else if (refine_cback != nullptr) {
msg += " refinement";
}
msg += " started... (recursive = %d, ";
if (!(field_detail == nullptr)) {
msg += "using details";
}
if (!(patches == nullptr)) {
msg += "using patches";
}
msg += ") -> %d fields";
m_log(msg.c_str(), recursive_adapt(), fields_.size());
//..........................................................................
// store the ptrs and the grid
cback_criterion_ptr_ = coarseref_cback_ptr;
cback_interpolate_ptr_ = interpolate_ptr;
p4est_forest_->user_pointer = reinterpret_cast<void*>(this);
// reset the status of everyblock to a neutral one
m_profStart(prof_, "reset");
DoOpMesh(nullptr, &GridBlock::StatusReset, this);
m_profStop(prof_, "reset");
//..........................................................................
// coarsening, need to have the 8 children on the same rank
iter_t iteration = 0;
iblock_t global_n_quad_to_adapt = 0;
do {
m_log("----> adaptation iteration %d", iteration);
m_log_level_plus;
//......................................................................
// cleanup the status
DoOpMesh(nullptr, &GridBlock::StatusCleanup, this);
#ifndef NDEBUG
{
const level_t min_level = this->MinLevel();
const level_t max_level = this->MaxLevel();
m_log("--> iteration on a grid with %ld blocks on %ld trees using %d ranks and %d threads (level from %d to %d)", p4est_forest_->global_num_quadrants, p4est_forest_->trees->elem_count, p4est_forest_->mpisize, omp_get_max_threads(), min_level, max_level);
}
#endif
//......................................................................
// get the desired status
if (!(field_detail == nullptr)) {
m_assert(!field_detail->is_temp(), "The criterion field cannot be temporary");
// ghost the dimension 0
m_profStart(prof_, "ghost for criterion");
// get the length
bidx_t ghost_len[2] = {interp_->nghost_front(), interp_->nghost_back()};
GhostPull_SetLength(field_detail, ghost_len);
// start the ghosting in the first dimension only
GhostPull_Post(field_detail, 0, ghost_len);
GhostPull_Wait(field_detail, 0, ghost_len);
m_profStop(prof_, "ghost for criterion");
// now we can start the next dimensions
for (lda_t ida = 1; ida < field_detail->lda(); ++ida) {
// start the ghosts for the next dimension
m_profStart(prof_, "ghost for criterion");
GhostPull_Post(field_detail, ida, ghost_len);
m_profStop(prof_, "ghost for criterion");
// compute the criterion on the previous dimension
m_profStart(prof_, "criterion");
DoOpMesh(nullptr, &GridBlock::UpdateStatusFromCriterion, this, interp_, rtol_, ctol_, field_detail, ida - 1);
m_profStop(prof_, "criterion");
// finish the ghost for the current dimension
m_profStart(prof_, "ghost for criterion");
GhostPull_Wait(field_detail, ida, ghost_len);
m_profStop(prof_, "ghost for criterion");
}
// finally, compute on the last dimension of the field
m_profStart(prof_, "criterion");
const lda_t criterion_dim = field_detail->lda() - 1;
DoOpMesh(nullptr, &GridBlock::UpdateStatusFromCriterion, this, interp_, rtol_, ctol_, field_detail, criterion_dim);
m_profStop(prof_, "criterion");
// register the computed ghosts
field_detail->ghost_len(ghost_len);
}
// if needed, compute some patches
if (!(patches == nullptr)) {
// get the patches processed
m_profStart(prof_, "patch");
DoOpMesh(nullptr, &GridBlock::UpdateStatusFromPatches, this, interp_, patches);
m_profStop(prof_, "patch");
}
//......................................................................
#ifndef NDEBUG
m_profStart(prof_, "assert rtol");
if (field_detail != nullptr) {
// check/get the max detail on the current grid
real_t det_maxmin[2];
this->MaxMinDetails(field_detail, det_maxmin);
m_log("--> before adaptation: tols = {%e , %e}, max detail = %e", this->rtol(), this->ctol(), det_maxmin[0]);
}
m_profStop(prof_, "assert rtol");
#endif
//......................................................................
// every block has its own desired status by now: finer, coarser or same
// we need to apply a few policies to make sure that
// (1) two neighboring blocks don't do the opposite operation (coarsen and refine)
// (2)
{
m_profStart(prof_, "update status");
// first apply the local policies (max/min levels)
DoOpMesh(nullptr, &GridBlock::UpdateStatusFromLevel, this, level_limit_min_, level_limit_max_);
// allocate the neighbor status vectors on everyblock
ghost_->SyncStatusInit();
// I need to make sure that the if one block needs to refine, all the coarser neighbors get that signal
// first step is to put refine to everybody
const level_t max_level = MaxLevel();
const level_t min_level = MinLevel();
for (level_t il = (max_level - 1); il >= min_level; --il) {
// the finer level fills the status
ghost_->SyncStatusFill(il + 1, il + 1);
// get the update in the current level
ghost_->SyncStatusUpdate(il, il);
// forward the refinement criterion: if my finer neighbor has to refine, I refine as well
DoOpMeshLevel(nullptr, &GridBlock::UpdateStatusForwardRefinement, this, il);
}
// now adapt my status based on the status of my neighbors
ghost_->SyncStatusFill();
ghost_->SyncStatusUpdate();
DoOpMesh(nullptr, &GridBlock::UpdateStatusFromGlobalPolicy, this);
ghost_->SyncStatusFinalize();
m_profStop(prof_, "update status");
}
//......................................................................
// after this point, we cannot access the old blocks anymore, p4est will destroy the access.
// we still save them as dependencies but all the rest is gone.
m_profStart(prof_, "destroy mesh and ghost");
DestroyMeshGhost();
m_profStop(prof_, "destroy mesh and ghost");
//......................................................................
// reset the adapt counter, it will be updated in the interpolate fct
n_quad_to_refine_ = 0;
n_quad_to_coarsen_ = 0;
// WARNING: always try to COARSEN first (no idea why but the other way around doesn't work!)
// coarsening for p4est-> only one level
// The limit in levels are handled directly on the block, not in p4est
if (coarsen_cback != nullptr) {
m_profStart(prof_, "p4est coarsen");
p8est_coarsen_ext(p4est_forest_, 0, 0, coarsen_cback, nullptr, interpolate_fct);
m_profStop(prof_, "p4est coarsen");
}
// refinement -> only one level
// The limit in levels are handled directly on the block, not in p4est
if (refine_cback != nullptr) {
m_profStart(prof_, "p4est refine");
p8est_refine_ext(p4est_forest_, 0, P8EST_QMAXLEVEL, refine_cback, nullptr, interpolate_fct);
m_profStop(prof_, "p4est refine");
}
// get the 2:1 constrain on the grid, should be guaranteed by the criterion, but just in case
// m_profStart(prof_, "p4est balance");
// p8est_balance_ext(p4est_forest_, P8EST_CONNECT_FULL, nullptr, interpolate_fct);
// m_profStop(prof_, "p4est balance");
#ifdef M_MPI_AGGRESSIVE
// the number of adapted block has been fixed, I can now reduce them and get the result later
m_profStart(prof_, "compute nblocks");
m_assert(n_quad_to_coarsen_ < std::numeric_limits<int>::max(), "we must be smaller than the integer limit");
m_assert(n_quad_to_refine_ < std::numeric_limits<int>::max(), "we must be smaller than the integer limit");
m_assert((n_quad_to_coarsen_ % 8) == 0, "the number of quad to coarsen must be a multiple of 8 isntead of %d", n_quad_to_coarsen_);
MPI_Request n_adapt_request;
int global_n_adapt[2];
int n_adapt[2] = {n_quad_to_coarsen_, n_quad_to_refine_};
MPI_Iallreduce(n_adapt, global_n_adapt, 2, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &n_adapt_request);
m_profStop(prof_, "compute nblocks");
#endif
//......................................................................
// solve the dependencies on the grid
// warn the user that we do not interpolate a temporary field
// for (auto fid = FieldBegin(); fid != FieldEnd(); ++fid) {
// m_log("field <%s> %s", fid->second->name().c_str(), fid->second->is_temp() ? "is discarded" : "will be interpolated");
// }
m_profStart(prof_, "solve dependency");
DoOpTree(nullptr, &GridBlock::SolveDependency, this, interp_, FieldBegin(), FieldEnd());
m_profStop(prof_, "solve dependency");
//......................................................................
// update the partitioning and check for new block to change
m_profStart(prof_, "partition init");
Partitioner* partition= new Partitioner(&fields_, this, true);
m_profStop(prof_, "partition init");
m_profStart(prof_, "partition comm");
#ifdef M_MPI_AGGRESSIVE
partition->SendRecv(&fields_, M_FORWARD);
#else
partition->Start(&fields_, M_FORWARD);
partition->End(&fields_, M_FORWARD);
#endif
delete(partition);
m_profStop(prof_, "partition comm");
// m_log("partitioning is over");
//......................................................................
// create a new ghost and mesh as the partioning is done
m_profStart(prof_, "setup mesh and ghost");
SetupMeshGhost();
m_profStop(prof_, "setup mesh and ghost");
//......................................................................
// solve the jump in resolution: we need to smooth now
// it cannot be done earlier because we need the new ghost structure
// which comes after the partitioning -> partitioning must send the GP
m_profStart(prof_, "update status");
// get to know the status of my neighbors
ghost_->SyncStatusInit();
ghost_->SyncStatusFill();
ghost_->SyncStatusUpdate();
m_profStop(prof_, "update status");
// solve resolution jump if needed
m_verb("solve jump resolution");
m_profStart(prof_, "smooth jump");
DoOpTree(nullptr, &GridBlock::SmoothResolutionJump, this, interp_, FieldBegin(), FieldEnd());
m_profStop(prof_, "smooth jump");
m_profStart(prof_, "finalize status");
ghost_->SyncStatusFinalize();
m_profStop(prof_, "finalize status");
//......................................................................
// sum over the ranks and see if we keep going
m_profStart(prof_, "compute nblocks");
#ifdef M_MPI_AGGRESSIVE
MPI_Wait(&n_adapt_request, MPI_STATUS_IGNORE);
#else
m_assert(n_quad_to_coarsen_ < std::numeric_limits<int>::max(), "we must be smaller than the integer limit");
m_assert(n_quad_to_refine_ < std::numeric_limits<int>::max(), "we must be smaller than the integer limit");
m_assert((n_quad_to_coarsen_ % 8) == 0, "the number of quad to coarsen must be a multiple of 8 isntead of %d", n_quad_to_coarsen_);
int global_n_adapt[2];
int n_adapt[2] = {n_quad_to_coarsen_, n_quad_to_refine_};
MPI_Allreduce(n_adapt, global_n_adapt, 2, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
#endif
global_n_quad_to_adapt = global_n_adapt[0] + global_n_adapt[1];
m_log("we have coarsened %d blocks and refined %d blocks -> %d new blocks", global_n_adapt[0], global_n_adapt[1], global_n_adapt[0] / 8 + 8 * global_n_adapt[1]);
m_profStop(prof_, "compute nblocks");
//......................................................................
// if we adapted some blocks, then the ghosting is not valid
if (global_n_quad_to_adapt > 0) {
for (auto fid : fields_) {
// m_log("changing ghost status of <%s>", fid.second->name().c_str());
const bidx_t ghost_len[2] = {0, 0};
if (!fid.second->is_expr()) {
fid.second->ghost_len(ghost_len);
}
}
}
#ifndef NDEBUG
m_profStart(prof_, "assert rtol");
if (field_detail != nullptr) {
// check/get the max detail on the current grid
real_t det_maxmin[2];
this->MaxMinDetails(field_detail, det_maxmin);
m_log("--> after adaptation: tol = {%e , %e}, max detail = %e", this->rtol(), this->ctol(), det_maxmin[0]);
}
m_profStop(prof_, "assert rtol");
#endif
m_log_level_minus;
// increment the counter
++iteration;
} while (global_n_quad_to_adapt > 0 && recursive_adapt() && iteration < P8EST_QMAXLEVEL);
//..........................................................................
// reset the analytical expression
m_verb("resetting the analytical expression");
for (auto expr_it : expr_) {
string field_name = expr_it.first;
DoOpTree(nullptr, &GridBlock::SetExpr, this, fields_[field_name], expr_it.second);
}
//..........................................................................
// reset the forest pointer
cback_criterion_ptr_ = nullptr;
cback_interpolate_ptr_ = nullptr;
p4est_forest_->user_pointer = nullptr;
// reset the recursive to false
SetRecursiveAdapt(false);
// and finally end that stuff
m_profStop(prof_, "adaptation");
//--------------------------------------------------------------------------
m_assert(cback_criterion_ptr_ == nullptr, "the pointer `cback_criterion_ptr` must be nullptr");
m_assert(cback_interpolate_ptr_ == nullptr, "the pointer `cback_interpolate_ptr` must be nullptr");
m_assert(p4est_forest_->user_pointer == nullptr, "we must reset the user_pointer to nullptr");
const level_t min_level = this->MinLevel();
const level_t max_level = this->MaxLevel();
const MemLayout block_layout(M_LAYOUT_BLOCK, M_GS, M_N);
const real_t mem_per_dim = p4est_forest_->global_num_quadrants * block_layout.n_elem * sizeof(real_t) / 1.0e+9;
// m_log_level_minus;
m_log("--> grid adaptation done: now %ld blocks (%.2e Gb/dim) on %ld trees using %d ranks and %d threads (level from %d to %d)", p4est_forest_->global_num_quadrants, mem_per_dim, p4est_forest_->trees->elem_count, p4est_forest_->mpisize, omp_get_max_threads(), min_level, max_level);
#ifndef NDEBUG
if (field_detail != nullptr) {
// check/get the max detail on the current grid
real_t det_maxmin[2];
this->MaxMinDetails(field_detail, det_maxmin);
m_log("rtol = %e, max detail = %e", this->rtol(), det_maxmin[0]);
m_assert(this->rtol() >= det_maxmin[0], "the max detail cannot be > than the tol: %e vs %e", det_maxmin[0], this->rtol());
}
#endif
m_end;
}
/**
* @brief Compute and store the details from the criterion field
*
* @param criterion the field on which we compute details
* @param details the field containing the details
*/
void Grid::StoreDetails(Field* criterion, Field* details) {
m_begin;
m_assert(criterion->lda() == details->lda(), "field <%s> and <%s> must have the same size", criterion->name().c_str(), details->name().c_str());
//--------------------------------------------------------------------------
{
const bidx_t ghost_len[2] = {interp_->nghost_front(), interp_->nghost_back()};
this->GhostPull(criterion, ghost_len);
}
DoOpMesh(nullptr, &GridBlock::StoreDetails, this, interp(), criterion, details);
{
const bidx_t ghost_len[2] = {0, 0};
details->ghost_len(ghost_len);
}
//--------------------------------------------------------------------------
m_end;
}
void Grid::MaxMinDetails(Field* criterion, real_t maxmin[2]) {
//---------------------------------------------------------------------------
// get the ghosts values
const bidx_t ghost_len[2] = {interp_->nghost_front(), interp_->nghost_back()};
this->GhostPull(criterion, ghost_len);
// get the minmax
real_t local_maxmin[2];
local_maxmin[0] = 0.0;
local_maxmin[1] = std::numeric_limits<real_t>::max();
DoOpMesh(nullptr, &GridBlock::MaxMinDetails, this, interp(), criterion, local_maxmin, nullptr, 0.0, 0.0, 0);
// reduce is on the whole mesh
maxmin[0] = 0.0;
maxmin[1] = 0.0;
MPI_Allreduce(local_maxmin, maxmin, 1, M_MPI_REAL, MPI_MAX, MPI_COMM_WORLD);
MPI_Allreduce(local_maxmin + 1, maxmin + 1, 1, M_MPI_REAL, MPI_MIN, MPI_COMM_WORLD);
//---------------------------------------------------------------------------
}
// // must be moved ot a diagnostics
// void Grid::DistributionDetails(const iter_t id, const std::string folder, const std::string suffix, Field* criterion,
// const short_t n_cat, const real_t max_value_cat) {
// //---------------------------------------------------------------------------
// // get the ghosts values
// const bidx_t ghost_len[2] = {interp_->nghost_front(), interp_->nghost_back()};
// this->GhostPull(criterion, ghost_len);
// bidx_t* n_block_local = reinterpret_cast<bidx_t*>(m_calloc(n_cat * sizeof(bidx_t)));
// bidx_t* n_block_global = reinterpret_cast<bidx_t*>(m_calloc(n_cat * sizeof(bidx_t)));
// // get the minmax for the whole grid + for each block
// real_t to_trash[2];
// to_trash[0] = 0.0;
// to_trash[1] = std::numeric_limits<real_t>::max();
// DoOpMesh(nullptr, &GridBlock::MaxMinDetails, this, interp(), criterion, to_trash, n_block_local, max_value_cat, 1e-16, n_cat);
// // sum everything on rank 0 to dump
// const rank_t root = 0;
// m_assert(sizeof(bidx_t) == sizeof(int), "the two sizes must match");
// MPI_Reduce(n_block_local, n_block_global, n_cat, MPI_INT, MPI_SUM, root, MPI_COMM_WORLD);
// // dump
// rank_t rank;
// MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// long nblock = this->global_num_quadrants();
// FILE* file_diag;
// if (rank == root) {
// file_diag = fopen(std::string(folder + "/detail_histogram" + suffix + ".data").c_str(), "a+");
// fprintf(file_diag, "%d;%ld", id, nblock);
// long block_count = 0;
// for (level_t il = 0; il < n_cat; ++il) {
// fprintf(file_diag, ";%d", n_block_global[il]);
// block_count += n_block_global[il];
// }
// fprintf(file_diag, "\n");
// fclose(file_diag);
// m_assert(block_count == nblock, "the two counts must match: %ld %ld", block_count, nblock);
// }
// m_free(n_block_local);
// m_free(n_block_global);
// //---------------------------------------------------------------------------
// } | 45.447479 | 286 | 0.577151 | [
"mesh",
"object"
] |
2e03fca985592c746630c84b55d0e23f28a45def | 581 | cpp | C++ | Todolister/ArgTranslator.cpp | vabalcar/Todolister | 7b9c06956239a7f06b0fdba478773894aa250cff | [
"MIT"
] | null | null | null | Todolister/ArgTranslator.cpp | vabalcar/Todolister | 7b9c06956239a7f06b0fdba478773894aa250cff | [
"MIT"
] | null | null | null | Todolister/ArgTranslator.cpp | vabalcar/Todolister | 7b9c06956239a7f06b0fdba478773894aa250cff | [
"MIT"
] | null | null | null | #include "ArgTranslator.h"
void ArgTranslator::translate(vector<string>& args) const {
for (size_t i = 0; i < args.size(); i++) {
translate(args[i]);
if (followedByArg_.count(args[i]) != 0) ++i;
}
}
void ArgTranslator::translate(string& arg) const {
toLower(arg);
if (dictionary_.count(arg) == 1) {
arg = dictionary_.at(arg);
}
}
string ArgTranslator::inverseTranslate(const string& arg) const {
string result = arg;
toLower(result);
for (auto it = dictionary_.begin(); it != dictionary_.end(); ++it) {
if (it->second == result) return it->first;
}
return "";
} | 26.409091 | 69 | 0.657487 | [
"vector"
] |
2e0d9202f0176544ecd3d2f88195f97913288dcf | 943 | cpp | C++ | src/0892.cpp | killf/leetcode_cpp | d1f308a9c3da55ae5416ea28ec2e7a3146533ae9 | [
"MIT"
] | null | null | null | src/0892.cpp | killf/leetcode_cpp | d1f308a9c3da55ae5416ea28ec2e7a3146533ae9 | [
"MIT"
] | null | null | null | src/0892.cpp | killf/leetcode_cpp | d1f308a9c3da55ae5416ea28ec2e7a3146533ae9 | [
"MIT"
] | null | null | null | #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <hash_map>
#include <map>
#include <sstream>
#include <type_traits>
#include <algorithm>
#include <stack>
#include <queue>
#include <bitset>
#include <set>
using namespace std;
class Solution {
public:
int surfaceArea(vector<vector<int>> &grid) {
int row = grid.size(), col = grid.size(), sum = 0;
for (int r = 0; r < row; r++) {
sum += grid[r][0] + grid[r][col - 1];
for (int c = 0; c < col - 1; c++) {
sum += abs(grid[r][c] - grid[r][c + 1]);
if (grid[r][c] > 0) sum += 1;
}
if (grid[r][col - 1] > 0) sum += 1;
}
for (int c = 0; c < col; c++) {
sum += grid[0][c] + grid[row - 1][c];
for (int r = 0; r < row - 1; r++) {
sum += abs(grid[r][c] - grid[r + 1][c]);
if (grid[r][c] > 0) sum += 1;
}
if (grid[row - 1][c] > 0) sum += 1;
}
return sum;
}
}; | 22.452381 | 54 | 0.494168 | [
"vector"
] |
2e0dc026db19ab437f275bd9e3696c86f70f5307 | 5,063 | cc | C++ | dsp_util_test.cc | Siddhant-K-code/lyra | 9721651ababfc95e7ebd4547a5cc30460d56d491 | [
"Apache-2.0"
] | 1 | 2021-04-26T01:05:53.000Z | 2021-04-26T01:05:53.000Z | dsp_util_test.cc | Siddhant-K-code/lyra | 9721651ababfc95e7ebd4547a5cc30460d56d491 | [
"Apache-2.0"
] | null | null | null | dsp_util_test.cc | Siddhant-K-code/lyra | 9721651ababfc95e7ebd4547a5cc30460d56d491 | [
"Apache-2.0"
] | 2 | 2021-04-13T08:24:11.000Z | 2022-02-08T08:36:52.000Z | // Copyright 2021 Google LLC
//
// 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.
#include "dsp_util.h"
#include <cstdint>
#include <limits>
#include <numeric>
#include <optional>
#include <vector>
#include "absl/types/span.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace chromemedia {
namespace codec {
namespace {
TEST(DspUtilTest, LogSpectralDistanceTest) {
std::vector<float> first_log_spectrum(10);
std::iota(first_log_spectrum.begin(), first_log_spectrum.end(), 0);
std::vector<float> second_log_spectrum(10);
std::iota(second_log_spectrum.begin(), second_log_spectrum.end(), 1);
const auto log_spectral_distance_or =
LogSpectralDistance(absl::MakeConstSpan(first_log_spectrum),
absl::MakeConstSpan(second_log_spectrum));
ASSERT_TRUE(log_spectral_distance_or.has_value());
EXPECT_NEAR(log_spectral_distance_or.value(), 10.0f, 0.0001);
}
TEST(DspUtilTest, ClipTest) {
const float kMax = ClipToInt16(10000000);
EXPECT_EQ(kMax, std::numeric_limits<int16_t>::max());
const float kZero = ClipToInt16(0);
EXPECT_EQ(kZero, 0);
const float kMin = ClipToInt16(-10000000);
EXPECT_EQ(kMin, std::numeric_limits<int16_t>::min());
}
// Pair of input and output types to be tested for casting and their
// relevant data.
template <typename I, typename O>
struct InputOutputTypes {
using InputType = I;
using OutputType = O;
// The range of values that are safe to put in the input vector vector
// without clipping.
static float InputAbsMax() {
if constexpr (csrblocksparse::IsFixedType<InputType>::value) {
return (1 << InputType::kExponentBits) - 0.5;
} else {
return 10.0f;
}
}
// For fixed point types, set the tolerance to be the resolution. For floats,
// use a constant 1e-7f.
static float Tolerance() {
if constexpr (csrblocksparse::IsFixedType<InputType>::value) {
return 1.0f / (1 << OutputType::kMantissaBits);
} else {
return 1e-7f;
}
}
};
template <typename InputOutputTypes>
class CastVectorTest : public ::testing::Test {
public:
CastVectorTest()
: input_(kNumElements),
output_(kNumElements),
expected_output_(kNumElements),
tolerance_(InputOutputTypes::Tolerance()) {
input_.FillRandom(-InputOutputTypes::InputAbsMax(),
InputOutputTypes::InputAbsMax());
for (int i = 0; i < kNumElements; ++i) {
expected_output_[i] =
static_cast<float>(static_cast<typename InputOutputTypes::OutputType>(
static_cast<float>(input_[i])));
}
}
protected:
static constexpr int kNumElements = 11;
csrblocksparse::CacheAlignedVector<typename InputOutputTypes::InputType>
input_;
csrblocksparse::CacheAlignedVector<typename InputOutputTypes::OutputType>
output_;
std::vector<float> expected_output_;
const float tolerance_;
};
using CastVectorTypes = ::testing::Types<
// fixed16 --> fixed16: casting to equal, more, and fewer exponent bits.
InputOutputTypes<csrblocksparse::fixed16<4>, csrblocksparse::fixed16<4>>,
InputOutputTypes<csrblocksparse::fixed16<5>, csrblocksparse::fixed16<4>>,
InputOutputTypes<csrblocksparse::fixed16<3>, csrblocksparse::fixed16<4>>,
// fixed32 --> fixed32: casting to equal, more, and fewer exponent bits.
InputOutputTypes<csrblocksparse::fixed32<8>, csrblocksparse::fixed32<8>>,
InputOutputTypes<csrblocksparse::fixed32<11>, csrblocksparse::fixed32<8>>,
InputOutputTypes<csrblocksparse::fixed32<5>, csrblocksparse::fixed32<8>>,
// fixed32 --> fixed16: {s < 0, s == 0, 0 < s <=16, s > 16}, where |s| is
// the shift amount: 16 + |output exponent bits| - |input exponent bits|.
InputOutputTypes<csrblocksparse::fixed32<22>, csrblocksparse::fixed16<4>>,
InputOutputTypes<csrblocksparse::fixed32<20>, csrblocksparse::fixed16<4>>,
InputOutputTypes<csrblocksparse::fixed32<5>, csrblocksparse::fixed16<4>>,
InputOutputTypes<csrblocksparse::fixed32<3>, csrblocksparse::fixed16<4>>,
// float --> float.
InputOutputTypes<float, float>>;
TYPED_TEST_SUITE(CastVectorTest, CastVectorTypes);
TYPED_TEST(CastVectorTest, ResultsCloseToCastingThroughFloat) {
CastVector(0, this->kNumElements, this->input_.data(), this->output_.data());
EXPECT_THAT(std::vector<float>(this->output_.begin(), this->output_.end()),
testing::Pointwise(testing::FloatNear(this->tolerance_),
this->expected_output_));
}
} // namespace
} // namespace codec
} // namespace chromemedia
| 36.956204 | 80 | 0.707486 | [
"vector"
] |
2e14a9a2a90e0bfa0c389cfd2fecdfd9b1558b73 | 5,267 | hpp | C++ | include/operations/CompoundOperation.hpp | Tonanguyxiro/qfr | 0c5a75c1ee68157de082a05650bc72aef41998c4 | [
"MIT"
] | 1 | 2021-03-05T09:17:36.000Z | 2021-03-05T09:17:36.000Z | include/operations/CompoundOperation.hpp | Tonanguyxiro/qfr | 0c5a75c1ee68157de082a05650bc72aef41998c4 | [
"MIT"
] | null | null | null | include/operations/CompoundOperation.hpp | Tonanguyxiro/qfr | 0c5a75c1ee68157de082a05650bc72aef41998c4 | [
"MIT"
] | null | null | null | /*
* This file is part of IIC-JKU QFR library which is released under the MIT license.
* See file README.md or go to http://iic.jku.at/eda/research/quantum/ for more information.
*/
#ifndef INTERMEDIATEREPRESENTATION_COMPOUNDOPERATION_H
#define INTERMEDIATEREPRESENTATION_COMPOUNDOPERATION_H
#include "Operation.hpp"
namespace qc {
class CompoundOperation : public Operation {
protected:
std::vector<std::unique_ptr<Operation>> ops{ };
public:
explicit CompoundOperation(unsigned short nq) {
std::strcpy(name, "Compound operation:");
nqubits = nq;
type = Compound;
}
template<class T>
void emplace_back(std::unique_ptr<T>& op) {
parameter[0]++;
ops.emplace_back(std::move(op));
}
template<class T, class... Args>
void emplace_back(Args&& ... args) {
parameter[0]++;
ops.emplace_back(std::make_unique<T>(args ...));
}
void setNqubits(unsigned short nq) override {
nqubits = nq;
for (auto& op:ops) {
op->setNqubits(nq);
}
}
bool isCompoundOperation() const override {
return true;
}
bool isNonUnitaryOperation() const override {
bool isNonUnitary = false;
for (const auto& op: ops) {
isNonUnitary |= op->isNonUnitaryOperation();
}
return isNonUnitary;
}
dd::Edge getDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line) const override {
dd::Edge e = dd->makeIdent(0, short(nqubits - 1));
for (auto& op: ops) {
e = dd->multiply(op->getDD(dd, line), e);
}
return e;
}
dd::Edge getInverseDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line) const override {
dd::Edge e = dd->makeIdent(0, short(nqubits - 1));
for (auto& op: ops) {
e = dd->multiply(e, op->getInverseDD(dd, line));
}
return e;
}
dd::Edge getDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line, std::map<unsigned short, unsigned short>& permutation) const override {
dd::Edge e = dd->makeIdent(0, short(nqubits - 1));
for (auto& op: ops) {
e = dd->multiply(op->getDD(dd, line, permutation), e);
}
return e;
}
dd::Edge getInverseDD(std::unique_ptr<dd::Package>& dd, std::array<short, MAX_QUBITS>& line, std::map<unsigned short, unsigned short>& permutation) const override {
dd::Edge e = dd->makeIdent(0, short(nqubits - 1));
for (auto& op: ops) {
e = dd->multiply(e, op->getInverseDD(dd, line, permutation));
}
return e;
}
std::ostream& print(std::ostream& os) const override {
return print(os, standardPermutation);
}
std::ostream& print(std::ostream& os, const std::map<unsigned short, unsigned short>& permutation) const override {
os << name;
for (const auto & op : ops) {
os << std::endl << "\t";
op->print(os, permutation);
}
return os;
}
bool actsOn(unsigned short i) override {
for (const auto& op: ops) {
if(op->actsOn(i))
return true;
}
return false;
}
void dumpOpenQASM(std::ostream& of, const regnames_t& qreg, const regnames_t& creg) const override {
for (auto& op: ops) {
op->dumpOpenQASM(of, qreg, creg);
}
}
void dumpReal(std::ostream& of) const override {
for (auto& op: ops) {
op->dumpReal(of);
}
}
void dumpQiskit(std::ostream& of, const regnames_t& qreg, const regnames_t& creg, const char *anc_reg_name) const override {
for (auto& op: ops) {
op->dumpQiskit(of, qreg, creg, anc_reg_name);
}
}
/**
* Pass-Through
*/
// Iterators (pass-through)
auto begin() noexcept { return ops.begin(); }
auto begin() const noexcept { return ops.begin(); }
auto cbegin() const noexcept { return ops.cbegin(); }
auto end() noexcept { return ops.end(); }
auto end() const noexcept { return ops.end(); }
auto cend() const noexcept { return ops.cend(); }
auto rbegin() noexcept { return ops.rbegin(); }
auto rbegin() const noexcept { return ops.rbegin(); }
auto crbegin() const noexcept { return ops.crbegin(); }
auto rend() noexcept { return ops.rend(); }
auto rend() const noexcept { return ops.rend(); }
auto crend() const noexcept { return ops.crend(); }
// Capacity (pass-through)
bool empty() const noexcept { return ops.empty(); }
size_t size() const noexcept { return ops.size(); }
size_t max_size() const noexcept { return ops.max_size(); }
size_t capacity() const noexcept { return ops.capacity(); }
void reserve(size_t new_cap) { ops.reserve(new_cap); }
void shrink_to_fit() { ops.shrink_to_fit(); }
// Modifiers (pass-through)
void clear() noexcept { ops.clear(); }
void pop_back() { return ops.pop_back(); }
void resize(size_t count) { ops.resize(count); }
std::vector<std::unique_ptr<Operation>>::iterator erase( std::vector<std::unique_ptr<Operation>>::const_iterator pos ) { return ops.erase(pos); }
std::vector<std::unique_ptr<Operation>>::iterator erase( std::vector<std::unique_ptr<Operation>>::const_iterator first, std::vector<std::unique_ptr<Operation>>::const_iterator last ) { return ops.erase(first, last); }
};
}
#endif //INTERMEDIATEREPRESENTATION_COMPOUNDOPERATION_H
| 32.512346 | 219 | 0.636415 | [
"vector"
] |
2e1ba6b67ee9a15b8cb6e554786653c0a9f5f2f7 | 557,496 | cpp | C++ | hphp/parser/hphp.tab.cpp | arnononline/hhvm | f80bfae3394cc48a0a99a49e003c7c3cd92e444f | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | hphp/parser/hphp.tab.cpp | arnononline/hhvm | f80bfae3394cc48a0a99a49e003c7c3cd92e444f | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | hphp/parser/hphp.tab.cpp | arnononline/hhvm | f80bfae3394cc48a0a99a49e003c7c3cd92e444f | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | // @generated
/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
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/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.4.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 1
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Using locations. */
#define YYLSP_NEEDED 1
/* Substitute the variable and function names. */
#define yyparse Compilerparse
#define yylex Compilerlex
#define yyerror Compilererror
#define yylval Compilerlval
#define yychar Compilerchar
#define yydebug Compilerdebug
#define yynerrs Compilernerrs
#define yylloc Compilerlloc
/* Copy the first part of user declarations. */
/* Line 189 of yacc.c */
#line 1 "hphp.y"
// macros for bison
#define YYSTYPE HPHP::HPHP_PARSER_NS::Token
#define YYSTYPE_IS_TRIVIAL false
#define YYLTYPE HPHP::Location
#define YYLTYPE_IS_TRIVIAL true
#define YYERROR_VERBOSE
#define YYINITDEPTH 500
#define YYLEX_PARAM _p
#include "hphp/compiler/parser/parser.h"
#include "folly/Conv.h"
#include "hphp/util/text-util.h"
#include "hphp/util/logger.h"
#ifdef yyerror
#undef yyerror
#endif
#define yyerror(loc,p,msg) p->parseFatal(loc,msg)
#ifdef YYLLOC_DEFAULT
# undef YYLLOC_DEFAULT
#endif
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) { \
(Current).first(YYRHSLOC (Rhs, 1)); \
(Current).last (YYRHSLOC (Rhs, N)); \
} else { \
(Current).line0 = (Current).line1 = YYRHSLOC (Rhs, 0).line1; \
(Current).char0 = (Current).char1 = YYRHSLOC (Rhs, 0).char1; \
} \
while (0); \
_p->setRuleLocation(&Current);
#define YYCOPY(To, From, Count) \
do { \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) { \
(To)[yyi] = (From)[yyi]; \
} \
if (From != From ## a) { \
YYSTACK_FREE (From); \
} \
} \
while (0)
#define YYCOPY_RESET(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) { \
(To)[yyi] = (From)[yyi]; \
(From)[yyi].reset(); \
} \
if (From != From ## a) { \
YYSTACK_FREE (From); \
} \
} \
while (0)
#define YYTOKEN_RESET(From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) { \
(From)[yyi].reset(); \
} \
if (From != From ## a) { \
YYSTACK_FREE (From); \
} \
} \
while (0)
# define YYSTACK_RELOCATE_RESET(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY_RESET (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#define YYSTACK_CLEANUP \
YYTOKEN_RESET (yyvs, yystacksize); \
if (yyvs != yyvsa) { \
YYSTACK_FREE (yyvs); \
} \
if (yyls != yylsa) { \
YYSTACK_FREE (yyls); \
} \
// macros for rules
#define BEXP(e...) _p->onBinaryOpExp(e);
#define UEXP(e...) _p->onUnaryOpExp(e);
using namespace HPHP::HPHP_PARSER_NS;
typedef HPHP::ClosureType ClosureType;
///////////////////////////////////////////////////////////////////////////////
// helpers
static void scalar_num(Parser *_p, Token &out, const char *num) {
Token t;
t.setText(num);
_p->onScalar(out, T_LNUMBER, t);
}
static void scalar_num(Parser *_p, Token &out, int num) {
Token t;
t.setText(folly::to<std::string>(num));
_p->onScalar(out, T_LNUMBER, t);
}
static void scalar_null(Parser *_p, Token &out) {
Token tnull; tnull.setText("null");
_p->onConstantValue(out, tnull);
}
static void scalar_file(Parser *_p, Token &out) {
Token file; file.setText("__FILE__");
_p->onScalar(out, T_FILE, file);
}
static void scalar_line(Parser *_p, Token &out) {
Token line; line.setText("__LINE__");
_p->onScalar(out, T_LINE, line);
}
///////////////////////////////////////////////////////////////////////////////
static void constant_ae(Parser *_p, Token &out, Token &value) {
const std::string& valueStr = value.text();
if (valueStr.size() < 3 || valueStr.size() > 5 ||
(strcasecmp("true", valueStr.c_str()) != 0 &&
strcasecmp("false", valueStr.c_str()) != 0 &&
strcasecmp("null", valueStr.c_str()) != 0 &&
strcasecmp("inf", valueStr.c_str()) != 0 &&
strcasecmp("nan", valueStr.c_str()) != 0)) {
HPHP_PARSER_ERROR("User-defined constants are not allowed in user "
"attribute expressions", _p);
}
_p->onConstantValue(out, value);
}
///////////////////////////////////////////////////////////////////////////////
/**
* XHP functions: They are defined here, so different parsers don't have to
* handle XHP rules at all.
*/
static void xhp_tag(Parser *_p, Token &out, Token &label, Token &body) {
if (!body.text().empty() && body.text() != label.text()) {
HPHP_PARSER_ERROR("XHP: mismatched tag: '%s' not the same as '%s'",
_p, body.text().c_str(), label.text().c_str());
}
label.xhpLabel();
Token name; _p->onName(name, label, Parser::StringName);
_p->onNewObject(out, name, body);
}
static void xhp_attribute(Parser *_p, Token &out, Token &type, Token &label,
Token &def, Token &req) {
/**
* The bool, int, float, and string typenames are not given any special
* treatment by the parser and are treated the same as regular class names
* (which initially gets marked as type code 5). However, XHP wants to use
* different type codes for bool, int, float, and string, so we need to fix
* up the type code here to make XHP happy.
*/
if (type.num() == 5) {
auto* str = type.text().c_str();
if (_p->scanner().isHHSyntaxEnabled()) {
switch (type.text().size()) {
case 6:
if (!strcasecmp(str, "HH\\int")) {
type.reset(); type.setNum(3);
}
break;
case 7:
if (!strcasecmp(str, "HH\\bool")) {
type.reset(); type.setNum(2);
}
break;
case 8:
if (!strcasecmp(str, "HH\\float")) {
type.reset(); type.setNum(8);
} else if (!strcasecmp(str, "HH\\mixed")) {
type.reset(); type.setNum(6);
}
break;
case 9:
if (!strcasecmp(str, "HH\\string")) {
type.reset(); type.setNum(1);
}
break;
default:
break;
}
} else {
switch (type.text().size()) {
case 3:
if (!strcasecmp(str, "int")) {
type.reset(); type.setNum(3);
}
break;
case 4:
if (!strcasecmp(str, "bool")) {
type.reset(); type.setNum(2);
} else if (!strcasecmp(str, "real")) {
type.reset(); type.setNum(8);
}
break;
case 5:
if (!strcasecmp(str, "float")) {
type.reset(); type.setNum(8);
} else if (!strcasecmp(str, "mixed")) {
type.reset(); type.setNum(6);
}
break;
case 6:
if (!strcasecmp(str, "string")) {
type.reset(); type.setNum(1);
} else if (!strcasecmp(str, "double")) {
type.reset(); type.setNum(8);
}
break;
case 7:
if (!strcasecmp(str, "integer")) {
type.reset(); type.setNum(3);
} else if (!strcasecmp(str, "boolean")) {
type.reset(); type.setNum(2);
}
break;
default:
break;
}
}
}
Token num; scalar_num(_p, num, type.num());
Token arr1; _p->onArrayPair(arr1, 0, 0, num, 0);
Token arr2;
switch (type.num()) {
case 5: /* class */ {
Token cls; _p->onScalar(cls, T_CONSTANT_ENCAPSED_STRING, type);
_p->onArrayPair(arr2, &arr1, 0, cls, 0);
break;
}
case 7: /* enum */ {
Token arr; _p->onArray(arr, type);
_p->onArrayPair(arr2, &arr1, 0, arr, 0);
break;
}
default: {
Token tnull; scalar_null(_p, tnull);
_p->onArrayPair(arr2, &arr1, 0, tnull, 0);
break;
}
}
Token arr3; _p->onArrayPair(arr3, &arr2, 0, def, 0);
Token arr4; _p->onArrayPair(arr4, &arr3, 0, req, 0);
_p->onArray(out, arr4);
out.setText(label);
}
static void xhp_attribute_list(Parser *_p, Token &out, Token *list,
Token &decl) {
if (decl.num() == 0) {
decl.xhpLabel();
if (list) {
out = *list;
out.setText(list->text() + ":" + decl.text()); // avoiding vector<string>
} else {
out.setText(decl);
}
} else {
Token name; _p->onScalar(name, T_CONSTANT_ENCAPSED_STRING, decl);
_p->onArrayPair(out, list, &name, decl, 0);
if (list) {
out.setText(list->text());
} else {
out.setText("");
}
}
}
static void xhp_attribute_stmt(Parser *_p, Token &out, Token &attributes) {
Token modifiers;
Token fname; fname.setText("__xhpAttributeDeclaration");
{
Token m;
Token m1; m1.setNum(T_PROTECTED); _p->onMemberModifier(m, NULL, m1);
Token m2; m2.setNum(T_STATIC); _p->onMemberModifier(modifiers, &m, m2);
}
_p->pushFuncLocation();
_p->onMethodStart(fname, modifiers);
std::vector<std::string> classes;
HPHP::split(':', attributes.text().c_str(), classes, true);
Token arrAttributes; _p->onArray(arrAttributes, attributes);
Token dummy;
Token stmts0;
{
_p->onStatementListStart(stmts0);
}
Token stmts1;
{
// static $_ = -1;
Token one; scalar_num(_p, one, "1");
Token mone; UEXP(mone, one, '-', 1);
Token var; var.set(T_VARIABLE, "_");
Token decl; _p->onStaticVariable(decl, 0, var, &mone);
Token sdecl; _p->onStatic(sdecl, decl);
_p->addStatement(stmts1, stmts0, sdecl);
}
Token stmts2;
{
// if ($_ === -1) {
// $_ = array_merge(parent::__xhpAttributeDeclaration(),
// attributes);
// }
Token parent; parent.set(T_STRING, "parent");
Token cls; _p->onName(cls, parent, Parser::StringName);
Token fname; fname.setText("__xhpAttributeDeclaration");
Token param1; _p->onCall(param1, 0, fname, dummy, &cls);
Token params1; _p->onCallParam(params1, NULL, param1, false, false);
for (unsigned int i = 0; i < classes.size(); i++) {
Token parent; parent.set(T_STRING, classes[i]);
Token cls; _p->onName(cls, parent, Parser::StringName);
Token fname; fname.setText("__xhpAttributeDeclaration");
Token param; _p->onCall(param, 0, fname, dummy, &cls);
Token params; _p->onCallParam(params, ¶ms1, param, false, false);
params1 = params;
}
Token params2; _p->onCallParam(params2, ¶ms1, arrAttributes,
false, false);
Token name; name.set(T_STRING, "array_merge");
Token call; _p->onCall(call, 0, name, params2, NULL);
Token tvar; tvar.set(T_VARIABLE, "_");
Token var; _p->onSimpleVariable(var, tvar);
Token assign; _p->onAssign(assign, var, call, 0);
Token exp; _p->onExpStatement(exp, assign);
Token block; _p->onBlock(block, exp);
Token tvar2; tvar2.set(T_VARIABLE, "_");
Token var2; _p->onSimpleVariable(var2, tvar2);
Token one; scalar_num(_p, one, "1");
Token mone; UEXP(mone, one, '-', 1);
Token cond; BEXP(cond, var2, mone, T_IS_IDENTICAL);
Token dummy1, dummy2;
Token sif; _p->onIf(sif, cond, block, dummy1, dummy2);
_p->addStatement(stmts2, stmts1, sif);
}
Token stmts3;
{
// return $_;
Token tvar; tvar.set(T_VARIABLE, "_");
Token var; _p->onSimpleVariable(var, tvar);
Token ret; _p->onReturn(ret, &var);
_p->addStatement(stmts3, stmts2, ret);
}
Token stmt;
{
_p->finishStatement(stmt, stmts3);
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
static void xhp_collect_attributes(Parser *_p, Token &out, Token &stmts) {
Token *attr = _p->xhpGetAttributes();
if (attr) {
Token stmt;
xhp_attribute_stmt(_p, stmt, *attr);
_p->onClassStatement(out, stmts, stmt);
} else {
out = stmts;
}
}
static void xhp_category_stmt(Parser *_p, Token &out, Token &categories) {
Token fname; fname.setText("__xhpCategoryDeclaration");
Token m1; m1.setNum(T_PROTECTED);
Token modifiers; _p->onMemberModifier(modifiers, 0, m1);
_p->pushFuncLocation();
_p->onMethodStart(fname, modifiers);
Token stmts0;
{
_p->onStatementListStart(stmts0);
}
Token stmts1;
{
// static $_ = categories;
Token arr; _p->onArray(arr, categories);
Token var; var.set(T_VARIABLE, "_");
Token decl; _p->onStaticVariable(decl, 0, var, &arr);
Token sdecl; _p->onStatic(sdecl, decl);
_p->addStatement(stmts1, stmts0, sdecl);
}
Token stmts2;
{
// return $_;
Token tvar; tvar.set(T_VARIABLE, "_");
Token var; _p->onSimpleVariable(var, tvar);
Token ret; _p->onReturn(ret, &var);
_p->addStatement(stmts2, stmts1, ret);
}
Token stmt;
{
_p->finishStatement(stmt, stmts2);
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
static void xhp_children_decl_tag(Parser *_p, Token &arr, Token &tag) {
Token num; scalar_num(_p, num, tag.num());
Token arr1; _p->onArrayPair(arr1, &arr, 0, num, 0);
Token name;
if (tag.num() == 3 || tag.num() == 4) {
_p->onScalar(name, T_CONSTANT_ENCAPSED_STRING, tag);
} else if (tag.num() >= 0) {
scalar_null(_p, name);
} else {
HPHP_PARSER_ERROR("XHP: unknown children declaration", _p);
}
Token arr2; _p->onArrayPair(arr2, &arr1, 0, name, 0);
arr = arr2;
}
static void xhp_children_decl(Parser *_p, Token &out, Token &op1, int op,
Token *op2) {
Token num; scalar_num(_p, num, op);
Token arr; _p->onArrayPair(arr, 0, 0, num, 0);
if (op2) {
Token arr1; _p->onArrayPair(arr1, &arr, 0, op1, 0);
Token arr2; _p->onArrayPair(arr2, &arr1, 0, *op2, 0);
_p->onArray(out, arr2);
} else {
xhp_children_decl_tag(_p, arr, op1);
_p->onArray(out, arr);
}
}
static void xhp_children_paren(Parser *_p, Token &out, Token exp, int op) {
Token num; scalar_num(_p, num, op);
Token arr1; _p->onArrayPair(arr1, 0, 0, num, 0);
Token num5; scalar_num(_p, num5, 5);
Token arr2; _p->onArrayPair(arr2, &arr1, 0, num5, 0);
Token arr3; _p->onArrayPair(arr3, &arr2, 0, exp, 0);
_p->onArray(out, arr3);
}
static void xhp_children_stmt(Parser *_p, Token &out, Token &children) {
Token fname; fname.setText("__xhpChildrenDeclaration");
Token m1; m1.setNum(T_PROTECTED);
Token modifiers; _p->onMemberModifier(modifiers, 0, m1);
_p->pushFuncLocation();
_p->onMethodStart(fname, modifiers);
Token stmts0;
{
_p->onStatementListStart(stmts0);
}
Token stmts1;
{
// static $_ = children;
Token arr;
if (children.num() == 2) {
arr = children;
} else if (children.num() >= 0) {
scalar_num(_p, arr, children.num());
} else {
HPHP_PARSER_ERROR("XHP: XHP unknown children declaration", _p);
}
Token var; var.set(T_VARIABLE, "_");
Token decl; _p->onStaticVariable(decl, 0, var, &arr);
Token sdecl; _p->onStatic(sdecl, decl);
_p->addStatement(stmts1, stmts0, sdecl);
}
Token stmts2;
{
// return $_;
Token tvar; tvar.set(T_VARIABLE, "_");
Token var; _p->onSimpleVariable(var, tvar);
Token ret; _p->onReturn(ret, &var);
_p->addStatement(stmts2, stmts1, ret);
}
Token stmt;
{
_p->finishStatement(stmt, stmts2);
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
static void only_in_hh_syntax(Parser *_p) {
if (!_p->scanner().isHHSyntaxEnabled()) {
HPHP_PARSER_ERROR(
"Syntax only allowed in Hack files (<?hh) or with -v "
"Eval.EnableHipHopSyntax=true",
_p);
}
}
static void validate_hh_variadic_variant(Parser* _p,
Token& userAttrs, Token& typehint,
Token* mod) {
if (!userAttrs.text().empty() || !typehint.text().empty() ||
(mod && !mod->text().empty())) {
HPHP_PARSER_ERROR("Variadic '...' should be followed by a '$variable'", _p);
}
only_in_hh_syntax(_p);
}
// Shapes may not have leading integers in key names, considered as a
// parse time error. This is because at runtime they are currently
// hphp arrays, which will treat leading integer keys as numbers.
static void validate_shape_keyname(Token& tok, Parser* _p) {
if (tok.text().empty()) {
HPHP_PARSER_ERROR("Shape key names may not be empty", _p);
}
if (isdigit(tok.text()[0])) {
HPHP_PARSER_ERROR("Shape key names may not start with integers", _p);
}
}
///////////////////////////////////////////////////////////////////////////////
static int yylex(YYSTYPE *token, HPHP::Location *loc, Parser *_p) {
return _p->scan(token, loc);
}
/* Line 189 of yacc.c */
#line 646 "hphp.tab.cpp"
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
T_REQUIRE_ONCE = 258,
T_REQUIRE = 259,
T_EVAL = 260,
T_INCLUDE_ONCE = 261,
T_INCLUDE = 262,
T_LAMBDA_ARROW = 263,
T_LOGICAL_OR = 264,
T_LOGICAL_XOR = 265,
T_LOGICAL_AND = 266,
T_PRINT = 267,
T_POW_EQUAL = 268,
T_SR_EQUAL = 269,
T_SL_EQUAL = 270,
T_XOR_EQUAL = 271,
T_OR_EQUAL = 272,
T_AND_EQUAL = 273,
T_MOD_EQUAL = 274,
T_CONCAT_EQUAL = 275,
T_DIV_EQUAL = 276,
T_MUL_EQUAL = 277,
T_MINUS_EQUAL = 278,
T_PLUS_EQUAL = 279,
T_YIELD = 280,
T_AWAIT = 281,
T_BOOLEAN_OR = 282,
T_BOOLEAN_AND = 283,
T_IS_NOT_IDENTICAL = 284,
T_IS_IDENTICAL = 285,
T_IS_NOT_EQUAL = 286,
T_IS_EQUAL = 287,
T_IS_GREATER_OR_EQUAL = 288,
T_IS_SMALLER_OR_EQUAL = 289,
T_SR = 290,
T_SL = 291,
T_INSTANCEOF = 292,
T_UNSET_CAST = 293,
T_BOOL_CAST = 294,
T_OBJECT_CAST = 295,
T_ARRAY_CAST = 296,
T_STRING_CAST = 297,
T_DOUBLE_CAST = 298,
T_INT_CAST = 299,
T_DEC = 300,
T_INC = 301,
T_POW = 302,
T_CLONE = 303,
T_NEW = 304,
T_EXIT = 305,
T_IF = 306,
T_ELSEIF = 307,
T_ELSE = 308,
T_ENDIF = 309,
T_LNUMBER = 310,
T_DNUMBER = 311,
T_ONUMBER = 312,
T_STRING = 313,
T_STRING_VARNAME = 314,
T_VARIABLE = 315,
T_NUM_STRING = 316,
T_INLINE_HTML = 317,
T_HASHBANG = 318,
T_CHARACTER = 319,
T_BAD_CHARACTER = 320,
T_ENCAPSED_AND_WHITESPACE = 321,
T_CONSTANT_ENCAPSED_STRING = 322,
T_ECHO = 323,
T_DO = 324,
T_WHILE = 325,
T_ENDWHILE = 326,
T_FOR = 327,
T_ENDFOR = 328,
T_FOREACH = 329,
T_ENDFOREACH = 330,
T_DECLARE = 331,
T_ENDDECLARE = 332,
T_AS = 333,
T_SWITCH = 334,
T_ENDSWITCH = 335,
T_CASE = 336,
T_DEFAULT = 337,
T_BREAK = 338,
T_GOTO = 339,
T_CONTINUE = 340,
T_FUNCTION = 341,
T_CONST = 342,
T_RETURN = 343,
T_TRY = 344,
T_CATCH = 345,
T_THROW = 346,
T_USE = 347,
T_GLOBAL = 348,
T_PUBLIC = 349,
T_PROTECTED = 350,
T_PRIVATE = 351,
T_FINAL = 352,
T_ABSTRACT = 353,
T_STATIC = 354,
T_VAR = 355,
T_UNSET = 356,
T_ISSET = 357,
T_EMPTY = 358,
T_HALT_COMPILER = 359,
T_CLASS = 360,
T_INTERFACE = 361,
T_EXTENDS = 362,
T_IMPLEMENTS = 363,
T_OBJECT_OPERATOR = 364,
T_NULLSAFE_OBJECT_OPERATOR = 365,
T_DOUBLE_ARROW = 366,
T_LIST = 367,
T_ARRAY = 368,
T_CALLABLE = 369,
T_CLASS_C = 370,
T_METHOD_C = 371,
T_FUNC_C = 372,
T_LINE = 373,
T_FILE = 374,
T_COMMENT = 375,
T_DOC_COMMENT = 376,
T_OPEN_TAG = 377,
T_OPEN_TAG_WITH_ECHO = 378,
T_CLOSE_TAG = 379,
T_WHITESPACE = 380,
T_START_HEREDOC = 381,
T_END_HEREDOC = 382,
T_DOLLAR_OPEN_CURLY_BRACES = 383,
T_CURLY_OPEN = 384,
T_DOUBLE_COLON = 385,
T_NAMESPACE = 386,
T_NS_C = 387,
T_DIR = 388,
T_NS_SEPARATOR = 389,
T_XHP_LABEL = 390,
T_XHP_TEXT = 391,
T_XHP_ATTRIBUTE = 392,
T_XHP_CATEGORY = 393,
T_XHP_CATEGORY_LABEL = 394,
T_XHP_CHILDREN = 395,
T_ENUM = 396,
T_XHP_REQUIRED = 397,
T_TRAIT = 398,
T_ELLIPSIS = 399,
T_INSTEADOF = 400,
T_TRAIT_C = 401,
T_HH_ERROR = 402,
T_FINALLY = 403,
T_XHP_TAG_LT = 404,
T_XHP_TAG_GT = 405,
T_TYPELIST_LT = 406,
T_TYPELIST_GT = 407,
T_UNRESOLVED_LT = 408,
T_COLLECTION = 409,
T_SHAPE = 410,
T_VARRAY = 411,
T_MIARRAY = 412,
T_MSARRAY = 413,
T_TYPE = 414,
T_UNRESOLVED_TYPE = 415,
T_NEWTYPE = 416,
T_UNRESOLVED_NEWTYPE = 417,
T_COMPILER_HALT_OFFSET = 418,
T_ASYNC = 419,
T_FROM = 420,
T_WHERE = 421,
T_JOIN = 422,
T_IN = 423,
T_ON = 424,
T_EQUALS = 425,
T_INTO = 426,
T_LET = 427,
T_ORDERBY = 428,
T_ASCENDING = 429,
T_DESCENDING = 430,
T_SELECT = 431,
T_GROUP = 432,
T_BY = 433,
T_LAMBDA_OP = 434,
T_LAMBDA_CP = 435,
T_UNRESOLVED_OP = 436
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
int line0;
int char0;
int line1;
int char1;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
/* Copy the second part of user declarations. */
/* Line 264 of yacc.c */
#line 882 "hphp.tab.cpp"
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#elif (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
typedef signed char yytype_int8;
#else
typedef short int yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
#else
# define YYUSE(e) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
YYID (int yyi)
#else
static int
YYID (yyi)
int yyi;
#endif
{
return yyi;
}
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined _STDLIB_H \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
struct yyalloc
{
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
YYLTYPE yyls_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (struct yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAXIMUM)
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (YYID (0))
#endif
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 3
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 16688
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 211
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 279
/* YYNRULES -- Number of rules. */
#define YYNRULES 942
/* YYNRULES -- Number of states. */
#define YYNSTATES 1766
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 436
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 52, 209, 2, 206, 51, 35, 210,
201, 202, 49, 46, 9, 47, 48, 50, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 30, 203,
40, 14, 41, 29, 55, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 66, 2, 208, 34, 2, 207, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 204, 33, 205, 54, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 10, 11, 12, 13, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 31, 32, 36, 37, 38, 39, 42, 43,
44, 45, 53, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 67, 68, 69, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, 199, 200
};
#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
static const yytype_uint16 yyprhs[] =
{
0, 0, 3, 4, 7, 10, 11, 13, 15, 17,
19, 21, 23, 28, 32, 33, 40, 41, 47, 51,
56, 61, 64, 66, 68, 70, 72, 74, 76, 78,
80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
100, 102, 106, 108, 112, 114, 118, 120, 122, 125,
129, 134, 136, 139, 143, 148, 150, 153, 157, 162,
164, 168, 170, 174, 177, 179, 182, 185, 191, 196,
199, 200, 202, 204, 206, 208, 212, 218, 227, 228,
233, 234, 241, 242, 253, 254, 259, 262, 266, 269,
273, 276, 280, 284, 288, 292, 296, 302, 304, 306,
308, 309, 319, 320, 331, 337, 338, 352, 353, 359,
363, 367, 370, 373, 376, 379, 382, 385, 389, 392,
395, 399, 402, 403, 408, 418, 419, 420, 425, 428,
429, 431, 432, 434, 435, 445, 446, 457, 458, 470,
471, 481, 482, 493, 494, 503, 504, 514, 515, 523,
524, 533, 534, 542, 543, 552, 554, 556, 558, 560,
562, 565, 569, 573, 576, 579, 580, 583, 584, 587,
588, 590, 594, 596, 600, 603, 604, 606, 609, 614,
616, 621, 623, 628, 630, 635, 637, 642, 646, 652,
656, 661, 666, 672, 678, 683, 684, 686, 688, 693,
694, 700, 701, 704, 705, 709, 710, 718, 727, 734,
737, 743, 750, 755, 756, 761, 767, 775, 782, 789,
797, 807, 816, 823, 831, 837, 840, 845, 851, 855,
856, 860, 865, 872, 878, 884, 891, 900, 908, 911,
912, 914, 917, 920, 924, 929, 934, 938, 940, 942,
945, 950, 954, 960, 962, 966, 969, 970, 973, 977,
980, 981, 982, 987, 988, 994, 997, 998, 1009, 1010,
1022, 1026, 1030, 1034, 1039, 1044, 1048, 1054, 1057, 1060,
1061, 1068, 1074, 1079, 1083, 1085, 1087, 1091, 1096, 1098,
1100, 1102, 1104, 1109, 1111, 1113, 1117, 1120, 1121, 1124,
1125, 1127, 1131, 1133, 1135, 1137, 1139, 1143, 1148, 1153,
1158, 1160, 1162, 1165, 1168, 1171, 1175, 1179, 1181, 1183,
1185, 1187, 1191, 1193, 1197, 1199, 1201, 1203, 1204, 1206,
1209, 1211, 1213, 1215, 1217, 1219, 1221, 1223, 1225, 1226,
1228, 1230, 1232, 1236, 1242, 1244, 1248, 1254, 1259, 1263,
1267, 1270, 1272, 1274, 1278, 1282, 1284, 1286, 1287, 1289,
1292, 1297, 1301, 1308, 1311, 1315, 1322, 1324, 1326, 1328,
1330, 1332, 1339, 1343, 1348, 1355, 1359, 1363, 1367, 1371,
1375, 1379, 1383, 1387, 1391, 1395, 1399, 1403, 1406, 1409,
1412, 1415, 1419, 1423, 1427, 1431, 1435, 1439, 1443, 1447,
1451, 1455, 1459, 1463, 1467, 1471, 1475, 1479, 1483, 1486,
1489, 1492, 1495, 1499, 1503, 1507, 1511, 1515, 1519, 1523,
1527, 1531, 1535, 1541, 1546, 1548, 1551, 1554, 1557, 1560,
1563, 1566, 1569, 1572, 1575, 1577, 1579, 1581, 1583, 1585,
1589, 1592, 1594, 1600, 1601, 1602, 1614, 1615, 1628, 1629,
1633, 1634, 1639, 1640, 1647, 1648, 1656, 1657, 1663, 1666,
1669, 1674, 1676, 1678, 1684, 1688, 1694, 1698, 1701, 1702,
1705, 1706, 1711, 1716, 1720, 1725, 1730, 1735, 1740, 1745,
1750, 1755, 1760, 1765, 1770, 1772, 1774, 1776, 1778, 1782,
1785, 1789, 1794, 1797, 1801, 1803, 1806, 1808, 1811, 1813,
1815, 1817, 1819, 1821, 1823, 1828, 1833, 1836, 1845, 1856,
1859, 1861, 1865, 1867, 1870, 1872, 1874, 1876, 1878, 1881,
1886, 1890, 1894, 1899, 1901, 1904, 1909, 1912, 1919, 1920,
1922, 1927, 1928, 1931, 1932, 1934, 1936, 1940, 1942, 1946,
1948, 1950, 1954, 1958, 1960, 1962, 1964, 1966, 1968, 1970,
1972, 1974, 1976, 1978, 1980, 1982, 1984, 1986, 1988, 1990,
1992, 1994, 1996, 1998, 2000, 2002, 2004, 2006, 2008, 2010,
2012, 2014, 2016, 2018, 2020, 2022, 2024, 2026, 2028, 2030,
2032, 2034, 2036, 2038, 2040, 2042, 2044, 2046, 2048, 2050,
2052, 2054, 2056, 2058, 2060, 2062, 2064, 2066, 2068, 2070,
2072, 2074, 2076, 2078, 2080, 2082, 2084, 2086, 2088, 2090,
2092, 2094, 2096, 2098, 2100, 2102, 2104, 2106, 2108, 2110,
2112, 2114, 2116, 2118, 2123, 2125, 2127, 2129, 2131, 2133,
2135, 2137, 2139, 2142, 2144, 2145, 2146, 2148, 2150, 2154,
2155, 2157, 2159, 2161, 2163, 2165, 2167, 2169, 2171, 2173,
2175, 2177, 2179, 2181, 2185, 2188, 2190, 2192, 2197, 2201,
2206, 2208, 2210, 2212, 2214, 2218, 2222, 2226, 2230, 2234,
2238, 2242, 2246, 2250, 2254, 2258, 2262, 2266, 2270, 2274,
2278, 2282, 2286, 2289, 2292, 2295, 2298, 2302, 2306, 2310,
2314, 2318, 2322, 2326, 2330, 2336, 2341, 2345, 2349, 2353,
2355, 2357, 2359, 2361, 2365, 2369, 2373, 2376, 2377, 2379,
2380, 2382, 2383, 2389, 2393, 2397, 2399, 2401, 2403, 2405,
2407, 2411, 2414, 2416, 2418, 2420, 2422, 2424, 2426, 2429,
2432, 2437, 2441, 2446, 2449, 2450, 2456, 2460, 2464, 2466,
2470, 2472, 2475, 2476, 2482, 2486, 2489, 2490, 2494, 2495,
2500, 2503, 2504, 2508, 2512, 2514, 2515, 2517, 2519, 2521,
2523, 2527, 2529, 2531, 2533, 2537, 2539, 2541, 2545, 2549,
2552, 2557, 2560, 2565, 2567, 2569, 2571, 2573, 2575, 2579,
2585, 2589, 2594, 2599, 2603, 2605, 2607, 2609, 2611, 2615,
2621, 2626, 2630, 2632, 2634, 2638, 2642, 2644, 2646, 2654,
2664, 2672, 2679, 2688, 2690, 2693, 2698, 2703, 2705, 2707,
2712, 2714, 2715, 2717, 2720, 2722, 2724, 2728, 2734, 2738,
2742, 2743, 2745, 2749, 2755, 2759, 2762, 2766, 2773, 2774,
2776, 2781, 2784, 2785, 2791, 2795, 2799, 2801, 2808, 2813,
2818, 2821, 2824, 2825, 2831, 2835, 2839, 2841, 2844, 2845,
2851, 2855, 2859, 2861, 2864, 2865, 2868, 2869, 2875, 2879,
2883, 2885, 2888, 2889, 2892, 2893, 2899, 2903, 2907, 2909,
2912, 2915, 2917, 2920, 2922, 2927, 2931, 2935, 2942, 2946,
2948, 2950, 2952, 2957, 2962, 2967, 2972, 2977, 2982, 2985,
2988, 2993, 2996, 2999, 3001, 3005, 3009, 3013, 3014, 3017,
3023, 3030, 3032, 3035, 3037, 3042, 3046, 3047, 3049, 3053,
3056, 3060, 3062, 3064, 3065, 3066, 3069, 3074, 3077, 3084,
3089, 3091, 3093, 3094, 3098, 3104, 3108, 3110, 3113, 3114,
3119, 3122, 3125, 3127, 3129, 3131, 3133, 3138, 3145, 3147,
3156, 3163, 3165
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int16 yyrhs[] =
{
212, 0, -1, -1, 213, 214, -1, 214, 215, -1,
-1, 233, -1, 250, -1, 257, -1, 254, -1, 262,
-1, 474, -1, 123, 201, 202, 203, -1, 150, 225,
203, -1, -1, 150, 225, 204, 216, 214, 205, -1,
-1, 150, 204, 217, 214, 205, -1, 111, 219, 203,
-1, 111, 105, 220, 203, -1, 111, 106, 221, 203,
-1, 230, 203, -1, 77, -1, 156, -1, 157, -1,
159, -1, 161, -1, 160, -1, 185, -1, 186, -1,
188, -1, 187, -1, 189, -1, 190, -1, 191, -1,
192, -1, 193, -1, 194, -1, 195, -1, 196, -1,
197, -1, 219, 9, 222, -1, 222, -1, 223, 9,
223, -1, 223, -1, 224, 9, 224, -1, 224, -1,
225, -1, 153, 225, -1, 225, 97, 218, -1, 153,
225, 97, 218, -1, 225, -1, 153, 225, -1, 225,
97, 218, -1, 153, 225, 97, 218, -1, 225, -1,
153, 225, -1, 225, 97, 218, -1, 153, 225, 97,
218, -1, 218, -1, 225, 153, 218, -1, 225, -1,
150, 153, 225, -1, 153, 225, -1, 226, -1, 226,
477, -1, 226, 477, -1, 230, 9, 475, 14, 408,
-1, 106, 475, 14, 408, -1, 231, 232, -1, -1,
233, -1, 250, -1, 257, -1, 262, -1, 204, 231,
205, -1, 70, 333, 233, 284, 286, -1, 70, 333,
30, 231, 285, 287, 73, 203, -1, -1, 89, 333,
234, 278, -1, -1, 88, 235, 233, 89, 333, 203,
-1, -1, 91, 201, 335, 203, 335, 203, 335, 202,
236, 276, -1, -1, 98, 333, 237, 281, -1, 102,
203, -1, 102, 342, 203, -1, 104, 203, -1, 104,
342, 203, -1, 107, 203, -1, 107, 342, 203, -1,
27, 102, 203, -1, 112, 294, 203, -1, 118, 296,
203, -1, 87, 334, 203, -1, 120, 201, 471, 202,
203, -1, 203, -1, 81, -1, 82, -1, -1, 93,
201, 342, 97, 275, 274, 202, 238, 277, -1, -1,
93, 201, 342, 28, 97, 275, 274, 202, 239, 277,
-1, 95, 201, 280, 202, 279, -1, -1, 108, 242,
109, 201, 401, 79, 202, 204, 231, 205, 244, 240,
247, -1, -1, 108, 242, 167, 241, 245, -1, 110,
342, 203, -1, 103, 218, 203, -1, 342, 203, -1,
336, 203, -1, 337, 203, -1, 338, 203, -1, 339,
203, -1, 340, 203, -1, 107, 339, 203, -1, 341,
203, -1, 371, 203, -1, 107, 370, 203, -1, 218,
30, -1, -1, 204, 243, 231, 205, -1, 244, 109,
201, 401, 79, 202, 204, 231, 205, -1, -1, -1,
204, 246, 231, 205, -1, 167, 245, -1, -1, 35,
-1, -1, 105, -1, -1, 249, 248, 476, 251, 201,
290, 202, 481, 322, -1, -1, 326, 249, 248, 476,
252, 201, 290, 202, 481, 322, -1, -1, 428, 325,
249, 248, 476, 253, 201, 290, 202, 481, 322, -1,
-1, 160, 218, 255, 30, 488, 473, 204, 297, 205,
-1, -1, 428, 160, 218, 256, 30, 488, 473, 204,
297, 205, -1, -1, 268, 265, 258, 269, 270, 204,
300, 205, -1, -1, 428, 268, 265, 259, 269, 270,
204, 300, 205, -1, -1, 125, 266, 260, 271, 204,
300, 205, -1, -1, 428, 125, 266, 261, 271, 204,
300, 205, -1, -1, 162, 267, 263, 270, 204, 300,
205, -1, -1, 428, 162, 267, 264, 270, 204, 300,
205, -1, 476, -1, 154, -1, 476, -1, 476, -1,
124, -1, 117, 124, -1, 117, 116, 124, -1, 116,
117, 124, -1, 116, 124, -1, 126, 401, -1, -1,
127, 272, -1, -1, 126, 272, -1, -1, 401, -1,
272, 9, 401, -1, 401, -1, 273, 9, 401, -1,
130, 275, -1, -1, 438, -1, 35, 438, -1, 131,
201, 452, 202, -1, 233, -1, 30, 231, 92, 203,
-1, 233, -1, 30, 231, 94, 203, -1, 233, -1,
30, 231, 90, 203, -1, 233, -1, 30, 231, 96,
203, -1, 218, 14, 408, -1, 280, 9, 218, 14,
408, -1, 204, 282, 205, -1, 204, 203, 282, 205,
-1, 30, 282, 99, 203, -1, 30, 203, 282, 99,
203, -1, 282, 100, 342, 283, 231, -1, 282, 101,
283, 231, -1, -1, 30, -1, 203, -1, 284, 71,
333, 233, -1, -1, 285, 71, 333, 30, 231, -1,
-1, 72, 233, -1, -1, 72, 30, 231, -1, -1,
289, 9, 429, 328, 489, 163, 79, -1, 289, 9,
429, 328, 489, 35, 163, 79, -1, 289, 9, 429,
328, 489, 163, -1, 289, 413, -1, 429, 328, 489,
163, 79, -1, 429, 328, 489, 35, 163, 79, -1,
429, 328, 489, 163, -1, -1, 429, 328, 489, 79,
-1, 429, 328, 489, 35, 79, -1, 429, 328, 489,
35, 79, 14, 408, -1, 429, 328, 489, 79, 14,
408, -1, 289, 9, 429, 328, 489, 79, -1, 289,
9, 429, 328, 489, 35, 79, -1, 289, 9, 429,
328, 489, 35, 79, 14, 408, -1, 289, 9, 429,
328, 489, 79, 14, 408, -1, 291, 9, 429, 489,
163, 79, -1, 291, 9, 429, 489, 35, 163, 79,
-1, 291, 9, 429, 489, 163, -1, 291, 413, -1,
429, 489, 163, 79, -1, 429, 489, 35, 163, 79,
-1, 429, 489, 163, -1, -1, 429, 489, 79, -1,
429, 489, 35, 79, -1, 429, 489, 35, 79, 14,
408, -1, 429, 489, 79, 14, 408, -1, 291, 9,
429, 489, 79, -1, 291, 9, 429, 489, 35, 79,
-1, 291, 9, 429, 489, 35, 79, 14, 408, -1,
291, 9, 429, 489, 79, 14, 408, -1, 293, 413,
-1, -1, 342, -1, 35, 438, -1, 163, 342, -1,
293, 9, 342, -1, 293, 9, 163, 342, -1, 293,
9, 35, 438, -1, 294, 9, 295, -1, 295, -1,
79, -1, 206, 438, -1, 206, 204, 342, 205, -1,
296, 9, 79, -1, 296, 9, 79, 14, 408, -1,
79, -1, 79, 14, 408, -1, 297, 298, -1, -1,
299, 203, -1, 475, 14, 408, -1, 300, 301, -1,
-1, -1, 324, 302, 330, 203, -1, -1, 326, 488,
303, 330, 203, -1, 331, 203, -1, -1, 325, 249,
248, 476, 201, 304, 288, 202, 481, 323, -1, -1,
428, 325, 249, 248, 476, 201, 305, 288, 202, 481,
323, -1, 156, 310, 203, -1, 157, 316, 203, -1,
159, 318, 203, -1, 4, 126, 401, 203, -1, 4,
127, 401, 203, -1, 111, 273, 203, -1, 111, 273,
204, 306, 205, -1, 306, 307, -1, 306, 308, -1,
-1, 229, 149, 218, 164, 273, 203, -1, 309, 97,
325, 218, 203, -1, 309, 97, 326, 203, -1, 229,
149, 218, -1, 218, -1, 311, -1, 310, 9, 311,
-1, 312, 398, 314, 315, -1, 154, -1, 132, -1,
401, -1, 119, -1, 160, 204, 313, 205, -1, 133,
-1, 407, -1, 313, 9, 407, -1, 14, 408, -1,
-1, 55, 161, -1, -1, 317, -1, 316, 9, 317,
-1, 158, -1, 319, -1, 218, -1, 122, -1, 201,
320, 202, -1, 201, 320, 202, 49, -1, 201, 320,
202, 29, -1, 201, 320, 202, 46, -1, 319, -1,
321, -1, 321, 49, -1, 321, 29, -1, 321, 46,
-1, 320, 9, 320, -1, 320, 33, 320, -1, 218,
-1, 154, -1, 158, -1, 203, -1, 204, 231, 205,
-1, 203, -1, 204, 231, 205, -1, 326, -1, 119,
-1, 326, -1, -1, 327, -1, 326, 327, -1, 113,
-1, 114, -1, 115, -1, 118, -1, 117, -1, 116,
-1, 183, -1, 329, -1, -1, 113, -1, 114, -1,
115, -1, 330, 9, 79, -1, 330, 9, 79, 14,
408, -1, 79, -1, 79, 14, 408, -1, 331, 9,
475, 14, 408, -1, 106, 475, 14, 408, -1, 201,
332, 202, -1, 68, 403, 406, -1, 67, 342, -1,
390, -1, 362, -1, 201, 342, 202, -1, 334, 9,
342, -1, 342, -1, 334, -1, -1, 27, -1, 27,
342, -1, 27, 342, 130, 342, -1, 438, 14, 336,
-1, 131, 201, 452, 202, 14, 336, -1, 28, 342,
-1, 438, 14, 339, -1, 131, 201, 452, 202, 14,
339, -1, 343, -1, 438, -1, 332, -1, 442, -1,
441, -1, 131, 201, 452, 202, 14, 342, -1, 438,
14, 342, -1, 438, 14, 35, 438, -1, 438, 14,
35, 68, 403, 406, -1, 438, 26, 342, -1, 438,
25, 342, -1, 438, 24, 342, -1, 438, 23, 342,
-1, 438, 22, 342, -1, 438, 21, 342, -1, 438,
20, 342, -1, 438, 19, 342, -1, 438, 18, 342,
-1, 438, 17, 342, -1, 438, 16, 342, -1, 438,
15, 342, -1, 438, 64, -1, 64, 438, -1, 438,
63, -1, 63, 438, -1, 342, 31, 342, -1, 342,
32, 342, -1, 342, 10, 342, -1, 342, 12, 342,
-1, 342, 11, 342, -1, 342, 33, 342, -1, 342,
35, 342, -1, 342, 34, 342, -1, 342, 48, 342,
-1, 342, 46, 342, -1, 342, 47, 342, -1, 342,
49, 342, -1, 342, 50, 342, -1, 342, 65, 342,
-1, 342, 51, 342, -1, 342, 45, 342, -1, 342,
44, 342, -1, 46, 342, -1, 47, 342, -1, 52,
342, -1, 54, 342, -1, 342, 37, 342, -1, 342,
36, 342, -1, 342, 39, 342, -1, 342, 38, 342,
-1, 342, 40, 342, -1, 342, 43, 342, -1, 342,
41, 342, -1, 342, 42, 342, -1, 342, 53, 403,
-1, 201, 343, 202, -1, 342, 29, 342, 30, 342,
-1, 342, 29, 30, 342, -1, 470, -1, 62, 342,
-1, 61, 342, -1, 60, 342, -1, 59, 342, -1,
58, 342, -1, 57, 342, -1, 56, 342, -1, 69,
404, -1, 55, 342, -1, 410, -1, 361, -1, 360,
-1, 363, -1, 364, -1, 207, 405, 207, -1, 13,
342, -1, 368, -1, 111, 201, 389, 413, 202, -1,
-1, -1, 249, 248, 201, 346, 290, 202, 481, 344,
204, 231, 205, -1, -1, 326, 249, 248, 201, 347,
290, 202, 481, 344, 204, 231, 205, -1, -1, 79,
349, 354, -1, -1, 183, 79, 350, 354, -1, -1,
198, 351, 290, 199, 481, 354, -1, -1, 183, 198,
352, 290, 199, 481, 354, -1, -1, 183, 204, 353,
231, 205, -1, 8, 342, -1, 8, 339, -1, 8,
204, 231, 205, -1, 86, -1, 472, -1, 356, 9,
355, 130, 342, -1, 355, 130, 342, -1, 357, 9,
355, 130, 408, -1, 355, 130, 408, -1, 356, 412,
-1, -1, 357, 412, -1, -1, 174, 201, 358, 202,
-1, 132, 201, 453, 202, -1, 66, 453, 208, -1,
401, 204, 455, 205, -1, 176, 201, 459, 202, -1,
177, 201, 459, 202, -1, 175, 201, 460, 202, -1,
176, 201, 463, 202, -1, 177, 201, 463, 202, -1,
175, 201, 464, 202, -1, 401, 204, 457, 205, -1,
368, 66, 448, 208, -1, 369, 66, 448, 208, -1,
361, -1, 472, -1, 441, -1, 86, -1, 201, 343,
202, -1, 372, 373, -1, 438, 14, 370, -1, 184,
79, 187, 342, -1, 374, 385, -1, 374, 385, 388,
-1, 385, -1, 385, 388, -1, 375, -1, 374, 375,
-1, 376, -1, 377, -1, 378, -1, 379, -1, 380,
-1, 381, -1, 184, 79, 187, 342, -1, 191, 79,
14, 342, -1, 185, 342, -1, 186, 79, 187, 342,
188, 342, 189, 342, -1, 186, 79, 187, 342, 188,
342, 189, 342, 190, 79, -1, 192, 382, -1, 383,
-1, 382, 9, 383, -1, 342, -1, 342, 384, -1,
193, -1, 194, -1, 386, -1, 387, -1, 195, 342,
-1, 196, 342, 197, 342, -1, 190, 79, 373, -1,
389, 9, 79, -1, 389, 9, 35, 79, -1, 79,
-1, 35, 79, -1, 168, 154, 391, 169, -1, 393,
50, -1, 393, 169, 394, 168, 50, 392, -1, -1,
154, -1, 393, 395, 14, 396, -1, -1, 394, 397,
-1, -1, 154, -1, 155, -1, 204, 342, 205, -1,
155, -1, 204, 342, 205, -1, 390, -1, 399, -1,
398, 30, 399, -1, 398, 47, 399, -1, 218, -1,
69, -1, 105, -1, 106, -1, 107, -1, 27, -1,
28, -1, 108, -1, 109, -1, 167, -1, 110, -1,
70, -1, 71, -1, 73, -1, 72, -1, 89, -1,
90, -1, 88, -1, 91, -1, 92, -1, 93, -1,
94, -1, 95, -1, 96, -1, 53, -1, 97, -1,
98, -1, 99, -1, 100, -1, 101, -1, 102, -1,
104, -1, 103, -1, 87, -1, 13, -1, 124, -1,
125, -1, 126, -1, 127, -1, 68, -1, 67, -1,
119, -1, 5, -1, 7, -1, 6, -1, 4, -1,
3, -1, 150, -1, 111, -1, 112, -1, 121, -1,
122, -1, 123, -1, 118, -1, 117, -1, 116, -1,
115, -1, 114, -1, 113, -1, 183, -1, 120, -1,
131, -1, 132, -1, 10, -1, 12, -1, 11, -1,
134, -1, 136, -1, 135, -1, 137, -1, 138, -1,
152, -1, 151, -1, 182, -1, 162, -1, 165, -1,
164, -1, 178, -1, 180, -1, 174, -1, 228, 201,
292, 202, -1, 229, -1, 154, -1, 401, -1, 118,
-1, 446, -1, 401, -1, 118, -1, 450, -1, 201,
202, -1, 333, -1, -1, -1, 85, -1, 467, -1,
201, 292, 202, -1, -1, 74, -1, 75, -1, 76,
-1, 86, -1, 137, -1, 138, -1, 152, -1, 134,
-1, 165, -1, 135, -1, 136, -1, 151, -1, 182,
-1, 145, 85, 146, -1, 145, 146, -1, 407, -1,
227, -1, 132, 201, 411, 202, -1, 66, 411, 208,
-1, 174, 201, 359, 202, -1, 409, -1, 367, -1,
365, -1, 366, -1, 201, 408, 202, -1, 408, 31,
408, -1, 408, 32, 408, -1, 408, 10, 408, -1,
408, 12, 408, -1, 408, 11, 408, -1, 408, 33,
408, -1, 408, 35, 408, -1, 408, 34, 408, -1,
408, 48, 408, -1, 408, 46, 408, -1, 408, 47,
408, -1, 408, 49, 408, -1, 408, 50, 408, -1,
408, 51, 408, -1, 408, 45, 408, -1, 408, 44,
408, -1, 408, 65, 408, -1, 52, 408, -1, 54,
408, -1, 46, 408, -1, 47, 408, -1, 408, 37,
408, -1, 408, 36, 408, -1, 408, 39, 408, -1,
408, 38, 408, -1, 408, 40, 408, -1, 408, 43,
408, -1, 408, 41, 408, -1, 408, 42, 408, -1,
408, 29, 408, 30, 408, -1, 408, 29, 30, 408,
-1, 229, 149, 218, -1, 154, 149, 218, -1, 229,
149, 124, -1, 227, -1, 78, -1, 472, -1, 407,
-1, 209, 467, 209, -1, 210, 467, 210, -1, 145,
467, 146, -1, 414, 412, -1, -1, 9, -1, -1,
9, -1, -1, 414, 9, 408, 130, 408, -1, 414,
9, 408, -1, 408, 130, 408, -1, 408, -1, 74,
-1, 75, -1, 76, -1, 86, -1, 145, 85, 146,
-1, 145, 146, -1, 74, -1, 75, -1, 76, -1,
218, -1, 415, -1, 218, -1, 46, 416, -1, 47,
416, -1, 132, 201, 418, 202, -1, 66, 418, 208,
-1, 174, 201, 421, 202, -1, 419, 412, -1, -1,
419, 9, 417, 130, 417, -1, 419, 9, 417, -1,
417, 130, 417, -1, 417, -1, 420, 9, 417, -1,
417, -1, 422, 412, -1, -1, 422, 9, 355, 130,
417, -1, 355, 130, 417, -1, 420, 412, -1, -1,
201, 423, 202, -1, -1, 425, 9, 218, 424, -1,
218, 424, -1, -1, 427, 425, 412, -1, 45, 426,
44, -1, 428, -1, -1, 128, -1, 129, -1, 218,
-1, 154, -1, 204, 342, 205, -1, 431, -1, 445,
-1, 218, -1, 204, 342, 205, -1, 433, -1, 445,
-1, 66, 448, 208, -1, 204, 342, 205, -1, 439,
435, -1, 201, 332, 202, 435, -1, 451, 435, -1,
201, 332, 202, 435, -1, 445, -1, 400, -1, 443,
-1, 444, -1, 436, -1, 438, 430, 432, -1, 201,
332, 202, 430, 432, -1, 402, 149, 445, -1, 440,
201, 292, 202, -1, 441, 201, 292, 202, -1, 201,
438, 202, -1, 400, -1, 443, -1, 444, -1, 436,
-1, 438, 430, 431, -1, 201, 332, 202, 430, 431,
-1, 440, 201, 292, 202, -1, 201, 438, 202, -1,
445, -1, 436, -1, 201, 438, 202, -1, 201, 442,
202, -1, 345, -1, 348, -1, 438, 430, 434, 477,
201, 292, 202, -1, 201, 332, 202, 430, 434, 477,
201, 292, 202, -1, 402, 149, 218, 477, 201, 292,
202, -1, 402, 149, 445, 201, 292, 202, -1, 402,
149, 204, 342, 205, 201, 292, 202, -1, 446, -1,
449, 446, -1, 446, 66, 448, 208, -1, 446, 204,
342, 205, -1, 447, -1, 79, -1, 206, 204, 342,
205, -1, 342, -1, -1, 206, -1, 449, 206, -1,
445, -1, 437, -1, 450, 430, 432, -1, 201, 332,
202, 430, 432, -1, 402, 149, 445, -1, 201, 438,
202, -1, -1, 437, -1, 450, 430, 431, -1, 201,
332, 202, 430, 431, -1, 201, 438, 202, -1, 452,
9, -1, 452, 9, 438, -1, 452, 9, 131, 201,
452, 202, -1, -1, 438, -1, 131, 201, 452, 202,
-1, 454, 412, -1, -1, 454, 9, 342, 130, 342,
-1, 454, 9, 342, -1, 342, 130, 342, -1, 342,
-1, 454, 9, 342, 130, 35, 438, -1, 454, 9,
35, 438, -1, 342, 130, 35, 438, -1, 35, 438,
-1, 456, 412, -1, -1, 456, 9, 342, 130, 342,
-1, 456, 9, 342, -1, 342, 130, 342, -1, 342,
-1, 458, 412, -1, -1, 458, 9, 408, 130, 408,
-1, 458, 9, 408, -1, 408, 130, 408, -1, 408,
-1, 461, 412, -1, -1, 462, 412, -1, -1, 461,
9, 342, 130, 342, -1, 342, 130, 342, -1, 462,
9, 342, -1, 342, -1, 465, 412, -1, -1, 466,
412, -1, -1, 465, 9, 408, 130, 408, -1, 408,
130, 408, -1, 466, 9, 408, -1, 408, -1, 467,
468, -1, 467, 85, -1, 468, -1, 85, 468, -1,
79, -1, 79, 66, 469, 208, -1, 79, 430, 218,
-1, 147, 342, 205, -1, 147, 78, 66, 342, 208,
205, -1, 148, 438, 205, -1, 218, -1, 80, -1,
79, -1, 121, 201, 471, 202, -1, 122, 201, 438,
202, -1, 122, 201, 343, 202, -1, 122, 201, 442,
202, -1, 122, 201, 441, 202, -1, 122, 201, 332,
202, -1, 7, 342, -1, 6, 342, -1, 5, 201,
342, 202, -1, 4, 342, -1, 3, 342, -1, 438,
-1, 471, 9, 438, -1, 402, 149, 218, -1, 402,
149, 124, -1, -1, 97, 488, -1, 178, 476, 14,
488, 203, -1, 180, 476, 473, 14, 488, 203, -1,
218, -1, 488, 218, -1, 218, -1, 218, 170, 482,
171, -1, 170, 479, 171, -1, -1, 488, -1, 478,
9, 488, -1, 478, 412, -1, 478, 9, 163, -1,
479, -1, 163, -1, -1, -1, 30, 488, -1, 482,
9, 483, 218, -1, 483, 218, -1, 482, 9, 483,
218, 97, 488, -1, 483, 218, 97, 488, -1, 46,
-1, 47, -1, -1, 86, 130, 488, -1, 229, 149,
218, 130, 488, -1, 485, 9, 484, -1, 484, -1,
485, 412, -1, -1, 174, 201, 486, 202, -1, 29,
488, -1, 55, 488, -1, 229, -1, 132, -1, 133,
-1, 487, -1, 132, 170, 488, 171, -1, 132, 170,
488, 9, 488, 171, -1, 154, -1, 201, 105, 201,
480, 202, 30, 488, 202, -1, 201, 488, 9, 478,
412, 202, -1, 488, -1, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 737, 737, 737, 746, 748, 751, 752, 753, 754,
755, 756, 757, 760, 762, 762, 764, 764, 766, 767,
769, 771, 776, 777, 778, 779, 780, 781, 782, 783,
784, 785, 786, 787, 788, 789, 790, 791, 792, 793,
794, 798, 800, 804, 806, 810, 812, 816, 817, 818,
819, 824, 825, 826, 827, 832, 833, 834, 835, 840,
841, 845, 846, 848, 851, 857, 864, 871, 875, 881,
883, 886, 887, 888, 889, 892, 893, 897, 902, 902,
908, 908, 915, 914, 920, 920, 925, 926, 927, 928,
929, 930, 931, 932, 933, 934, 935, 936, 937, 938,
942, 940, 949, 947, 954, 962, 956, 966, 964, 968,
969, 973, 974, 975, 976, 977, 978, 979, 980, 981,
982, 983, 991, 991, 996, 1002, 1006, 1006, 1014, 1015,
1019, 1020, 1024, 1029, 1028, 1041, 1039, 1053, 1051, 1067,
1066, 1075, 1073, 1085, 1084, 1103, 1101, 1120, 1119, 1128,
1126, 1138, 1137, 1149, 1147, 1160, 1161, 1165, 1168, 1171,
1172, 1173, 1176, 1177, 1180, 1182, 1185, 1186, 1189, 1190,
1193, 1194, 1198, 1199, 1204, 1205, 1208, 1209, 1210, 1214,
1215, 1219, 1220, 1224, 1225, 1229, 1230, 1235, 1236, 1241,
1242, 1243, 1244, 1247, 1250, 1252, 1255, 1256, 1260, 1262,
1265, 1268, 1271, 1272, 1275, 1276, 1280, 1286, 1292, 1299,
1301, 1306, 1311, 1317, 1321, 1325, 1329, 1334, 1339, 1344,
1349, 1355, 1364, 1369, 1374, 1380, 1382, 1386, 1390, 1395,
1399, 1402, 1405, 1409, 1413, 1417, 1421, 1426, 1434, 1436,
1439, 1440, 1441, 1442, 1444, 1446, 1451, 1452, 1455, 1456,
1457, 1461, 1462, 1464, 1465, 1469, 1471, 1474, 1478, 1484,
1486, 1489, 1489, 1493, 1492, 1496, 1500, 1498, 1513, 1510,
1523, 1525, 1527, 1529, 1531, 1533, 1535, 1539, 1540, 1541,
1544, 1550, 1553, 1559, 1562, 1567, 1569, 1574, 1579, 1583,
1584, 1590, 1591, 1593, 1597, 1598, 1603, 1604, 1608, 1609,
1613, 1615, 1621, 1626, 1627, 1629, 1633, 1634, 1635, 1636,
1640, 1641, 1642, 1643, 1644, 1645, 1647, 1652, 1655, 1656,
1660, 1661, 1665, 1666, 1669, 1670, 1673, 1674, 1677, 1678,
1682, 1683, 1684, 1685, 1686, 1687, 1688, 1692, 1693, 1696,
1697, 1698, 1701, 1703, 1705, 1706, 1709, 1711, 1716, 1717,
1719, 1720, 1721, 1724, 1728, 1729, 1733, 1734, 1738, 1739,
1740, 1744, 1748, 1753, 1757, 1761, 1766, 1767, 1768, 1769,
1770, 1774, 1776, 1777, 1778, 1781, 1782, 1783, 1784, 1785,
1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795,
1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805,
1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815,
1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1825, 1826,
1828, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838,
1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848,
1849, 1850, 1854, 1858, 1863, 1862, 1877, 1875, 1892, 1892,
1908, 1907, 1925, 1925, 1941, 1940, 1959, 1958, 1979, 1980,
1981, 1986, 1988, 1992, 1996, 2002, 2006, 2012, 2014, 2018,
2020, 2024, 2028, 2029, 2033, 2040, 2041, 2045, 2049, 2051,
2056, 2061, 2068, 2070, 2075, 2076, 2077, 2078, 2080, 2084,
2088, 2092, 2096, 2098, 2100, 2102, 2107, 2108, 2113, 2114,
2115, 2116, 2117, 2118, 2122, 2126, 2130, 2134, 2139, 2144,
2148, 2149, 2153, 2154, 2158, 2159, 2163, 2164, 2168, 2172,
2176, 2180, 2181, 2182, 2183, 2187, 2193, 2202, 2215, 2216,
2219, 2222, 2225, 2226, 2229, 2233, 2236, 2239, 2246, 2247,
2251, 2252, 2254, 2258, 2259, 2260, 2261, 2262, 2263, 2264,
2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274,
2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284,
2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294,
2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304,
2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314,
2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324,
2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2334,
2335, 2336, 2337, 2341, 2346, 2347, 2350, 2351, 2352, 2356,
2357, 2358, 2362, 2363, 2364, 2368, 2369, 2370, 2373, 2375,
2379, 2380, 2381, 2382, 2384, 2385, 2386, 2387, 2388, 2389,
2390, 2391, 2392, 2393, 2396, 2401, 2402, 2403, 2405, 2406,
2408, 2409, 2410, 2411, 2412, 2413, 2415, 2417, 2419, 2421,
2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432,
2433, 2434, 2435, 2436, 2437, 2438, 2439, 2441, 2443, 2445,
2447, 2448, 2451, 2452, 2456, 2458, 2462, 2465, 2468, 2474,
2475, 2476, 2477, 2478, 2479, 2480, 2485, 2487, 2491, 2492,
2495, 2496, 2500, 2503, 2505, 2507, 2511, 2512, 2513, 2514,
2516, 2519, 2523, 2524, 2525, 2526, 2529, 2530, 2531, 2532,
2533, 2535, 2536, 2541, 2543, 2546, 2549, 2551, 2553, 2556,
2558, 2562, 2564, 2567, 2570, 2576, 2578, 2581, 2582, 2587,
2590, 2594, 2594, 2599, 2602, 2603, 2607, 2608, 2612, 2613,
2614, 2618, 2619, 2623, 2624, 2628, 2629, 2633, 2634, 2638,
2639, 2644, 2646, 2651, 2652, 2653, 2654, 2655, 2656, 2658,
2661, 2664, 2666, 2668, 2672, 2673, 2674, 2675, 2676, 2679,
2683, 2685, 2689, 2690, 2691, 2695, 2699, 2700, 2704, 2707,
2714, 2718, 2722, 2729, 2730, 2735, 2737, 2738, 2741, 2742,
2745, 2746, 2750, 2751, 2755, 2756, 2757, 2760, 2763, 2766,
2769, 2770, 2771, 2774, 2778, 2782, 2783, 2784, 2786, 2787,
2788, 2792, 2794, 2797, 2799, 2800, 2801, 2802, 2805, 2807,
2808, 2812, 2814, 2817, 2819, 2820, 2821, 2825, 2827, 2830,
2833, 2835, 2837, 2841, 2843, 2846, 2848, 2851, 2853, 2856,
2857, 2861, 2863, 2866, 2868, 2871, 2874, 2878, 2880, 2884,
2885, 2887, 2888, 2894, 2895, 2897, 2899, 2901, 2903, 2906,
2907, 2908, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919,
2920, 2921, 2922, 2926, 2927, 2931, 2933, 2941, 2943, 2947,
2951, 2958, 2959, 2965, 2966, 2973, 2976, 2980, 2983, 2988,
2993, 2995, 2996, 2997, 3001, 3002, 3006, 3008, 3009, 3012,
3017, 3018, 3019, 3023, 3026, 3035, 3037, 3041, 3044, 3047,
3055, 3058, 3061, 3062, 3065, 3068, 3069, 3072, 3076, 3080,
3086, 3096, 3097
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "T_REQUIRE_ONCE", "T_REQUIRE", "T_EVAL",
"T_INCLUDE_ONCE", "T_INCLUDE", "T_LAMBDA_ARROW", "','", "T_LOGICAL_OR",
"T_LOGICAL_XOR", "T_LOGICAL_AND", "T_PRINT", "'='", "T_POW_EQUAL",
"T_SR_EQUAL", "T_SL_EQUAL", "T_XOR_EQUAL", "T_OR_EQUAL", "T_AND_EQUAL",
"T_MOD_EQUAL", "T_CONCAT_EQUAL", "T_DIV_EQUAL", "T_MUL_EQUAL",
"T_MINUS_EQUAL", "T_PLUS_EQUAL", "T_YIELD", "T_AWAIT", "'?'", "':'",
"T_BOOLEAN_OR", "T_BOOLEAN_AND", "'|'", "'^'", "'&'",
"T_IS_NOT_IDENTICAL", "T_IS_IDENTICAL", "T_IS_NOT_EQUAL", "T_IS_EQUAL",
"'<'", "'>'", "T_IS_GREATER_OR_EQUAL", "T_IS_SMALLER_OR_EQUAL", "T_SR",
"T_SL", "'+'", "'-'", "'.'", "'*'", "'/'", "'%'", "'!'", "T_INSTANCEOF",
"'~'", "'@'", "T_UNSET_CAST", "T_BOOL_CAST", "T_OBJECT_CAST",
"T_ARRAY_CAST", "T_STRING_CAST", "T_DOUBLE_CAST", "T_INT_CAST", "T_DEC",
"T_INC", "T_POW", "'['", "T_CLONE", "T_NEW", "T_EXIT", "T_IF",
"T_ELSEIF", "T_ELSE", "T_ENDIF", "T_LNUMBER", "T_DNUMBER", "T_ONUMBER",
"T_STRING", "T_STRING_VARNAME", "T_VARIABLE", "T_NUM_STRING",
"T_INLINE_HTML", "T_HASHBANG", "T_CHARACTER", "T_BAD_CHARACTER",
"T_ENCAPSED_AND_WHITESPACE", "T_CONSTANT_ENCAPSED_STRING", "T_ECHO",
"T_DO", "T_WHILE", "T_ENDWHILE", "T_FOR", "T_ENDFOR", "T_FOREACH",
"T_ENDFOREACH", "T_DECLARE", "T_ENDDECLARE", "T_AS", "T_SWITCH",
"T_ENDSWITCH", "T_CASE", "T_DEFAULT", "T_BREAK", "T_GOTO", "T_CONTINUE",
"T_FUNCTION", "T_CONST", "T_RETURN", "T_TRY", "T_CATCH", "T_THROW",
"T_USE", "T_GLOBAL", "T_PUBLIC", "T_PROTECTED", "T_PRIVATE", "T_FINAL",
"T_ABSTRACT", "T_STATIC", "T_VAR", "T_UNSET", "T_ISSET", "T_EMPTY",
"T_HALT_COMPILER", "T_CLASS", "T_INTERFACE", "T_EXTENDS", "T_IMPLEMENTS",
"T_OBJECT_OPERATOR", "T_NULLSAFE_OBJECT_OPERATOR", "T_DOUBLE_ARROW",
"T_LIST", "T_ARRAY", "T_CALLABLE", "T_CLASS_C", "T_METHOD_C", "T_FUNC_C",
"T_LINE", "T_FILE", "T_COMMENT", "T_DOC_COMMENT", "T_OPEN_TAG",
"T_OPEN_TAG_WITH_ECHO", "T_CLOSE_TAG", "T_WHITESPACE", "T_START_HEREDOC",
"T_END_HEREDOC", "T_DOLLAR_OPEN_CURLY_BRACES", "T_CURLY_OPEN",
"T_DOUBLE_COLON", "T_NAMESPACE", "T_NS_C", "T_DIR", "T_NS_SEPARATOR",
"T_XHP_LABEL", "T_XHP_TEXT", "T_XHP_ATTRIBUTE", "T_XHP_CATEGORY",
"T_XHP_CATEGORY_LABEL", "T_XHP_CHILDREN", "T_ENUM", "T_XHP_REQUIRED",
"T_TRAIT", "\"...\"", "T_INSTEADOF", "T_TRAIT_C", "T_HH_ERROR",
"T_FINALLY", "T_XHP_TAG_LT", "T_XHP_TAG_GT", "T_TYPELIST_LT",
"T_TYPELIST_GT", "T_UNRESOLVED_LT", "T_COLLECTION", "T_SHAPE",
"T_VARRAY", "T_MIARRAY", "T_MSARRAY", "T_TYPE", "T_UNRESOLVED_TYPE",
"T_NEWTYPE", "T_UNRESOLVED_NEWTYPE", "T_COMPILER_HALT_OFFSET", "T_ASYNC",
"T_FROM", "T_WHERE", "T_JOIN", "T_IN", "T_ON", "T_EQUALS", "T_INTO",
"T_LET", "T_ORDERBY", "T_ASCENDING", "T_DESCENDING", "T_SELECT",
"T_GROUP", "T_BY", "T_LAMBDA_OP", "T_LAMBDA_CP", "T_UNRESOLVED_OP",
"'('", "')'", "';'", "'{'", "'}'", "'$'", "'`'", "']'", "'\"'", "'\\''",
"$accept", "start", "$@1", "top_statement_list", "top_statement", "$@2",
"$@3", "ident", "use_declarations", "use_fn_declarations",
"use_const_declarations", "use_declaration", "use_fn_declaration",
"use_const_declaration", "namespace_name", "namespace_string_base",
"namespace_string", "namespace_string_typeargs",
"class_namespace_string_typeargs", "constant_declaration",
"inner_statement_list", "inner_statement", "statement", "$@4", "$@5",
"$@6", "$@7", "$@8", "$@9", "$@10", "$@11", "try_statement_list", "$@12",
"additional_catches", "finally_statement_list", "$@13",
"optional_finally", "is_reference", "function_loc",
"function_declaration_statement", "$@14", "$@15", "$@16",
"enum_declaration_statement", "$@17", "$@18",
"class_declaration_statement", "$@19", "$@20", "$@21", "$@22",
"trait_declaration_statement", "$@23", "$@24", "class_decl_name",
"interface_decl_name", "trait_decl_name", "class_entry_type",
"extends_from", "implements_list", "interface_extends_list",
"interface_list", "trait_list", "foreach_optional_arg",
"foreach_variable", "for_statement", "foreach_statement",
"while_statement", "declare_statement", "declare_list",
"switch_case_list", "case_list", "case_separator", "elseif_list",
"new_elseif_list", "else_single", "new_else_single",
"method_parameter_list", "non_empty_method_parameter_list",
"parameter_list", "non_empty_parameter_list",
"function_call_parameter_list", "non_empty_fcall_parameter_list",
"global_var_list", "global_var", "static_var_list",
"enum_statement_list", "enum_statement", "enum_constant_declaration",
"class_statement_list", "class_statement", "$@25", "$@26", "$@27",
"$@28", "trait_rules", "trait_precedence_rule", "trait_alias_rule",
"trait_alias_rule_method", "xhp_attribute_stmt", "xhp_attribute_decl",
"xhp_attribute_decl_type", "xhp_attribute_enum", "xhp_attribute_default",
"xhp_attribute_is_required", "xhp_category_stmt", "xhp_category_decl",
"xhp_children_stmt", "xhp_children_paren_expr", "xhp_children_decl_expr",
"xhp_children_decl_tag", "function_body", "method_body",
"variable_modifiers", "method_modifiers", "non_empty_member_modifiers",
"member_modifier", "parameter_modifiers", "parameter_modifier",
"class_variable_declaration", "class_constant_declaration",
"expr_with_parens", "parenthesis_expr", "expr_list", "for_expr",
"yield_expr", "yield_assign_expr", "yield_list_assign_expr",
"await_expr", "await_assign_expr", "await_list_assign_expr", "expr",
"expr_no_variable", "lambda_use_vars", "closure_expression", "$@29",
"$@30", "lambda_expression", "$@31", "$@32", "$@33", "$@34", "$@35",
"lambda_body", "shape_keyname", "non_empty_shape_pair_list",
"non_empty_static_shape_pair_list", "shape_pair_list",
"static_shape_pair_list", "shape_literal", "array_literal",
"collection_literal", "map_array_literal", "varray_literal",
"static_map_array_literal", "static_varray_literal",
"static_collection_literal", "dim_expr", "dim_expr_base", "query_expr",
"query_assign_expr", "query_head", "query_body", "query_body_clauses",
"query_body_clause", "from_clause", "let_clause", "where_clause",
"join_clause", "join_into_clause", "orderby_clause", "orderings",
"ordering", "ordering_direction", "select_or_group_clause",
"select_clause", "group_clause", "query_continuation",
"lexical_var_list", "xhp_tag", "xhp_tag_body", "xhp_opt_end_label",
"xhp_attributes", "xhp_children", "xhp_attribute_name",
"xhp_attribute_value", "xhp_child", "xhp_label_ws", "xhp_bareword",
"simple_function_call", "fully_qualified_class_name",
"static_class_name", "class_name_reference", "exit_expr",
"backticks_expr", "ctor_arguments", "common_scalar", "static_expr",
"static_class_constant", "scalar", "static_array_pair_list",
"possible_comma", "hh_possible_comma",
"non_empty_static_array_pair_list", "common_scalar_ae",
"static_numeric_scalar_ae", "static_scalar_ae",
"static_array_pair_list_ae", "non_empty_static_array_pair_list_ae",
"non_empty_static_scalar_list_ae", "static_shape_pair_list_ae",
"non_empty_static_shape_pair_list_ae", "static_scalar_list_ae",
"attribute_static_scalar_list", "non_empty_user_attribute_list",
"user_attribute_list", "$@36", "non_empty_user_attributes",
"optional_user_attributes", "object_operator",
"object_property_name_no_variables", "object_property_name",
"object_method_name_no_variables", "object_method_name", "array_access",
"dimmable_variable_access", "dimmable_variable_no_calls_access",
"variable", "dimmable_variable", "callable_variable",
"lambda_or_closure_with_parens", "lambda_or_closure",
"object_method_call", "class_method_call", "variable_no_objects",
"reference_variable", "compound_variable", "dim_offset",
"simple_indirect_reference", "variable_no_calls",
"dimmable_variable_no_calls", "assignment_list", "array_pair_list",
"non_empty_array_pair_list", "collection_init",
"non_empty_collection_init", "static_collection_init",
"non_empty_static_collection_init", "map_array_init", "varray_init",
"non_empty_map_array_init", "non_empty_varray_init",
"static_map_array_init", "static_varray_init",
"non_empty_static_map_array_init", "non_empty_static_varray_init",
"encaps_list", "encaps_var", "encaps_var_offset", "internal_functions",
"variable_list", "class_constant", "hh_opt_constraint",
"hh_type_alias_statement", "hh_name_with_type", "hh_name_with_typevar",
"hh_typeargs_opt", "hh_non_empty_type_list", "hh_type_list",
"hh_func_type_list", "hh_opt_return_type", "hh_typevar_list",
"hh_typevar_variance", "hh_shape_member_type",
"hh_non_empty_shape_member_list", "hh_shape_member_list",
"hh_shape_type", "hh_type", "hh_type_opt", 0
};
#endif
# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
token YYLEX-NUM. */
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 44,
264, 265, 266, 267, 61, 268, 269, 270, 271, 272,
273, 274, 275, 276, 277, 278, 279, 280, 281, 63,
58, 282, 283, 124, 94, 38, 284, 285, 286, 287,
60, 62, 288, 289, 290, 291, 43, 45, 46, 42,
47, 37, 33, 292, 126, 64, 293, 294, 295, 296,
297, 298, 299, 300, 301, 302, 91, 303, 304, 305,
306, 307, 308, 309, 310, 311, 312, 313, 314, 315,
316, 317, 318, 319, 320, 321, 322, 323, 324, 325,
326, 327, 328, 329, 330, 331, 332, 333, 334, 335,
336, 337, 338, 339, 340, 341, 342, 343, 344, 345,
346, 347, 348, 349, 350, 351, 352, 353, 354, 355,
356, 357, 358, 359, 360, 361, 362, 363, 364, 365,
366, 367, 368, 369, 370, 371, 372, 373, 374, 375,
376, 377, 378, 379, 380, 381, 382, 383, 384, 385,
386, 387, 388, 389, 390, 391, 392, 393, 394, 395,
396, 397, 398, 399, 400, 401, 402, 403, 404, 405,
406, 407, 408, 409, 410, 411, 412, 413, 414, 415,
416, 417, 418, 419, 420, 421, 422, 423, 424, 425,
426, 427, 428, 429, 430, 431, 432, 433, 434, 435,
436, 40, 41, 59, 123, 125, 36, 96, 93, 34,
39
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint16 yyr1[] =
{
0, 211, 213, 212, 214, 214, 215, 215, 215, 215,
215, 215, 215, 215, 216, 215, 217, 215, 215, 215,
215, 215, 218, 218, 218, 218, 218, 218, 218, 218,
218, 218, 218, 218, 218, 218, 218, 218, 218, 218,
218, 219, 219, 220, 220, 221, 221, 222, 222, 222,
222, 223, 223, 223, 223, 224, 224, 224, 224, 225,
225, 226, 226, 226, 227, 228, 229, 230, 230, 231,
231, 232, 232, 232, 232, 233, 233, 233, 234, 233,
235, 233, 236, 233, 237, 233, 233, 233, 233, 233,
233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
238, 233, 239, 233, 233, 240, 233, 241, 233, 233,
233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
233, 233, 243, 242, 244, 244, 246, 245, 247, 247,
248, 248, 249, 251, 250, 252, 250, 253, 250, 255,
254, 256, 254, 258, 257, 259, 257, 260, 257, 261,
257, 263, 262, 264, 262, 265, 265, 266, 267, 268,
268, 268, 268, 268, 269, 269, 270, 270, 271, 271,
272, 272, 273, 273, 274, 274, 275, 275, 275, 276,
276, 277, 277, 278, 278, 279, 279, 280, 280, 281,
281, 281, 281, 282, 282, 282, 283, 283, 284, 284,
285, 285, 286, 286, 287, 287, 288, 288, 288, 288,
288, 288, 288, 288, 289, 289, 289, 289, 289, 289,
289, 289, 290, 290, 290, 290, 290, 290, 290, 290,
291, 291, 291, 291, 291, 291, 291, 291, 292, 292,
293, 293, 293, 293, 293, 293, 294, 294, 295, 295,
295, 296, 296, 296, 296, 297, 297, 298, 299, 300,
300, 302, 301, 303, 301, 301, 304, 301, 305, 301,
301, 301, 301, 301, 301, 301, 301, 306, 306, 306,
307, 308, 308, 309, 309, 310, 310, 311, 311, 312,
312, 312, 312, 312, 313, 313, 314, 314, 315, 315,
316, 316, 317, 318, 318, 318, 319, 319, 319, 319,
320, 320, 320, 320, 320, 320, 320, 321, 321, 321,
322, 322, 323, 323, 324, 324, 325, 325, 326, 326,
327, 327, 327, 327, 327, 327, 327, 328, 328, 329,
329, 329, 330, 330, 330, 330, 331, 331, 332, 332,
332, 332, 332, 333, 334, 334, 335, 335, 336, 336,
336, 337, 338, 339, 340, 341, 342, 342, 342, 342,
342, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 344, 344, 346, 345, 347, 345, 349, 348,
350, 348, 351, 348, 352, 348, 353, 348, 354, 354,
354, 355, 355, 356, 356, 357, 357, 358, 358, 359,
359, 360, 361, 361, 362, 363, 363, 364, 365, 365,
366, 367, 368, 368, 369, 369, 369, 369, 369, 370,
371, 372, 373, 373, 373, 373, 374, 374, 375, 375,
375, 375, 375, 375, 376, 377, 378, 379, 380, 381,
382, 382, 383, 383, 384, 384, 385, 385, 386, 387,
388, 389, 389, 389, 389, 390, 391, 391, 392, 392,
393, 393, 394, 394, 395, 396, 396, 397, 397, 397,
398, 398, 398, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
399, 399, 399, 400, 401, 401, 402, 402, 402, 403,
403, 403, 404, 404, 404, 405, 405, 405, 406, 406,
407, 407, 407, 407, 407, 407, 407, 407, 407, 407,
407, 407, 407, 407, 407, 408, 408, 408, 408, 408,
408, 408, 408, 408, 408, 408, 408, 408, 408, 408,
408, 408, 408, 408, 408, 408, 408, 408, 408, 408,
408, 408, 408, 408, 408, 408, 408, 408, 408, 408,
408, 408, 408, 408, 408, 408, 409, 409, 409, 410,
410, 410, 410, 410, 410, 410, 411, 411, 412, 412,
413, 413, 414, 414, 414, 414, 415, 415, 415, 415,
415, 415, 416, 416, 416, 416, 417, 417, 417, 417,
417, 417, 417, 418, 418, 419, 419, 419, 419, 420,
420, 421, 421, 422, 422, 423, 423, 424, 424, 425,
425, 427, 426, 428, 429, 429, 430, 430, 431, 431,
431, 432, 432, 433, 433, 434, 434, 435, 435, 436,
436, 437, 437, 438, 438, 438, 438, 438, 438, 438,
438, 438, 438, 438, 439, 439, 439, 439, 439, 439,
439, 439, 440, 440, 440, 441, 442, 442, 443, 443,
444, 444, 444, 445, 445, 446, 446, 446, 447, 447,
448, 448, 449, 449, 450, 450, 450, 450, 450, 450,
451, 451, 451, 451, 451, 452, 452, 452, 452, 452,
452, 453, 453, 454, 454, 454, 454, 454, 454, 454,
454, 455, 455, 456, 456, 456, 456, 457, 457, 458,
458, 458, 458, 459, 459, 460, 460, 461, 461, 462,
462, 463, 463, 464, 464, 465, 465, 466, 466, 467,
467, 467, 467, 468, 468, 468, 468, 468, 468, 469,
469, 469, 470, 470, 470, 470, 470, 470, 470, 470,
470, 470, 470, 471, 471, 472, 472, 473, 473, 474,
474, 475, 475, 476, 476, 477, 477, 478, 478, 479,
480, 480, 480, 480, 481, 481, 482, 482, 482, 482,
483, 483, 483, 484, 484, 485, 485, 486, 486, 487,
488, 488, 488, 488, 488, 488, 488, 488, 488, 488,
488, 489, 489
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 0, 2, 2, 0, 1, 1, 1, 1,
1, 1, 4, 3, 0, 6, 0, 5, 3, 4,
4, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 3, 1, 3, 1, 3, 1, 1, 2, 3,
4, 1, 2, 3, 4, 1, 2, 3, 4, 1,
3, 1, 3, 2, 1, 2, 2, 5, 4, 2,
0, 1, 1, 1, 1, 3, 5, 8, 0, 4,
0, 6, 0, 10, 0, 4, 2, 3, 2, 3,
2, 3, 3, 3, 3, 3, 5, 1, 1, 1,
0, 9, 0, 10, 5, 0, 13, 0, 5, 3,
3, 2, 2, 2, 2, 2, 2, 3, 2, 2,
3, 2, 0, 4, 9, 0, 0, 4, 2, 0,
1, 0, 1, 0, 9, 0, 10, 0, 11, 0,
9, 0, 10, 0, 8, 0, 9, 0, 7, 0,
8, 0, 7, 0, 8, 1, 1, 1, 1, 1,
2, 3, 3, 2, 2, 0, 2, 0, 2, 0,
1, 3, 1, 3, 2, 0, 1, 2, 4, 1,
4, 1, 4, 1, 4, 1, 4, 3, 5, 3,
4, 4, 5, 5, 4, 0, 1, 1, 4, 0,
5, 0, 2, 0, 3, 0, 7, 8, 6, 2,
5, 6, 4, 0, 4, 5, 7, 6, 6, 7,
9, 8, 6, 7, 5, 2, 4, 5, 3, 0,
3, 4, 6, 5, 5, 6, 8, 7, 2, 0,
1, 2, 2, 3, 4, 4, 3, 1, 1, 2,
4, 3, 5, 1, 3, 2, 0, 2, 3, 2,
0, 0, 4, 0, 5, 2, 0, 10, 0, 11,
3, 3, 3, 4, 4, 3, 5, 2, 2, 0,
6, 5, 4, 3, 1, 1, 3, 4, 1, 1,
1, 1, 4, 1, 1, 3, 2, 0, 2, 0,
1, 3, 1, 1, 1, 1, 3, 4, 4, 4,
1, 1, 2, 2, 2, 3, 3, 1, 1, 1,
1, 3, 1, 3, 1, 1, 1, 0, 1, 2,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1, 1, 3, 5, 1, 3, 5, 4, 3, 3,
2, 1, 1, 3, 3, 1, 1, 0, 1, 2,
4, 3, 6, 2, 3, 6, 1, 1, 1, 1,
1, 6, 3, 4, 6, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 2, 2,
2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 5, 4, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 1, 1, 1, 1, 1, 3,
2, 1, 5, 0, 0, 11, 0, 12, 0, 3,
0, 4, 0, 6, 0, 7, 0, 5, 2, 2,
4, 1, 1, 5, 3, 5, 3, 2, 0, 2,
0, 4, 4, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 1, 1, 1, 1, 3, 2,
3, 4, 2, 3, 1, 2, 1, 2, 1, 1,
1, 1, 1, 1, 4, 4, 2, 8, 10, 2,
1, 3, 1, 2, 1, 1, 1, 1, 2, 4,
3, 3, 4, 1, 2, 4, 2, 6, 0, 1,
4, 0, 2, 0, 1, 1, 3, 1, 3, 1,
1, 3, 3, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 4, 1, 1, 1, 1, 1, 1,
1, 1, 2, 1, 0, 0, 1, 1, 3, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 3, 2, 1, 1, 4, 3, 4,
1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 2, 2, 2, 2, 3, 3, 3, 3,
3, 3, 3, 3, 5, 4, 3, 3, 3, 1,
1, 1, 1, 3, 3, 3, 2, 0, 1, 0,
1, 0, 5, 3, 3, 1, 1, 1, 1, 1,
3, 2, 1, 1, 1, 1, 1, 1, 2, 2,
4, 3, 4, 2, 0, 5, 3, 3, 1, 3,
1, 2, 0, 5, 3, 2, 0, 3, 0, 4,
2, 0, 3, 3, 1, 0, 1, 1, 1, 1,
3, 1, 1, 1, 3, 1, 1, 3, 3, 2,
4, 2, 4, 1, 1, 1, 1, 1, 3, 5,
3, 4, 4, 3, 1, 1, 1, 1, 3, 5,
4, 3, 1, 1, 3, 3, 1, 1, 7, 9,
7, 6, 8, 1, 2, 4, 4, 1, 1, 4,
1, 0, 1, 2, 1, 1, 3, 5, 3, 3,
0, 1, 3, 5, 3, 2, 3, 6, 0, 1,
4, 2, 0, 5, 3, 3, 1, 6, 4, 4,
2, 2, 0, 5, 3, 3, 1, 2, 0, 5,
3, 3, 1, 2, 0, 2, 0, 5, 3, 3,
1, 2, 0, 2, 0, 5, 3, 3, 1, 2,
2, 1, 2, 1, 4, 3, 3, 6, 3, 1,
1, 1, 4, 4, 4, 4, 4, 4, 2, 2,
4, 2, 2, 1, 3, 3, 3, 0, 2, 5,
6, 1, 2, 1, 4, 3, 0, 1, 3, 2,
3, 1, 1, 0, 0, 2, 4, 2, 6, 4,
1, 1, 0, 3, 5, 3, 1, 2, 0, 4,
2, 2, 1, 1, 1, 1, 4, 6, 1, 8,
6, 1, 0
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */
static const yytype_uint16 yydefact[] =
{
2, 0, 5, 1, 3, 0, 0, 0, 0, 0,
0, 358, 0, 751, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 832, 0,
820, 634, 0, 640, 641, 642, 22, 700, 808, 98,
99, 643, 0, 80, 0, 0, 0, 0, 0, 0,
0, 0, 132, 0, 0, 0, 0, 0, 0, 330,
331, 332, 335, 334, 333, 0, 0, 0, 0, 159,
0, 0, 0, 647, 649, 650, 644, 645, 0, 0,
651, 646, 0, 625, 23, 24, 25, 27, 26, 0,
648, 0, 0, 0, 0, 0, 0, 0, 652, 336,
28, 29, 31, 30, 32, 33, 34, 35, 36, 37,
38, 39, 40, 452, 0, 97, 70, 812, 635, 0,
0, 4, 59, 61, 64, 699, 0, 624, 0, 6,
131, 7, 9, 8, 10, 0, 0, 328, 368, 0,
0, 0, 0, 0, 0, 0, 366, 796, 797, 436,
435, 352, 437, 438, 441, 0, 0, 351, 774, 626,
0, 702, 434, 327, 777, 367, 0, 0, 370, 369,
775, 776, 773, 803, 807, 0, 424, 701, 11, 335,
334, 333, 0, 0, 27, 59, 131, 0, 892, 367,
891, 0, 889, 888, 440, 0, 359, 363, 0, 0,
408, 409, 410, 411, 433, 431, 430, 429, 428, 427,
426, 425, 808, 627, 0, 906, 626, 0, 390, 0,
388, 0, 836, 0, 709, 350, 630, 0, 906, 629,
0, 639, 815, 814, 631, 0, 0, 633, 432, 0,
0, 0, 0, 355, 0, 78, 357, 0, 0, 84,
86, 0, 0, 88, 0, 0, 0, 933, 934, 938,
0, 0, 59, 932, 0, 935, 0, 0, 90, 0,
0, 0, 0, 122, 0, 0, 0, 0, 0, 0,
42, 47, 248, 0, 0, 247, 0, 163, 0, 160,
253, 0, 0, 0, 0, 0, 903, 147, 157, 828,
832, 873, 0, 654, 0, 0, 0, 871, 0, 16,
0, 63, 139, 151, 158, 531, 468, 856, 854, 854,
0, 897, 450, 454, 456, 755, 368, 0, 366, 367,
369, 0, 0, 636, 0, 637, 0, 0, 0, 121,
0, 0, 66, 239, 0, 21, 130, 0, 156, 143,
155, 333, 336, 131, 329, 112, 113, 114, 115, 116,
118, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 820, 0, 111, 811,
811, 119, 842, 0, 0, 0, 0, 0, 0, 326,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 389, 387, 756, 757, 0, 811, 0,
769, 239, 239, 811, 0, 813, 804, 828, 0, 131,
0, 0, 92, 0, 753, 748, 709, 0, 0, 0,
0, 0, 840, 0, 473, 708, 831, 0, 0, 66,
0, 239, 349, 0, 771, 632, 0, 70, 199, 0,
449, 0, 95, 0, 0, 356, 0, 0, 0, 0,
0, 87, 110, 89, 930, 931, 0, 928, 0, 0,
0, 902, 0, 117, 91, 120, 0, 0, 0, 0,
0, 0, 0, 489, 0, 496, 498, 499, 500, 501,
502, 503, 494, 516, 517, 70, 0, 107, 109, 0,
0, 44, 51, 0, 0, 46, 55, 48, 0, 18,
0, 0, 249, 0, 93, 162, 161, 0, 0, 94,
893, 0, 0, 368, 366, 367, 370, 369, 0, 922,
169, 0, 829, 0, 0, 0, 0, 653, 872, 700,
0, 0, 870, 705, 869, 62, 5, 13, 14, 0,
167, 0, 0, 461, 0, 0, 709, 0, 0, 628,
462, 860, 0, 709, 0, 0, 709, 0, 0, 0,
0, 0, 755, 70, 0, 711, 754, 942, 348, 421,
783, 795, 75, 69, 71, 72, 73, 74, 327, 0,
439, 703, 704, 60, 709, 0, 907, 0, 0, 0,
711, 240, 0, 444, 133, 165, 0, 393, 395, 394,
0, 0, 391, 392, 396, 398, 397, 413, 412, 415,
414, 416, 418, 419, 417, 407, 406, 400, 401, 399,
402, 403, 405, 420, 404, 810, 0, 0, 846, 0,
709, 896, 0, 895, 780, 803, 149, 141, 153, 145,
131, 358, 0, 361, 364, 372, 490, 386, 385, 384,
383, 382, 381, 380, 379, 378, 377, 376, 375, 759,
0, 758, 761, 778, 765, 906, 762, 0, 0, 0,
0, 0, 0, 0, 0, 890, 360, 746, 750, 708,
752, 0, 0, 906, 0, 835, 0, 834, 0, 819,
818, 0, 0, 758, 761, 816, 762, 353, 201, 203,
70, 459, 458, 354, 0, 70, 183, 79, 357, 0,
0, 0, 0, 0, 195, 195, 85, 0, 0, 0,
926, 709, 0, 913, 0, 0, 0, 0, 0, 707,
643, 0, 0, 625, 0, 0, 0, 0, 0, 64,
656, 624, 662, 663, 661, 0, 655, 68, 660, 0,
0, 506, 0, 0, 512, 509, 510, 518, 0, 497,
492, 0, 495, 0, 0, 0, 52, 19, 0, 0,
56, 20, 0, 0, 0, 41, 49, 0, 246, 254,
251, 0, 0, 882, 887, 884, 883, 886, 885, 12,
920, 921, 0, 0, 0, 0, 828, 825, 0, 472,
881, 880, 879, 0, 875, 0, 876, 878, 0, 5,
0, 0, 0, 525, 526, 534, 533, 0, 0, 708,
467, 471, 0, 477, 708, 855, 0, 475, 708, 853,
476, 0, 898, 0, 451, 0, 0, 914, 755, 225,
941, 0, 0, 770, 809, 708, 909, 905, 241, 242,
623, 710, 238, 0, 755, 0, 0, 167, 446, 135,
423, 0, 482, 483, 0, 474, 708, 841, 0, 0,
239, 169, 0, 167, 165, 0, 820, 373, 0, 0,
767, 768, 781, 782, 805, 806, 0, 0, 0, 734,
716, 717, 718, 719, 0, 0, 0, 727, 726, 740,
709, 0, 748, 839, 838, 0, 0, 772, 638, 0,
205, 0, 0, 76, 0, 0, 0, 0, 0, 0,
0, 175, 176, 187, 0, 70, 185, 104, 195, 0,
195, 0, 0, 936, 0, 0, 708, 927, 929, 912,
709, 911, 0, 709, 684, 685, 682, 683, 715, 0,
709, 707, 0, 0, 470, 864, 862, 862, 0, 0,
848, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 491, 0, 0,
0, 514, 515, 513, 0, 0, 493, 0, 123, 0,
126, 108, 0, 43, 53, 0, 45, 57, 50, 250,
0, 894, 96, 922, 904, 917, 168, 170, 260, 0,
0, 826, 0, 874, 0, 17, 0, 897, 166, 260,
0, 0, 464, 0, 895, 859, 858, 0, 899, 0,
914, 457, 0, 0, 942, 0, 230, 228, 761, 779,
906, 908, 0, 0, 243, 67, 0, 755, 164, 0,
755, 0, 422, 845, 844, 0, 239, 0, 0, 0,
0, 167, 137, 639, 760, 239, 0, 722, 723, 724,
725, 728, 729, 738, 0, 709, 734, 0, 721, 742,
708, 745, 747, 749, 0, 833, 761, 817, 760, 0,
0, 0, 0, 202, 460, 81, 0, 357, 175, 177,
828, 0, 0, 0, 0, 0, 0, 0, 0, 0,
189, 0, 923, 0, 925, 708, 0, 0, 0, 658,
708, 706, 0, 697, 0, 709, 0, 868, 0, 709,
0, 0, 709, 0, 664, 698, 696, 852, 0, 709,
667, 669, 668, 0, 0, 665, 666, 670, 672, 671,
687, 686, 689, 688, 690, 692, 693, 691, 680, 679,
674, 675, 673, 676, 677, 678, 681, 504, 0, 505,
511, 519, 520, 0, 70, 54, 58, 252, 0, 0,
0, 327, 830, 828, 362, 365, 371, 0, 15, 0,
327, 537, 0, 0, 539, 532, 535, 0, 530, 0,
0, 900, 0, 915, 453, 0, 231, 0, 0, 226,
0, 245, 244, 914, 0, 260, 0, 755, 0, 239,
0, 801, 260, 897, 260, 0, 0, 374, 0, 0,
731, 708, 733, 0, 720, 0, 0, 709, 739, 837,
0, 70, 0, 198, 184, 0, 0, 0, 174, 100,
188, 0, 0, 191, 0, 196, 197, 70, 190, 937,
0, 910, 0, 940, 714, 713, 657, 0, 708, 469,
659, 480, 708, 863, 0, 478, 708, 861, 479, 0,
481, 708, 847, 695, 0, 0, 0, 0, 916, 919,
171, 0, 0, 0, 325, 0, 0, 0, 148, 259,
261, 0, 324, 0, 327, 0, 877, 256, 152, 528,
0, 0, 463, 857, 455, 0, 234, 224, 0, 227,
233, 239, 443, 914, 327, 914, 0, 843, 0, 800,
327, 0, 327, 260, 755, 798, 737, 736, 730, 0,
732, 708, 741, 70, 204, 77, 82, 102, 178, 0,
186, 192, 70, 194, 924, 0, 0, 466, 0, 867,
866, 0, 851, 850, 694, 0, 70, 127, 0, 0,
0, 0, 0, 172, 291, 289, 293, 625, 27, 0,
285, 0, 290, 302, 0, 300, 305, 0, 304, 0,
303, 0, 131, 263, 0, 265, 0, 827, 0, 529,
527, 538, 536, 235, 0, 0, 222, 232, 0, 0,
0, 0, 144, 443, 914, 802, 150, 256, 154, 327,
0, 0, 744, 0, 200, 0, 0, 70, 181, 101,
193, 939, 712, 0, 0, 0, 0, 0, 918, 0,
0, 0, 0, 275, 279, 0, 0, 270, 589, 588,
585, 587, 586, 606, 608, 607, 577, 548, 549, 567,
583, 582, 544, 554, 555, 557, 556, 576, 560, 558,
559, 561, 562, 563, 564, 565, 566, 568, 569, 570,
571, 572, 573, 575, 574, 545, 546, 547, 550, 551,
553, 591, 592, 601, 600, 599, 598, 597, 596, 584,
603, 593, 594, 595, 578, 579, 580, 581, 604, 605,
609, 611, 610, 612, 613, 590, 615, 614, 617, 619,
618, 552, 622, 620, 621, 616, 602, 543, 297, 540,
0, 271, 318, 319, 317, 310, 0, 311, 272, 344,
0, 0, 0, 0, 131, 140, 255, 0, 0, 0,
223, 237, 799, 0, 70, 320, 70, 134, 0, 0,
0, 146, 914, 735, 0, 70, 179, 83, 103, 0,
465, 865, 849, 507, 125, 273, 274, 347, 173, 0,
0, 294, 286, 0, 0, 0, 299, 301, 0, 0,
306, 313, 314, 312, 0, 0, 262, 0, 0, 0,
0, 257, 0, 236, 0, 523, 711, 0, 0, 70,
136, 142, 0, 743, 0, 0, 0, 105, 276, 59,
0, 277, 278, 0, 0, 292, 296, 541, 542, 0,
287, 315, 316, 308, 309, 307, 345, 342, 266, 264,
346, 0, 258, 524, 710, 0, 445, 321, 0, 138,
0, 182, 508, 0, 129, 0, 327, 295, 298, 0,
755, 268, 0, 521, 442, 447, 180, 0, 0, 106,
283, 0, 326, 343, 0, 711, 338, 755, 522, 0,
128, 0, 0, 282, 914, 755, 209, 339, 340, 341,
942, 337, 0, 0, 0, 281, 0, 338, 0, 914,
0, 280, 322, 70, 267, 942, 0, 214, 212, 0,
70, 0, 0, 215, 0, 0, 210, 269, 0, 323,
0, 218, 208, 0, 211, 217, 124, 219, 0, 0,
206, 216, 0, 207, 221, 220
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
-1, 1, 2, 4, 121, 829, 556, 185, 279, 510,
514, 280, 511, 515, 123, 124, 125, 126, 127, 128,
331, 593, 594, 464, 244, 1455, 470, 1379, 1456, 1684,
785, 274, 505, 1647, 1021, 1204, 1699, 347, 186, 595,
875, 1081, 1256, 132, 559, 892, 596, 615, 894, 540,
891, 597, 560, 893, 349, 297, 313, 135, 877, 832,
815, 1036, 1402, 1132, 941, 1597, 1459, 727, 947, 469,
736, 949, 1287, 719, 930, 933, 1121, 1704, 1705, 584,
585, 609, 610, 284, 285, 291, 1428, 1576, 1577, 1211,
1329, 1421, 1572, 1690, 1707, 1609, 1651, 1652, 1653, 1409,
1410, 1411, 1610, 1616, 1660, 1414, 1415, 1419, 1565, 1566,
1567, 1587, 1734, 1330, 1331, 187, 137, 1720, 1721, 1570,
1333, 138, 237, 465, 466, 139, 140, 141, 142, 143,
144, 145, 146, 1440, 147, 874, 1080, 148, 241, 581,
325, 582, 583, 460, 565, 566, 1155, 567, 1156, 149,
150, 151, 152, 153, 762, 763, 764, 154, 155, 271,
156, 272, 493, 494, 495, 496, 497, 498, 499, 500,
501, 775, 776, 1013, 502, 503, 504, 782, 1636, 157,
561, 1430, 562, 1050, 837, 1228, 1225, 1558, 1559, 158,
159, 160, 231, 238, 334, 452, 161, 968, 768, 162,
969, 866, 859, 970, 918, 1101, 1103, 1104, 1105, 920,
1266, 1267, 921, 698, 436, 198, 199, 598, 587, 417,
682, 683, 684, 685, 863, 164, 232, 189, 166, 167,
168, 169, 170, 171, 172, 173, 174, 646, 175, 234,
235, 543, 223, 224, 649, 650, 1168, 1169, 575, 572,
576, 573, 1161, 1158, 1162, 1159, 306, 307, 823, 176,
531, 177, 580, 178, 1578, 298, 342, 604, 605, 962,
1063, 812, 813, 740, 741, 742, 265, 266, 861
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
#define YYPACT_NINF -1484
static const yytype_int16 yypact[] =
{
-1484, 134, -1484, -1484, 5638, 13332, 13332, -62, 13332, 13332,
13332, 11420, 13332, -1484, 13332, 13332, 13332, 13332, 13332, 13332,
13332, 13332, 13332, 13332, 13332, 13332, 15340, 15340, 11628, 13332,
15406, -60, -56, -1484, -1484, -1484, -1484, -1484, 141, -1484,
-1484, 88, 13332, -1484, -56, -41, 132, 181, -56, 11794,
13001, 11960, -1484, 14472, 10422, 183, 13332, 14730, 103, -1484,
-1484, -1484, 349, 20, 24, 208, 214, 218, 225, -1484,
13001, 246, 254, -1484, -1484, -1484, -1484, -1484, 410, 1695,
-1484, -1484, 13001, -1484, -1484, -1484, -1484, 13001, -1484, 13001,
-1484, 164, 276, 278, 290, 295, 13001, 13001, -1484, 170,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, 13332, -1484, -1484, 266, 36, 365,
365, -1484, 201, 402, 229, -1484, 361, -1484, 30, -1484,
529, -1484, -1484, -1484, -1484, 16044, 370, -1484, -1484, 372,
383, 385, 387, 390, 441, 2169, -1484, -1484, -1484, -1484,
502, -1484, -1484, -1484, 579, 608, 474, -1484, 101, 465,
532, -1484, -1484, 621, 121, 2018, 112, 477, 23, -1484,
119, 120, 482, 39, -1484, 140, -1484, 618, -1484, -1484,
-1484, 536, 488, 538, -1484, -1484, 529, 370, 16426, 2297,
16426, 13332, 16426, 16426, 10613, 489, 15026, 10613, 653, 13001,
633, 633, 359, 633, 633, 633, 633, 633, 633, 633,
633, 633, -1484, -1484, 14535, 534, -1484, 557, -2, 506,
-2, 15340, 15617, 504, 704, -1484, 536, 14974, 534, 570,
574, 523, 124, -1484, -2, 112, 12126, -1484, -1484, 13332,
9174, 717, 56, 16426, 10214, -1484, 13332, 13332, 13001, -1484,
-1484, 13929, 530, -1484, 13973, 14472, 14472, 556, -1484, -1484,
539, 4729, 727, -1484, 729, -1484, 13001, 663, -1484, 547,
14017, 548, 728, -1484, -14, 14061, 16109, 16122, 13001, 60,
-1484, 17, -1484, 15115, 61, -1484, 628, -1484, 630, -1484,
748, 67, 15340, 15340, 13332, 563, 593, -1484, -1484, 15200,
11628, 391, 382, -1484, 13498, 15340, 492, -1484, 13001, -1484,
346, 402, -1484, -1484, -1484, -1484, 15429, 13332, 13332, 13332,
752, 670, -1484, -1484, -1484, 26, 568, 16426, 571, 2097,
572, 5846, 13332, 292, 565, 448, 292, 284, 253, -1484,
13001, 14472, 575, 10630, 14472, -1484, -1484, 11463, -1484, -1484,
-1484, -1484, -1484, 529, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, 13332, 13332, 13332, 12334, 13332, 13332, 13332, 13332, 13332,
13332, 13332, 13332, 13332, 13332, 13332, 13332, 13332, 13332, 13332,
13332, 13332, 13332, 13332, 13332, 13332, 15406, 13332, -1484, 13332,
13332, -1484, 13332, 3536, 13001, 13001, 13001, 16044, 673, 466,
4996, 13332, 13332, 13332, 13332, 13332, 13332, 13332, 13332, 13332,
13332, 13332, 13332, -1484, -1484, -1484, -1484, 2889, 13332, 13332,
-1484, 10630, 10630, 13332, 13332, 266, 154, 15200, 583, 529,
12542, 14105, -1484, 13332, -1484, 585, 771, 14535, 589, -10,
572, 4801, -2, 12750, -1484, 12958, -1484, 590, 256, -1484,
250, 10630, -1484, 3959, -1484, -1484, 14149, -1484, -1484, 10838,
-1484, 13332, -1484, 705, 9382, 784, 592, 16337, 782, 55,
22, -1484, -1484, -1484, -1484, -1484, 14472, 4212, 599, 794,
14826, -1484, 619, -1484, -1484, -1484, 726, 13332, 732, 733,
13332, 13332, 13332, -1484, 728, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, 626, -1484, -1484, -1484, 607, -1484, -1484, 13001,
614, 809, 27, 13001, 617, 812, 269, 275, 16167, -1484,
13001, 13332, -2, 103, -1484, -1484, -1484, 14826, 749, -1484,
-2, 58, 77, 627, 631, 2851, 113, 632, 634, 456,
714, 640, -2, 81, 643, 1997, 13001, -1484, -1484, 778,
1959, 224, -1484, -1484, -1484, 402, -1484, -1484, -1484, 816,
721, 681, 299, -1484, 266, 724, 842, 654, 708, 154,
-1484, 16426, 659, 853, 15661, 662, 859, 667, 14472, 14472,
857, 717, 26, -1484, 674, 866, -1484, 14472, 43, 810,
155, -1484, -1484, -1484, -1484, -1484, -1484, -1484, 511, 2898,
-1484, -1484, -1484, -1484, 869, 711, -1484, 15340, 13332, 682,
876, 16426, 872, -1484, -1484, 761, 12377, 11029, 16552, 10613,
13332, 16382, 2789, 2401, 3092, 16623, 3268, 12312, 12312, 12312,
12312, 2484, 2484, 2484, 2484, 917, 917, 603, 603, 603,
359, 359, 359, -1484, 633, 16426, 680, 684, 15717, 685,
880, -1484, 13332, -58, 694, 154, -1484, -1484, -1484, -1484,
529, 13332, 15061, -1484, -1484, 10613, -1484, 10613, 10613, 10613,
10613, 10613, 10613, 10613, 10613, 10613, 10613, 10613, 10613, -1484,
13332, -53, 157, -1484, -1484, 534, -45, 692, 3238, 699,
700, 707, 3348, 87, 706, -1484, 16426, 14958, -1484, 13001,
-1484, 568, 43, 534, 15340, 16426, 15340, 15761, 43, 163,
-1484, 716, 13332, -1484, 166, -1484, -1484, -1484, 8966, 334,
-1484, -1484, 16426, 16426, -56, -1484, -1484, -1484, 13332, 811,
14673, 14826, 13001, 9590, 713, 718, -1484, 68, 795, 780,
-1484, 918, 734, 14349, 14472, 14826, 14826, 14826, 14826, 14826,
-1484, 730, 15, 785, 736, 738, 740, 741, 14826, 327,
-1484, 796, -1484, -1484, -1484, 739, -1484, 16512, -1484, 13332,
757, 16426, 767, 941, 14237, 947, -1484, 16426, 14193, -1484,
626, 878, -1484, 6054, 15182, 755, 306, -1484, 16109, 13001,
311, -1484, 16122, 13001, 13001, -1484, -1484, 3495, -1484, 16512,
958, 15340, 768, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, 114, 13001, 15182, 769, 15200, 15285, 960, -1484,
-1484, -1484, -1484, 770, -1484, 13332, -1484, -1484, 5222, -1484,
14472, 15182, 773, -1484, -1484, -1484, -1484, 966, 13332, 15429,
-1484, -1484, 12585, -1484, 13332, -1484, 13332, -1484, 13332, -1484,
-1484, 783, -1484, 14472, -1484, 786, 6262, 951, 102, -1484,
-1484, 302, 2889, -1484, -1484, 14472, -1484, -1484, -2, 16426,
-1484, 11046, -1484, 14826, 84, 788, 15182, 721, -1484, -1484,
1685, 13332, -1484, -1484, 13332, -1484, 13332, -1484, 3546, 789,
10630, 714, 968, 721, 761, 13001, 15406, -2, 4013, 799,
-1484, -1484, 171, -1484, -1484, -1484, 991, 3912, 3912, 14958,
-1484, -1484, -1484, -1484, 806, 47, 807, -1484, -1484, -1484,
1000, 813, 585, -2, -2, 13166, 3959, -1484, -1484, 4449,
443, -56, 10214, -1484, 6470, 814, 6678, 817, 14673, 15340,
815, 882, -2, 16512, 1005, -1484, -1484, -1484, -1484, 406,
-1484, 51, 14472, -1484, 14472, 13001, 4212, -1484, -1484, -1484,
1013, -1484, 822, 869, 615, 615, 949, 949, 4280, 819,
1016, 14826, 883, 13001, 15429, 14826, 14826, 14826, 4383, 12793,
14826, 14826, 14826, 14826, 14624, 14826, 14826, 14826, 14826, 14826,
14826, 14826, 14826, 14826, 14826, 14826, 14826, 14826, 14826, 14826,
14826, 14826, 14826, 14826, 14826, 14826, 14826, 16426, 13332, 13332,
13332, -1484, -1484, -1484, 13332, 13332, -1484, 728, -1484, 952,
-1484, -1484, 13001, -1484, -1484, 13001, -1484, -1484, -1484, -1484,
14826, -2, -1484, 456, -1484, 931, 1023, -1484, -1484, 89,
832, -2, 11254, -1484, 165, -1484, 5430, 670, 1023, -1484,
-35, -47, 16426, 904, -1484, 16426, 16426, 15817, -1484, 833,
951, -1484, 14472, 717, 14472, 18, 1021, 959, 172, -1484,
534, -1484, 15340, 13332, 16426, 16512, 835, 84, -1484, 836,
84, 838, 1685, 16426, 15861, 840, 10630, 841, 843, 14472,
844, 721, -1484, 523, 210, 10630, 13332, -1484, -1484, -1484,
-1484, -1484, -1484, 914, 847, 1037, 14958, 903, -1484, 15429,
14958, -1484, -1484, -1484, 15340, 16426, 182, -1484, -1484, -56,
1022, 978, 10214, -1484, -1484, -1484, 855, 13332, 882, -2,
15200, 14673, 854, 14826, 6886, 435, 856, 13332, 74, 247,
-1484, 890, -1484, 935, -1484, 14398, 1036, 874, 14826, -1484,
14826, -1484, 875, -1484, 938, 1070, 879, 16512, 881, 1071,
15917, 885, 1073, 886, -1484, -1484, -1484, 15961, 884, 1075,
14902, 16592, 13742, 14826, 16470, 14806, 15248, 3587, 4809, 4234,
15159, 15159, 15159, 15159, 1529, 1529, 1529, 1529, 946, 946,
615, 615, 615, 949, 949, 949, 949, 16426, 3634, 16426,
-1484, 16426, -1484, 892, -1484, -1484, -1484, 16512, 13001, 14472,
15182, 544, -1484, 15200, -1484, -1484, 10613, 891, -1484, 896,
642, -1484, 10, 13332, -1484, -1484, -1484, 13332, -1484, 13332,
13332, -1484, 717, -1484, -1484, 304, 1081, 1006, 14826, -1484,
900, -2, 16426, 951, 902, -1484, 906, 84, 13332, 10630,
908, -1484, -1484, 670, -1484, 901, 913, -1484, 915, 14958,
-1484, 14958, -1484, 919, -1484, 986, 921, 1110, -1484, -2,
1094, -1484, 922, -1484, -1484, 924, 925, 92, -1484, -1484,
16512, 928, 932, -1484, 2365, -1484, -1484, -1484, -1484, -1484,
14472, -1484, 14472, -1484, 16512, 16017, -1484, 14826, 15429, -1484,
-1484, -1484, 14826, -1484, 14826, -1484, 14826, -1484, -1484, 14826,
-1484, 14826, -1484, 14401, 14826, 13332, 930, 7094, 1040, -1484,
-1484, 411, 14472, 15182, -1484, 16064, 982, 4607, -1484, -1484,
-1484, 673, 3743, 70, 466, 93, -1484, -1484, -1484, 987,
4704, 13690, 16426, 16426, -1484, 255, 1128, 1064, 14826, -1484,
16512, 10630, 1039, 951, 956, 951, 954, 16426, 955, -1484,
1169, 961, 1399, -1484, 84, -1484, -1484, 1028, -1484, 14958,
-1484, 15429, -1484, -1484, 8966, -1484, -1484, -1484, -1484, 9798,
-1484, -1484, -1484, 8966, -1484, 962, 14826, 16512, 1029, 16512,
16512, 16061, 16512, 16117, 14401, 14326, -1484, -1484, 14472, 15182,
15182, 1146, 48, -1484, -1484, -1484, -1484, 71, 963, 72,
-1484, 13741, -1484, -1484, 73, -1484, -1484, 14227, -1484, 967,
-1484, 1084, 529, -1484, 14472, -1484, 673, -1484, 2561, -1484,
-1484, -1484, -1484, 1160, 1096, 14826, -1484, 16512, 974, 976,
975, 419, -1484, 1039, 951, -1484, -1484, -1484, -1484, 1664,
979, 14958, -1484, 1050, 8966, 10006, 9798, -1484, -1484, -1484,
8966, -1484, 16512, 14826, 14826, 14826, 13332, 7302, -1484, 980,
983, 14826, 15182, -1484, -1484, 1017, 16064, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, 108, -1484,
982, -1484, -1484, -1484, -1484, -1484, 66, 117, -1484, 1171,
75, 13001, 1084, 1173, 529, -1484, -1484, 985, 1175, 14826,
-1484, 16512, -1484, 315, -1484, -1484, -1484, -1484, 989, 419,
3035, -1484, 951, -1484, 14958, -1484, -1484, -1484, -1484, 7510,
16512, 16512, 16512, 14281, -1484, -1484, -1484, 16512, -1484, 413,
29, -1484, -1484, 14826, 13741, 13741, 1136, -1484, 14227, 14227,
602, -1484, -1484, -1484, 14826, 1115, -1484, 994, 78, 14826,
13001, -1484, 14826, 16512, 1117, -1484, 1188, 7718, 7926, -1484,
-1484, -1484, 419, -1484, 8134, 997, 1123, 1097, -1484, 1106,
1056, -1484, -1484, 1111, 1017, -1484, 16512, -1484, -1484, 1046,
-1484, 1176, -1484, -1484, -1484, -1484, 16512, 1197, -1484, -1484,
16512, 1015, 16512, -1484, 344, 1019, -1484, -1484, 8342, -1484,
1020, -1484, -1484, 1024, 1055, 13001, 466, -1484, -1484, 14826,
85, -1484, 1145, -1484, -1484, -1484, -1484, 15182, 755, -1484,
1062, 13001, 408, 16512, 1026, 1220, 431, 85, -1484, 1151,
-1484, 15182, 1031, -1484, 951, 90, -1484, -1484, -1484, -1484,
14472, -1484, 1033, 1034, 79, -1484, 429, 431, 309, 951,
1027, -1484, -1484, -1484, -1484, 14472, 262, 1223, 1159, 429,
-1484, 8550, 319, 1225, 1162, 14826, -1484, -1484, 8758, -1484,
272, 1228, 1165, 14826, -1484, 16512, -1484, 1232, 1168, 14826,
-1484, 16512, 14826, -1484, 16512, 16512
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-1484, -1484, -1484, -512, -1484, -1484, -1484, -4, -1484, -1484,
-1484, 735, 460, 459, 34, 957, 3263, -1484, 2030, -1484,
-394, -1484, 44, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -446, -1484, -1484, -179, 4, 7,
-1484, -1484, -1484, -1484, -1484, -1484, 8, -1484, -1484, -1484,
-1484, 11, -1484, -1484, 861, 860, 863, -129, 366, -819,
373, 430, -445, 137, -831, -1484, -189, -1484, -1484, -1484,
-1484, -681, -16, -1484, -1484, -1484, -1484, -438, -1484, -576,
-1484, -390, -1484, -1484, 747, -1484, -176, -1484, -1484, -999,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484,
-200, -1484, -1484, -1484, -1484, -1484, -283, -1484, -49, -1002,
-1484, -1483, -460, -1484, -162, -1, -134, -437, -1484, -291,
-1484, -77, -22, 1247, -693, -370, -1484, -1484, -38, -1484,
-1484, 3462, -67, -152, -1484, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -553, -806, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, 893,
-1484, -1484, 277, -1484, 798, -1484, -1484, -1484, -1484, -1484,
-1484, -1484, 281, -1484, 802, -1484, -1484, 517, -1484, 252,
-1484, -1484, -1484, -1484, -1484, -1484, -1484, -1484, -995, -1484,
1493, 1846, -357, -1484, -1484, 207, 3211, 3632, -1484, -1484,
332, -156, -606, -1484, -1484, 396, -683, 199, -1484, -1484,
-1484, -1484, -1484, 384, -1484, -1484, -1484, 52, -841, -191,
-417, -408, -1484, 445, -141, -1484, -1484, 14, -1484, -1484,
416, -72, -1484, -1484, 21, -151, -1484, 169, -1484, -1484,
-1484, -400, 1008, -1484, -1484, -1484, -1484, -1484, 990, -1484,
-1484, -1484, 333, -1484, -1484, -1484, 495, 561, -1484, -1484,
1018, -307, -992, -1484, -48, -76, -205, -102, 569, -1484,
-998, -1484, 282, 358, -1484, -1484, -1484, -183, -1045
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -907
static const yytype_int16 yytable[] =
{
122, 398, 354, 136, 872, 264, 855, 428, 130, 570,
240, 131, 133, 314, 919, 134, 269, 1064, 165, 1235,
320, 321, 245, 449, 426, 420, 249, 693, 854, 643,
663, 689, 690, 1053, 397, 937, 714, 326, 1654, 344,
218, 220, 330, 453, 828, 715, 252, 328, 129, 262,
1220, 233, 734, 354, 951, 1219, 163, 1472, 1079, 350,
1339, 711, 1232, 718, 732, 461, 296, 801, 446, 518,
523, 13, 474, 475, 1090, 1618, 528, 952, 479, 1424,
-288, 1476, 1560, 312, 1625, 296, 801, 1625, 1472, -486,
817, 281, 296, 296, 454, 506, 817, 1236, 817, 1619,
972, 817, 817, 290, 1285, 423, 1640, 1128, 1226, 418,
546, 783, 341, 310, 520, 301, 311, -763, 415, 416,
1221, 333, 1613, 1033, 789, -766, 415, 416, 329, 13,
13, 296, 1107, 1222, 3, 13, 288, 438, 1614, 191,
353, 236, 440, -906, 289, 239, 1621, 13, -763, -448,
447, 1137, 1138, 507, -487, 1615, -766, 1227, 606, 1679,
246, 303, 399, 1622, 315, 569, 1623, -784, 1154, 1223,
340, 415, 416, -627, 616, 361, 362, 363, 418, -486,
340, 1237, 282, 304, 305, -785, -786, -787, -628, 856,
-821, 429, 590, 1108, 364, 435, 365, 366, 367, 368,
369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
379, 380, 381, 382, 383, 384, 385, 533, 386, 212,
423, -791, 537, -788, 422, -229, 735, 534, 439, -824,
387, 339, -822, 345, 1655, 442, 122, -790, -789, 953,
122, 448, 655, 424, 468, 1352, 1354, 419, -823, 322,
694, 1473, 1474, 1360, 165, 1362, 1140, 733, 165, 462,
802, 1361, 481, 519, 524, 354, 655, 1135, 1620, 1139,
529, 614, 1255, 1425, -288, 1477, 1561, 1286, 1626, 803,
700, 1669, 1731, 818, 458, 1034, -229, -213, 463, 906,
655, 1212, -710, 737, 1378, 1427, 612, 522, 1076, 655,
1278, -710, 655, 1265, -710, -784, 530, 530, 535, 283,
512, 516, 517, 542, 422, 807, 419, 1046, 315, 551,
314, 350, -793, -785, -786, -787, 934, 122, -821, 212,
136, 936, 301, 247, 1433, 130, 603, 1065, 552, 1345,
262, 1743, 555, 296, 1736, 165, 425, 1137, 1138, 834,
1634, 1757, 415, 416, 1750, 1441, -794, 1443, 424, -791,
701, -788, 664, 301, 1449, 440, 793, -824, 323, 552,
-822, 301, 794, 1217, 324, -790, -789, 586, -906, 1692,
-764, 1066, 248, 1346, 415, 416, -823, 273, 1737, 653,
296, 657, 296, 296, 1635, 851, 852, 862, 1751, 341,
304, 305, 660, 1022, 860, 931, 932, 233, 1025, 292,
840, -764, 386, 681, 654, 293, 1039, 845, 1434, 294,
849, 721, 340, 1693, 387, 1744, 295, 1268, 340, 827,
-906, 304, 305, -906, 1275, 1758, 398, 703, 686, 304,
305, 542, 219, 219, 301, 1068, 1589, 299, 889, 713,
336, 439, 1288, 835, 1069, 300, 117, 545, 709, 340,
122, 301, 654, 602, 340, 1067, 286, 1347, 836, 397,
332, 710, 1738, 287, 716, 52, -906, 316, 165, 317,
899, 895, 1752, 59, 60, 61, 179, 180, 351, 301,
36, 318, 1388, 601, 887, 302, 319, 341, 889, 340,
1087, 1244, 810, 811, 1246, 1136, 1137, 1138, 726, 1116,
1234, 862, 304, 305, 1119, 1120, 796, 926, 1117, 415,
416, 59, 60, 61, 179, 180, 351, 301, 547, 304,
305, -906, 570, 552, 1282, 1137, 1138, 1399, 1400, 1093,
879, 822, 824, 786, 1717, 1718, 1719, 790, 1321, 557,
558, 1134, 281, 352, 449, 340, 303, 304, 305, 647,
606, 606, 343, 183, 346, 1453, 82, 927, -484, 84,
85, 301, 86, 184, 88, 355, 1366, 552, 1367, 59,
60, 61, 179, 180, 351, 957, 356, 687, 357, 13,
358, 352, 691, 359, 1642, 304, 305, 399, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 1713, 296, 335, 337, 338, 1661, 1662, 1648, 1657,
1658, 868, 1585, 1586, 59, 60, 61, 62, 63, 351,
219, 1663, 1732, 1733, 586, 69, 394, 219, 553, 304,
305, 960, 963, 219, 360, 389, 1321, 1047, 1664, 352,
1322, 1665, 383, 384, 385, 1323, 386, 59, 60, 61,
179, 180, 351, 1324, 1003, 1004, 1005, 570, 387, 392,
1059, 1356, 1214, 396, 390, 1728, 897, 391, 421, 1344,
1006, 393, 1071, -792, -485, -627, 1452, 13, 569, 427,
1742, 308, 432, 917, 352, 922, 1250, 434, 387, 219,
1325, 1326, 935, 1327, 341, 1258, 441, 422, 219, 219,
536, 655, 444, 445, 122, 219, 1726, 136, 923, -626,
924, 219, 130, 450, 451, 459, 476, 352, 944, 122,
1277, 1739, 165, 472, 59, 60, 61, 62, 63, 351,
477, -901, 482, 480, 942, 69, 394, 165, 1322, 1328,
483, 485, 525, 1323, 526, 59, 60, 61, 179, 180,
351, 1324, 527, 539, 1111, 538, 578, 579, 1593, 1141,
588, 1142, 600, 589, 591, 655, -65, 946, 52, 122,
699, 395, 136, 396, 613, 1024, 697, 130, 1450, 1027,
1028, 702, 708, 461, 724, 728, 731, 165, 1325, 1326,
743, 1327, 570, 744, 352, 770, 769, 1147, 784, 1035,
1317, 772, 773, 1335, 1151, 1031, 781, 787, 788, 1092,
791, 792, 512, 569, 122, 352, 516, 136, 800, 804,
542, 1041, 130, 805, 808, 131, 133, 809, 1054, 134,
814, 816, 165, 219, 825, 819, 830, 1338, 831, 1706,
833, 839, 122, 219, 838, 136, 841, 842, 681, 1358,
130, 843, 844, 548, 847, 1240, 1706, 554, 848, 850,
165, 853, 129, 857, 1727, 858, -488, 1374, 865, 1233,
163, 860, 867, 686, 870, 871, 873, 876, 882, 886,
885, 296, 883, 1383, 548, 890, 554, 548, 554, 554,
900, 902, 903, 1100, 1100, 917, 1253, 878, 938, 1122,
586, 1643, 486, 487, 488, 904, 948, 233, 928, 489,
490, 950, 713, 491, 492, 954, 586, 956, 122, 955,
122, 971, 122, 136, 973, 136, 958, 974, 130, 975,
130, 976, 977, 980, 1008, 979, 165, 716, 165, 1262,
165, 1143, 942, 1129, 1009, 1010, 1014, 1017, 569, 1020,
1321, 1438, 1071, 380, 381, 382, 383, 384, 385, 1153,
386, 1032, 1030, 1038, 1042, 1166, 1123, 1049, 1043, 1454,
1051, 1062, 387, 215, 215, 1060, 1058, 228, 1460, 1077,
1086, 570, 1000, 1001, 1002, 1003, 1004, 1005, 1089, 1299,
1095, 13, 1467, 1303, 1215, 1096, 1307, 1106, 1109, 1110,
228, 1006, 1131, 1312, 1006, 1112, 1130, 1125, 1205, 1133,
1127, 1206, 1145, 219, 1146, 1150, 1319, 1149, 1209, 547,
1675, 1203, 1210, 1213, 1229, 1238, 1231, 1243, 1239, 1247,
1245, 1249, 122, 1251, 1259, 136, 1261, 1252, 1254, 1264,
130, 1272, 1271, 131, 133, 1260, 1279, 134, 1274, 1283,
165, 1289, 1322, 1599, 570, 1290, 1292, 1323, 1297, 59,
60, 61, 179, 180, 351, 1324, 1293, 1296, 219, 1298,
1302, 1300, 1306, 1301, 1311, 1349, 1241, 1305, 1308, 1310,
129, 33, 34, 35, 1316, 1348, 1336, 1270, 163, 1716,
1337, 1351, 917, 750, 1353, 1363, 917, 1384, 1355, 1385,
1359, 1372, 1325, 1326, 1364, 1327, 1369, 1365, 122, 1371,
219, 1368, 219, 1370, 1373, 1375, 1376, 1377, 1269, 586,
122, 1380, 586, 136, 1396, 1381, 165, 1398, 130, 352,
1413, 1429, 1435, 1436, 542, 942, 219, 569, 165, 1423,
1439, 73, 74, 75, 76, 77, 1444, 1445, 1451, 1463,
1471, 1442, 752, 1569, 1461, 1447, 1273, 1475, 80, 81,
1568, 215, 1426, 1321, 1579, 1580, 1582, 1583, 215, 1584,
1594, 1592, 90, 1605, 215, 1624, 1606, 1629, 1631, 1632,
1637, 1659, 1638, 1639, 1667, 1668, 1673, 1674, 354, 98,
1681, 1644, 1682, -284, 1318, 1685, 1683, 1688, 1686, 1619,
1332, 1689, 228, 228, 13, 1468, 1691, 219, 228, 1332,
569, 1694, 1698, 1696, 1708, 1697, 1711, 542, 1714, 1715,
1723, 1740, 219, 219, 1725, 1729, 1730, 1745, 1746, 1753,
215, 1754, 1759, 1571, 1760, 1678, 1762, 1763, 1023, 215,
215, 1026, 1710, 795, 656, 917, 215, 917, 659, 658,
1091, 1048, 215, 1334, 1088, 1276, 1724, 1598, 1382, 1722,
798, 1590, 1334, 228, 1401, 1322, 1612, 1617, 1420, 1747,
1323, 1628, 59, 60, 61, 179, 180, 351, 1324, 242,
1735, 1588, 779, 666, 1202, 1200, 780, 1016, 228, 586,
1257, 228, 1224, 1152, 1102, 1263, 1113, 1070, 544, 577,
1163, 532, 961, 122, 1144, 1208, 136, 0, 262, 0,
0, 130, 0, 1418, 0, 1325, 1326, 0, 1327, 0,
0, 165, 0, 399, 0, 1422, 0, 0, 0, 1741,
0, 0, 0, 228, 0, 0, 1748, 0, 0, 0,
0, 0, 352, 1332, 219, 219, 0, 0, 0, 1332,
0, 1332, 0, 0, 0, 917, 0, 0, 0, 0,
122, 0, 0, 136, 1446, 122, 1573, 0, 130, 122,
0, 0, 136, 0, 215, 0, 0, 130, 165, 0,
0, 0, 0, 165, 215, 1630, 0, 165, 0, 0,
0, 0, 0, 1321, 0, 0, 1334, 1557, 0, 0,
0, 0, 1334, 1564, 1334, 0, 586, 0, 0, 0,
262, 0, 0, 1458, 262, 0, 0, 0, 0, 0,
1574, 0, 0, 228, 228, 0, 0, 759, 0, 0,
0, 0, 0, 0, 13, 0, 0, 917, 1332, 0,
122, 122, 122, 136, 0, 0, 122, 0, 130, 136,
0, 0, 0, 122, 130, 0, 136, 0, 165, 165,
165, 130, 0, 0, 165, 0, 0, 0, 0, 0,
0, 165, 0, 0, 759, 0, 0, 0, 219, 0,
0, 0, 0, 0, 0, 1627, 0, 0, 0, 1596,
1458, 1334, 0, 0, 0, 1322, 0, 0, 0, 0,
1323, 0, 59, 60, 61, 179, 180, 351, 1324, 216,
216, 0, 0, 229, 1701, 0, 0, 0, 0, 0,
219, 0, 0, 0, 0, 228, 228, 860, 0, 0,
0, 0, 0, 0, 228, 0, 219, 219, 0, 0,
0, 0, 860, 0, 1671, 1325, 1326, 0, 1327, 0,
0, 0, 0, 0, 215, 0, 0, 296, 354, -907,
-907, -907, -907, 998, 999, 1000, 1001, 1002, 1003, 1004,
1005, 0, 352, 0, 0, 0, 262, 0, 0, 0,
917, 0, 0, 0, 1006, 122, 0, 0, 136, 0,
0, 0, 0, 130, 1448, 1649, 0, 0, 0, 0,
1557, 1557, 0, 165, 1564, 1564, 0, 0, 0, 215,
0, 0, 0, 0, 0, 0, 296, 0, 0, 219,
0, 0, 0, 122, 122, 0, 136, 136, 0, 0,
122, 130, 130, 136, 0, 0, 0, 0, 130, 0,
0, 165, 165, 0, 0, 0, 0, 0, 165, 0,
0, 215, 0, 215, 0, 0, 0, 0, 1321, 0,
0, 0, 0, 0, 122, 0, 0, 136, 0, 0,
0, 1700, 130, 0, 0, 1702, 0, 215, 759, 0,
0, 0, 165, 0, 0, 0, 0, 1712, 0, 0,
228, 228, 759, 759, 759, 759, 759, 0, 0, 13,
0, 0, 0, 0, 216, 759, 365, 366, 367, 368,
369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
379, 380, 381, 382, 383, 384, 385, 122, 386, 0,
136, 228, 586, 0, 122, 130, 0, 136, 0, 0,
387, 0, 130, 0, 0, 165, 0, 0, 215, 586,
0, 0, 165, 0, 0, 0, 0, 586, 0, 0,
1322, 228, 36, 215, 215, 1323, 216, 59, 60, 61,
179, 180, 351, 1324, 0, 216, 216, 228, 228, 0,
0, 0, 216, 0, 0, 0, 228, 0, 216, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 216,
228, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1325, 1326, 228, 1327, 0, 0, 0, 0, 0, 0,
759, 0, 0, 228, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 352, 308, 0,
0, 84, 85, 228, 86, 184, 88, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1591,
0, 0, 217, 217, 0, 0, 230, 0, 0, 229,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 0, 0, 215, 215, 0, 0, 309,
0, 0, 0, 0, 0, 0, 0, 0, 0, 228,
0, 228, 0, 228, 0, 0, 0, 0, 0, 0,
216, 0, 0, 0, 0, 0, 0, 0, 759, 0,
0, 228, 759, 759, 759, 0, 0, 759, 759, 759,
759, 759, 759, 759, 759, 759, 759, 759, 759, 759,
759, 759, 759, 759, 759, 759, 759, 759, 759, 759,
759, 759, 759, 759, 0, 0, 0, 0, 0, 361,
362, 363, 0, 765, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 759, 364, 0,
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 0, 386, 0, 0, 0, 0, 0, 0, 228,
765, 228, 0, 0, 387, 0, 0, 0, 0, 215,
0, 0, 400, 401, 402, 403, 404, 405, 406, 407,
408, 409, 410, 411, 412, 0, 228, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
217, 0, 0, 0, 0, 0, 228, 217, 0, 0,
0, 215, 0, 217, 36, 0, 820, 821, 0, 0,
0, 413, 414, 263, 0, 0, 0, 215, 215, 0,
759, 0, 0, 0, 0, 0, 0, 0, 0, 0,
216, 0, 228, 0, 0, 759, 0, 759, 0, 0,
0, 430, 401, 402, 403, 404, 405, 406, 407, 408,
409, 410, 411, 412, 0, 0, 0, 0, 0, 217,
759, 0, 0, 0, 0, 0, 0, 0, 217, 217,
0, 0, 0, 0, 0, 217, 415, 416, 0, 0,
0, 217, 0, 84, 85, 216, 86, 184, 88, 0,
413, 414, 568, 0, 826, 0, 228, 228, 0, 0,
215, 0, 0, 0, 0, 0, 0, 0, 0, 361,
362, 363, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 111, 112, 759, 0, 216, 364, 216,
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 0, 386, 216, 765, 415, 416, 0, 0, 0,
0, 0, 230, 0, 387, 0, 0, 0, 765, 765,
765, 765, 765, 0, 0, 0, 0, 228, 0, 228,
0, 765, 0, 0, 759, 228, 0, 0, 0, 759,
0, 759, 0, 759, 0, 0, 759, 0, 759, 0,
0, 759, 0, 217, 0, 0, 0, 1019, 0, 228,
228, 0, 228, 217, 0, 263, 263, 0, 0, 228,
0, 263, 0, 0, 216, 0, 0, 0, 0, 590,
0, 0, 0, 0, 0, 759, 0, 1037, 0, 216,
216, 430, 401, 402, 403, 404, 405, 406, 407, 408,
409, 410, 411, 412, 1037, 0, 0, 0, 228, 0,
0, 0, 216, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 759, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 228, 228, 228, 0, 0,
413, 414, 0, 0, 0, 0, 765, 0, 0, 1078,
0, 263, 388, 0, 263, 361, 362, 363, 0, 0,
0, 228, 0, 0, 0, 228, 0, 0, 0, 229,
0, 0, 759, 0, 364, 1285, 365, 366, 367, 368,
369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
379, 380, 381, 382, 383, 384, 385, 0, 386, 0,
759, 759, 759, 0, 0, 415, 416, 0, 759, 228,
387, 216, 216, 228, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
383, 384, 385, 217, 386, 0, 0, 0, 0, 0,
0, 0, 0, 0, 765, 0, 387, 216, 765, 765,
765, 0, 0, 765, 765, 765, 765, 765, 765, 765,
765, 765, 765, 765, 765, 765, 765, 765, 765, 765,
765, 765, 765, 765, 765, 765, 765, 765, 765, 765,
0, 0, 0, 0, 0, 0, 263, 739, 217, 0,
761, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 765, -907, -907, -907, -907, 378, 379,
380, 381, 382, 383, 384, 385, 759, 386, 0, 0,
0, 0, 0, 0, 0, 0, 0, 228, 0, 387,
217, 0, 217, 0, 0, 0, 0, 761, 0, 0,
0, 0, 0, 0, 0, 216, 228, 0, 1286, 0,
759, 0, 0, 0, 0, 0, 217, 0, 0, 0,
0, 759, 0, 0, 0, 0, 759, 0, 0, 759,
255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 216, 0, 0, 0, 0, 216, 263, 263,
0, 0, 0, 0, 0, 0, 256, 263, 0, 0,
0, 0, 0, 216, 216, 0, 765, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 36, 0,
0, 765, 0, 765, 0, 0, 759, 217, 0, 0,
0, 0, 0, 0, 228, 0, 0, 0, 0, 0,
0, 0, 217, 217, 0, 0, 765, 0, 228, 0,
0, 0, 0, 0, 0, 0, 0, 228, 0, 0,
0, 0, 0, 0, 0, 568, 0, 0, 0, 0,
0, 0, 228, 257, 258, 0, 0, 0, 0, 0,
0, 0, 759, 1320, 0, 0, 216, 0, 0, 0,
759, 183, 0, 0, 82, 259, 759, 84, 85, 759,
86, 184, 88, 0, 0, 0, 0, 0, 0, 0,
0, 765, 0, 0, 0, 260, 0, 0, 0, 0,
0, 0, 230, 0, 0, 0, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 0,
0, 761, 261, 0, 0, 0, 1575, 0, 0, 0,
0, 0, 0, 263, 263, 761, 761, 761, 761, 761,
0, 0, 0, 0, 217, 217, 0, 0, 761, 0,
765, 216, 0, 0, 0, 765, 0, 765, 0, 765,
0, 0, 765, 0, 765, 0, 0, 765, 0, 0,
0, 0, 0, 0, 0, 0, 1403, 0, 1412, 0,
568, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 765, 386, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 387, 0, 0, 0, 0, 0,
263, 0, 0, 0, 216, 430, 401, 402, 403, 404,
405, 406, 407, 408, 409, 410, 411, 412, 0, 765,
0, 0, 0, 263, 0, 0, 0, 0, 0, 0,
0, 0, 1469, 1470, 0, 263, 0, 0, 0, 0,
0, 0, 0, 761, 0, 0, 0, 0, 361, 362,
363, 0, 0, 0, 413, 414, 0, 0, 217, 0,
0, 0, 0, 0, 0, 0, 0, 364, 765, 365,
366, 367, 368, 369, 370, 371, 372, 373, 374, 375,
376, 377, 378, 379, 380, 381, 382, 383, 384, 385,
0, 386, 0, 0, 0, 568, 765, 765, 765, 0,
217, 0, 0, 387, 765, 1608, 36, 0, 212, 1412,
0, 0, 0, 0, 0, 0, 217, 217, 0, 415,
416, 0, 263, 0, 263, 0, 739, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 761, 0, 0, 0, 761, 761, 761, 0, 0,
761, 761, 761, 761, 761, 761, 761, 761, 761, 761,
761, 761, 761, 761, 761, 761, 761, 761, 761, 761,
761, 761, 761, 761, 761, 761, 761, 0, 0, 0,
0, 0, 0, 679, 0, 84, 85, 0, 86, 184,
88, 0, 0, 806, 0, 0, 0, 0, 0, 217,
761, 0, 0, 0, 255, 0, 0, 0, 0, 0,
0, 0, 765, 0, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 0, 0, 0,
256, 0, 263, 680, 263, 117, 0, 0, 0, 0,
0, 0, 0, 864, 0, 0, 765, 0, 0, 0,
0, 0, 36, 0, 0, 0, 0, 765, 0, 263,
0, 0, 765, 0, 0, 765, 368, 369, 370, 371,
372, 373, 374, 375, 376, 377, 378, 379, 380, 381,
382, 383, 384, 385, 568, 386, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 387, 0, 0,
0, 0, 0, 761, 0, 0, 0, 257, 258, 0,
0, 0, 0, 0, 0, 263, 0, 0, 761, 0,
761, 0, 765, 0, 0, 183, 0, 0, 82, 259,
1709, 84, 85, 0, 86, 184, 88, 0, 0, 0,
0, 0, 0, 761, 1403, 0, 0, 0, 0, 260,
0, 0, 0, 0, 0, 0, 0, 568, 0, 0,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 0, 0, 0, 261, 0, 765, 263,
1641, 0, 0, 0, 0, 0, 765, 0, 361, 362,
363, 0, 765, 0, 0, 765, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 364, 761, 365,
366, 367, 368, 369, 370, 371, 372, 373, 374, 375,
376, 377, 378, 379, 380, 381, 382, 383, 384, 385,
0, 386, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 387, 370, 371, 372, 373, 374, 375,
376, 377, 378, 379, 380, 381, 382, 383, 384, 385,
263, 386, 263, 0, 0, 0, 0, 761, 0, 0,
0, 0, 761, 387, 761, 0, 761, 0, 0, 761,
0, 761, 0, 0, 761, 0, 0, 0, 0, 0,
0, 0, 263, 0, 0, 0, 0, 0, 361, 362,
363, 0, 263, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 364, 761, 365,
366, 367, 368, 369, 370, 371, 372, 373, 374, 375,
376, 377, 378, 379, 380, 381, 382, 383, 384, 385,
0, 386, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 387, 0, 0, 761, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 263, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 901, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 263, 0, 0, 0, 263, 0,
0, 0, 0, 0, 0, 761, 0, 188, 190, 0,
192, 193, 194, 196, 197, 0, 200, 201, 202, 203,
204, 205, 206, 207, 208, 209, 210, 211, 0, 0,
222, 225, 0, 761, 761, 761, 0, 0, 0, 0,
0, 761, 0, 0, 243, 361, 362, 363, 0, 0,
0, 251, 0, 254, 0, 0, 270, 0, 275, 0,
0, 0, 0, 0, 364, 0, 365, 366, 367, 368,
369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
379, 380, 381, 382, 383, 384, 385, 0, 386, 0,
0, 0, 0, 905, 0, 0, 361, 362, 363, 0,
387, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 364, 327, 365, 366, 367,
368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
378, 379, 380, 381, 382, 383, 384, 385, 0, 386,
0, 0, 0, 0, 0, 0, 0, 0, 0, 761,
0, 387, 0, 36, 0, 212, 0, 0, 0, 0,
263, 988, 989, 990, 991, 992, 993, 994, 995, 996,
997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1650,
0, 0, 0, 761, 361, 362, 363, 0, 0, 0,
0, 0, 1006, 431, 761, 0, 0, 0, 0, 761,
651, 0, 761, 364, 0, 365, 366, 367, 368, 369,
370, 371, 372, 373, 374, 375, 376, 377, 378, 379,
380, 381, 382, 383, 384, 385, 0, 386, 0, 0,
0, 766, 84, 85, 0, 86, 184, 88, 456, 387,
1029, 456, 0, 0, 0, 0, 0, 0, 243, 467,
0, 0, 0, 0, 0, 0, 0, 0, 0, 761,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 0, 0, 0, 0, 766, 0,
652, 0, 117, 760, 0, 0, 0, 0, 0, 0,
263, 1085, 0, 0, 0, 0, 327, 0, 0, 0,
0, 0, 222, 0, 0, 263, 550, 0, 0, 0,
0, 0, 255, 0, 0, 761, 0, 0, 0, 571,
574, 574, 0, 761, 0, 0, 0, 0, 0, 761,
760, 0, 761, 0, 599, 0, 0, 0, 256, 0,
0, 0, 0, 0, 0, 611, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36, 0, 1315, 617, 618, 619, 621, 622, 623, 624,
625, 626, 627, 628, 629, 630, 631, 632, 633, 634,
635, 636, 637, 638, 639, 640, 641, 642, -326, 644,
0, 645, 645, 0, 648, 0, 59, 60, 61, 179,
180, 351, 665, 667, 668, 669, 670, 671, 672, 673,
674, 675, 676, 677, 678, 257, 258, 0, 0, 0,
645, 688, 0, 611, 611, 645, 692, 0, 0, 0,
0, 0, 665, 183, 0, 696, 82, 259, 0, 84,
85, 0, 86, 184, 88, 705, 0, 707, 0, 0,
0, 0, 0, 611, 0, 0, 0, 260, 0, 0,
0, 722, 0, 723, 0, 0, 352, 0, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 0, 766, 0, 261, 0, 0, 0, 0, 771,
0, 0, 774, 777, 778, 0, 766, 766, 766, 766,
766, 0, 0, 0, 0, 0, 0, 0, 0, 766,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 797, 0, 0, 1097, 1098, 1099, 36,
0, 0, 0, 0, 760, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 760, 760,
760, 760, 760, 0, 0, 0, 0, 0, 0, 0,
0, 760, 0, 361, 362, 363, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 36, 0, 212, 0,
0, 0, 364, 0, 365, 366, 367, 368, 369, 370,
371, 372, 373, 374, 375, 376, 377, 378, 379, 380,
381, 382, 383, 384, 385, 0, 386, 0, 84, 85,
869, 86, 184, 88, 0, 0, 0, 0, 387, 0,
0, 0, 880, 0, 766, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
0, 0, 767, 679, 888, 84, 85, 0, 86, 184,
88, 0, 0, 196, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 760, 0, 0, 0,
0, 0, 898, 0, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 0, 0, 799,
0, 0, 0, 712, 0, 117, 0, 0, 0, 0,
0, 0, 0, 0, 929, 0, 0, 0, 0, 0,
0, 0, 766, 0, 0, 0, 766, 766, 766, 0,
243, 766, 766, 766, 766, 766, 766, 766, 766, 766,
766, 766, 766, 766, 766, 766, 766, 766, 766, 766,
766, 766, 766, 766, 766, 766, 766, 766, 1094, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1007, 0, 0, 760, 0, 0, 0, 760, 760,
760, 766, 0, 760, 760, 760, 760, 760, 760, 760,
760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
760, 760, 760, 760, 760, 760, 760, 760, 760, 760,
990, 991, 992, 993, 994, 995, 996, 997, 998, 999,
1000, 1001, 1002, 1003, 1004, 1005, 0, 1044, 0, 36,
981, 982, 983, 760, 0, 0, 0, 0, 738, 1006,
1052, 0, 0, 0, 0, 0, 1055, 0, 1056, 984,
1057, 985, 986, 987, 988, 989, 990, 991, 992, 993,
994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003,
1004, 1005, 0, 1074, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1082, 766, 1006, 1083, 0, 1084, 0,
0, 0, 611, 0, 0, 0, 0, 0, 0, 766,
0, 766, 183, 943, 0, 82, 0, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 964, 965, 966,
967, 0, 0, 0, 766, 0, 0, 1115, 0, 0,
978, 0, 0, 981, 982, 983, 760, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
1148, 760, 984, 760, 985, 986, 987, 988, 989, 990,
991, 992, 993, 994, 995, 996, 997, 998, 999, 1000,
1001, 1002, 1003, 1004, 1005, 0, 760, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1006, 766,
0, 0, 0, 0, 0, 0, 0, 0, 0, 361,
362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
1197, 1198, 1199, 0, 0, 0, 774, 1201, 364, 0,
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 760, 386, 0, 1216, 1075, 0, 0, 766, 0,
0, 0, 0, 766, 387, 766, 0, 766, 0, 0,
766, 0, 766, 0, 0, 766, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1242, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 611, 0,
0, 0, 0, 0, 0, 0, 0, 611, 1216, 766,
760, 0, 0, 0, 0, 760, 0, 760, 0, 760,
0, 0, 760, 0, 760, 0, 0, 760, 0, 0,
0, 0, 0, 0, 0, 1164, 0, 0, 0, 243,
0, 0, 0, 0, 0, 0, 0, 766, 0, 1284,
0, 0, 0, 0, 0, 0, 0, 1157, 1160, 1160,
0, 760, 1167, 1170, 1171, 1172, 1174, 1175, 1176, 1177,
1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187,
1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 0,
0, 0, 0, 0, 0, 0, 766, 0, 0, 760,
0, 0, 0, 0, 1118, 0, 0, 0, 0, 0,
0, 0, 1207, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 766, 766, 766, 0, 0, 0,
0, 0, 766, 0, 36, 1340, 1611, 0, 0, 1341,
0, 1342, 1343, 0, 0, 0, 0, 0, 760, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1357, 611, 0, 0, 361, 362, 363, 0, 0, 0,
0, 0, 0, 0, 0, 0, 760, 760, 760, 1416,
0, 0, 0, 364, 760, 365, 366, 367, 368, 369,
370, 371, 372, 373, 374, 375, 376, 377, 378, 379,
380, 381, 382, 383, 384, 385, 0, 386, 255, 0,
0, 0, 0, 84, 85, 1280, 86, 184, 88, 387,
0, 0, 0, 0, 0, 0, 0, 1395, 0, 0,
1294, 0, 1295, 0, 256, 0, 0, 0, 0, 0,
766, 0, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 111, 112, 1313, 36, 0, 1417, 0,
0, 0, 0, 611, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 766, 0, 0, 0, 0, 0,
0, 0, 0, 0, 478, 766, 0, 0, 0, 0,
766, 0, 760, 766, 989, 990, 991, 992, 993, 994,
995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004,
1005, 257, 258, 0, 0, 1687, 0, 0, 0, 0,
1350, 0, 0, 0, 1006, 0, 760, 0, 36, 183,
212, 0, 82, 259, 0, 84, 85, 760, 86, 184,
88, 0, 760, 0, 0, 760, 0, 0, 0, 0,
766, 0, 0, 260, 0, 0, 0, 0, 0, 1431,
0, 0, 0, 0, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 0, 1603, 1387,
261, 0, 0, 0, 1389, 0, 1390, 0, 1391, 0,
0, 1392, 0, 1393, 0, 0, 1394, 0, 0, 0,
0, 0, 760, 0, 0, 0, 766, 84, 85, 0,
86, 184, 88, 0, 766, 0, 0, 0, 0, 0,
766, 0, 0, 766, 0, 0, 0, 0, 0, 0,
1437, 0, 0, 0, 0, 0, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 5,
6, 7, 8, 9, 0, 652, 0, 117, 760, 10,
0, 0, 0, 0, 0, 0, 760, 0, 1462, 0,
0, 0, 760, 661, 12, 760, 0, 0, 0, 0,
0, 662, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 0, 1581, 0, 0,
33, 34, 35, 36, 37, 38, 0, 0, 0, 0,
0, 0, 41, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1600, 1601, 1602, 0, 0,
0, 52, 0, 1607, 0, 0, 0, 0, 0, 59,
60, 61, 179, 180, 181, 0, 0, 66, 67, 0,
0, 0, 0, 0, 0, 0, 0, 182, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 0, 0,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
267, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 0,
0, 0, 117, 118, 0, 119, 120, 0, 0, 0,
0, 1633, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 5, 6, 7, 8, 9,
0, 0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1656, 0, 0, 0, 11,
12, 0, 0, 0, 0, 0, 1666, 0, 0, 0,
0, 1670, 0, 0, 1672, 0, 0, 13, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 32, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 39, 40, 0, 0, 0, 41, 42,
43, 44, 0, 45, 0, 46, 0, 47, 0, 0,
48, 1703, 0, 0, 49, 50, 51, 52, 53, 54,
55, 0, 56, 57, 58, 59, 60, 61, 62, 63,
64, 0, 65, 66, 67, 68, 69, 70, 0, 0,
0, 0, 0, 71, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 79, 80, 81, 82, 83, 1755, 84, 85,
0, 86, 87, 88, 89, 1761, 0, 90, 0, 0,
91, 1764, 0, 0, 1765, 0, 92, 93, 94, 95,
96, 0, 97, 0, 98, 99, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 0, 0, 114, 0, 115, 116, 1045, 117, 118,
0, 119, 120, 5, 6, 7, 8, 9, 0, 0,
0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 11, 12, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 13, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
32, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 39, 40, 0, 0, 0, 41, 42, 43, 44,
0, 45, 0, 46, 0, 47, 0, 0, 48, 0,
0, 0, 49, 50, 51, 52, 53, 54, 55, 0,
56, 57, 58, 59, 60, 61, 62, 63, 64, 0,
65, 66, 67, 68, 69, 70, 0, 0, 0, 0,
0, 71, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
79, 80, 81, 82, 83, 0, 84, 85, 0, 86,
87, 88, 89, 0, 0, 90, 0, 0, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 96, 0,
97, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 0,
0, 114, 0, 115, 116, 1218, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 11, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 13, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 32, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 39,
40, 0, 0, 0, 41, 42, 43, 44, 0, 45,
0, 46, 0, 47, 0, 0, 48, 0, 0, 0,
49, 50, 51, 52, 53, 54, 55, 0, 56, 57,
58, 59, 60, 61, 62, 63, 64, 0, 65, 66,
67, 68, 69, 70, 0, 0, 0, 0, 0, 71,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 79, 80,
81, 82, 83, 0, 84, 85, 0, 86, 87, 88,
89, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 96, 0, 97, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
0, 115, 116, 0, 117, 118, 0, 119, 120, 5,
6, 7, 8, 9, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 11, 12, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 13, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 32, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 39, 40, 0,
0, 0, 41, 42, 43, 44, 0, 45, 0, 46,
0, 47, 0, 0, 48, 0, 0, 0, 49, 50,
51, 52, 0, 54, 55, 0, 56, 0, 58, 59,
60, 61, 62, 63, 64, 0, 65, 66, 67, 0,
69, 70, 0, 0, 0, 0, 0, 71, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 89, 0,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 115,
116, 592, 117, 118, 0, 119, 120, 5, 6, 7,
8, 9, 0, 0, 0, 0, 0, 10, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 11, 12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 13,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 32, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 39, 40, 0, 0, 0,
41, 42, 43, 44, 0, 45, 0, 46, 0, 47,
0, 0, 48, 0, 0, 0, 49, 50, 51, 52,
0, 54, 55, 0, 56, 0, 58, 59, 60, 61,
62, 63, 64, 0, 65, 66, 67, 0, 69, 70,
0, 0, 0, 0, 0, 71, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 89, 0, 0, 90,
0, 0, 91, 0, 0, 0, 0, 0, 92, 93,
94, 95, 0, 0, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 0, 0, 114, 0, 115, 116, 1018,
117, 118, 0, 119, 120, 5, 6, 7, 8, 9,
0, 0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 11,
12, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 13, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 32, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 39, 40, 0, 0, 0, 41, 42,
43, 44, 0, 45, 0, 46, 0, 47, 0, 0,
48, 0, 0, 0, 49, 50, 51, 52, 0, 54,
55, 0, 56, 0, 58, 59, 60, 61, 62, 63,
64, 0, 65, 66, 67, 0, 69, 70, 0, 0,
0, 0, 0, 71, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 183, 80, 81, 82, 83, 0, 84, 85,
0, 86, 184, 88, 89, 0, 0, 90, 0, 0,
91, 0, 0, 0, 0, 0, 92, 93, 94, 95,
0, 0, 0, 0, 98, 99, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 0, 0, 114, 0, 115, 116, 1061, 117, 118,
0, 119, 120, 5, 6, 7, 8, 9, 0, 0,
0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 11, 12, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 13, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
32, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 39, 40, 0, 0, 0, 41, 42, 43, 44,
0, 45, 0, 46, 0, 47, 0, 0, 48, 0,
0, 0, 49, 50, 51, 52, 0, 54, 55, 0,
56, 0, 58, 59, 60, 61, 62, 63, 64, 0,
65, 66, 67, 0, 69, 70, 0, 0, 0, 0,
0, 71, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 89, 0, 0, 90, 0, 0, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 0, 0,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 0,
0, 114, 0, 115, 116, 1124, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 11, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 13, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 32, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 39,
40, 0, 0, 0, 41, 42, 43, 44, 1126, 45,
0, 46, 0, 47, 0, 0, 48, 0, 0, 0,
49, 50, 51, 52, 0, 54, 55, 0, 56, 0,
58, 59, 60, 61, 62, 63, 64, 0, 65, 66,
67, 0, 69, 70, 0, 0, 0, 0, 0, 71,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
89, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 0, 0, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
0, 115, 116, 0, 117, 118, 0, 119, 120, 5,
6, 7, 8, 9, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 11, 12, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 13, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 32, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 39, 40, 0,
0, 0, 41, 42, 43, 44, 0, 45, 0, 46,
0, 47, 1281, 0, 48, 0, 0, 0, 49, 50,
51, 52, 0, 54, 55, 0, 56, 0, 58, 59,
60, 61, 62, 63, 64, 0, 65, 66, 67, 0,
69, 70, 0, 0, 0, 0, 0, 71, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 89, 0,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 115,
116, 0, 117, 118, 0, 119, 120, 5, 6, 7,
8, 9, 0, 0, 0, 0, 0, 10, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 11, 12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 13,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 32, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 39, 40, 0, 0, 0,
41, 42, 43, 44, 0, 45, 0, 46, 0, 47,
0, 0, 48, 0, 0, 0, 49, 50, 51, 52,
0, 54, 55, 0, 56, 0, 58, 59, 60, 61,
62, 63, 64, 0, 65, 66, 67, 0, 69, 70,
0, 0, 0, 0, 0, 71, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 89, 0, 0, 90,
0, 0, 91, 0, 0, 0, 0, 0, 92, 93,
94, 95, 0, 0, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 0, 0, 114, 0, 115, 116, 1397,
117, 118, 0, 119, 120, 5, 6, 7, 8, 9,
0, 0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 11,
12, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 13, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 32, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 39, 40, 0, 0, 0, 41, 42,
43, 44, 0, 45, 0, 46, 0, 47, 0, 0,
48, 0, 0, 0, 49, 50, 51, 52, 0, 54,
55, 0, 56, 0, 58, 59, 60, 61, 62, 63,
64, 0, 65, 66, 67, 0, 69, 70, 0, 0,
0, 0, 0, 71, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 183, 80, 81, 82, 83, 0, 84, 85,
0, 86, 184, 88, 89, 0, 0, 90, 0, 0,
91, 0, 0, 0, 0, 0, 92, 93, 94, 95,
0, 0, 0, 0, 98, 99, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 0, 0, 114, 0, 115, 116, 1604, 117, 118,
0, 119, 120, 5, 6, 7, 8, 9, 0, 0,
0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 11, 12, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 13, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
32, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 39, 40, 0, 0, 0, 41, 42, 43, 44,
0, 45, 0, 46, 1645, 47, 0, 0, 48, 0,
0, 0, 49, 50, 51, 52, 0, 54, 55, 0,
56, 0, 58, 59, 60, 61, 62, 63, 64, 0,
65, 66, 67, 0, 69, 70, 0, 0, 0, 0,
0, 71, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 89, 0, 0, 90, 0, 0, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 0, 0,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 0,
0, 114, 0, 115, 116, 0, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 11, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 13, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 32, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 39,
40, 0, 0, 0, 41, 42, 43, 44, 0, 45,
0, 46, 0, 47, 0, 0, 48, 0, 0, 0,
49, 50, 51, 52, 0, 54, 55, 0, 56, 0,
58, 59, 60, 61, 62, 63, 64, 0, 65, 66,
67, 0, 69, 70, 0, 0, 0, 0, 0, 71,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
89, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 0, 0, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
0, 115, 116, 1676, 117, 118, 0, 119, 120, 5,
6, 7, 8, 9, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 11, 12, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 13, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 32, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 39, 40, 0,
0, 0, 41, 42, 43, 44, 0, 45, 0, 46,
0, 47, 0, 0, 48, 0, 0, 0, 49, 50,
51, 52, 0, 54, 55, 0, 56, 0, 58, 59,
60, 61, 62, 63, 64, 0, 65, 66, 67, 0,
69, 70, 0, 0, 0, 0, 0, 71, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 89, 0,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 115,
116, 1677, 117, 118, 0, 119, 120, 5, 6, 7,
8, 9, 0, 0, 0, 0, 0, 10, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 11, 12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 13,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 32, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 39, 40, 0, 0, 0,
41, 42, 43, 44, 0, 45, 1680, 46, 0, 47,
0, 0, 48, 0, 0, 0, 49, 50, 51, 52,
0, 54, 55, 0, 56, 0, 58, 59, 60, 61,
62, 63, 64, 0, 65, 66, 67, 0, 69, 70,
0, 0, 0, 0, 0, 71, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 89, 0, 0, 90,
0, 0, 91, 0, 0, 0, 0, 0, 92, 93,
94, 95, 0, 0, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 0, 0, 114, 0, 115, 116, 0,
117, 118, 0, 119, 120, 5, 6, 7, 8, 9,
0, 0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 11,
12, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 13, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 32, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 39, 40, 0, 0, 0, 41, 42,
43, 44, 0, 45, 0, 46, 0, 47, 0, 0,
48, 0, 0, 0, 49, 50, 51, 52, 0, 54,
55, 0, 56, 0, 58, 59, 60, 61, 62, 63,
64, 0, 65, 66, 67, 0, 69, 70, 0, 0,
0, 0, 0, 71, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 183, 80, 81, 82, 83, 0, 84, 85,
0, 86, 184, 88, 89, 0, 0, 90, 0, 0,
91, 0, 0, 0, 0, 0, 92, 93, 94, 95,
0, 0, 0, 0, 98, 99, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 0, 0, 114, 0, 115, 116, 1695, 117, 118,
0, 119, 120, 5, 6, 7, 8, 9, 0, 0,
0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 11, 12, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 13, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
32, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 39, 40, 0, 0, 0, 41, 42, 43, 44,
0, 45, 0, 46, 0, 47, 0, 0, 48, 0,
0, 0, 49, 50, 51, 52, 0, 54, 55, 0,
56, 0, 58, 59, 60, 61, 62, 63, 64, 0,
65, 66, 67, 0, 69, 70, 0, 0, 0, 0,
0, 71, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 89, 0, 0, 90, 0, 0, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 0, 0,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 0,
0, 114, 0, 115, 116, 1749, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 11, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 13, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 32, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 39,
40, 0, 0, 0, 41, 42, 43, 44, 0, 45,
0, 46, 0, 47, 0, 0, 48, 0, 0, 0,
49, 50, 51, 52, 0, 54, 55, 0, 56, 0,
58, 59, 60, 61, 62, 63, 64, 0, 65, 66,
67, 0, 69, 70, 0, 0, 0, 0, 0, 71,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
89, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 0, 0, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
0, 115, 116, 1756, 117, 118, 0, 119, 120, 5,
6, 7, 8, 9, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 11, 12, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 13, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 32, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 39, 40, 0,
0, 0, 41, 42, 43, 44, 0, 45, 0, 46,
0, 47, 0, 0, 48, 0, 0, 0, 49, 50,
51, 52, 0, 54, 55, 0, 56, 0, 58, 59,
60, 61, 62, 63, 64, 0, 65, 66, 67, 0,
69, 70, 0, 0, 0, 0, 0, 71, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 89, 0,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 115,
116, 0, 117, 118, 0, 119, 120, 5, 6, 7,
8, 9, 0, 0, 0, 0, 0, 10, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 11, 12, 0, 457, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 32, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 39, 40, 0, 0, 0,
41, 42, 43, 44, 0, 45, 0, 46, 0, 47,
0, 0, 48, 0, 0, 0, 49, 50, 51, 52,
0, 54, 55, 0, 56, 0, 58, 59, 60, 61,
179, 180, 64, 0, 65, 66, 67, 0, 0, 0,
0, 0, 0, 0, 0, 71, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 0, 0, 0, 90,
0, 0, 91, 0, 0, 0, 0, 0, 92, 93,
94, 95, 0, 0, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 0, 0, 114, 0, 115, 116, 0,
117, 118, 0, 119, 120, 5, 6, 7, 8, 9,
0, 0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 11,
12, 0, 725, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 32, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 39, 40, 0, 0, 0, 41, 42,
43, 44, 0, 45, 0, 46, 0, 47, 0, 0,
48, 0, 0, 0, 49, 50, 51, 52, 0, 54,
55, 0, 56, 0, 58, 59, 60, 61, 179, 180,
64, 0, 65, 66, 67, 0, 0, 0, 0, 0,
0, 0, 0, 71, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 183, 80, 81, 82, 83, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 90, 0, 0,
91, 0, 0, 0, 0, 0, 92, 93, 94, 95,
0, 0, 0, 0, 98, 99, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 0, 0, 114, 0, 115, 116, 0, 117, 118,
0, 119, 120, 5, 6, 7, 8, 9, 0, 0,
0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 11, 12, 0,
945, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
32, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 39, 40, 0, 0, 0, 41, 42, 43, 44,
0, 45, 0, 46, 0, 47, 0, 0, 48, 0,
0, 0, 49, 50, 51, 52, 0, 54, 55, 0,
56, 0, 58, 59, 60, 61, 179, 180, 64, 0,
65, 66, 67, 0, 0, 0, 0, 0, 0, 0,
0, 71, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 0, 0, 0, 90, 0, 0, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 0, 0,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 0,
0, 114, 0, 115, 116, 0, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 11, 12, 0, 1457, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 32, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 39,
40, 0, 0, 0, 41, 42, 43, 44, 0, 45,
0, 46, 0, 47, 0, 0, 48, 0, 0, 0,
49, 50, 51, 52, 0, 54, 55, 0, 56, 0,
58, 59, 60, 61, 179, 180, 64, 0, 65, 66,
67, 0, 0, 0, 0, 0, 0, 0, 0, 71,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
0, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 0, 0, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
0, 115, 116, 0, 117, 118, 0, 119, 120, 5,
6, 7, 8, 9, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 11, 12, 0, 1595, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 32, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 39, 40, 0,
0, 0, 41, 42, 43, 44, 0, 45, 0, 46,
0, 47, 0, 0, 48, 0, 0, 0, 49, 50,
51, 52, 0, 54, 55, 0, 56, 0, 58, 59,
60, 61, 179, 180, 64, 0, 65, 66, 67, 0,
0, 0, 0, 0, 0, 0, 0, 71, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 0, 0,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 115,
116, 0, 117, 118, 0, 119, 120, 5, 6, 7,
8, 9, 0, 0, 0, 0, 0, 10, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 11, 12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 32, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 39, 40, 0, 0, 0,
41, 42, 43, 44, 0, 45, 0, 46, 0, 47,
0, 0, 48, 0, 0, 0, 49, 50, 51, 52,
0, 54, 55, 0, 56, 0, 58, 59, 60, 61,
179, 180, 64, 0, 65, 66, 67, 0, 0, 0,
0, 0, 0, 0, 0, 71, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 0, 0, 0, 90,
0, 0, 91, 0, 0, 0, 0, 0, 92, 93,
94, 95, 0, 0, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 0, 0, 114, 0, 115, 116, 0,
117, 118, 0, 119, 120, 5, 6, 7, 8, 9,
0, 0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
12, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 0, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 0, 0, 0, 0, 0, 41, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 52, 0, 0,
0, 0, 0, 0, 0, 59, 60, 61, 179, 180,
181, 0, 0, 66, 67, 0, 0, 0, 0, 0,
0, 0, 0, 182, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 183, 80, 81, 82, 83, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 90, 0, 0,
91, 0, 0, 0, 0, 0, 92, 93, 94, 95,
0, 0, 0, 0, 98, 99, 267, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 0, 0, 114, 0, 268, 0, 0, 117, 118,
0, 119, 120, 5, 6, 7, 8, 9, 0, 0,
0, 0, 364, 10, 365, 366, 367, 368, 369, 370,
371, 372, 373, 374, 375, 376, 377, 378, 379, 380,
381, 382, 383, 384, 385, 607, 386, 0, 0, 0,
0, 0, 0, 0, 0, 0, 14, 15, 387, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
0, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 0, 0, 0, 0, 0, 41, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 52, 0, 0, 0, 0,
0, 0, 0, 59, 60, 61, 179, 180, 181, 0,
0, 66, 67, 0, 0, 0, 0, 0, 0, 0,
0, 182, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 0, 608, 0, 90, 0, 0, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 0, 0,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 0,
0, 114, 0, 0, 0, 0, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 0, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 0,
0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 52, 0, 0, 0, 0, 0, 0,
0, 59, 60, 61, 179, 180, 181, 0, 0, 66,
67, 0, 0, 0, 0, 0, 0, 0, 0, 182,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
0, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 0, 0, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
362, 363, 720, 0, 117, 118, 0, 119, 120, 5,
6, 7, 8, 9, 0, 0, 0, 0, 364, 10,
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 1072, 386, 0, 0, 0, 0, 0, 0, 0,
0, 0, 14, 15, 387, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 0, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 0, 0, 0,
0, 0, 41, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 52, 0, 0, 0, 0, 0, 0, 0, 59,
60, 61, 179, 180, 181, 0, 0, 66, 67, 0,
0, 0, 0, 0, 0, 0, 0, 182, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 0, 1073,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 0,
0, 0, 117, 118, 0, 119, 120, 5, 6, 7,
8, 9, 0, 0, 0, 0, 0, 10, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 661, 12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 0, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 52,
0, 0, 0, 0, 0, 0, 0, 59, 60, 61,
179, 180, 181, 0, 0, 66, 67, 0, 0, 0,
0, 0, 0, 0, 0, 182, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 0, 0, 0, 90,
0, 0, 91, 5, 6, 7, 8, 9, 92, 93,
94, 95, 0, 10, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 0, 0, 114, 0, 0, 0, 0,
117, 118, 0, 119, 120, 0, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
0, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 0, 0, 0, 0, 0, 41, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 195, 0, 0, 52, 0, 0, 0, 0,
0, 0, 0, 59, 60, 61, 179, 180, 181, 0,
36, 66, 67, 0, 0, 0, 0, 0, 0, 0,
0, 182, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 0, 0, 0, 90, 0, 0, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 0, 0,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 84,
85, 114, 86, 184, 88, 0, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 0, 0, 221, 613, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 0, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 0,
0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 52, 0, 0, 0, 0, 0, 0,
0, 59, 60, 61, 179, 180, 181, 0, 0, 66,
67, 0, 0, 0, 0, 0, 0, 0, 0, 182,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
0, 0, 0, 90, 0, 0, 91, 5, 6, 7,
8, 9, 92, 93, 94, 95, 0, 10, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
0, 0, 0, 0, 117, 118, 0, 119, 120, 0,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 0, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 52,
0, 0, 0, 0, 0, 0, 0, 59, 60, 61,
179, 180, 181, 0, 0, 66, 67, 0, 0, 0,
0, 0, 0, 0, 0, 182, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 0, 0, 0, 90,
0, 0, 91, 5, 6, 7, 8, 9, 92, 93,
94, 95, 0, 10, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 0, 0, 114, 0, 250, 0, 0,
117, 118, 0, 119, 120, 0, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
0, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 0, 0, 0, 0, 0, 41, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 52, 0, 0, 0, 0,
0, 0, 0, 59, 60, 61, 179, 180, 181, 0,
0, 66, 67, 0, 0, 0, 0, 0, 0, 0,
0, 182, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 0, 0, 0, 90, 0, 0, 91, 5,
6, 7, 8, 9, 92, 93, 94, 95, 0, 10,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 0,
0, 114, 0, 253, 0, 0, 117, 118, 0, 119,
120, 0, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 0, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 0, 0, 0,
0, 0, 41, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 52, 0, 0, 0, 0, 0, 0, 0, 59,
60, 61, 179, 180, 181, 0, 0, 66, 67, 0,
0, 0, 0, 0, 0, 0, 0, 182, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 0, 0,
0, 90, 0, 0, 91, 0, 0, 0, 0, 0,
92, 93, 94, 95, 0, 0, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 455, 0,
0, 0, 117, 118, 0, 119, 120, 5, 6, 7,
8, 9, 0, 0, 0, 0, 0, 10, -907, -907,
-907, -907, 374, 375, 376, 377, 378, 379, 380, 381,
382, 383, 384, 385, 620, 386, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 387, 0, 0,
14, 15, 0, 0, 0, 0, 16, 0, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
28, 29, 30, 31, 0, 0, 0, 0, 33, 34,
35, 36, 37, 38, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 52,
0, 0, 0, 0, 0, 0, 0, 59, 60, 61,
179, 180, 181, 0, 36, 66, 67, 0, 0, 0,
0, 0, 0, 0, 0, 182, 72, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 78,
0, 0, 0, 0, 183, 80, 81, 82, 83, 0,
84, 85, 0, 86, 184, 88, 0, 0, 0, 90,
0, 0, 91, 0, 0, 0, 0, 0, 92, 93,
94, 95, 0, 0, 0, 0, 98, 99, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 84, 85, 114, 86, 184, 88, 0,
117, 118, 0, 119, 120, 5, 6, 7, 8, 9,
0, 0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 111, 112, 0, 0, 662, 878, 0,
0, 0, 0, 0, 0, 0, 0, 0, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 0, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 0, 0, 0, 0, 0, 41, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 52, 0, 0,
0, 0, 0, 0, 0, 59, 60, 61, 179, 180,
181, 0, 36, 66, 67, 0, 0, 0, 0, 0,
0, 0, 0, 182, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 183, 80, 81, 82, 83, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 90, 0, 651,
91, 0, 0, 0, 0, 0, 92, 93, 94, 95,
0, 0, 0, 0, 98, 99, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 84, 85, 114, 86, 184, 88, 0, 117, 118,
0, 119, 120, 5, 6, 7, 8, 9, 0, 0,
0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 0, 0, 704, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 14, 15, 0, 0,
0, 0, 16, 0, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 0, 28, 29, 30, 31,
0, 0, 0, 0, 33, 34, 35, 36, 37, 38,
0, 0, 0, 0, 0, 0, 41, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 52, 0, 0, 0, 0,
0, 0, 0, 59, 60, 61, 179, 180, 181, 0,
36, 66, 67, 0, 0, 0, 0, 0, 0, 0,
0, 182, 72, 0, 73, 74, 75, 76, 77, 0,
0, 0, 0, 0, 0, 78, 0, 0, 0, 0,
183, 80, 81, 82, 83, 0, 84, 85, 0, 86,
184, 88, 0, 0, 0, 90, 0, 1165, 91, 0,
0, 0, 0, 0, 92, 93, 94, 95, 0, 0,
0, 0, 98, 99, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 84,
85, 114, 86, 184, 88, 0, 117, 118, 0, 119,
120, 5, 6, 7, 8, 9, 0, 0, 0, 0,
0, 10, 0, 0, 0, 0, 0, 0, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 0, 0, 706, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 0, 0,
0, 0, 33, 34, 35, 36, 37, 38, 0, 0,
0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 52, 0, 0, 0, 0, 0, 0,
0, 59, 60, 61, 179, 180, 181, 0, 36, 66,
67, 0, 0, 0, 0, 0, 0, 0, 0, 182,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
0, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 0, 0, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 84, 85, 114,
86, 184, 88, 0, 117, 118, 0, 119, 120, 5,
6, 7, 8, 9, 0, 0, 0, 0, 0, 10,
0, 0, 0, 0, 0, 0, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 0,
0, 1114, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 14, 15, 0, 0, 0, 0, 16, 0,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 0, 28, 29, 30, 31, 0, 0, 0, 0,
33, 34, 35, 36, 37, 38, 0, 0, 0, 0,
0, 0, 41, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 52, 0, 0, 0, 0, 0, 0, 0, 59,
60, 61, 179, 180, 181, 0, 0, 66, 67, 0,
0, 0, 0, 0, 0, 0, 0, 182, 72, 0,
73, 74, 75, 76, 77, 0, 0, 0, 0, 0,
0, 78, 0, 0, 0, 0, 183, 80, 81, 82,
83, 0, 84, 85, 0, 86, 184, 88, 0, 0,
0, 90, 0, 0, 91, 5, 6, 7, 8, 9,
92, 93, 94, 95, 0, 10, 0, 0, 98, 99,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 0, 0, 114, 0, 0,
0, 0, 117, 118, 0, 119, 120, 0, 14, 15,
0, 0, 0, 0, 16, 0, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 0, 28, 29,
30, 31, 0, 0, 0, 0, 33, 34, 35, 36,
37, 38, 0, 0, 0, 0, 0, 0, 41, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 52, 0, 0,
0, 0, 0, 0, 0, 59, 60, 61, 179, 180,
181, 0, 0, 66, 67, 0, 0, 0, 0, 0,
0, 0, 0, 182, 72, 0, 73, 74, 75, 76,
77, 0, 0, 0, 0, 0, 0, 78, 0, 0,
0, 0, 183, 80, 81, 82, 83, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 90, 0, 0,
91, 5, 6, 7, 8, 9, 92, 93, 94, 95,
0, 10, 0, 0, 98, 99, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 0, 0, 114, 0, 0, 0, 0, 117, 118,
0, 119, 120, 0, 14, 15, 0, 0, 0, 0,
16, 0, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 0, 28, 29, 30, 31, 0, 0,
0, 0, 33, 34, 35, 36, 549, 38, 0, 0,
0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 52, 0, 0, 0, 0, 0, 0,
0, 59, 60, 61, 179, 180, 181, 0, 0, 66,
67, 0, 0, 0, 0, 0, 0, 0, 0, 182,
72, 0, 73, 74, 75, 76, 77, 0, 0, 0,
0, 0, 0, 78, 0, 0, 0, 0, 183, 80,
81, 82, 83, 0, 84, 85, 0, 86, 184, 88,
0, 0, 0, 90, 0, 0, 91, 0, 0, 0,
0, 0, 92, 93, 94, 95, 0, 0, 0, 0,
98, 99, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 0, 0, 114,
361, 362, 363, 0, 117, 118, 0, 119, 120, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 364,
0, 365, 366, 367, 368, 369, 370, 371, 372, 373,
374, 375, 376, 377, 378, 379, 380, 381, 382, 383,
384, 385, 0, 386, 1478, 1479, 1480, 1481, 1482, 0,
0, 1483, 1484, 1485, 1486, 387, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1487, 1488,
0, 984, 0, 985, 986, 987, 988, 989, 990, 991,
992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001,
1002, 1003, 1004, 1005, 1489, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1006, 1490, 1491,
1492, 1493, 1494, 1495, 1496, 0, 0, 0, 36, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1497, 1498,
1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508,
1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518,
1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528,
1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 0,
0, 0, 1538, 1539, 0, 1540, 1541, 1542, 1543, 1544,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1545, 1546, 1547, 0, 1432, 0, 84, 85, 0,
86, 184, 88, 1548, 0, 1549, 1550, 0, 1551, 0,
0, 0, 0, 0, 0, 1552, 0, 0, 0, 1553,
0, 1554, 0, 1555, 1556, 0, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 361,
362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 364, 0,
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 0, 386, 361, 362, 363, 0, 0, 0, 0,
0, 0, 0, 0, 387, 0, 0, 0, 0, 0,
0, 0, 364, 0, 365, 366, 367, 368, 369, 370,
371, 372, 373, 374, 375, 376, 377, 378, 379, 380,
381, 382, 383, 384, 385, 0, 386, 361, 362, 363,
0, 0, 0, 0, 0, 0, 0, 0, 387, 0,
0, 0, 0, 0, 0, 0, 364, 0, 365, 366,
367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
377, 378, 379, 380, 381, 382, 383, 384, 385, 0,
386, 361, 362, 363, 0, 0, 0, 0, 0, 0,
0, 0, 387, 0, 0, 0, 0, 0, 0, 0,
364, 0, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
383, 384, 385, 0, 386, 361, 362, 363, 0, 0,
0, 0, 0, 0, 0, 0, 387, 0, 0, 0,
0, 0, 471, 0, 364, 0, 365, 366, 367, 368,
369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
379, 380, 381, 382, 383, 384, 385, 0, 386, 361,
362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
387, 0, 0, 0, 0, 0, 473, 0, 364, 0,
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 0, 386, 361, 362, 363, 0, 0, 0, 0,
0, 0, 0, 0, 387, 0, 0, 0, 0, 0,
484, 0, 364, 0, 365, 366, 367, 368, 369, 370,
371, 372, 373, 374, 375, 376, 377, 378, 379, 380,
381, 382, 383, 384, 385, 0, 386, 361, 362, 363,
0, 0, 0, 0, 0, 0, 0, 0, 387, 0,
0, 0, 0, 0, 508, 0, 364, 0, 365, 366,
367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
377, 378, 379, 380, 381, 382, 383, 384, 385, 0,
386, 361, 362, 363, 0, 0, 0, 0, 0, 0,
0, 0, 387, 0, 36, 0, 0, 695, 0, 0,
364, 0, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
383, 384, 385, 0, 386, 0, 361, 362, 363, 0,
0, 0, 0, 0, 0, 0, 387, 0, 0, 0,
0, 717, 0, 0, 0, 364, 0, 365, 366, 367,
368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
378, 379, 380, 381, 382, 383, 384, 385, 255, 386,
0, 1562, 0, 84, 85, 1563, 86, 184, 88, 0,
1015, 387, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 256, 0, 0, 0, 0, 0,
0, 0, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 111, 112, 0, 36, 255, 1417, 0,
1011, 1012, 985, 986, 987, 988, 989, 990, 991, 992,
993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002,
1003, 1004, 1005, 256, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1006, 0, 0, 0,
0, 1646, 0, 0, 0, 36, 0, 0, 0, 0,
0, 257, 258, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 183,
0, 255, 82, 259, 0, 84, 85, 0, 86, 184,
88, 0, 959, 0, 0, 1466, 0, 0, 0, 0,
0, 0, 0, 260, 0, 0, 0, 256, 0, 0,
257, 258, 0, 0, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 0, 183, 36,
261, 82, 259, 0, 84, 85, 0, 86, 184, 88,
0, 1291, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 260, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 0, 0, 0, 261,
0, 0, 29, 30, 257, 258, 0, 0, 0, 0,
0, 0, 36, 0, 38, 0, 0, 0, 0, 0,
0, 0, 183, 0, 0, 82, 259, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 0, 0, 0,
52, 0, 0, 0, 0, 0, 260, 0, 59, 60,
61, 179, 180, 181, 1173, 0, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
745, 746, 0, 261, 0, 0, 747, 0, 748, 0,
0, 0, 0, 0, 0, 183, 0, 0, 82, 83,
749, 84, 85, 0, 86, 184, 88, 0, 33, 34,
35, 36, 0, 91, 0, 0, 0, 0, 939, 0,
750, 0, 0, 0, 0, 0, 0, 0, 99, 0,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 0, 0, 437, 0, 0, 0,
0, 117, 0, 0, 0, 0, 0, 0, 0, 0,
36, 0, 212, 0, 0, 0, 751, 0, 73, 74,
75, 76, 77, 0, 0, 0, 0, 0, 0, 752,
0, 0, 0, 0, 183, 80, 81, 82, 753, 0,
84, 85, 0, 86, 184, 88, 0, 0, 0, 90,
0, 213, 0, 0, 0, 0, 0, 0, 754, 755,
756, 757, 0, 0, 940, 0, 98, 36, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 0, 183, 0, 758, 82, 83, 0, 84,
85, 0, 86, 184, 88, 276, 277, 0, 986, 987,
988, 989, 990, 991, 992, 993, 994, 995, 996, 997,
998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 1006, 745, 746, 214, 0, 0, 0, 747, 117,
748, 0, 0, 278, 0, 0, 84, 85, 0, 86,
184, 88, 749, 0, 0, 0, 0, 0, 0, 0,
33, 34, 35, 36, 0, 0, 0, 0, 0, 0,
0, 0, 750, 982, 983, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 0, 0,
0, 984, 0, 985, 986, 987, 988, 989, 990, 991,
992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001,
1002, 1003, 1004, 1005, 0, 0, 0, 0, 751, 0,
73, 74, 75, 76, 77, 0, 0, 1006, 0, 0,
0, 752, 0, 0, 0, 0, 183, 80, 81, 82,
753, 0, 84, 85, 0, 86, 184, 88, 0, 0,
0, 90, 0, 0, 0, 0, 0, 0, 0, 0,
754, 755, 756, 757, 907, 908, 0, 0, 98, 0,
0, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 909, 0, 0, 758, 0, 0,
0, 0, 910, 911, 912, 36, 361, 362, 363, 0,
0, 29, 30, 0, 913, 0, 0, 0, 0, 0,
0, 36, 0, 212, 0, 364, 0, 365, 366, 367,
368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
378, 379, 380, 381, 382, 383, 384, 385, 0, 386,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
914, 387, 213, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 915, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 84, 85, 0, 86, 184, 88,
0, 0, 0, 0, 183, 0, 0, 82, 83, 896,
84, 85, 916, 86, 184, 88, 0, 0, 36, 0,
212, 0, 91, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 433, 0, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 0, 0, 0, 437, 0, 0, 0, 213,
117, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 36, 0, 212, -907, -907, -907, -907, 994,
995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004,
1005, 183, 0, 0, 82, 83, 0, 84, 85, 0,
86, 184, 88, 0, 1006, 0, 0, 0, 0, 0,
0, 0, 0, 213, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 36,
0, 0, 214, 0, 0, 183, 0, 117, 82, 83,
0, 84, 85, 0, 86, 184, 88, 36, 0, 212,
0, 987, 988, 989, 990, 991, 992, 993, 994, 995,
996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 1006, 0, 0, 214, 0, 213, 521,
0, 117, 0, 0, 0, 0, 0, 0, 0, 0,
0, 541, 183, 0, 0, 82, 83, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 0, 0, 0,
183, 0, 0, 82, 83, 0, 84, 85, 0, 86,
184, 88, 36, 0, 212, 0, 0, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
0, 0, 0, 0, 0, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 0, 0,
0, 214, 0, 213, 0, 0, 117, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1040, 36, 0, 212,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 183, 0, 0, 82, 83,
0, 84, 85, 0, 86, 184, 88, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 213, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 36, 0, 212, 214, 0, 0, 0,
183, 117, 0, 82, 83, 0, 84, 85, 0, 86,
184, 88, 0, 0, 0, 0, 36, 0, 212, 0,
0, 0, 0, 0, 0, 563, 0, 0, 0, 0,
0, 0, 0, 0, 226, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 0, 0,
0, 214, 0, 0, 0, 0, 117, 213, 0, 0,
0, 0, 0, 0, 0, 0, 183, 0, 0, 82,
83, 0, 84, 85, 0, 86, 184, 88, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 183,
0, 0, 82, 83, 0, 84, 85, 0, 86, 184,
88, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 0, 0, 0, 227, 0, 0,
0, 0, 117, 0, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 361, 362, 363,
0, 0, 0, 0, 0, 564, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 364, 0, 365, 366,
367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
377, 378, 379, 380, 381, 382, 383, 384, 385, 0,
386, 361, 362, 363, 0, 0, 0, 0, 0, 0,
0, 0, 387, 0, 0, 0, 0, 0, 0, 0,
364, 0, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
383, 384, 385, 0, 386, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 387, 361, 362, 363,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 364, 443, 365, 366,
367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
377, 378, 379, 380, 381, 382, 383, 384, 385, 0,
386, 361, 362, 363, 0, 0, 0, 0, 0, 0,
0, 0, 387, 0, 0, 0, 0, 0, 0, 0,
364, 846, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
383, 384, 385, 0, 386, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 387, 361, 362, 363,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 364, 884, 365, 366,
367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
377, 378, 379, 380, 381, 382, 383, 384, 385, 0,
386, 361, 362, 363, 0, 0, 0, 0, 0, 0,
0, 0, 387, 0, 0, 0, 0, 0, 0, 0,
364, 925, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
383, 384, 385, 0, 386, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 387, 981, 982, 983,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 984, 1230, 985, 986,
987, 988, 989, 990, 991, 992, 993, 994, 995, 996,
997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 0,
0, 981, 982, 983, 0, 0, 0, 0, 0, 0,
0, 0, 1006, 0, 0, 0, 0, 0, 0, 0,
984, 1248, 985, 986, 987, 988, 989, 990, 991, 992,
993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002,
1003, 1004, 1005, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1006, 981, 982, 983,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 984, 1304, 985, 986,
987, 988, 989, 990, 991, 992, 993, 994, 995, 996,
997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 0,
0, 981, 982, 983, 0, 0, 0, 0, 0, 0,
0, 0, 1006, 0, 0, 0, 0, 0, 0, 0,
984, 1309, 985, 986, 987, 988, 989, 990, 991, 992,
993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002,
1003, 1004, 1005, 0, 0, 0, 0, 0, 0, 0,
0, 36, 0, 0, 0, 0, 1006, 981, 982, 983,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 36, 0, 0, 0, 0, 984, 1386, 985, 986,
987, 988, 989, 990, 991, 992, 993, 994, 995, 996,
997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1006, 1404, 0, 0, 36, 0, 0, 0,
0, 1464, 0, 0, 0, 0, 1405, 1406, 348, 36,
84, 85, 0, 86, 184, 88, 0, 0, 0, 0,
0, 0, 0, 0, 183, 0, 0, 82, 1407, 0,
84, 85, 0, 86, 1408, 88, 0, 0, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 0, 0, 36, 0, 0, 1465, 0, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 509, 0, 0, 84, 85, 0, 86, 184,
88, 0, 0, 0, 0, 513, 0, 0, 84, 85,
0, 86, 184, 88, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
278, 0, 0, 84, 85, 0, 86, 184, 88, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 361, 362, 363,
0, 0, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 111, 112, 729, 364, 0, 365, 366,
367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
377, 378, 379, 380, 381, 382, 383, 384, 385, 0,
386, 0, 361, 362, 363, 0, 0, 0, 0, 0,
0, 0, 387, 0, 0, 0, 0, 0, 0, 0,
0, 364, 881, 365, 366, 367, 368, 369, 370, 371,
372, 373, 374, 375, 376, 377, 378, 379, 380, 381,
382, 383, 384, 385, 730, 386, 361, 362, 363, 0,
0, 0, 0, 0, 0, 0, 0, 387, 0, 0,
0, 0, 0, 0, 0, 364, 0, 365, 366, 367,
368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
378, 379, 380, 381, 382, 383, 384, 385, 0, 386,
981, 982, 983, 0, 0, 0, 0, 0, 0, 0,
0, 387, 0, 0, 0, 0, 0, 0, 0, 984,
1314, 985, 986, 987, 988, 989, 990, 991, 992, 993,
994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003,
1004, 1005, 981, 982, 983, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1006, 0, 0, 0, 0,
0, 984, 0, 985, 986, 987, 988, 989, 990, 991,
992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001,
1002, 1003, 1004, 1005, 363, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1006, 0, 0,
0, 364, 0, 365, 366, 367, 368, 369, 370, 371,
372, 373, 374, 375, 376, 377, 378, 379, 380, 381,
382, 383, 384, 385, 983, 386, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 387, 0, 0,
0, 984, 0, 985, 986, 987, 988, 989, 990, 991,
992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001,
1002, 1003, 1004, 1005, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1006, 369, 370,
371, 372, 373, 374, 375, 376, 377, 378, 379, 380,
381, 382, 383, 384, 385, 0, 386, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 387
};
static const yytype_int16 yycheck[] =
{
4, 163, 136, 4, 610, 53, 582, 186, 4, 316,
32, 4, 4, 89, 697, 4, 54, 858, 4, 1064,
96, 97, 44, 228, 175, 166, 48, 427, 581, 386,
400, 421, 422, 839, 163, 728, 453, 114, 9, 9,
26, 27, 114, 234, 556, 453, 50, 114, 4, 53,
1049, 30, 30, 187, 735, 1047, 4, 9, 877, 135,
50, 451, 1060, 457, 9, 9, 70, 9, 224, 9,
9, 45, 255, 256, 893, 9, 9, 9, 261, 9,
9, 9, 9, 87, 9, 89, 9, 9, 9, 66,
9, 57, 96, 97, 235, 109, 9, 79, 9, 33,
85, 9, 9, 79, 30, 66, 1589, 938, 155, 66,
301, 505, 170, 79, 97, 79, 82, 170, 128, 129,
155, 85, 14, 9, 97, 170, 128, 129, 114, 45,
45, 135, 85, 168, 0, 45, 116, 214, 30, 201,
136, 201, 214, 201, 124, 201, 29, 45, 201, 8,
227, 100, 101, 167, 66, 47, 201, 204, 341, 1642,
201, 146, 163, 46, 154, 316, 49, 66, 974, 204,
153, 128, 129, 149, 353, 10, 11, 12, 66, 66,
153, 163, 79, 147, 148, 66, 66, 66, 149, 583,
66, 187, 202, 146, 29, 199, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 294, 53, 79,
66, 66, 294, 66, 201, 199, 204, 294, 214, 66,
65, 30, 66, 203, 205, 221, 240, 66, 66, 171,
244, 227, 393, 204, 248, 1243, 1245, 204, 66, 79,
429, 203, 204, 1252, 240, 1254, 205, 202, 244, 203,
202, 1253, 266, 203, 203, 399, 417, 948, 202, 950,
203, 347, 1091, 203, 203, 203, 203, 203, 203, 202,
436, 203, 203, 202, 240, 171, 202, 202, 244, 202,
441, 202, 202, 476, 202, 202, 344, 283, 874, 450,
1131, 199, 453, 1109, 202, 204, 292, 293, 294, 206,
276, 277, 278, 299, 201, 202, 204, 829, 154, 305,
396, 397, 201, 204, 204, 204, 720, 331, 204, 79,
331, 725, 79, 201, 79, 331, 340, 35, 85, 35,
344, 79, 308, 347, 35, 331, 206, 100, 101, 50,
35, 79, 128, 129, 35, 1353, 201, 1355, 204, 204,
437, 204, 400, 79, 1363, 437, 97, 204, 198, 85,
204, 79, 97, 208, 204, 204, 204, 325, 149, 35,
170, 79, 201, 79, 128, 129, 204, 204, 79, 393,
394, 395, 396, 397, 79, 578, 579, 588, 79, 170,
147, 148, 398, 97, 587, 71, 72, 386, 97, 201,
566, 201, 53, 417, 393, 201, 816, 573, 163, 201,
576, 459, 153, 79, 65, 163, 201, 1110, 153, 205,
201, 147, 148, 204, 1127, 163, 598, 441, 417, 147,
148, 427, 26, 27, 79, 862, 1444, 201, 653, 453,
85, 437, 205, 154, 862, 201, 206, 66, 202, 153,
464, 79, 441, 210, 153, 163, 117, 163, 169, 598,
204, 450, 163, 124, 453, 105, 149, 201, 464, 201,
685, 660, 163, 113, 114, 115, 116, 117, 118, 79,
77, 201, 1298, 209, 650, 85, 201, 170, 703, 153,
890, 1077, 46, 47, 1080, 99, 100, 101, 464, 926,
1063, 702, 147, 148, 71, 72, 520, 708, 926, 128,
129, 113, 114, 115, 116, 117, 118, 79, 146, 147,
148, 204, 839, 85, 99, 100, 101, 126, 127, 896,
616, 545, 546, 509, 113, 114, 115, 513, 4, 203,
204, 945, 518, 183, 759, 153, 146, 147, 148, 390,
743, 744, 201, 150, 35, 1371, 153, 708, 66, 156,
157, 79, 159, 160, 161, 203, 1259, 85, 1261, 113,
114, 115, 116, 117, 118, 741, 203, 418, 203, 45,
203, 183, 423, 203, 1592, 147, 148, 598, 185, 186,
187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 203, 616, 118, 119, 120, 1618, 1619, 205, 1614,
1615, 607, 203, 204, 113, 114, 115, 116, 117, 118,
214, 29, 203, 204, 582, 124, 125, 221, 146, 147,
148, 743, 744, 227, 203, 66, 4, 830, 46, 183,
106, 49, 49, 50, 51, 111, 53, 113, 114, 115,
116, 117, 118, 119, 49, 50, 51, 974, 65, 204,
853, 1247, 1042, 162, 66, 1720, 662, 203, 201, 1232,
65, 149, 865, 201, 66, 149, 1369, 45, 839, 201,
1735, 153, 203, 697, 183, 699, 1086, 44, 65, 283,
156, 157, 724, 159, 170, 1095, 149, 201, 292, 293,
294, 862, 208, 9, 718, 299, 1714, 718, 704, 149,
706, 305, 718, 149, 201, 8, 170, 183, 732, 733,
1130, 1729, 718, 203, 113, 114, 115, 116, 117, 118,
201, 14, 79, 14, 730, 124, 125, 733, 106, 205,
203, 203, 124, 111, 124, 113, 114, 115, 116, 117,
118, 119, 14, 170, 920, 202, 14, 97, 1451, 952,
202, 954, 207, 202, 202, 926, 201, 733, 105, 783,
9, 160, 783, 162, 201, 789, 201, 783, 1364, 793,
794, 202, 202, 9, 89, 203, 14, 783, 156, 157,
201, 159, 1109, 9, 183, 79, 187, 963, 201, 813,
1204, 79, 79, 1213, 970, 801, 190, 203, 9, 895,
203, 9, 788, 974, 828, 183, 792, 828, 79, 202,
816, 817, 828, 202, 202, 828, 828, 203, 842, 828,
126, 201, 828, 427, 66, 202, 30, 205, 127, 1690,
169, 9, 856, 437, 130, 856, 202, 149, 862, 1249,
856, 202, 9, 302, 202, 1070, 1707, 306, 9, 202,
856, 14, 828, 199, 1715, 9, 66, 1271, 9, 1062,
828, 1064, 171, 862, 202, 9, 14, 126, 208, 9,
205, 895, 208, 1287, 333, 201, 335, 336, 337, 338,
208, 202, 202, 907, 908, 909, 1089, 201, 97, 931,
858, 1594, 184, 185, 186, 208, 203, 896, 202, 191,
192, 203, 926, 195, 196, 130, 874, 9, 932, 149,
934, 201, 936, 934, 149, 936, 202, 201, 934, 201,
936, 201, 201, 204, 187, 149, 932, 926, 934, 1105,
936, 955, 938, 939, 187, 14, 9, 79, 1109, 204,
4, 1351, 1145, 46, 47, 48, 49, 50, 51, 973,
53, 203, 14, 204, 14, 979, 932, 204, 208, 1373,
14, 30, 65, 26, 27, 199, 203, 30, 1382, 201,
201, 1298, 46, 47, 48, 49, 50, 51, 30, 1155,
201, 45, 1396, 1159, 1042, 14, 1162, 201, 201, 9,
53, 65, 130, 1169, 65, 202, 201, 203, 1022, 14,
203, 1025, 9, 607, 202, 9, 1209, 208, 97, 146,
1636, 79, 9, 201, 130, 14, 203, 202, 79, 201,
204, 201, 1046, 202, 130, 1046, 9, 204, 204, 146,
1046, 73, 30, 1046, 1046, 208, 202, 1046, 203, 203,
1046, 171, 106, 1457, 1371, 130, 30, 111, 130, 113,
114, 115, 116, 117, 118, 119, 202, 202, 662, 9,
9, 202, 9, 202, 9, 79, 1072, 202, 202, 205,
1046, 74, 75, 76, 202, 14, 205, 1119, 1046, 1705,
204, 201, 1106, 86, 202, 204, 1110, 1290, 202, 1292,
202, 1267, 156, 157, 201, 159, 130, 202, 1122, 9,
704, 202, 706, 202, 30, 203, 202, 202, 1114, 1077,
1134, 203, 1080, 1134, 204, 203, 1122, 97, 1134, 183,
158, 154, 14, 79, 1130, 1131, 730, 1298, 1134, 1332,
111, 134, 135, 136, 137, 138, 202, 202, 130, 130,
14, 205, 145, 79, 202, 204, 1122, 204, 151, 152,
203, 214, 1334, 4, 14, 79, 202, 201, 221, 204,
130, 202, 165, 203, 227, 14, 203, 14, 203, 14,
1584, 55, 1586, 204, 79, 201, 79, 9, 1332, 182,
203, 1595, 79, 97, 1208, 149, 109, 161, 97, 33,
1211, 14, 255, 256, 45, 1398, 201, 801, 261, 1220,
1371, 202, 167, 203, 79, 201, 164, 1213, 202, 9,
79, 204, 816, 817, 203, 202, 202, 14, 79, 14,
283, 79, 14, 1422, 79, 1639, 14, 79, 788, 292,
293, 792, 1698, 518, 394, 1259, 299, 1261, 397, 396,
894, 831, 305, 1211, 891, 1128, 1711, 1456, 1284, 1707,
523, 1447, 1220, 316, 1322, 106, 1476, 1560, 1327, 1739,
111, 1572, 113, 114, 115, 116, 117, 118, 119, 42,
1727, 1443, 494, 400, 1017, 1014, 494, 780, 341, 1247,
1093, 344, 1050, 971, 908, 1106, 922, 862, 300, 319,
977, 293, 743, 1317, 956, 1033, 1317, -1, 1322, -1,
-1, 1317, -1, 1327, -1, 156, 157, -1, 159, -1,
-1, 1317, -1, 1334, -1, 1331, -1, -1, -1, 1733,
-1, -1, -1, 386, -1, -1, 1740, -1, -1, -1,
-1, -1, 183, 1354, 938, 939, -1, -1, -1, 1360,
-1, 1362, -1, -1, -1, 1369, -1, -1, -1, -1,
1374, -1, -1, 1374, 205, 1379, 1424, -1, 1374, 1383,
-1, -1, 1383, -1, 427, -1, -1, 1383, 1374, -1,
-1, -1, -1, 1379, 437, 1574, -1, 1383, -1, -1,
-1, -1, -1, 4, -1, -1, 1354, 1411, -1, -1,
-1, -1, 1360, 1417, 1362, -1, 1364, -1, -1, -1,
1424, -1, -1, 1379, 1428, -1, -1, -1, -1, -1,
1426, -1, -1, 476, 477, -1, -1, 480, -1, -1,
-1, -1, -1, -1, 45, -1, -1, 1451, 1449, -1,
1454, 1455, 1456, 1454, -1, -1, 1460, -1, 1454, 1460,
-1, -1, -1, 1467, 1460, -1, 1467, -1, 1454, 1455,
1456, 1467, -1, -1, 1460, -1, -1, -1, -1, -1,
-1, 1467, -1, -1, 527, -1, -1, -1, 1072, -1,
-1, -1, -1, -1, -1, 1571, -1, -1, -1, 1455,
1456, 1449, -1, -1, -1, 106, -1, -1, -1, -1,
111, -1, 113, 114, 115, 116, 117, 118, 119, 26,
27, -1, -1, 30, 1686, -1, -1, -1, -1, -1,
1114, -1, -1, -1, -1, 578, 579, 1720, -1, -1,
-1, -1, -1, -1, 587, -1, 1130, 1131, -1, -1,
-1, -1, 1735, -1, 1630, 156, 157, -1, 159, -1,
-1, -1, -1, -1, 607, -1, -1, 1571, 1702, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, -1, 183, -1, -1, -1, 1590, -1, -1, -1,
1594, -1, -1, -1, 65, 1599, -1, -1, 1599, -1,
-1, -1, -1, 1599, 205, 1609, -1, -1, -1, -1,
1614, 1615, -1, 1599, 1618, 1619, -1, -1, -1, 662,
-1, -1, -1, -1, -1, -1, 1630, -1, -1, 1213,
-1, -1, -1, 1637, 1638, -1, 1637, 1638, -1, -1,
1644, 1637, 1638, 1644, -1, -1, -1, -1, 1644, -1,
-1, 1637, 1638, -1, -1, -1, -1, -1, 1644, -1,
-1, 704, -1, 706, -1, -1, -1, -1, 4, -1,
-1, -1, -1, -1, 1678, -1, -1, 1678, -1, -1,
-1, 1685, 1678, -1, -1, 1686, -1, 730, 731, -1,
-1, -1, 1678, -1, -1, -1, -1, 1701, -1, -1,
743, 744, 745, 746, 747, 748, 749, -1, -1, 45,
-1, -1, -1, -1, 221, 758, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 1741, 53, -1,
1741, 784, 1690, -1, 1748, 1741, -1, 1748, -1, -1,
65, -1, 1748, -1, -1, 1741, -1, -1, 801, 1707,
-1, -1, 1748, -1, -1, -1, -1, 1715, -1, -1,
106, 814, 77, 816, 817, 111, 283, 113, 114, 115,
116, 117, 118, 119, -1, 292, 293, 830, 831, -1,
-1, -1, 299, -1, -1, -1, 839, -1, 305, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 316,
853, -1, -1, -1, -1, -1, -1, -1, -1, -1,
156, 157, 865, 159, -1, -1, -1, -1, -1, -1,
873, -1, -1, 876, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 183, 153, -1,
-1, 156, 157, 896, 159, 160, 161, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 205,
-1, -1, 26, 27, -1, -1, 30, -1, -1, 386,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, -1, -1, 938, 939, -1, -1, 204,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 952,
-1, 954, -1, 956, -1, -1, -1, -1, -1, -1,
427, -1, -1, -1, -1, -1, -1, -1, 971, -1,
-1, 974, 975, 976, 977, -1, -1, 980, 981, 982,
983, 984, 985, 986, 987, 988, 989, 990, 991, 992,
993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002,
1003, 1004, 1005, 1006, -1, -1, -1, -1, -1, 10,
11, 12, -1, 480, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 1030, 29, -1,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, -1, 53, -1, -1, -1, -1, -1, -1, 1062,
527, 1064, -1, -1, 65, -1, -1, -1, -1, 1072,
-1, -1, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, -1, 1089, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
214, -1, -1, -1, -1, -1, 1109, 221, -1, -1,
-1, 1114, -1, 227, 77, -1, 79, 80, -1, -1,
-1, 63, 64, 53, -1, -1, -1, 1130, 1131, -1,
1133, -1, -1, -1, -1, -1, -1, -1, -1, -1,
607, -1, 1145, -1, -1, 1148, -1, 1150, -1, -1,
-1, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, -1, -1, -1, -1, -1, 283,
1173, -1, -1, -1, -1, -1, -1, -1, 292, 293,
-1, -1, -1, -1, -1, 299, 128, 129, -1, -1,
-1, 305, -1, 156, 157, 662, 159, 160, 161, -1,
63, 64, 316, -1, 205, -1, 1209, 1210, -1, -1,
1213, -1, -1, -1, -1, -1, -1, -1, -1, 10,
11, 12, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, 1238, -1, 704, 29, 706,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, -1, 53, 730, 731, 128, 129, -1, -1, -1,
-1, -1, 386, -1, 65, -1, -1, -1, 745, 746,
747, 748, 749, -1, -1, -1, -1, 1290, -1, 1292,
-1, 758, -1, -1, 1297, 1298, -1, -1, -1, 1302,
-1, 1304, -1, 1306, -1, -1, 1309, -1, 1311, -1,
-1, 1314, -1, 427, -1, -1, -1, 784, -1, 1322,
1323, -1, 1325, 437, -1, 255, 256, -1, -1, 1332,
-1, 261, -1, -1, 801, -1, -1, -1, -1, 202,
-1, -1, -1, -1, -1, 1348, -1, 814, -1, 816,
817, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 831, -1, -1, -1, 1371, -1,
-1, -1, 839, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 1386, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 1398, 1399, 1400, -1, -1,
63, 64, -1, -1, -1, -1, 873, -1, -1, 876,
-1, 341, 203, -1, 344, 10, 11, 12, -1, -1,
-1, 1424, -1, -1, -1, 1428, -1, -1, -1, 896,
-1, -1, 1435, -1, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, -1, 53, -1,
1463, 1464, 1465, -1, -1, 128, 129, -1, 1471, 1472,
65, 938, 939, 1476, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 607, 53, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 971, -1, 65, 974, 975, 976,
977, -1, -1, 980, 981, 982, 983, 984, 985, 986,
987, 988, 989, 990, 991, 992, 993, 994, 995, 996,
997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006,
-1, -1, -1, -1, -1, -1, 476, 477, 662, -1,
480, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 1030, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 1579, 53, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 1590, -1, 65,
704, -1, 706, -1, -1, -1, -1, 527, -1, -1,
-1, -1, -1, -1, -1, 1072, 1609, -1, 203, -1,
1613, -1, -1, -1, -1, -1, 730, -1, -1, -1,
-1, 1624, -1, -1, -1, -1, 1629, -1, -1, 1632,
29, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 1109, -1, -1, -1, -1, 1114, 578, 579,
-1, -1, -1, -1, -1, -1, 55, 587, -1, -1,
-1, -1, -1, 1130, 1131, -1, 1133, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 77, -1,
-1, 1148, -1, 1150, -1, -1, 1689, 801, -1, -1,
-1, -1, -1, -1, 1697, -1, -1, -1, -1, -1,
-1, -1, 816, 817, -1, -1, 1173, -1, 1711, -1,
-1, -1, -1, -1, -1, -1, -1, 1720, -1, -1,
-1, -1, -1, -1, -1, 839, -1, -1, -1, -1,
-1, -1, 1735, 132, 133, -1, -1, -1, -1, -1,
-1, -1, 1745, 1210, -1, -1, 1213, -1, -1, -1,
1753, 150, -1, -1, 153, 154, 1759, 156, 157, 1762,
159, 160, 161, -1, -1, -1, -1, -1, -1, -1,
-1, 1238, -1, -1, -1, 174, -1, -1, -1, -1,
-1, -1, 896, -1, -1, -1, 185, 186, 187, 188,
189, 190, 191, 192, 193, 194, 195, 196, 197, -1,
-1, 731, 201, -1, -1, -1, 205, -1, -1, -1,
-1, -1, -1, 743, 744, 745, 746, 747, 748, 749,
-1, -1, -1, -1, 938, 939, -1, -1, 758, -1,
1297, 1298, -1, -1, -1, 1302, -1, 1304, -1, 1306,
-1, -1, 1309, -1, 1311, -1, -1, 1314, -1, -1,
-1, -1, -1, -1, -1, -1, 1323, -1, 1325, -1,
974, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 1348, 53, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
830, -1, -1, -1, 1371, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, -1, 1386,
-1, -1, -1, 853, -1, -1, -1, -1, -1, -1,
-1, -1, 1399, 1400, -1, 865, -1, -1, -1, -1,
-1, -1, -1, 873, -1, -1, -1, -1, 10, 11,
12, -1, -1, -1, 63, 64, -1, -1, 1072, -1,
-1, -1, -1, -1, -1, -1, -1, 29, 1435, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
-1, 53, -1, -1, -1, 1109, 1463, 1464, 1465, -1,
1114, -1, -1, 65, 1471, 1472, 77, -1, 79, 1476,
-1, -1, -1, -1, -1, -1, 1130, 1131, -1, 128,
129, -1, 952, -1, 954, -1, 956, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 971, -1, -1, -1, 975, 976, 977, -1, -1,
980, 981, 982, 983, 984, 985, 986, 987, 988, 989,
990, 991, 992, 993, 994, 995, 996, 997, 998, 999,
1000, 1001, 1002, 1003, 1004, 1005, 1006, -1, -1, -1,
-1, -1, -1, 154, -1, 156, 157, -1, 159, 160,
161, -1, -1, 202, -1, -1, -1, -1, -1, 1213,
1030, -1, -1, -1, 29, -1, -1, -1, -1, -1,
-1, -1, 1579, -1, 185, 186, 187, 188, 189, 190,
191, 192, 193, 194, 195, 196, 197, -1, -1, -1,
55, -1, 1062, 204, 1064, 206, -1, -1, -1, -1,
-1, -1, -1, 205, -1, -1, 1613, -1, -1, -1,
-1, -1, 77, -1, -1, -1, -1, 1624, -1, 1089,
-1, -1, 1629, -1, -1, 1632, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 1298, 53, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 65, -1, -1,
-1, -1, -1, 1133, -1, -1, -1, 132, 133, -1,
-1, -1, -1, -1, -1, 1145, -1, -1, 1148, -1,
1150, -1, 1689, -1, -1, 150, -1, -1, 153, 154,
1697, 156, 157, -1, 159, 160, 161, -1, -1, -1,
-1, -1, -1, 1173, 1711, -1, -1, -1, -1, 174,
-1, -1, -1, -1, -1, -1, -1, 1371, -1, -1,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, -1, -1, -1, 201, -1, 1745, 1209,
205, -1, -1, -1, -1, -1, 1753, -1, 10, 11,
12, -1, 1759, -1, -1, 1762, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 29, 1238, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
-1, 53, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 65, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
1290, 53, 1292, -1, -1, -1, -1, 1297, -1, -1,
-1, -1, 1302, 65, 1304, -1, 1306, -1, -1, 1309,
-1, 1311, -1, -1, 1314, -1, -1, -1, -1, -1,
-1, -1, 1322, -1, -1, -1, -1, -1, 10, 11,
12, -1, 1332, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 29, 1348, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
-1, 53, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 65, -1, -1, 1386, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 1398, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 205, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 1424, -1, -1, -1, 1428, -1,
-1, -1, -1, -1, -1, 1435, -1, 5, 6, -1,
8, 9, 10, 11, 12, -1, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, -1, -1,
28, 29, -1, 1463, 1464, 1465, -1, -1, -1, -1,
-1, 1471, -1, -1, 42, 10, 11, 12, -1, -1,
-1, 49, -1, 51, -1, -1, 54, -1, 56, -1,
-1, -1, -1, -1, 29, -1, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, -1, 53, -1,
-1, -1, -1, 205, -1, -1, 10, 11, 12, -1,
65, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 29, 114, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, -1, 53,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 1579,
-1, 65, -1, 77, -1, 79, -1, -1, -1, -1,
1590, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 1609,
-1, -1, -1, 1613, 10, 11, 12, -1, -1, -1,
-1, -1, 65, 191, 1624, -1, -1, -1, -1, 1629,
124, -1, 1632, 29, -1, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, -1, 53, -1, -1,
-1, 480, 156, 157, -1, 159, 160, 161, 236, 65,
205, 239, -1, -1, -1, -1, -1, -1, 246, 247,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 1689,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, -1, -1, -1, -1, 527, -1,
204, -1, 206, 480, -1, -1, -1, -1, -1, -1,
1720, 205, -1, -1, -1, -1, 294, -1, -1, -1,
-1, -1, 300, -1, -1, 1735, 304, -1, -1, -1,
-1, -1, 29, -1, -1, 1745, -1, -1, -1, 317,
318, 319, -1, 1753, -1, -1, -1, -1, -1, 1759,
527, -1, 1762, -1, 332, -1, -1, -1, 55, -1,
-1, -1, -1, -1, -1, 343, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
77, -1, 188, 361, 362, 363, 364, 365, 366, 367,
368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
378, 379, 380, 381, 382, 383, 384, 385, 105, 387,
-1, 389, 390, -1, 392, -1, 113, 114, 115, 116,
117, 118, 400, 401, 402, 403, 404, 405, 406, 407,
408, 409, 410, 411, 412, 132, 133, -1, -1, -1,
418, 419, -1, 421, 422, 423, 424, -1, -1, -1,
-1, -1, 430, 150, -1, 433, 153, 154, -1, 156,
157, -1, 159, 160, 161, 443, -1, 445, -1, -1,
-1, -1, -1, 451, -1, -1, -1, 174, -1, -1,
-1, 459, -1, 461, -1, -1, 183, -1, 185, 186,
187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, -1, 731, -1, 201, -1, -1, -1, -1, 487,
-1, -1, 490, 491, 492, -1, 745, 746, 747, 748,
749, -1, -1, -1, -1, -1, -1, -1, -1, 758,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 521, -1, -1, 74, 75, 76, 77,
-1, -1, -1, -1, 731, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 745, 746,
747, 748, 749, -1, -1, -1, -1, -1, -1, -1,
-1, 758, -1, 10, 11, 12, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 77, -1, 79, -1,
-1, -1, 29, -1, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, -1, 53, -1, 156, 157,
608, 159, 160, 161, -1, -1, -1, -1, 65, -1,
-1, -1, 620, -1, 873, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
-1, -1, 480, 154, 652, 156, 157, -1, 159, 160,
161, -1, -1, 661, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 873, -1, -1, -1,
-1, -1, 680, -1, 185, 186, 187, 188, 189, 190,
191, 192, 193, 194, 195, 196, 197, -1, -1, 527,
-1, -1, -1, 204, -1, 206, -1, -1, -1, -1,
-1, -1, -1, -1, 712, -1, -1, -1, -1, -1,
-1, -1, 971, -1, -1, -1, 975, 976, 977, -1,
728, 980, 981, 982, 983, 984, 985, 986, 987, 988,
989, 990, 991, 992, 993, 994, 995, 996, 997, 998,
999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 205, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 769, -1, -1, 971, -1, -1, -1, 975, 976,
977, 1030, -1, 980, 981, 982, 983, 984, 985, 986,
987, 988, 989, 990, 991, 992, 993, 994, 995, 996,
997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, -1, 825, -1, 77,
10, 11, 12, 1030, -1, -1, -1, -1, 86, 65,
838, -1, -1, -1, -1, -1, 844, -1, 846, 29,
848, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, -1, 871, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 881, 1133, 65, 884, -1, 886, -1,
-1, -1, 890, -1, -1, -1, -1, -1, -1, 1148,
-1, 1150, 150, 731, -1, 153, -1, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, 745, 746, 747,
748, -1, -1, -1, 1173, -1, -1, 925, -1, -1,
758, -1, -1, 10, 11, 12, 1133, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
130, 1148, 29, 1150, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, -1, 1173, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 65, 1238,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 10,
11, 12, -1, -1, -1, -1, -1, -1, -1, -1,
1008, 1009, 1010, -1, -1, -1, 1014, 1015, 29, -1,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 1238, 53, -1, 1042, 873, -1, -1, 1297, -1,
-1, -1, -1, 1302, 65, 1304, -1, 1306, -1, -1,
1309, -1, 1311, -1, -1, 1314, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 1073, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 1086, -1,
-1, -1, -1, -1, -1, -1, -1, 1095, 1096, 1348,
1297, -1, -1, -1, -1, 1302, -1, 1304, -1, 1306,
-1, -1, 1309, -1, 1311, -1, -1, 1314, -1, -1,
-1, -1, -1, -1, -1, 202, -1, -1, -1, 1127,
-1, -1, -1, -1, -1, -1, -1, 1386, -1, 1137,
-1, -1, -1, -1, -1, -1, -1, 975, 976, 977,
-1, 1348, 980, 981, 982, 983, 984, 985, 986, 987,
988, 989, 990, 991, 992, 993, 994, 995, 996, 997,
998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, -1,
-1, -1, -1, -1, -1, -1, 1435, -1, -1, 1386,
-1, -1, -1, -1, 205, -1, -1, -1, -1, -1,
-1, -1, 1030, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 1463, 1464, 1465, -1, -1, -1,
-1, -1, 1471, -1, 77, 1223, 1475, -1, -1, 1227,
-1, 1229, 1230, -1, -1, -1, -1, -1, 1435, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1248, 1249, -1, -1, 10, 11, 12, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 1463, 1464, 1465, 122,
-1, -1, -1, 29, 1471, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, -1, 53, 29, -1,
-1, -1, -1, 156, 157, 1133, 159, 160, 161, 65,
-1, -1, -1, -1, -1, -1, -1, 1315, -1, -1,
1148, -1, 1150, -1, 55, -1, -1, -1, -1, -1,
1579, -1, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, 1173, 77, -1, 201, -1,
-1, -1, -1, 1351, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 1613, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 105, 1624, -1, -1, -1, -1,
1629, -1, 1579, 1632, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 132, 133, -1, -1, 1654, -1, -1, -1, -1,
1238, -1, -1, -1, 65, -1, 1613, -1, 77, 150,
79, -1, 153, 154, -1, 156, 157, 1624, 159, 160,
161, -1, 1629, -1, -1, 1632, -1, -1, -1, -1,
1689, -1, -1, 174, -1, -1, -1, -1, -1, 205,
-1, -1, -1, -1, 185, 186, 187, 188, 189, 190,
191, 192, 193, 194, 195, 196, 197, -1, 1466, 1297,
201, -1, -1, -1, 1302, -1, 1304, -1, 1306, -1,
-1, 1309, -1, 1311, -1, -1, 1314, -1, -1, -1,
-1, -1, 1689, -1, -1, -1, 1745, 156, 157, -1,
159, 160, 161, -1, 1753, -1, -1, -1, -1, -1,
1759, -1, -1, 1762, -1, -1, -1, -1, -1, -1,
1348, -1, -1, -1, -1, -1, 185, 186, 187, 188,
189, 190, 191, 192, 193, 194, 195, 196, 197, 3,
4, 5, 6, 7, -1, 204, -1, 206, 1745, 13,
-1, -1, -1, -1, -1, -1, 1753, -1, 1386, -1,
-1, -1, 1759, 27, 28, 1762, -1, -1, -1, -1,
-1, 35, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, -1, 1435, -1, -1,
74, 75, 76, 77, 78, 79, -1, -1, -1, -1,
-1, -1, 86, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 1463, 1464, 1465, -1, -1,
-1, 105, -1, 1471, -1, -1, -1, -1, -1, 113,
114, 115, 116, 117, 118, -1, -1, 121, 122, -1,
-1, -1, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, -1, -1,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, -1,
-1, -1, 206, 207, -1, 209, 210, -1, -1, -1,
-1, 1579, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, 13, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 1613, -1, -1, -1, 27,
28, -1, -1, -1, -1, -1, 1624, -1, -1, -1,
-1, 1629, -1, -1, 1632, -1, -1, 45, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, 70, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, 81, 82, -1, -1, -1, 86, 87,
88, 89, -1, 91, -1, 93, -1, 95, -1, -1,
98, 1689, -1, -1, 102, 103, 104, 105, 106, 107,
108, -1, 110, 111, 112, 113, 114, 115, 116, 117,
118, -1, 120, 121, 122, 123, 124, 125, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, 1745, 156, 157,
-1, 159, 160, 161, 162, 1753, -1, 165, -1, -1,
168, 1759, -1, -1, 1762, -1, 174, 175, 176, 177,
178, -1, 180, -1, 182, 183, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, -1, -1, 201, -1, 203, 204, 205, 206, 207,
-1, 209, 210, 3, 4, 5, 6, 7, -1, -1,
-1, -1, -1, 13, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 27, 28, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 45, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
70, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, 81, 82, -1, -1, -1, 86, 87, 88, 89,
-1, 91, -1, 93, -1, 95, -1, -1, 98, -1,
-1, -1, 102, 103, 104, 105, 106, 107, 108, -1,
110, 111, 112, 113, 114, 115, 116, 117, 118, -1,
120, 121, 122, 123, 124, 125, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, 162, -1, -1, 165, -1, -1, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, 178, -1,
180, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, -1,
-1, 201, -1, 203, 204, 205, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 27, 28, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 45, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, 70, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, 81,
82, -1, -1, -1, 86, 87, 88, 89, -1, 91,
-1, 93, -1, 95, -1, -1, 98, -1, -1, -1,
102, 103, 104, 105, 106, 107, 108, -1, 110, 111,
112, 113, 114, 115, 116, 117, 118, -1, 120, 121,
122, 123, 124, 125, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
162, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, 178, -1, 180, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
-1, 203, 204, -1, 206, 207, -1, 209, 210, 3,
4, 5, 6, 7, -1, -1, -1, -1, -1, 13,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 27, 28, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 45, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, 70, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, 81, 82, -1,
-1, -1, 86, 87, 88, 89, -1, 91, -1, 93,
-1, 95, -1, -1, 98, -1, -1, -1, 102, 103,
104, 105, -1, 107, 108, -1, 110, -1, 112, 113,
114, 115, 116, 117, 118, -1, 120, 121, 122, -1,
124, 125, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, 162, -1,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, 203,
204, 205, 206, 207, -1, 209, 210, 3, 4, 5,
6, 7, -1, -1, -1, -1, -1, 13, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 27, 28, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 45,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, 70, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, 81, 82, -1, -1, -1,
86, 87, 88, 89, -1, 91, -1, 93, -1, 95,
-1, -1, 98, -1, -1, -1, 102, 103, 104, 105,
-1, 107, 108, -1, 110, -1, 112, 113, 114, 115,
116, 117, 118, -1, 120, 121, 122, -1, 124, 125,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, 162, -1, -1, 165,
-1, -1, 168, -1, -1, -1, -1, -1, 174, 175,
176, 177, -1, -1, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, -1, -1, 201, -1, 203, 204, 205,
206, 207, -1, 209, 210, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, 13, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 27,
28, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, 70, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, 81, 82, -1, -1, -1, 86, 87,
88, 89, -1, 91, -1, 93, -1, 95, -1, -1,
98, -1, -1, -1, 102, 103, 104, 105, -1, 107,
108, -1, 110, -1, 112, 113, 114, 115, 116, 117,
118, -1, 120, 121, 122, -1, 124, 125, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, -1, 156, 157,
-1, 159, 160, 161, 162, -1, -1, 165, -1, -1,
168, -1, -1, -1, -1, -1, 174, 175, 176, 177,
-1, -1, -1, -1, 182, 183, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, -1, -1, 201, -1, 203, 204, 205, 206, 207,
-1, 209, 210, 3, 4, 5, 6, 7, -1, -1,
-1, -1, -1, 13, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 27, 28, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 45, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
70, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, 81, 82, -1, -1, -1, 86, 87, 88, 89,
-1, 91, -1, 93, -1, 95, -1, -1, 98, -1,
-1, -1, 102, 103, 104, 105, -1, 107, 108, -1,
110, -1, 112, 113, 114, 115, 116, 117, 118, -1,
120, 121, 122, -1, 124, 125, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, 162, -1, -1, 165, -1, -1, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, -1, -1,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, -1,
-1, 201, -1, 203, 204, 205, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 27, 28, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 45, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, 70, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, 81,
82, -1, -1, -1, 86, 87, 88, 89, 90, 91,
-1, 93, -1, 95, -1, -1, 98, -1, -1, -1,
102, 103, 104, 105, -1, 107, 108, -1, 110, -1,
112, 113, 114, 115, 116, 117, 118, -1, 120, 121,
122, -1, 124, 125, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
162, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, -1, -1, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
-1, 203, 204, -1, 206, 207, -1, 209, 210, 3,
4, 5, 6, 7, -1, -1, -1, -1, -1, 13,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 27, 28, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 45, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, 70, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, 81, 82, -1,
-1, -1, 86, 87, 88, 89, -1, 91, -1, 93,
-1, 95, 96, -1, 98, -1, -1, -1, 102, 103,
104, 105, -1, 107, 108, -1, 110, -1, 112, 113,
114, 115, 116, 117, 118, -1, 120, 121, 122, -1,
124, 125, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, 162, -1,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, 203,
204, -1, 206, 207, -1, 209, 210, 3, 4, 5,
6, 7, -1, -1, -1, -1, -1, 13, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 27, 28, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 45,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, 70, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, 81, 82, -1, -1, -1,
86, 87, 88, 89, -1, 91, -1, 93, -1, 95,
-1, -1, 98, -1, -1, -1, 102, 103, 104, 105,
-1, 107, 108, -1, 110, -1, 112, 113, 114, 115,
116, 117, 118, -1, 120, 121, 122, -1, 124, 125,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, 162, -1, -1, 165,
-1, -1, 168, -1, -1, -1, -1, -1, 174, 175,
176, 177, -1, -1, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, -1, -1, 201, -1, 203, 204, 205,
206, 207, -1, 209, 210, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, 13, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 27,
28, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, 70, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, 81, 82, -1, -1, -1, 86, 87,
88, 89, -1, 91, -1, 93, -1, 95, -1, -1,
98, -1, -1, -1, 102, 103, 104, 105, -1, 107,
108, -1, 110, -1, 112, 113, 114, 115, 116, 117,
118, -1, 120, 121, 122, -1, 124, 125, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, -1, 156, 157,
-1, 159, 160, 161, 162, -1, -1, 165, -1, -1,
168, -1, -1, -1, -1, -1, 174, 175, 176, 177,
-1, -1, -1, -1, 182, 183, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, -1, -1, 201, -1, 203, 204, 205, 206, 207,
-1, 209, 210, 3, 4, 5, 6, 7, -1, -1,
-1, -1, -1, 13, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 27, 28, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 45, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
70, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, 81, 82, -1, -1, -1, 86, 87, 88, 89,
-1, 91, -1, 93, 94, 95, -1, -1, 98, -1,
-1, -1, 102, 103, 104, 105, -1, 107, 108, -1,
110, -1, 112, 113, 114, 115, 116, 117, 118, -1,
120, 121, 122, -1, 124, 125, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, 162, -1, -1, 165, -1, -1, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, -1, -1,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, -1,
-1, 201, -1, 203, 204, -1, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 27, 28, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 45, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, 70, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, 81,
82, -1, -1, -1, 86, 87, 88, 89, -1, 91,
-1, 93, -1, 95, -1, -1, 98, -1, -1, -1,
102, 103, 104, 105, -1, 107, 108, -1, 110, -1,
112, 113, 114, 115, 116, 117, 118, -1, 120, 121,
122, -1, 124, 125, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
162, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, -1, -1, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
-1, 203, 204, 205, 206, 207, -1, 209, 210, 3,
4, 5, 6, 7, -1, -1, -1, -1, -1, 13,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 27, 28, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 45, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, 70, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, 81, 82, -1,
-1, -1, 86, 87, 88, 89, -1, 91, -1, 93,
-1, 95, -1, -1, 98, -1, -1, -1, 102, 103,
104, 105, -1, 107, 108, -1, 110, -1, 112, 113,
114, 115, 116, 117, 118, -1, 120, 121, 122, -1,
124, 125, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, 162, -1,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, 203,
204, 205, 206, 207, -1, 209, 210, 3, 4, 5,
6, 7, -1, -1, -1, -1, -1, 13, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 27, 28, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 45,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, 70, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, 81, 82, -1, -1, -1,
86, 87, 88, 89, -1, 91, 92, 93, -1, 95,
-1, -1, 98, -1, -1, -1, 102, 103, 104, 105,
-1, 107, 108, -1, 110, -1, 112, 113, 114, 115,
116, 117, 118, -1, 120, 121, 122, -1, 124, 125,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, 162, -1, -1, 165,
-1, -1, 168, -1, -1, -1, -1, -1, 174, 175,
176, 177, -1, -1, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, -1, -1, 201, -1, 203, 204, -1,
206, 207, -1, 209, 210, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, 13, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 27,
28, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, 70, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, 81, 82, -1, -1, -1, 86, 87,
88, 89, -1, 91, -1, 93, -1, 95, -1, -1,
98, -1, -1, -1, 102, 103, 104, 105, -1, 107,
108, -1, 110, -1, 112, 113, 114, 115, 116, 117,
118, -1, 120, 121, 122, -1, 124, 125, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, -1, 156, 157,
-1, 159, 160, 161, 162, -1, -1, 165, -1, -1,
168, -1, -1, -1, -1, -1, 174, 175, 176, 177,
-1, -1, -1, -1, 182, 183, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, -1, -1, 201, -1, 203, 204, 205, 206, 207,
-1, 209, 210, 3, 4, 5, 6, 7, -1, -1,
-1, -1, -1, 13, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 27, 28, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 45, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
70, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, 81, 82, -1, -1, -1, 86, 87, 88, 89,
-1, 91, -1, 93, -1, 95, -1, -1, 98, -1,
-1, -1, 102, 103, 104, 105, -1, 107, 108, -1,
110, -1, 112, 113, 114, 115, 116, 117, 118, -1,
120, 121, 122, -1, 124, 125, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, 162, -1, -1, 165, -1, -1, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, -1, -1,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, -1,
-1, 201, -1, 203, 204, 205, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 27, 28, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 45, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, 70, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, 81,
82, -1, -1, -1, 86, 87, 88, 89, -1, 91,
-1, 93, -1, 95, -1, -1, 98, -1, -1, -1,
102, 103, 104, 105, -1, 107, 108, -1, 110, -1,
112, 113, 114, 115, 116, 117, 118, -1, 120, 121,
122, -1, 124, 125, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
162, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, -1, -1, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
-1, 203, 204, 205, 206, 207, -1, 209, 210, 3,
4, 5, 6, 7, -1, -1, -1, -1, -1, 13,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 27, 28, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 45, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, 70, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, 81, 82, -1,
-1, -1, 86, 87, 88, 89, -1, 91, -1, 93,
-1, 95, -1, -1, 98, -1, -1, -1, 102, 103,
104, 105, -1, 107, 108, -1, 110, -1, 112, 113,
114, 115, 116, 117, 118, -1, 120, 121, 122, -1,
124, 125, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, 162, -1,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, 203,
204, -1, 206, 207, -1, 209, 210, 3, 4, 5,
6, 7, -1, -1, -1, -1, -1, 13, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 27, 28, -1, 30, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, 70, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, 81, 82, -1, -1, -1,
86, 87, 88, 89, -1, 91, -1, 93, -1, 95,
-1, -1, 98, -1, -1, -1, 102, 103, 104, 105,
-1, 107, 108, -1, 110, -1, 112, 113, 114, 115,
116, 117, 118, -1, 120, 121, 122, -1, -1, -1,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, -1, -1, -1, 165,
-1, -1, 168, -1, -1, -1, -1, -1, 174, 175,
176, 177, -1, -1, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, -1, -1, 201, -1, 203, 204, -1,
206, 207, -1, 209, 210, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, 13, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 27,
28, -1, 30, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, 70, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, 81, 82, -1, -1, -1, 86, 87,
88, 89, -1, 91, -1, 93, -1, 95, -1, -1,
98, -1, -1, -1, 102, 103, 104, 105, -1, 107,
108, -1, 110, -1, 112, 113, 114, 115, 116, 117,
118, -1, 120, 121, 122, -1, -1, -1, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, 165, -1, -1,
168, -1, -1, -1, -1, -1, 174, 175, 176, 177,
-1, -1, -1, -1, 182, 183, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, -1, -1, 201, -1, 203, 204, -1, 206, 207,
-1, 209, 210, 3, 4, 5, 6, 7, -1, -1,
-1, -1, -1, 13, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 27, 28, -1,
30, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
70, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, 81, 82, -1, -1, -1, 86, 87, 88, 89,
-1, 91, -1, 93, -1, 95, -1, -1, 98, -1,
-1, -1, 102, 103, 104, 105, -1, 107, 108, -1,
110, -1, 112, 113, 114, 115, 116, 117, 118, -1,
120, 121, 122, -1, -1, -1, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, -1, -1, -1, 165, -1, -1, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, -1, -1,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, -1,
-1, 201, -1, 203, 204, -1, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 27, 28, -1, 30, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, 70, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, 81,
82, -1, -1, -1, 86, 87, 88, 89, -1, 91,
-1, 93, -1, 95, -1, -1, 98, -1, -1, -1,
102, 103, 104, 105, -1, 107, 108, -1, 110, -1,
112, 113, 114, 115, 116, 117, 118, -1, 120, 121,
122, -1, -1, -1, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
-1, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, -1, -1, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
-1, 203, 204, -1, 206, 207, -1, 209, 210, 3,
4, 5, 6, 7, -1, -1, -1, -1, -1, 13,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 27, 28, -1, 30, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, 70, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, 81, 82, -1,
-1, -1, 86, 87, 88, 89, -1, 91, -1, 93,
-1, 95, -1, -1, 98, -1, -1, -1, 102, 103,
104, 105, -1, 107, 108, -1, 110, -1, 112, 113,
114, 115, 116, 117, 118, -1, 120, 121, 122, -1,
-1, -1, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, -1, -1,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, 203,
204, -1, 206, 207, -1, 209, 210, 3, 4, 5,
6, 7, -1, -1, -1, -1, -1, 13, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 27, 28, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, 70, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, 81, 82, -1, -1, -1,
86, 87, 88, 89, -1, 91, -1, 93, -1, 95,
-1, -1, 98, -1, -1, -1, 102, 103, 104, 105,
-1, 107, 108, -1, 110, -1, 112, 113, 114, 115,
116, 117, 118, -1, 120, 121, 122, -1, -1, -1,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, -1, -1, -1, 165,
-1, -1, 168, -1, -1, -1, -1, -1, 174, 175,
176, 177, -1, -1, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, -1, -1, 201, -1, 203, 204, -1,
206, 207, -1, 209, 210, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, 13, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
28, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, -1, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, -1, -1, -1, -1, -1, 86, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 105, -1, -1,
-1, -1, -1, -1, -1, 113, 114, 115, 116, 117,
118, -1, -1, 121, 122, -1, -1, -1, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, 165, -1, -1,
168, -1, -1, -1, -1, -1, 174, 175, 176, 177,
-1, -1, -1, -1, 182, 183, 184, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, -1, -1, 201, -1, 203, -1, -1, 206, 207,
-1, 209, 210, 3, 4, 5, 6, 7, -1, -1,
-1, -1, 29, 13, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, 35, 53, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 46, 47, 65, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
-1, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, -1, -1, -1, -1, -1, 86, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 105, -1, -1, -1, -1,
-1, -1, -1, 113, 114, 115, 116, 117, 118, -1,
-1, 121, 122, -1, -1, -1, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, -1, 163, -1, 165, -1, -1, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, -1, -1,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, -1,
-1, 201, -1, -1, -1, -1, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 28, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, -1, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, -1,
-1, -1, -1, -1, 86, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 105, -1, -1, -1, -1, -1, -1,
-1, 113, 114, 115, 116, 117, 118, -1, -1, 121,
122, -1, -1, -1, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
-1, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, -1, -1, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
11, 12, 204, -1, 206, 207, -1, 209, 210, 3,
4, 5, 6, 7, -1, -1, -1, -1, 29, 13,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 35, 53, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 46, 47, 65, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, -1, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, -1, -1, -1,
-1, -1, 86, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 105, -1, -1, -1, -1, -1, -1, -1, 113,
114, 115, 116, 117, 118, -1, -1, 121, 122, -1,
-1, -1, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, -1, 163,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, -1,
-1, -1, 206, 207, -1, 209, 210, 3, 4, 5,
6, 7, -1, -1, -1, -1, -1, 13, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 27, 28, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, -1, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, -1, -1, -1, -1, -1,
86, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 105,
-1, -1, -1, -1, -1, -1, -1, 113, 114, 115,
116, 117, 118, -1, -1, 121, 122, -1, -1, -1,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, -1, -1, -1, 165,
-1, -1, 168, 3, 4, 5, 6, 7, 174, 175,
176, 177, -1, 13, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, -1, -1, 201, -1, -1, -1, -1,
206, 207, -1, 209, 210, -1, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
-1, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, -1, -1, -1, -1, -1, 86, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 102, -1, -1, 105, -1, -1, -1, -1,
-1, -1, -1, 113, 114, 115, 116, 117, 118, -1,
77, 121, 122, -1, -1, -1, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, -1, -1, -1, 165, -1, -1, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, -1, -1,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 156,
157, 201, 159, 160, 161, -1, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, 185, 186,
187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, -1, -1, 35, 201, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, -1, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, -1,
-1, -1, -1, -1, 86, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 105, -1, -1, -1, -1, -1, -1,
-1, 113, 114, 115, 116, 117, 118, -1, -1, 121,
122, -1, -1, -1, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
-1, -1, -1, 165, -1, -1, 168, 3, 4, 5,
6, 7, 174, 175, 176, 177, -1, 13, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
-1, -1, -1, -1, 206, 207, -1, 209, 210, -1,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, -1, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, -1, -1, -1, -1, -1,
86, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 105,
-1, -1, -1, -1, -1, -1, -1, 113, 114, 115,
116, 117, 118, -1, -1, 121, 122, -1, -1, -1,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, -1, -1, -1, 165,
-1, -1, 168, 3, 4, 5, 6, 7, 174, 175,
176, 177, -1, 13, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, -1, -1, 201, -1, 203, -1, -1,
206, 207, -1, 209, 210, -1, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
-1, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, -1, -1, -1, -1, -1, 86, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 105, -1, -1, -1, -1,
-1, -1, -1, 113, 114, 115, 116, 117, 118, -1,
-1, 121, 122, -1, -1, -1, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, -1, -1, -1, 165, -1, -1, 168, 3,
4, 5, 6, 7, 174, 175, 176, 177, -1, 13,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, -1,
-1, 201, -1, 203, -1, -1, 206, 207, -1, 209,
210, -1, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, -1, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, -1, -1, -1,
-1, -1, 86, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 105, -1, -1, -1, -1, -1, -1, -1, 113,
114, 115, 116, 117, 118, -1, -1, 121, 122, -1,
-1, -1, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, -1, -1,
-1, 165, -1, -1, 168, -1, -1, -1, -1, -1,
174, 175, 176, 177, -1, -1, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, 202, -1,
-1, -1, 206, 207, -1, 209, 210, 3, 4, 5,
6, 7, -1, -1, -1, -1, -1, 13, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 30, 53, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 65, -1, -1,
46, 47, -1, -1, -1, -1, 52, -1, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, -1,
66, 67, 68, 69, -1, -1, -1, -1, 74, 75,
76, 77, 78, 79, -1, -1, -1, -1, -1, -1,
86, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 105,
-1, -1, -1, -1, -1, -1, -1, 113, 114, 115,
116, 117, 118, -1, 77, 121, 122, -1, -1, -1,
-1, -1, -1, -1, -1, 131, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, -1, -1, -1, 165,
-1, -1, 168, -1, -1, -1, -1, -1, 174, 175,
176, 177, -1, -1, -1, -1, 182, 183, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 198, 156, 157, 201, 159, 160, 161, -1,
206, 207, -1, 209, 210, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, 13, -1, -1, -1, -1,
-1, -1, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, -1, -1, 35, 201, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, -1, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, -1, -1, -1, -1, -1, 86, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 105, -1, -1,
-1, -1, -1, -1, -1, 113, 114, 115, 116, 117,
118, -1, 77, 121, 122, -1, -1, -1, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, 165, -1, 124,
168, -1, -1, -1, -1, -1, 174, 175, 176, 177,
-1, -1, -1, -1, 182, 183, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, 156, 157, 201, 159, 160, 161, -1, 206, 207,
-1, 209, 210, 3, 4, 5, 6, 7, -1, -1,
-1, -1, -1, 13, -1, -1, -1, -1, -1, -1,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, -1, -1, 35, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 46, 47, -1, -1,
-1, -1, 52, -1, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, -1, 66, 67, 68, 69,
-1, -1, -1, -1, 74, 75, 76, 77, 78, 79,
-1, -1, -1, -1, -1, -1, 86, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 105, -1, -1, -1, -1,
-1, -1, -1, 113, 114, 115, 116, 117, 118, -1,
77, 121, 122, -1, -1, -1, -1, -1, -1, -1,
-1, 131, 132, -1, 134, 135, 136, 137, 138, -1,
-1, -1, -1, -1, -1, 145, -1, -1, -1, -1,
150, 151, 152, 153, 154, -1, 156, 157, -1, 159,
160, 161, -1, -1, -1, 165, -1, 124, 168, -1,
-1, -1, -1, -1, 174, 175, 176, 177, -1, -1,
-1, -1, 182, 183, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 156,
157, 201, 159, 160, 161, -1, 206, 207, -1, 209,
210, 3, 4, 5, 6, 7, -1, -1, -1, -1,
-1, 13, -1, -1, -1, -1, -1, -1, 185, 186,
187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, -1, -1, 35, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, -1, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, -1,
-1, -1, -1, -1, 86, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 105, -1, -1, -1, -1, -1, -1,
-1, 113, 114, 115, 116, 117, 118, -1, 77, 121,
122, -1, -1, -1, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
-1, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, -1, -1, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, 156, 157, 201,
159, 160, 161, -1, 206, 207, -1, 209, 210, 3,
4, 5, 6, 7, -1, -1, -1, -1, -1, 13,
-1, -1, -1, -1, -1, -1, 185, 186, 187, 188,
189, 190, 191, 192, 193, 194, 195, 196, 197, -1,
-1, 35, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 46, 47, -1, -1, -1, -1, 52, -1,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, -1, 66, 67, 68, 69, -1, -1, -1, -1,
74, 75, 76, 77, 78, 79, -1, -1, -1, -1,
-1, -1, 86, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 105, -1, -1, -1, -1, -1, -1, -1, 113,
114, 115, 116, 117, 118, -1, -1, 121, 122, -1,
-1, -1, -1, -1, -1, -1, -1, 131, 132, -1,
134, 135, 136, 137, 138, -1, -1, -1, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, -1, -1,
-1, 165, -1, -1, 168, 3, 4, 5, 6, 7,
174, 175, 176, 177, -1, 13, -1, -1, 182, 183,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 198, -1, -1, 201, -1, -1,
-1, -1, 206, 207, -1, 209, 210, -1, 46, 47,
-1, -1, -1, -1, 52, -1, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64, -1, 66, 67,
68, 69, -1, -1, -1, -1, 74, 75, 76, 77,
78, 79, -1, -1, -1, -1, -1, -1, 86, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 105, -1, -1,
-1, -1, -1, -1, -1, 113, 114, 115, 116, 117,
118, -1, -1, 121, 122, -1, -1, -1, -1, -1,
-1, -1, -1, 131, 132, -1, 134, 135, 136, 137,
138, -1, -1, -1, -1, -1, -1, 145, -1, -1,
-1, -1, 150, 151, 152, 153, 154, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, 165, -1, -1,
168, 3, 4, 5, 6, 7, 174, 175, 176, 177,
-1, 13, -1, -1, 182, 183, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
198, -1, -1, 201, -1, -1, -1, -1, 206, 207,
-1, 209, 210, -1, 46, 47, -1, -1, -1, -1,
52, -1, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, -1, 66, 67, 68, 69, -1, -1,
-1, -1, 74, 75, 76, 77, 78, 79, -1, -1,
-1, -1, -1, -1, 86, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 105, -1, -1, -1, -1, -1, -1,
-1, 113, 114, 115, 116, 117, 118, -1, -1, 121,
122, -1, -1, -1, -1, -1, -1, -1, -1, 131,
132, -1, 134, 135, 136, 137, 138, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, 150, 151,
152, 153, 154, -1, 156, 157, -1, 159, 160, 161,
-1, -1, -1, 165, -1, -1, 168, -1, -1, -1,
-1, -1, 174, 175, 176, 177, -1, -1, -1, -1,
182, 183, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, -1, -1, 201,
10, 11, 12, -1, 206, 207, -1, 209, 210, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 29,
-1, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, -1, 53, 3, 4, 5, 6, 7, -1,
-1, 10, 11, 12, 13, 65, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 27, 28,
-1, 29, -1, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 53, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 65, 67, 68,
69, 70, 71, 72, 73, -1, -1, -1, 77, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 87, 88,
89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 123, 124, 125, 126, 127, -1,
-1, -1, 131, 132, -1, 134, 135, 136, 137, 138,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 150, 151, 152, -1, 205, -1, 156, 157, -1,
159, 160, 161, 162, -1, 164, 165, -1, 167, -1,
-1, -1, -1, -1, -1, 174, -1, -1, -1, 178,
-1, 180, -1, 182, 183, -1, 185, 186, 187, 188,
189, 190, 191, 192, 193, 194, 195, 196, 197, 10,
11, 12, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 29, -1,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, -1, 53, 10, 11, 12, -1, -1, -1, -1,
-1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
-1, -1, 29, -1, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, -1, 53, 10, 11, 12,
-1, -1, -1, -1, -1, -1, -1, -1, 65, -1,
-1, -1, -1, -1, -1, -1, 29, -1, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
53, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 65, -1, -1, -1, -1, -1, -1, -1,
29, -1, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, 53, 10, 11, 12, -1, -1,
-1, -1, -1, -1, -1, -1, 65, -1, -1, -1,
-1, -1, 203, -1, 29, -1, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, -1, 53, 10,
11, 12, -1, -1, -1, -1, -1, -1, -1, -1,
65, -1, -1, -1, -1, -1, 203, -1, 29, -1,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, -1, 53, 10, 11, 12, -1, -1, -1, -1,
-1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
203, -1, 29, -1, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, -1, 53, 10, 11, 12,
-1, -1, -1, -1, -1, -1, -1, -1, 65, -1,
-1, -1, -1, -1, 203, -1, 29, -1, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
53, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 65, -1, 77, -1, -1, 202, -1, -1,
29, -1, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, 53, -1, 10, 11, 12, -1,
-1, -1, -1, -1, -1, -1, 65, -1, -1, -1,
-1, 202, -1, -1, -1, 29, -1, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 29, 53,
-1, 154, -1, 156, 157, 158, 159, 160, 161, -1,
197, 65, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 55, -1, -1, -1, -1, -1,
-1, -1, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, -1, 77, 29, 201, -1,
193, 194, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 55, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 65, -1, -1, -1,
-1, 190, -1, -1, -1, 77, -1, -1, -1, -1,
-1, 132, 133, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 150,
-1, 29, 153, 154, -1, 156, 157, -1, 159, 160,
161, -1, 163, -1, -1, 189, -1, -1, -1, -1,
-1, -1, -1, 174, -1, -1, -1, 55, -1, -1,
132, 133, -1, -1, 185, 186, 187, 188, 189, 190,
191, 192, 193, 194, 195, 196, 197, -1, 150, 77,
201, 153, 154, -1, 156, 157, -1, 159, 160, 161,
-1, 163, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 174, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, -1, -1, -1, 201,
-1, -1, 67, 68, 132, 133, -1, -1, -1, -1,
-1, -1, 77, -1, 79, -1, -1, -1, -1, -1,
-1, -1, 150, -1, -1, 153, 154, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, -1, -1, -1,
105, -1, -1, -1, -1, -1, 174, -1, 113, 114,
115, 116, 117, 118, 30, -1, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
46, 47, -1, 201, -1, -1, 52, -1, 54, -1,
-1, -1, -1, -1, -1, 150, -1, -1, 153, 154,
66, 156, 157, -1, 159, 160, 161, -1, 74, 75,
76, 77, -1, 168, -1, -1, -1, -1, 35, -1,
86, -1, -1, -1, -1, -1, -1, -1, 183, -1,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, -1, -1, 201, -1, -1, -1,
-1, 206, -1, -1, -1, -1, -1, -1, -1, -1,
77, -1, 79, -1, -1, -1, 132, -1, 134, 135,
136, 137, 138, -1, -1, -1, -1, -1, -1, 145,
-1, -1, -1, -1, 150, 151, 152, 153, 154, -1,
156, 157, -1, 159, 160, 161, -1, -1, -1, 165,
-1, 118, -1, -1, -1, -1, -1, -1, 174, 175,
176, 177, -1, -1, 131, -1, 182, 77, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, -1, 150, -1, 201, 153, 154, -1, 156,
157, -1, 159, 160, 161, 105, 106, -1, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 185, 186,
187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
197, 65, 46, 47, 201, -1, -1, -1, 52, 206,
54, -1, -1, 153, -1, -1, 156, 157, -1, 159,
160, 161, 66, -1, -1, -1, -1, -1, -1, -1,
74, 75, 76, 77, -1, -1, -1, -1, -1, -1,
-1, -1, 86, 11, 12, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, -1, -1,
-1, 29, -1, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, -1, -1, -1, -1, 132, -1,
134, 135, 136, 137, 138, -1, -1, 65, -1, -1,
-1, 145, -1, -1, -1, -1, 150, 151, 152, 153,
154, -1, 156, 157, -1, 159, 160, 161, -1, -1,
-1, 165, -1, -1, -1, -1, -1, -1, -1, -1,
174, 175, 176, 177, 46, 47, -1, -1, 182, -1,
-1, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, 66, -1, -1, 201, -1, -1,
-1, -1, 74, 75, 76, 77, 10, 11, 12, -1,
-1, 67, 68, -1, 86, -1, -1, -1, -1, -1,
-1, 77, -1, 79, -1, 29, -1, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, -1, 53,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
132, 65, 118, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 145, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 156, 157, -1, 159, 160, 161,
-1, -1, -1, -1, 150, -1, -1, 153, 154, 68,
156, 157, 174, 159, 160, 161, -1, -1, 77, -1,
79, -1, 168, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 130, -1, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, -1, -1, -1, 201, -1, -1, -1, 118,
206, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 77, -1, 79, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 150, -1, -1, 153, 154, -1, 156, 157, -1,
159, 160, 161, -1, 65, -1, -1, -1, -1, -1,
-1, -1, -1, 118, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 185, 186, 187, 188,
189, 190, 191, 192, 193, 194, 195, 196, 197, 77,
-1, -1, 201, -1, -1, 150, -1, 206, 153, 154,
-1, 156, 157, -1, 159, 160, 161, 77, -1, 79,
-1, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 65, -1, -1, 201, -1, 118, 204,
-1, 206, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 131, 150, -1, -1, 153, 154, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, -1, -1, -1,
150, -1, -1, 153, 154, -1, 156, 157, -1, 159,
160, 161, 77, -1, 79, -1, -1, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
-1, -1, -1, -1, -1, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, -1, -1,
-1, 201, -1, 118, -1, -1, 206, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 131, 77, -1, 79,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 150, -1, -1, 153, 154,
-1, 156, 157, -1, 159, 160, 161, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 118, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 77, -1, 79, 201, -1, -1, -1,
150, 206, -1, 153, 154, -1, 156, 157, -1, 159,
160, 161, -1, -1, -1, -1, 77, -1, 79, -1,
-1, -1, -1, -1, -1, 86, -1, -1, -1, -1,
-1, -1, -1, -1, 118, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, -1, -1,
-1, 201, -1, -1, -1, -1, 206, 118, -1, -1,
-1, -1, -1, -1, -1, -1, 150, -1, -1, 153,
154, -1, 156, 157, -1, 159, 160, 161, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 150,
-1, -1, 153, 154, -1, 156, 157, -1, 159, 160,
161, 185, 186, 187, 188, 189, 190, 191, 192, 193,
194, 195, 196, 197, -1, -1, -1, 201, -1, -1,
-1, -1, 206, -1, 185, 186, 187, 188, 189, 190,
191, 192, 193, 194, 195, 196, 197, 10, 11, 12,
-1, -1, -1, -1, -1, 206, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 29, -1, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
53, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 65, -1, -1, -1, -1, -1, -1, -1,
29, -1, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, 53, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 65, 10, 11, 12,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 29, 130, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
53, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 65, -1, -1, -1, -1, -1, -1, -1,
29, 130, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, 53, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 65, 10, 11, 12,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 29, 130, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
53, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 65, -1, -1, -1, -1, -1, -1, -1,
29, 130, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, 53, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 65, 10, 11, 12,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 29, 130, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
-1, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 65, -1, -1, -1, -1, -1, -1, -1,
29, 130, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 65, 10, 11, 12,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 29, 130, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
-1, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 65, -1, -1, -1, -1, -1, -1, -1,
29, 130, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, -1, -1, -1, -1, -1, -1,
-1, 77, -1, -1, -1, -1, 65, 10, 11, 12,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 77, -1, -1, -1, -1, 29, 130, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 65, 119, -1, -1, 77, -1, -1, -1,
-1, 130, -1, -1, -1, -1, 132, 133, 154, 77,
156, 157, -1, 159, 160, 161, -1, -1, -1, -1,
-1, -1, -1, -1, 150, -1, -1, 153, 154, -1,
156, 157, -1, 159, 160, 161, -1, -1, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, -1, -1, 77, -1, -1, 130, -1, 185,
186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
196, 197, 153, -1, -1, 156, 157, -1, 159, 160,
161, -1, -1, -1, -1, 153, -1, -1, 156, 157,
-1, 159, 160, 161, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 185, 186, 187, 188, 189, 190,
191, 192, 193, 194, 195, 196, 197, 185, 186, 187,
188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
153, -1, -1, 156, 157, -1, 159, 160, 161, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 10, 11, 12,
-1, -1, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, 28, 29, -1, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
53, -1, 10, 11, 12, -1, -1, -1, -1, -1,
-1, -1, 65, -1, -1, -1, -1, -1, -1, -1,
-1, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 97, 53, 10, 11, 12, -1,
-1, -1, -1, -1, -1, -1, -1, 65, -1, -1,
-1, -1, -1, -1, -1, 29, -1, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, -1, 53,
10, 11, 12, -1, -1, -1, -1, -1, -1, -1,
-1, 65, -1, -1, -1, -1, -1, -1, -1, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 10, 11, 12, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
-1, 29, -1, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 12, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 65, -1, -1,
-1, 29, -1, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 12, 53, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 65, -1, -1,
-1, 29, -1, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 65, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, -1, 53, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 65
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint16 yystos[] =
{
0, 212, 213, 0, 214, 3, 4, 5, 6, 7,
13, 27, 28, 45, 46, 47, 52, 54, 55, 56,
57, 58, 59, 60, 61, 62, 63, 64, 66, 67,
68, 69, 70, 74, 75, 76, 77, 78, 79, 81,
82, 86, 87, 88, 89, 91, 93, 95, 98, 102,
103, 104, 105, 106, 107, 108, 110, 111, 112, 113,
114, 115, 116, 117, 118, 120, 121, 122, 123, 124,
125, 131, 132, 134, 135, 136, 137, 138, 145, 150,
151, 152, 153, 154, 156, 157, 159, 160, 161, 162,
165, 168, 174, 175, 176, 177, 178, 180, 182, 183,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, 201, 203, 204, 206, 207, 209,
210, 215, 218, 225, 226, 227, 228, 229, 230, 233,
249, 250, 254, 257, 262, 268, 326, 327, 332, 336,
337, 338, 339, 340, 341, 342, 343, 345, 348, 360,
361, 362, 363, 364, 368, 369, 371, 390, 400, 401,
402, 407, 410, 428, 436, 438, 439, 440, 441, 442,
443, 444, 445, 446, 447, 449, 470, 472, 474, 116,
117, 118, 131, 150, 160, 218, 249, 326, 342, 438,
342, 201, 342, 342, 342, 102, 342, 342, 426, 427,
342, 342, 342, 342, 342, 342, 342, 342, 342, 342,
342, 342, 79, 118, 201, 226, 401, 402, 438, 441,
438, 35, 342, 453, 454, 342, 118, 201, 226, 401,
402, 403, 437, 445, 450, 451, 201, 333, 404, 201,
333, 349, 334, 342, 235, 333, 201, 201, 201, 333,
203, 342, 218, 203, 342, 29, 55, 132, 133, 154,
174, 201, 218, 229, 475, 487, 488, 184, 203, 339,
342, 370, 372, 204, 242, 342, 105, 106, 153, 219,
222, 225, 79, 206, 294, 295, 117, 124, 116, 124,
79, 296, 201, 201, 201, 201, 218, 266, 476, 201,
201, 79, 85, 146, 147, 148, 467, 468, 153, 204,
225, 225, 218, 267, 476, 154, 201, 201, 201, 201,
476, 476, 79, 198, 204, 351, 332, 342, 343, 438,
442, 231, 204, 85, 405, 467, 85, 467, 467, 30,
153, 170, 477, 201, 9, 203, 35, 248, 154, 265,
476, 118, 183, 249, 327, 203, 203, 203, 203, 203,
203, 10, 11, 12, 29, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 53, 65, 203, 66,
66, 203, 204, 149, 125, 160, 162, 268, 325, 326,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 63, 64, 128, 129, 430, 66, 204,
435, 201, 201, 66, 204, 206, 446, 201, 248, 249,
14, 342, 203, 130, 44, 218, 425, 201, 332, 438,
442, 149, 438, 130, 208, 9, 412, 332, 438, 477,
149, 201, 406, 430, 435, 202, 342, 30, 233, 8,
354, 9, 203, 233, 234, 334, 335, 342, 218, 280,
237, 203, 203, 203, 488, 488, 170, 201, 105, 488,
14, 218, 79, 203, 203, 203, 184, 185, 186, 191,
192, 195, 196, 373, 374, 375, 376, 377, 378, 379,
380, 381, 385, 386, 387, 243, 109, 167, 203, 153,
220, 223, 225, 153, 221, 224, 225, 225, 9, 203,
97, 204, 438, 9, 203, 124, 124, 14, 9, 203,
438, 471, 471, 332, 343, 438, 441, 442, 202, 170,
260, 131, 438, 452, 453, 66, 430, 146, 468, 78,
342, 438, 85, 146, 468, 225, 217, 203, 204, 255,
263, 391, 393, 86, 206, 355, 356, 358, 402, 446,
472, 342, 460, 462, 342, 459, 461, 459, 14, 97,
473, 350, 352, 353, 290, 291, 428, 429, 202, 202,
202, 202, 205, 232, 233, 250, 257, 262, 428, 342,
207, 209, 210, 218, 478, 479, 488, 35, 163, 292,
293, 342, 475, 201, 476, 258, 248, 342, 342, 342,
30, 342, 342, 342, 342, 342, 342, 342, 342, 342,
342, 342, 342, 342, 342, 342, 342, 342, 342, 342,
342, 342, 342, 403, 342, 342, 448, 448, 342, 455,
456, 124, 204, 218, 445, 446, 266, 218, 267, 265,
249, 27, 35, 336, 339, 342, 370, 342, 342, 342,
342, 342, 342, 342, 342, 342, 342, 342, 342, 154,
204, 218, 431, 432, 433, 434, 445, 448, 342, 292,
292, 448, 342, 452, 248, 202, 342, 201, 424, 9,
412, 332, 202, 218, 35, 342, 35, 342, 202, 202,
445, 292, 204, 218, 431, 432, 445, 202, 231, 284,
204, 339, 342, 342, 89, 30, 233, 278, 203, 28,
97, 14, 9, 202, 30, 204, 281, 488, 86, 229,
484, 485, 486, 201, 9, 46, 47, 52, 54, 66,
86, 132, 145, 154, 174, 175, 176, 177, 201, 226,
227, 229, 365, 366, 367, 401, 407, 408, 409, 187,
79, 342, 79, 79, 342, 382, 383, 342, 342, 375,
385, 190, 388, 231, 201, 241, 225, 203, 9, 97,
225, 203, 9, 97, 97, 222, 218, 342, 295, 408,
79, 9, 202, 202, 202, 202, 202, 202, 202, 203,
46, 47, 482, 483, 126, 271, 201, 9, 202, 202,
79, 80, 218, 469, 218, 66, 205, 205, 214, 216,
30, 127, 270, 169, 50, 154, 169, 395, 130, 9,
412, 202, 149, 202, 9, 412, 130, 202, 9, 412,
202, 488, 488, 14, 354, 290, 231, 199, 9, 413,
488, 489, 430, 435, 205, 9, 412, 171, 438, 342,
202, 9, 413, 14, 346, 251, 126, 269, 201, 476,
342, 30, 208, 208, 130, 205, 9, 412, 342, 477,
201, 261, 256, 264, 259, 248, 68, 438, 342, 477,
208, 205, 202, 202, 208, 205, 202, 46, 47, 66,
74, 75, 76, 86, 132, 145, 174, 218, 415, 417,
420, 423, 218, 438, 438, 130, 430, 435, 202, 342,
285, 71, 72, 286, 231, 333, 231, 335, 97, 35,
131, 275, 438, 408, 218, 30, 233, 279, 203, 282,
203, 282, 9, 171, 130, 149, 9, 412, 202, 163,
478, 479, 480, 478, 408, 408, 408, 408, 408, 411,
414, 201, 85, 149, 201, 201, 201, 201, 408, 149,
204, 10, 11, 12, 29, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 65, 342, 187, 187,
14, 193, 194, 384, 9, 197, 388, 79, 205, 401,
204, 245, 97, 223, 218, 97, 224, 218, 218, 205,
14, 438, 203, 9, 171, 218, 272, 401, 204, 452,
131, 438, 14, 208, 342, 205, 214, 488, 272, 204,
394, 14, 342, 355, 218, 342, 342, 342, 203, 488,
199, 205, 30, 481, 429, 35, 79, 163, 431, 432,
434, 488, 35, 163, 342, 408, 290, 201, 401, 270,
347, 252, 342, 342, 342, 205, 201, 292, 271, 30,
270, 269, 476, 403, 205, 201, 14, 74, 75, 76,
218, 416, 416, 417, 418, 419, 201, 85, 146, 201,
9, 412, 202, 424, 35, 342, 431, 432, 205, 71,
72, 287, 333, 233, 205, 203, 90, 203, 275, 438,
201, 130, 274, 14, 231, 282, 99, 100, 101, 282,
205, 488, 488, 218, 484, 9, 202, 412, 130, 208,
9, 412, 411, 218, 355, 357, 359, 408, 464, 466,
408, 463, 465, 463, 202, 124, 218, 408, 457, 458,
408, 408, 408, 30, 408, 408, 408, 408, 408, 408,
408, 408, 408, 408, 408, 408, 408, 408, 408, 408,
408, 408, 408, 408, 408, 408, 408, 342, 342, 342,
383, 342, 373, 79, 246, 218, 218, 408, 483, 97,
9, 300, 202, 201, 336, 339, 342, 208, 205, 473,
300, 155, 168, 204, 390, 397, 155, 204, 396, 130,
130, 203, 481, 488, 354, 489, 79, 163, 14, 79,
477, 438, 342, 202, 290, 204, 290, 201, 130, 201,
292, 202, 204, 488, 204, 270, 253, 406, 292, 130,
208, 9, 412, 418, 146, 355, 421, 422, 417, 438,
333, 30, 73, 233, 203, 335, 274, 452, 275, 202,
408, 96, 99, 203, 342, 30, 203, 283, 205, 171,
130, 163, 30, 202, 408, 408, 202, 130, 9, 412,
202, 202, 9, 412, 130, 202, 9, 412, 202, 130,
205, 9, 412, 408, 30, 188, 202, 231, 218, 488,
401, 4, 106, 111, 119, 156, 157, 159, 205, 301,
324, 325, 326, 331, 428, 452, 205, 204, 205, 50,
342, 342, 342, 342, 354, 35, 79, 163, 14, 79,
408, 201, 481, 202, 300, 202, 290, 342, 292, 202,
300, 473, 300, 204, 201, 202, 417, 417, 202, 130,
202, 9, 412, 30, 231, 203, 202, 202, 202, 238,
203, 203, 283, 231, 488, 488, 130, 408, 355, 408,
408, 408, 408, 408, 408, 342, 204, 205, 97, 126,
127, 475, 273, 401, 119, 132, 133, 154, 160, 310,
311, 312, 401, 158, 316, 317, 122, 201, 218, 318,
319, 302, 249, 488, 9, 203, 325, 202, 297, 154,
392, 205, 205, 79, 163, 14, 79, 408, 292, 111,
344, 481, 205, 481, 202, 202, 205, 204, 205, 300,
290, 130, 417, 355, 231, 236, 239, 30, 233, 277,
231, 202, 408, 130, 130, 130, 189, 231, 488, 401,
401, 14, 9, 203, 204, 204, 9, 203, 3, 4,
5, 6, 7, 10, 11, 12, 13, 27, 28, 53,
67, 68, 69, 70, 71, 72, 73, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 123, 124, 125, 126, 127, 131, 132,
134, 135, 136, 137, 138, 150, 151, 152, 162, 164,
165, 167, 174, 178, 180, 182, 183, 218, 398, 399,
9, 203, 154, 158, 218, 319, 320, 321, 203, 79,
330, 248, 303, 475, 249, 205, 298, 299, 475, 14,
79, 408, 202, 201, 204, 203, 204, 322, 344, 481,
297, 205, 202, 417, 130, 30, 233, 276, 277, 231,
408, 408, 408, 342, 205, 203, 203, 408, 401, 306,
313, 407, 311, 14, 30, 47, 314, 317, 9, 33,
202, 29, 46, 49, 14, 9, 203, 476, 330, 14,
248, 203, 14, 408, 35, 79, 389, 231, 231, 204,
322, 205, 481, 417, 231, 94, 190, 244, 205, 218,
229, 307, 308, 309, 9, 205, 408, 399, 399, 55,
315, 320, 320, 29, 46, 49, 408, 79, 201, 203,
408, 476, 408, 79, 9, 413, 205, 205, 231, 322,
92, 203, 79, 109, 240, 149, 97, 407, 161, 14,
304, 201, 35, 79, 202, 205, 203, 201, 167, 247,
218, 325, 326, 408, 288, 289, 429, 305, 79, 401,
245, 164, 218, 203, 202, 9, 413, 113, 114, 115,
328, 329, 288, 79, 273, 203, 481, 429, 489, 202,
202, 203, 203, 204, 323, 328, 35, 79, 163, 481,
204, 231, 489, 79, 163, 14, 79, 323, 231, 205,
35, 79, 163, 14, 79, 408, 205, 79, 163, 14,
79, 408, 14, 79, 408, 408
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
yytoken = YYTRANSLATE (yychar); \
YYPOPSTACK (1); \
goto yybackup; \
} \
else \
{ \
yyerror (&yylloc, _p, YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (YYID (0))
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).line0 = YYRHSLOC (Rhs, 1).line0; \
(Current).char0 = YYRHSLOC (Rhs, 1).char0; \
(Current).line1 = YYRHSLOC (Rhs, N).line1; \
(Current).char1 = YYRHSLOC (Rhs, N).char1; \
} \
else \
{ \
(Current).line0 = (Current).line1 = \
YYRHSLOC (Rhs, 0).line1; \
(Current).char0 = (Current).char1 = \
YYRHSLOC (Rhs, 0).char1; \
} \
while (YYID (0))
#endif
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# if YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).line0, (Loc).char0, \
(Loc).line1, (Loc).char1)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
#else
# define YYLEX yylex (&yylval, &yylloc, _p)
#endif
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (YYID (0))
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value, Location, _p); \
YYFPRINTF (stderr, "\n"); \
} \
} while (YYID (0))
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, HPHP::HPHP_PARSER_NS::Parser *_p)
#else
static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, _p)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
YYLTYPE const * const yylocationp;
HPHP::HPHP_PARSER_NS::Parser *_p;
#endif
{
if (!yyvaluep)
return;
YYUSE (yylocationp);
YYUSE (_p);
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# else
YYUSE (yyoutput);
# endif
switch (yytype)
{
default:
break;
}
}
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, HPHP::HPHP_PARSER_NS::Parser *_p)
#else
static void
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, _p)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
YYLTYPE const * const yylocationp;
HPHP::HPHP_PARSER_NS::Parser *_p;
#endif
{
if (yytype < YYNTOKENS)
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
YY_LOCATION_PRINT (yyoutput, *yylocationp);
YYFPRINTF (yyoutput, ": ");
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, _p);
YYFPRINTF (yyoutput, ")");
}
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
yy_stack_print (yybottom, yytop)
yytype_int16 *yybottom;
yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (YYID (0))
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, HPHP::HPHP_PARSER_NS::Parser *_p)
#else
static void
yy_reduce_print (yyvsp, yylsp, yyrule, _p)
YYSTYPE *yyvsp;
YYLTYPE *yylsp;
int yyrule;
HPHP::HPHP_PARSER_NS::Parser *_p;
#endif
{
int yynrhs = yyr2[yyrule];
int yyi;
unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) , _p);
YYFPRINTF (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyvsp, yylsp, Rule, _p); \
} while (YYID (0))
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static YYSIZE_T
yystrlen (const char *yystr)
#else
static YYSIZE_T
yystrlen (yystr)
const char *yystr;
#endif
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
# endif
# ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static char *
yystpcpy (char *yydest, const char *yysrc)
#else
static char *
yystpcpy (yydest, yysrc)
char *yydest;
const char *yysrc;
#endif
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYSIZE_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
}
# endif
/* Copy into YYRESULT an error message about the unexpected token
YYCHAR while in state YYSTATE. Return the number of bytes copied,
including the terminating null byte. If YYRESULT is null, do not
copy anything; just return the number of bytes that would be
copied. As a special case, return 0 if an ordinary "syntax error"
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
size calculation. */
static YYSIZE_T
yysyntax_error (char *yyresult, int yystate, int yychar)
{
int yyn = yypact[yystate];
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
return 0;
else
{
int yytype = YYTRANSLATE (yychar);
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
int yysize_overflow = 0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
int yyx;
# if 0
/* This is so xgettext sees the translatable formats that are
constructed on the fly. */
YY_("syntax error, unexpected %s");
YY_("syntax error, unexpected %s, expecting %s");
YY_("syntax error, unexpected %s, expecting %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
# endif
char *yyfmt;
char const *yyf;
static char const yyunexpected[] = "syntax error, unexpected %s";
static char const yyexpecting[] = ", expecting %s";
static char const yyor[] = " or %s";
char yyformat[sizeof yyunexpected
+ sizeof yyexpecting - 1
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
* (sizeof yyor - 1))];
char const *yyprefix = yyexpecting;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yycount = 1;
yyarg[0] = yytname[yytype];
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
yyformat[sizeof yyunexpected - 1] = '\0';
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
yyfmt = yystpcpy (yyfmt, yyprefix);
yyprefix = yyor;
}
yyf = YY_(yyformat);
yysize1 = yysize + yystrlen (yyf);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
if (yysize_overflow)
return YYSIZE_MAXIMUM;
if (yyresult)
{
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
char *yyp = yyresult;
int yyi = 0;
while ((*yyp = *yyf) != '\0')
{
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyf += 2;
}
else
{
yyp++;
yyf++;
}
}
}
return yysize;
}
}
#endif /* YYERROR_VERBOSE */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, HPHP::HPHP_PARSER_NS::Parser *_p)
#else
static void
yydestruct (yymsg, yytype, yyvaluep, yylocationp, _p)
const char *yymsg;
int yytype;
YYSTYPE *yyvaluep;
YYLTYPE *yylocationp;
HPHP::HPHP_PARSER_NS::Parser *_p;
#endif
{
YYUSE (yyvaluep);
YYUSE (yylocationp);
YYUSE (_p);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
default:
break;
}
}
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (HPHP::HPHP_PARSER_NS::Parser *_p);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
/*-------------------------.
| yyparse or yypush_parse. |
`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
void *YYPARSE_PARAM;
#endif
#else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
yyparse (HPHP::HPHP_PARSER_NS::Parser *_p)
#else
int
yyparse (_p)
HPHP::HPHP_PARSER_NS::Parser *_p;
#endif
#endif
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
/* Number of syntax errors so far. */
int yynerrs;
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
`yyss': related to states.
`yyvs': related to semantic values.
`yyls': related to locations.
Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
/* The location stack. */
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls;
YYLTYPE *yylsp;
/* The locations where the error started and ended. */
YYLTYPE yyerror_range[2];
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
YYLTYPE yyloc;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yyls = yylsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
#if YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.line0 = yylloc.line1 = 1;
yylloc.char0 = yylloc.char1 = 1;
#endif
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
YYLTYPE *yyls1 = yyls;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
struct yyalloc *yyptr =
(struct yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
memset(yyptr, 0, YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE_RESET (yyvs_alloc, yyvs);
YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
yylsp = yyls + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yyn == 0 || yyn == YYTABLE_NINF)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
*++yylsp = yylloc;
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
/* Default location. */
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
/* Line 1455 of yacc.c */
#line 737 "hphp.y"
{ _p->onNewLabelScope(true);
_p->initParseTree();;}
break;
case 3:
/* Line 1455 of yacc.c */
#line 740 "hphp.y"
{ _p->popLabelInfo();
_p->finiParseTree();
_p->onCompleteLabelScope(true);;}
break;
case 4:
/* Line 1455 of yacc.c */
#line 747 "hphp.y"
{ _p->addTopStatement((yyvsp[(2) - (2)]));;}
break;
case 5:
/* Line 1455 of yacc.c */
#line 748 "hphp.y"
{ ;}
break;
case 6:
/* Line 1455 of yacc.c */
#line 751 "hphp.y"
{ _p->nns((yyvsp[(1) - (1)]).num(), (yyvsp[(1) - (1)]).text()); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 7:
/* Line 1455 of yacc.c */
#line 752 "hphp.y"
{ _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 8:
/* Line 1455 of yacc.c */
#line 753 "hphp.y"
{ _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 9:
/* Line 1455 of yacc.c */
#line 754 "hphp.y"
{ _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 10:
/* Line 1455 of yacc.c */
#line 755 "hphp.y"
{ _p->nns(); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 11:
/* Line 1455 of yacc.c */
#line 756 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 12:
/* Line 1455 of yacc.c */
#line 757 "hphp.y"
{ _p->onHaltCompiler();
_p->finiParseTree();
YYACCEPT;;}
break;
case 13:
/* Line 1455 of yacc.c */
#line 760 "hphp.y"
{ _p->onNamespaceStart((yyvsp[(2) - (3)]).text(), true);
(yyval).reset();;}
break;
case 14:
/* Line 1455 of yacc.c */
#line 762 "hphp.y"
{ _p->onNamespaceStart((yyvsp[(2) - (3)]).text());;}
break;
case 15:
/* Line 1455 of yacc.c */
#line 763 "hphp.y"
{ _p->onNamespaceEnd(); (yyval) = (yyvsp[(5) - (6)]);;}
break;
case 16:
/* Line 1455 of yacc.c */
#line 764 "hphp.y"
{ _p->onNamespaceStart("");;}
break;
case 17:
/* Line 1455 of yacc.c */
#line 765 "hphp.y"
{ _p->onNamespaceEnd(); (yyval) = (yyvsp[(4) - (5)]);;}
break;
case 18:
/* Line 1455 of yacc.c */
#line 766 "hphp.y"
{ _p->nns(); (yyval).reset();;}
break;
case 19:
/* Line 1455 of yacc.c */
#line 768 "hphp.y"
{ _p->nns(); (yyval).reset();;}
break;
case 20:
/* Line 1455 of yacc.c */
#line 770 "hphp.y"
{ _p->nns(); (yyval).reset();;}
break;
case 21:
/* Line 1455 of yacc.c */
#line 771 "hphp.y"
{ _p->nns();
_p->finishStatement((yyval), (yyvsp[(1) - (2)])); (yyval) = 1;;}
break;
case 22:
/* Line 1455 of yacc.c */
#line 776 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 23:
/* Line 1455 of yacc.c */
#line 777 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 24:
/* Line 1455 of yacc.c */
#line 778 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 25:
/* Line 1455 of yacc.c */
#line 779 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 26:
/* Line 1455 of yacc.c */
#line 780 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 27:
/* Line 1455 of yacc.c */
#line 781 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 28:
/* Line 1455 of yacc.c */
#line 782 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 29:
/* Line 1455 of yacc.c */
#line 783 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 30:
/* Line 1455 of yacc.c */
#line 784 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 31:
/* Line 1455 of yacc.c */
#line 785 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 32:
/* Line 1455 of yacc.c */
#line 786 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 33:
/* Line 1455 of yacc.c */
#line 787 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 34:
/* Line 1455 of yacc.c */
#line 788 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 35:
/* Line 1455 of yacc.c */
#line 789 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 36:
/* Line 1455 of yacc.c */
#line 790 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 37:
/* Line 1455 of yacc.c */
#line 791 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 38:
/* Line 1455 of yacc.c */
#line 792 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 39:
/* Line 1455 of yacc.c */
#line 793 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 40:
/* Line 1455 of yacc.c */
#line 794 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 41:
/* Line 1455 of yacc.c */
#line 799 "hphp.y"
{ ;}
break;
case 42:
/* Line 1455 of yacc.c */
#line 800 "hphp.y"
{ ;}
break;
case 43:
/* Line 1455 of yacc.c */
#line 805 "hphp.y"
{ ;}
break;
case 44:
/* Line 1455 of yacc.c */
#line 806 "hphp.y"
{ ;}
break;
case 45:
/* Line 1455 of yacc.c */
#line 811 "hphp.y"
{ ;}
break;
case 46:
/* Line 1455 of yacc.c */
#line 812 "hphp.y"
{ ;}
break;
case 47:
/* Line 1455 of yacc.c */
#line 816 "hphp.y"
{ _p->onUse((yyvsp[(1) - (1)]).text(),"");;}
break;
case 48:
/* Line 1455 of yacc.c */
#line 817 "hphp.y"
{ _p->onUse((yyvsp[(2) - (2)]).text(),"");;}
break;
case 49:
/* Line 1455 of yacc.c */
#line 818 "hphp.y"
{ _p->onUse((yyvsp[(1) - (3)]).text(),(yyvsp[(3) - (3)]).text());;}
break;
case 50:
/* Line 1455 of yacc.c */
#line 820 "hphp.y"
{ _p->onUse((yyvsp[(2) - (4)]).text(),(yyvsp[(4) - (4)]).text());;}
break;
case 51:
/* Line 1455 of yacc.c */
#line 824 "hphp.y"
{ _p->onUseFunction((yyvsp[(1) - (1)]).text(),"");;}
break;
case 52:
/* Line 1455 of yacc.c */
#line 825 "hphp.y"
{ _p->onUseFunction((yyvsp[(2) - (2)]).text(),"");;}
break;
case 53:
/* Line 1455 of yacc.c */
#line 826 "hphp.y"
{ _p->onUseFunction((yyvsp[(1) - (3)]).text(),(yyvsp[(3) - (3)]).text());;}
break;
case 54:
/* Line 1455 of yacc.c */
#line 828 "hphp.y"
{ _p->onUseFunction((yyvsp[(2) - (4)]).text(),(yyvsp[(4) - (4)]).text());;}
break;
case 55:
/* Line 1455 of yacc.c */
#line 832 "hphp.y"
{ _p->onUseConst((yyvsp[(1) - (1)]).text(),"");;}
break;
case 56:
/* Line 1455 of yacc.c */
#line 833 "hphp.y"
{ _p->onUseConst((yyvsp[(2) - (2)]).text(),"");;}
break;
case 57:
/* Line 1455 of yacc.c */
#line 834 "hphp.y"
{ _p->onUseConst((yyvsp[(1) - (3)]).text(),(yyvsp[(3) - (3)]).text());;}
break;
case 58:
/* Line 1455 of yacc.c */
#line 836 "hphp.y"
{ _p->onUseConst((yyvsp[(2) - (4)]).text(),(yyvsp[(4) - (4)]).text());;}
break;
case 59:
/* Line 1455 of yacc.c */
#line 840 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 60:
/* Line 1455 of yacc.c */
#line 842 "hphp.y"
{ (yyval) = (yyvsp[(1) - (3)]) + (yyvsp[(2) - (3)]) + (yyvsp[(3) - (3)]); (yyval) = (yyvsp[(1) - (3)]).num() | 2;;}
break;
case 61:
/* Line 1455 of yacc.c */
#line 845 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = (yyval).num() | 1;;}
break;
case 62:
/* Line 1455 of yacc.c */
#line 847 "hphp.y"
{ (yyval).set((yyvsp[(3) - (3)]).num() | 2, _p->nsDecl((yyvsp[(3) - (3)]).text()));;}
break;
case 63:
/* Line 1455 of yacc.c */
#line 848 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]); (yyval) = (yyval).num() | 2;;}
break;
case 64:
/* Line 1455 of yacc.c */
#line 851 "hphp.y"
{ if ((yyvsp[(1) - (1)]).num() & 1) {
(yyvsp[(1) - (1)]).setText(_p->resolve((yyvsp[(1) - (1)]).text(),0));
}
(yyval) = (yyvsp[(1) - (1)]);;}
break;
case 65:
/* Line 1455 of yacc.c */
#line 858 "hphp.y"
{ if ((yyvsp[(1) - (2)]).num() & 1) {
(yyvsp[(1) - (2)]).setText(_p->resolve((yyvsp[(1) - (2)]).text(),0));
}
(yyval) = (yyvsp[(1) - (2)]);;}
break;
case 66:
/* Line 1455 of yacc.c */
#line 865 "hphp.y"
{ if ((yyvsp[(1) - (2)]).num() & 1) {
(yyvsp[(1) - (2)]).setText(_p->resolve((yyvsp[(1) - (2)]).text(),1));
}
_p->onTypeAnnotation((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;}
break;
case 67:
/* Line 1455 of yacc.c */
#line 873 "hphp.y"
{ (yyvsp[(3) - (5)]).setText(_p->nsDecl((yyvsp[(3) - (5)]).text()));
_p->onConst((yyval),(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 68:
/* Line 1455 of yacc.c */
#line 876 "hphp.y"
{ (yyvsp[(2) - (4)]).setText(_p->nsDecl((yyvsp[(2) - (4)]).text()));
_p->onConst((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;}
break;
case 69:
/* Line 1455 of yacc.c */
#line 882 "hphp.y"
{ _p->addStatement((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
break;
case 70:
/* Line 1455 of yacc.c */
#line 883 "hphp.y"
{ _p->onStatementListStart((yyval));;}
break;
case 71:
/* Line 1455 of yacc.c */
#line 886 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 72:
/* Line 1455 of yacc.c */
#line 887 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 73:
/* Line 1455 of yacc.c */
#line 888 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 74:
/* Line 1455 of yacc.c */
#line 889 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 75:
/* Line 1455 of yacc.c */
#line 892 "hphp.y"
{ _p->onBlock((yyval), (yyvsp[(2) - (3)]));;}
break;
case 76:
/* Line 1455 of yacc.c */
#line 896 "hphp.y"
{ _p->onIf((yyval),(yyvsp[(2) - (5)]),(yyvsp[(3) - (5)]),(yyvsp[(4) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 77:
/* Line 1455 of yacc.c */
#line 901 "hphp.y"
{ _p->onIf((yyval),(yyvsp[(2) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(6) - (8)]));;}
break;
case 78:
/* Line 1455 of yacc.c */
#line 902 "hphp.y"
{ _p->onNewLabelScope(false);
_p->pushLabelScope();;}
break;
case 79:
/* Line 1455 of yacc.c */
#line 904 "hphp.y"
{ _p->popLabelScope();
_p->onWhile((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));
_p->onCompleteLabelScope(false);;}
break;
case 80:
/* Line 1455 of yacc.c */
#line 908 "hphp.y"
{ _p->onNewLabelScope(false);
_p->pushLabelScope();;}
break;
case 81:
/* Line 1455 of yacc.c */
#line 911 "hphp.y"
{ _p->popLabelScope();
_p->onDo((yyval),(yyvsp[(3) - (6)]),(yyvsp[(5) - (6)]));
_p->onCompleteLabelScope(false);;}
break;
case 82:
/* Line 1455 of yacc.c */
#line 915 "hphp.y"
{ _p->onNewLabelScope(false);
_p->pushLabelScope();;}
break;
case 83:
/* Line 1455 of yacc.c */
#line 917 "hphp.y"
{ _p->popLabelScope();
_p->onFor((yyval),(yyvsp[(3) - (10)]),(yyvsp[(5) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)]));
_p->onCompleteLabelScope(false);;}
break;
case 84:
/* Line 1455 of yacc.c */
#line 920 "hphp.y"
{ _p->onNewLabelScope(false);
_p->pushLabelScope();;}
break;
case 85:
/* Line 1455 of yacc.c */
#line 922 "hphp.y"
{ _p->popLabelScope();
_p->onSwitch((yyval),(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));
_p->onCompleteLabelScope(false);;}
break;
case 86:
/* Line 1455 of yacc.c */
#line 925 "hphp.y"
{ _p->onBreakContinue((yyval), true, NULL);;}
break;
case 87:
/* Line 1455 of yacc.c */
#line 926 "hphp.y"
{ _p->onBreakContinue((yyval), true, &(yyvsp[(2) - (3)]));;}
break;
case 88:
/* Line 1455 of yacc.c */
#line 927 "hphp.y"
{ _p->onBreakContinue((yyval), false, NULL);;}
break;
case 89:
/* Line 1455 of yacc.c */
#line 928 "hphp.y"
{ _p->onBreakContinue((yyval), false, &(yyvsp[(2) - (3)]));;}
break;
case 90:
/* Line 1455 of yacc.c */
#line 929 "hphp.y"
{ _p->onReturn((yyval), NULL);;}
break;
case 91:
/* Line 1455 of yacc.c */
#line 930 "hphp.y"
{ _p->onReturn((yyval), &(yyvsp[(2) - (3)]));;}
break;
case 92:
/* Line 1455 of yacc.c */
#line 931 "hphp.y"
{ _p->onYieldBreak((yyval));;}
break;
case 93:
/* Line 1455 of yacc.c */
#line 932 "hphp.y"
{ _p->onGlobal((yyval), (yyvsp[(2) - (3)]));;}
break;
case 94:
/* Line 1455 of yacc.c */
#line 933 "hphp.y"
{ _p->onStatic((yyval), (yyvsp[(2) - (3)]));;}
break;
case 95:
/* Line 1455 of yacc.c */
#line 934 "hphp.y"
{ _p->onEcho((yyval), (yyvsp[(2) - (3)]), 0);;}
break;
case 96:
/* Line 1455 of yacc.c */
#line 935 "hphp.y"
{ _p->onUnset((yyval), (yyvsp[(3) - (5)]));;}
break;
case 97:
/* Line 1455 of yacc.c */
#line 936 "hphp.y"
{ (yyval).reset(); (yyval) = ';';;}
break;
case 98:
/* Line 1455 of yacc.c */
#line 937 "hphp.y"
{ _p->onEcho((yyval), (yyvsp[(1) - (1)]), 1);;}
break;
case 99:
/* Line 1455 of yacc.c */
#line 938 "hphp.y"
{ _p->onHashBang((yyval), (yyvsp[(1) - (1)]));
(yyval) = T_HASHBANG;;}
break;
case 100:
/* Line 1455 of yacc.c */
#line 942 "hphp.y"
{ _p->onNewLabelScope(false);
_p->pushLabelScope();;}
break;
case 101:
/* Line 1455 of yacc.c */
#line 944 "hphp.y"
{ _p->popLabelScope();
_p->onForEach((yyval),(yyvsp[(3) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(6) - (9)]),(yyvsp[(9) - (9)]), false);
_p->onCompleteLabelScope(false);;}
break;
case 102:
/* Line 1455 of yacc.c */
#line 949 "hphp.y"
{ _p->onNewLabelScope(false);
_p->pushLabelScope();;}
break;
case 103:
/* Line 1455 of yacc.c */
#line 951 "hphp.y"
{ _p->popLabelScope();
_p->onForEach((yyval),(yyvsp[(3) - (10)]),(yyvsp[(6) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)]), true);
_p->onCompleteLabelScope(false);;}
break;
case 104:
/* Line 1455 of yacc.c */
#line 955 "hphp.y"
{ _p->onBlock((yyval), (yyvsp[(5) - (5)])); (yyval) = T_DECLARE;;}
break;
case 105:
/* Line 1455 of yacc.c */
#line 962 "hphp.y"
{ _p->onCompleteLabelScope(false);;}
break;
case 106:
/* Line 1455 of yacc.c */
#line 963 "hphp.y"
{ _p->onTry((yyval),(yyvsp[(2) - (13)]),(yyvsp[(5) - (13)]),(yyvsp[(6) - (13)]),(yyvsp[(9) - (13)]),(yyvsp[(11) - (13)]),(yyvsp[(13) - (13)]));;}
break;
case 107:
/* Line 1455 of yacc.c */
#line 966 "hphp.y"
{ _p->onCompleteLabelScope(false);;}
break;
case 108:
/* Line 1455 of yacc.c */
#line 967 "hphp.y"
{ _p->onTry((yyval), (yyvsp[(2) - (5)]), (yyvsp[(5) - (5)]));;}
break;
case 109:
/* Line 1455 of yacc.c */
#line 968 "hphp.y"
{ _p->onThrow((yyval), (yyvsp[(2) - (3)]));;}
break;
case 110:
/* Line 1455 of yacc.c */
#line 969 "hphp.y"
{ _p->onGoto((yyval), (yyvsp[(2) - (3)]), true);
_p->addGoto((yyvsp[(2) - (3)]).text(),
_p->getLocation(),
&(yyval));;}
break;
case 111:
/* Line 1455 of yacc.c */
#line 973 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 112:
/* Line 1455 of yacc.c */
#line 974 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 113:
/* Line 1455 of yacc.c */
#line 975 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 114:
/* Line 1455 of yacc.c */
#line 976 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 115:
/* Line 1455 of yacc.c */
#line 977 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 116:
/* Line 1455 of yacc.c */
#line 978 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 117:
/* Line 1455 of yacc.c */
#line 979 "hphp.y"
{ _p->onReturn((yyval), &(yyvsp[(2) - (3)])); ;}
break;
case 118:
/* Line 1455 of yacc.c */
#line 980 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 119:
/* Line 1455 of yacc.c */
#line 981 "hphp.y"
{ _p->onExpStatement((yyval), (yyvsp[(1) - (2)]));;}
break;
case 120:
/* Line 1455 of yacc.c */
#line 982 "hphp.y"
{ _p->onReturn((yyval), &(yyvsp[(2) - (3)])); ;}
break;
case 121:
/* Line 1455 of yacc.c */
#line 983 "hphp.y"
{ _p->onLabel((yyval), (yyvsp[(1) - (2)]));
_p->addLabel((yyvsp[(1) - (2)]).text(),
_p->getLocation(),
&(yyval));
_p->onScopeLabel((yyval), (yyvsp[(1) - (2)]));;}
break;
case 122:
/* Line 1455 of yacc.c */
#line 991 "hphp.y"
{ _p->onNewLabelScope(false);;}
break;
case 123:
/* Line 1455 of yacc.c */
#line 992 "hphp.y"
{ (yyval) = (yyvsp[(3) - (4)]);;}
break;
case 124:
/* Line 1455 of yacc.c */
#line 1001 "hphp.y"
{ _p->onCatch((yyval), (yyvsp[(1) - (9)]), (yyvsp[(4) - (9)]), (yyvsp[(5) - (9)]), (yyvsp[(8) - (9)]));;}
break;
case 125:
/* Line 1455 of yacc.c */
#line 1002 "hphp.y"
{ (yyval).reset();;}
break;
case 126:
/* Line 1455 of yacc.c */
#line 1006 "hphp.y"
{ _p->onNewLabelScope(false);
_p->pushLabelScope();;}
break;
case 127:
/* Line 1455 of yacc.c */
#line 1008 "hphp.y"
{ _p->popLabelScope();
_p->onFinally((yyval), (yyvsp[(3) - (4)]));
_p->onCompleteLabelScope(false);;}
break;
case 128:
/* Line 1455 of yacc.c */
#line 1014 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]);;}
break;
case 129:
/* Line 1455 of yacc.c */
#line 1015 "hphp.y"
{ (yyval).reset();;}
break;
case 130:
/* Line 1455 of yacc.c */
#line 1019 "hphp.y"
{ (yyval) = 1;;}
break;
case 131:
/* Line 1455 of yacc.c */
#line 1020 "hphp.y"
{ (yyval).reset();;}
break;
case 132:
/* Line 1455 of yacc.c */
#line 1024 "hphp.y"
{ _p->pushFuncLocation(); ;}
break;
case 133:
/* Line 1455 of yacc.c */
#line 1029 "hphp.y"
{ (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text()));
_p->onNewLabelScope(true);
_p->onFunctionStart((yyvsp[(3) - (3)]));
_p->pushLabelInfo();;}
break;
case 134:
/* Line 1455 of yacc.c */
#line 1035 "hphp.y"
{ _p->onFunction((yyval),nullptr,(yyvsp[(8) - (9)]),(yyvsp[(2) - (9)]),(yyvsp[(3) - (9)]),(yyvsp[(6) - (9)]),(yyvsp[(9) - (9)]),nullptr);
_p->popLabelInfo();
_p->popTypeScope();
_p->onCompleteLabelScope(true);;}
break;
case 135:
/* Line 1455 of yacc.c */
#line 1041 "hphp.y"
{ (yyvsp[(4) - (4)]).setText(_p->nsDecl((yyvsp[(4) - (4)]).text()));
_p->onNewLabelScope(true);
_p->onFunctionStart((yyvsp[(4) - (4)]));
_p->pushLabelInfo();;}
break;
case 136:
/* Line 1455 of yacc.c */
#line 1047 "hphp.y"
{ _p->onFunction((yyval),&(yyvsp[(1) - (10)]),(yyvsp[(9) - (10)]),(yyvsp[(3) - (10)]),(yyvsp[(4) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)]),nullptr);
_p->popLabelInfo();
_p->popTypeScope();
_p->onCompleteLabelScope(true);;}
break;
case 137:
/* Line 1455 of yacc.c */
#line 1053 "hphp.y"
{ (yyvsp[(5) - (5)]).setText(_p->nsDecl((yyvsp[(5) - (5)]).text()));
_p->onNewLabelScope(true);
_p->onFunctionStart((yyvsp[(5) - (5)]));
_p->pushLabelInfo();;}
break;
case 138:
/* Line 1455 of yacc.c */
#line 1059 "hphp.y"
{ _p->onFunction((yyval),&(yyvsp[(2) - (11)]),(yyvsp[(10) - (11)]),(yyvsp[(4) - (11)]),(yyvsp[(5) - (11)]),(yyvsp[(8) - (11)]),(yyvsp[(11) - (11)]),&(yyvsp[(1) - (11)]));
_p->popLabelInfo();
_p->popTypeScope();
_p->onCompleteLabelScope(true);;}
break;
case 139:
/* Line 1455 of yacc.c */
#line 1067 "hphp.y"
{ (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text()));
_p->onClassStart(T_ENUM,(yyvsp[(2) - (2)]));;}
break;
case 140:
/* Line 1455 of yacc.c */
#line 1071 "hphp.y"
{ _p->onEnum((yyval),(yyvsp[(2) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(8) - (9)]),0); ;}
break;
case 141:
/* Line 1455 of yacc.c */
#line 1075 "hphp.y"
{ (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text()));
_p->onClassStart(T_ENUM,(yyvsp[(3) - (3)]));;}
break;
case 142:
/* Line 1455 of yacc.c */
#line 1079 "hphp.y"
{ _p->onEnum((yyval),(yyvsp[(3) - (10)]),(yyvsp[(6) - (10)]),(yyvsp[(9) - (10)]),&(yyvsp[(1) - (10)])); ;}
break;
case 143:
/* Line 1455 of yacc.c */
#line 1085 "hphp.y"
{ (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text()));
_p->onClassStart((yyvsp[(1) - (2)]).num(),(yyvsp[(2) - (2)]));;}
break;
case 144:
/* Line 1455 of yacc.c */
#line 1088 "hphp.y"
{ Token stmts;
if (_p->peekClass()) {
xhp_collect_attributes(_p,stmts,(yyvsp[(7) - (8)]));
} else {
stmts = (yyvsp[(7) - (8)]);
}
_p->onClass((yyval),(yyvsp[(1) - (8)]).num(),(yyvsp[(2) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(5) - (8)]),
stmts,0,nullptr);
if (_p->peekClass()) {
_p->xhpResetAttributes();
}
_p->popClass();
_p->popTypeScope();;}
break;
case 145:
/* Line 1455 of yacc.c */
#line 1103 "hphp.y"
{ (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text()));
_p->onClassStart((yyvsp[(2) - (3)]).num(),(yyvsp[(3) - (3)]));;}
break;
case 146:
/* Line 1455 of yacc.c */
#line 1106 "hphp.y"
{ Token stmts;
if (_p->peekClass()) {
xhp_collect_attributes(_p,stmts,(yyvsp[(8) - (9)]));
} else {
stmts = (yyvsp[(8) - (9)]);
}
_p->onClass((yyval),(yyvsp[(2) - (9)]).num(),(yyvsp[(3) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(6) - (9)]),
stmts,&(yyvsp[(1) - (9)]),nullptr);
if (_p->peekClass()) {
_p->xhpResetAttributes();
}
_p->popClass();
_p->popTypeScope();;}
break;
case 147:
/* Line 1455 of yacc.c */
#line 1120 "hphp.y"
{ (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text()));
_p->onClassStart(T_INTERFACE,(yyvsp[(2) - (2)]));;}
break;
case 148:
/* Line 1455 of yacc.c */
#line 1123 "hphp.y"
{ _p->onInterface((yyval),(yyvsp[(2) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(6) - (7)]),0);
_p->popClass();
_p->popTypeScope();;}
break;
case 149:
/* Line 1455 of yacc.c */
#line 1128 "hphp.y"
{ (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text()));
_p->onClassStart(T_INTERFACE,(yyvsp[(3) - (3)]));;}
break;
case 150:
/* Line 1455 of yacc.c */
#line 1131 "hphp.y"
{ _p->onInterface((yyval),(yyvsp[(3) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(7) - (8)]),&(yyvsp[(1) - (8)]));
_p->popClass();
_p->popTypeScope();;}
break;
case 151:
/* Line 1455 of yacc.c */
#line 1138 "hphp.y"
{ (yyvsp[(2) - (2)]).setText(_p->nsDecl((yyvsp[(2) - (2)]).text()));
_p->onClassStart(T_TRAIT, (yyvsp[(2) - (2)]));;}
break;
case 152:
/* Line 1455 of yacc.c */
#line 1141 "hphp.y"
{ Token t_ext;
t_ext.reset();
_p->onClass((yyval),T_TRAIT,(yyvsp[(2) - (7)]),t_ext,(yyvsp[(4) - (7)]),
(yyvsp[(6) - (7)]), 0, nullptr);
_p->popClass();
_p->popTypeScope();;}
break;
case 153:
/* Line 1455 of yacc.c */
#line 1149 "hphp.y"
{ (yyvsp[(3) - (3)]).setText(_p->nsDecl((yyvsp[(3) - (3)]).text()));
_p->onClassStart(T_TRAIT, (yyvsp[(3) - (3)]));;}
break;
case 154:
/* Line 1455 of yacc.c */
#line 1152 "hphp.y"
{ Token t_ext;
t_ext.reset();
_p->onClass((yyval),T_TRAIT,(yyvsp[(3) - (8)]),t_ext,(yyvsp[(5) - (8)]),
(yyvsp[(7) - (8)]), &(yyvsp[(1) - (8)]), nullptr);
_p->popClass();
_p->popTypeScope();;}
break;
case 155:
/* Line 1455 of yacc.c */
#line 1160 "hphp.y"
{ _p->pushClass(false); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 156:
/* Line 1455 of yacc.c */
#line 1161 "hphp.y"
{ (yyvsp[(1) - (1)]).xhpLabel(); _p->pushTypeScope();
_p->pushClass(true); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 157:
/* Line 1455 of yacc.c */
#line 1165 "hphp.y"
{ _p->pushClass(false); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 158:
/* Line 1455 of yacc.c */
#line 1168 "hphp.y"
{ _p->pushClass(false); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 159:
/* Line 1455 of yacc.c */
#line 1171 "hphp.y"
{ (yyval) = T_CLASS;;}
break;
case 160:
/* Line 1455 of yacc.c */
#line 1172 "hphp.y"
{ (yyval) = T_ABSTRACT; ;}
break;
case 161:
/* Line 1455 of yacc.c */
#line 1173 "hphp.y"
{ only_in_hh_syntax(_p);
/* hacky, but transforming to a single token is quite convenient */
(yyval) = T_STATIC; ;}
break;
case 162:
/* Line 1455 of yacc.c */
#line 1176 "hphp.y"
{ only_in_hh_syntax(_p); (yyval) = T_STATIC; ;}
break;
case 163:
/* Line 1455 of yacc.c */
#line 1177 "hphp.y"
{ (yyval) = T_FINAL;;}
break;
case 164:
/* Line 1455 of yacc.c */
#line 1181 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]);;}
break;
case 165:
/* Line 1455 of yacc.c */
#line 1182 "hphp.y"
{ (yyval).reset();;}
break;
case 166:
/* Line 1455 of yacc.c */
#line 1185 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]);;}
break;
case 167:
/* Line 1455 of yacc.c */
#line 1186 "hphp.y"
{ (yyval).reset();;}
break;
case 168:
/* Line 1455 of yacc.c */
#line 1189 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]);;}
break;
case 169:
/* Line 1455 of yacc.c */
#line 1190 "hphp.y"
{ (yyval).reset();;}
break;
case 170:
/* Line 1455 of yacc.c */
#line 1193 "hphp.y"
{ _p->onInterfaceName((yyval), NULL, (yyvsp[(1) - (1)]));;}
break;
case 171:
/* Line 1455 of yacc.c */
#line 1195 "hphp.y"
{ _p->onInterfaceName((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;}
break;
case 172:
/* Line 1455 of yacc.c */
#line 1198 "hphp.y"
{ _p->onTraitName((yyval), NULL, (yyvsp[(1) - (1)]));;}
break;
case 173:
/* Line 1455 of yacc.c */
#line 1200 "hphp.y"
{ _p->onTraitName((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;}
break;
case 174:
/* Line 1455 of yacc.c */
#line 1204 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]);;}
break;
case 175:
/* Line 1455 of yacc.c */
#line 1205 "hphp.y"
{ (yyval).reset();;}
break;
case 176:
/* Line 1455 of yacc.c */
#line 1208 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = 0;;}
break;
case 177:
/* Line 1455 of yacc.c */
#line 1209 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]); (yyval) = 1;;}
break;
case 178:
/* Line 1455 of yacc.c */
#line 1210 "hphp.y"
{ _p->onListAssignment((yyval), (yyvsp[(3) - (4)]), NULL);;}
break;
case 179:
/* Line 1455 of yacc.c */
#line 1214 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 180:
/* Line 1455 of yacc.c */
#line 1216 "hphp.y"
{ (yyval) = (yyvsp[(2) - (4)]);;}
break;
case 181:
/* Line 1455 of yacc.c */
#line 1219 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 182:
/* Line 1455 of yacc.c */
#line 1221 "hphp.y"
{ (yyval) = (yyvsp[(2) - (4)]);;}
break;
case 183:
/* Line 1455 of yacc.c */
#line 1224 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 184:
/* Line 1455 of yacc.c */
#line 1226 "hphp.y"
{ (yyval) = (yyvsp[(2) - (4)]);;}
break;
case 185:
/* Line 1455 of yacc.c */
#line 1229 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 186:
/* Line 1455 of yacc.c */
#line 1231 "hphp.y"
{ (yyval) = (yyvsp[(2) - (4)]);;}
break;
case 189:
/* Line 1455 of yacc.c */
#line 1241 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 190:
/* Line 1455 of yacc.c */
#line 1242 "hphp.y"
{ (yyval) = (yyvsp[(3) - (4)]);;}
break;
case 191:
/* Line 1455 of yacc.c */
#line 1243 "hphp.y"
{ (yyval) = (yyvsp[(2) - (4)]);;}
break;
case 192:
/* Line 1455 of yacc.c */
#line 1244 "hphp.y"
{ (yyval) = (yyvsp[(3) - (5)]);;}
break;
case 193:
/* Line 1455 of yacc.c */
#line 1249 "hphp.y"
{ _p->onCase((yyval),(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 194:
/* Line 1455 of yacc.c */
#line 1251 "hphp.y"
{ _p->onCase((yyval),(yyvsp[(1) - (4)]),NULL,(yyvsp[(4) - (4)]));;}
break;
case 195:
/* Line 1455 of yacc.c */
#line 1252 "hphp.y"
{ (yyval).reset();;}
break;
case 196:
/* Line 1455 of yacc.c */
#line 1255 "hphp.y"
{ (yyval).reset();;}
break;
case 197:
/* Line 1455 of yacc.c */
#line 1256 "hphp.y"
{ (yyval).reset();;}
break;
case 198:
/* Line 1455 of yacc.c */
#line 1261 "hphp.y"
{ _p->onElseIf((yyval),(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)]));;}
break;
case 199:
/* Line 1455 of yacc.c */
#line 1262 "hphp.y"
{ (yyval).reset();;}
break;
case 200:
/* Line 1455 of yacc.c */
#line 1267 "hphp.y"
{ _p->onElseIf((yyval),(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 201:
/* Line 1455 of yacc.c */
#line 1268 "hphp.y"
{ (yyval).reset();;}
break;
case 202:
/* Line 1455 of yacc.c */
#line 1271 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]);;}
break;
case 203:
/* Line 1455 of yacc.c */
#line 1272 "hphp.y"
{ (yyval).reset();;}
break;
case 204:
/* Line 1455 of yacc.c */
#line 1275 "hphp.y"
{ (yyval) = (yyvsp[(3) - (3)]);;}
break;
case 205:
/* Line 1455 of yacc.c */
#line 1276 "hphp.y"
{ (yyval).reset();;}
break;
case 206:
/* Line 1455 of yacc.c */
#line 1284 "hphp.y"
{ _p->onVariadicParam((yyval),&(yyvsp[(1) - (7)]),(yyvsp[(5) - (7)]),(yyvsp[(7) - (7)]),false,
&(yyvsp[(3) - (7)]),&(yyvsp[(4) - (7)])); ;}
break;
case 207:
/* Line 1455 of yacc.c */
#line 1290 "hphp.y"
{ _p->onVariadicParam((yyval),&(yyvsp[(1) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(8) - (8)]),true,
&(yyvsp[(3) - (8)]),&(yyvsp[(4) - (8)])); ;}
break;
case 208:
/* Line 1455 of yacc.c */
#line 1296 "hphp.y"
{ validate_hh_variadic_variant(
_p, (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]), &(yyvsp[(4) - (6)]));
(yyval) = (yyvsp[(1) - (6)]); ;}
break;
case 209:
/* Line 1455 of yacc.c */
#line 1300 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 210:
/* Line 1455 of yacc.c */
#line 1304 "hphp.y"
{ _p->onVariadicParam((yyval),NULL,(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),false,
&(yyvsp[(1) - (5)]),&(yyvsp[(2) - (5)])); ;}
break;
case 211:
/* Line 1455 of yacc.c */
#line 1309 "hphp.y"
{ _p->onVariadicParam((yyval),NULL,(yyvsp[(3) - (6)]),(yyvsp[(6) - (6)]),true,
&(yyvsp[(1) - (6)]),&(yyvsp[(2) - (6)])); ;}
break;
case 212:
/* Line 1455 of yacc.c */
#line 1314 "hphp.y"
{ validate_hh_variadic_variant(
_p, (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]), &(yyvsp[(2) - (4)]));
(yyval).reset(); ;}
break;
case 213:
/* Line 1455 of yacc.c */
#line 1317 "hphp.y"
{ (yyval).reset(); ;}
break;
case 214:
/* Line 1455 of yacc.c */
#line 1323 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)]),0,
NULL,&(yyvsp[(1) - (4)]),&(yyvsp[(2) - (4)]));;}
break;
case 215:
/* Line 1455 of yacc.c */
#line 1327 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),1,
NULL,&(yyvsp[(1) - (5)]),&(yyvsp[(2) - (5)]));;}
break;
case 216:
/* Line 1455 of yacc.c */
#line 1332 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(3) - (7)]),(yyvsp[(5) - (7)]),1,
&(yyvsp[(7) - (7)]),&(yyvsp[(1) - (7)]),&(yyvsp[(2) - (7)]));;}
break;
case 217:
/* Line 1455 of yacc.c */
#line 1337 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(3) - (6)]),(yyvsp[(4) - (6)]),0,
&(yyvsp[(6) - (6)]),&(yyvsp[(1) - (6)]),&(yyvsp[(2) - (6)]));;}
break;
case 218:
/* Line 1455 of yacc.c */
#line 1342 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(5) - (6)]),(yyvsp[(6) - (6)]),0,
NULL,&(yyvsp[(3) - (6)]),&(yyvsp[(4) - (6)]));;}
break;
case 219:
/* Line 1455 of yacc.c */
#line 1347 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (7)]),(yyvsp[(5) - (7)]),(yyvsp[(7) - (7)]),1,
NULL,&(yyvsp[(3) - (7)]),&(yyvsp[(4) - (7)]));;}
break;
case 220:
/* Line 1455 of yacc.c */
#line 1353 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (9)]),(yyvsp[(5) - (9)]),(yyvsp[(7) - (9)]),1,
&(yyvsp[(9) - (9)]),&(yyvsp[(3) - (9)]),&(yyvsp[(4) - (9)]));;}
break;
case 221:
/* Line 1455 of yacc.c */
#line 1359 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (8)]),(yyvsp[(5) - (8)]),(yyvsp[(6) - (8)]),0,
&(yyvsp[(8) - (8)]),&(yyvsp[(3) - (8)]),&(yyvsp[(4) - (8)]));;}
break;
case 222:
/* Line 1455 of yacc.c */
#line 1367 "hphp.y"
{ _p->onVariadicParam((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(4) - (6)]),(yyvsp[(6) - (6)]),
false,&(yyvsp[(3) - (6)]),NULL); ;}
break;
case 223:
/* Line 1455 of yacc.c */
#line 1372 "hphp.y"
{ _p->onVariadicParam((yyval),&(yyvsp[(1) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(7) - (7)]),
true,&(yyvsp[(3) - (7)]),NULL); ;}
break;
case 224:
/* Line 1455 of yacc.c */
#line 1377 "hphp.y"
{ validate_hh_variadic_variant(
_p, (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), NULL);
(yyval) = (yyvsp[(1) - (5)]); ;}
break;
case 225:
/* Line 1455 of yacc.c */
#line 1381 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 226:
/* Line 1455 of yacc.c */
#line 1384 "hphp.y"
{ _p->onVariadicParam((yyval),NULL,(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]),
false,&(yyvsp[(1) - (4)]),NULL); ;}
break;
case 227:
/* Line 1455 of yacc.c */
#line 1388 "hphp.y"
{ _p->onVariadicParam((yyval),NULL,(yyvsp[(2) - (5)]),(yyvsp[(5) - (5)]),
true,&(yyvsp[(1) - (5)]),NULL); ;}
break;
case 228:
/* Line 1455 of yacc.c */
#line 1392 "hphp.y"
{ validate_hh_variadic_variant(
_p, (yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), NULL);
(yyval).reset(); ;}
break;
case 229:
/* Line 1455 of yacc.c */
#line 1395 "hphp.y"
{ (yyval).reset();;}
break;
case 230:
/* Line 1455 of yacc.c */
#line 1400 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(2) - (3)]),(yyvsp[(3) - (3)]),false,
NULL,&(yyvsp[(1) - (3)]),NULL); ;}
break;
case 231:
/* Line 1455 of yacc.c */
#line 1403 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]),true,
NULL,&(yyvsp[(1) - (4)]),NULL); ;}
break;
case 232:
/* Line 1455 of yacc.c */
#line 1407 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(2) - (6)]),(yyvsp[(4) - (6)]),true,
&(yyvsp[(6) - (6)]),&(yyvsp[(1) - (6)]),NULL); ;}
break;
case 233:
/* Line 1455 of yacc.c */
#line 1411 "hphp.y"
{ _p->onParam((yyval),NULL,(yyvsp[(2) - (5)]),(yyvsp[(3) - (5)]),false,
&(yyvsp[(5) - (5)]),&(yyvsp[(1) - (5)]),NULL); ;}
break;
case 234:
/* Line 1455 of yacc.c */
#line 1415 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(4) - (5)]),(yyvsp[(5) - (5)]),false,
NULL,&(yyvsp[(3) - (5)]),NULL); ;}
break;
case 235:
/* Line 1455 of yacc.c */
#line 1419 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(4) - (6)]),(yyvsp[(6) - (6)]),true,
NULL,&(yyvsp[(3) - (6)]),NULL); ;}
break;
case 236:
/* Line 1455 of yacc.c */
#line 1424 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (8)]),(yyvsp[(4) - (8)]),(yyvsp[(6) - (8)]),true,
&(yyvsp[(8) - (8)]),&(yyvsp[(3) - (8)]),NULL); ;}
break;
case 237:
/* Line 1455 of yacc.c */
#line 1429 "hphp.y"
{ _p->onParam((yyval),&(yyvsp[(1) - (7)]),(yyvsp[(4) - (7)]),(yyvsp[(5) - (7)]),false,
&(yyvsp[(7) - (7)]),&(yyvsp[(3) - (7)]),NULL); ;}
break;
case 238:
/* Line 1455 of yacc.c */
#line 1435 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 239:
/* Line 1455 of yacc.c */
#line 1436 "hphp.y"
{ (yyval).reset();;}
break;
case 240:
/* Line 1455 of yacc.c */
#line 1439 "hphp.y"
{ _p->onCallParam((yyval),NULL,(yyvsp[(1) - (1)]),false,false);;}
break;
case 241:
/* Line 1455 of yacc.c */
#line 1440 "hphp.y"
{ _p->onCallParam((yyval),NULL,(yyvsp[(2) - (2)]),true,false);;}
break;
case 242:
/* Line 1455 of yacc.c */
#line 1441 "hphp.y"
{ _p->onCallParam((yyval),NULL,(yyvsp[(2) - (2)]),false,true);;}
break;
case 243:
/* Line 1455 of yacc.c */
#line 1443 "hphp.y"
{ _p->onCallParam((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),false, false);;}
break;
case 244:
/* Line 1455 of yacc.c */
#line 1445 "hphp.y"
{ _p->onCallParam((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),false,true);;}
break;
case 245:
/* Line 1455 of yacc.c */
#line 1447 "hphp.y"
{ _p->onCallParam((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),true, false);;}
break;
case 246:
/* Line 1455 of yacc.c */
#line 1451 "hphp.y"
{ _p->onGlobalVar((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;}
break;
case 247:
/* Line 1455 of yacc.c */
#line 1452 "hphp.y"
{ _p->onGlobalVar((yyval), NULL, (yyvsp[(1) - (1)]));;}
break;
case 248:
/* Line 1455 of yacc.c */
#line 1455 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 249:
/* Line 1455 of yacc.c */
#line 1456 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]); (yyval) = 1;;}
break;
case 250:
/* Line 1455 of yacc.c */
#line 1457 "hphp.y"
{ (yyval) = (yyvsp[(3) - (4)]); (yyval) = 1;;}
break;
case 251:
/* Line 1455 of yacc.c */
#line 1461 "hphp.y"
{ _p->onStaticVariable((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;}
break;
case 252:
/* Line 1455 of yacc.c */
#line 1463 "hphp.y"
{ _p->onStaticVariable((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),&(yyvsp[(5) - (5)]));;}
break;
case 253:
/* Line 1455 of yacc.c */
#line 1464 "hphp.y"
{ _p->onStaticVariable((yyval),0,(yyvsp[(1) - (1)]),0);;}
break;
case 254:
/* Line 1455 of yacc.c */
#line 1465 "hphp.y"
{ _p->onStaticVariable((yyval),0,(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]));;}
break;
case 255:
/* Line 1455 of yacc.c */
#line 1470 "hphp.y"
{ _p->onClassStatement((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;}
break;
case 256:
/* Line 1455 of yacc.c */
#line 1471 "hphp.y"
{ (yyval).reset();;}
break;
case 257:
/* Line 1455 of yacc.c */
#line 1474 "hphp.y"
{ _p->onClassVariableStart
((yyval),NULL,(yyvsp[(1) - (2)]),NULL);;}
break;
case 258:
/* Line 1455 of yacc.c */
#line 1479 "hphp.y"
{ _p->onClassConstant((yyval),0,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 259:
/* Line 1455 of yacc.c */
#line 1485 "hphp.y"
{ _p->onClassStatement((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;}
break;
case 260:
/* Line 1455 of yacc.c */
#line 1486 "hphp.y"
{ (yyval).reset();;}
break;
case 261:
/* Line 1455 of yacc.c */
#line 1489 "hphp.y"
{ _p->onClassVariableModifer((yyvsp[(1) - (1)]));;}
break;
case 262:
/* Line 1455 of yacc.c */
#line 1490 "hphp.y"
{ _p->onClassVariableStart
((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;}
break;
case 263:
/* Line 1455 of yacc.c */
#line 1493 "hphp.y"
{ _p->onClassVariableModifer((yyvsp[(1) - (2)]));;}
break;
case 264:
/* Line 1455 of yacc.c */
#line 1494 "hphp.y"
{ _p->onClassVariableStart
((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(4) - (5)]),&(yyvsp[(2) - (5)]));;}
break;
case 265:
/* Line 1455 of yacc.c */
#line 1496 "hphp.y"
{ _p->onClassVariableStart
((yyval),NULL,(yyvsp[(1) - (2)]),NULL);;}
break;
case 266:
/* Line 1455 of yacc.c */
#line 1500 "hphp.y"
{ _p->onNewLabelScope(true);
_p->onMethodStart((yyvsp[(4) - (5)]), (yyvsp[(1) - (5)]));
_p->pushLabelInfo();;}
break;
case 267:
/* Line 1455 of yacc.c */
#line 1506 "hphp.y"
{ _p->onMethod((yyval),(yyvsp[(1) - (10)]),(yyvsp[(9) - (10)]),(yyvsp[(3) - (10)]),(yyvsp[(4) - (10)]),(yyvsp[(7) - (10)]),(yyvsp[(10) - (10)]),nullptr);
_p->popLabelInfo();
_p->popTypeScope();
_p->onCompleteLabelScope(true);;}
break;
case 268:
/* Line 1455 of yacc.c */
#line 1513 "hphp.y"
{ _p->onNewLabelScope(true);
_p->onMethodStart((yyvsp[(5) - (6)]), (yyvsp[(2) - (6)]));
_p->pushLabelInfo();;}
break;
case 269:
/* Line 1455 of yacc.c */
#line 1519 "hphp.y"
{ _p->onMethod((yyval),(yyvsp[(2) - (11)]),(yyvsp[(10) - (11)]),(yyvsp[(4) - (11)]),(yyvsp[(5) - (11)]),(yyvsp[(8) - (11)]),(yyvsp[(11) - (11)]),&(yyvsp[(1) - (11)]));
_p->popLabelInfo();
_p->popTypeScope();
_p->onCompleteLabelScope(true);;}
break;
case 270:
/* Line 1455 of yacc.c */
#line 1524 "hphp.y"
{ _p->xhpSetAttributes((yyvsp[(2) - (3)]));;}
break;
case 271:
/* Line 1455 of yacc.c */
#line 1526 "hphp.y"
{ xhp_category_stmt(_p,(yyval),(yyvsp[(2) - (3)]));;}
break;
case 272:
/* Line 1455 of yacc.c */
#line 1528 "hphp.y"
{ xhp_children_stmt(_p,(yyval),(yyvsp[(2) - (3)]));;}
break;
case 273:
/* Line 1455 of yacc.c */
#line 1530 "hphp.y"
{ _p->onClassRequire((yyval), (yyvsp[(3) - (4)]), true); ;}
break;
case 274:
/* Line 1455 of yacc.c */
#line 1532 "hphp.y"
{ _p->onClassRequire((yyval), (yyvsp[(3) - (4)]), false); ;}
break;
case 275:
/* Line 1455 of yacc.c */
#line 1533 "hphp.y"
{ Token t; t.reset();
_p->onTraitUse((yyval),(yyvsp[(2) - (3)]),t); ;}
break;
case 276:
/* Line 1455 of yacc.c */
#line 1536 "hphp.y"
{ _p->onTraitUse((yyval),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)])); ;}
break;
case 277:
/* Line 1455 of yacc.c */
#line 1539 "hphp.y"
{ _p->onTraitRule((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)])); ;}
break;
case 278:
/* Line 1455 of yacc.c */
#line 1540 "hphp.y"
{ _p->onTraitRule((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)])); ;}
break;
case 279:
/* Line 1455 of yacc.c */
#line 1541 "hphp.y"
{ (yyval).reset(); ;}
break;
case 280:
/* Line 1455 of yacc.c */
#line 1547 "hphp.y"
{ _p->onTraitPrecRule((yyval),(yyvsp[(1) - (6)]),(yyvsp[(3) - (6)]),(yyvsp[(5) - (6)]));;}
break;
case 281:
/* Line 1455 of yacc.c */
#line 1551 "hphp.y"
{ _p->onTraitAliasRuleModify((yyval),(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),
(yyvsp[(4) - (5)]));;}
break;
case 282:
/* Line 1455 of yacc.c */
#line 1554 "hphp.y"
{ Token t; t.reset();
_p->onTraitAliasRuleModify((yyval),(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),
t);;}
break;
case 283:
/* Line 1455 of yacc.c */
#line 1561 "hphp.y"
{ _p->onTraitAliasRuleStart((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 284:
/* Line 1455 of yacc.c */
#line 1562 "hphp.y"
{ Token t; t.reset();
_p->onTraitAliasRuleStart((yyval),t,(yyvsp[(1) - (1)]));;}
break;
case 285:
/* Line 1455 of yacc.c */
#line 1567 "hphp.y"
{ xhp_attribute_list(_p,(yyval),
_p->xhpGetAttributes(),(yyvsp[(1) - (1)]));;}
break;
case 286:
/* Line 1455 of yacc.c */
#line 1570 "hphp.y"
{ xhp_attribute_list(_p,(yyval), &(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 287:
/* Line 1455 of yacc.c */
#line 1577 "hphp.y"
{ xhp_attribute(_p,(yyval),(yyvsp[(1) - (4)]),(yyvsp[(2) - (4)]),(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)]));
(yyval) = 1;;}
break;
case 288:
/* Line 1455 of yacc.c */
#line 1579 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = 0;;}
break;
case 289:
/* Line 1455 of yacc.c */
#line 1583 "hphp.y"
{ (yyval) = 4;;}
break;
case 290:
/* Line 1455 of yacc.c */
#line 1584 "hphp.y"
{ /* This case handles all types other
than "array", "var" and "enum".
For now we just use type code 5;
later xhp_attribute() will fix up
the type code as appropriate. */
(yyval) = 5; (yyval).setText((yyvsp[(1) - (1)]));;}
break;
case 291:
/* Line 1455 of yacc.c */
#line 1590 "hphp.y"
{ (yyval) = 6;;}
break;
case 292:
/* Line 1455 of yacc.c */
#line 1592 "hphp.y"
{ (yyval) = (yyvsp[(3) - (4)]); (yyval) = 7;;}
break;
case 293:
/* Line 1455 of yacc.c */
#line 1593 "hphp.y"
{ (yyval) = 9; ;}
break;
case 294:
/* Line 1455 of yacc.c */
#line 1597 "hphp.y"
{ _p->onArrayPair((yyval), 0,0,(yyvsp[(1) - (1)]),0);;}
break;
case 295:
/* Line 1455 of yacc.c */
#line 1599 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]),0,(yyvsp[(3) - (3)]),0);;}
break;
case 296:
/* Line 1455 of yacc.c */
#line 1603 "hphp.y"
{ (yyval) = (yyvsp[(2) - (2)]);;}
break;
case 297:
/* Line 1455 of yacc.c */
#line 1604 "hphp.y"
{ scalar_null(_p, (yyval));;}
break;
case 298:
/* Line 1455 of yacc.c */
#line 1608 "hphp.y"
{ scalar_num(_p, (yyval), "1");;}
break;
case 299:
/* Line 1455 of yacc.c */
#line 1609 "hphp.y"
{ scalar_num(_p, (yyval), "0");;}
break;
case 300:
/* Line 1455 of yacc.c */
#line 1613 "hphp.y"
{ Token t; scalar_num(_p, t, "1");
_p->onArrayPair((yyval),0,&(yyvsp[(1) - (1)]),t,0);;}
break;
case 301:
/* Line 1455 of yacc.c */
#line 1616 "hphp.y"
{ Token t; scalar_num(_p, t, "1");
_p->onArrayPair((yyval),&(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]),t,0);;}
break;
case 302:
/* Line 1455 of yacc.c */
#line 1621 "hphp.y"
{ _p->onScalar((yyval),
T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;}
break;
case 303:
/* Line 1455 of yacc.c */
#line 1626 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = 2;;}
break;
case 304:
/* Line 1455 of yacc.c */
#line 1627 "hphp.y"
{ (yyval) = -1;
if ((yyvsp[(1) - (1)]).same("any")) (yyval) = 1;;}
break;
case 305:
/* Line 1455 of yacc.c */
#line 1629 "hphp.y"
{ (yyval) = 0;;}
break;
case 306:
/* Line 1455 of yacc.c */
#line 1633 "hphp.y"
{ xhp_children_paren(_p, (yyval), (yyvsp[(2) - (3)]), 0);;}
break;
case 307:
/* Line 1455 of yacc.c */
#line 1634 "hphp.y"
{ xhp_children_paren(_p, (yyval), (yyvsp[(2) - (4)]), 1);;}
break;
case 308:
/* Line 1455 of yacc.c */
#line 1635 "hphp.y"
{ xhp_children_paren(_p, (yyval), (yyvsp[(2) - (4)]), 2);;}
break;
case 309:
/* Line 1455 of yacc.c */
#line 1636 "hphp.y"
{ xhp_children_paren(_p, (yyval), (yyvsp[(2) - (4)]), 3);;}
break;
case 310:
/* Line 1455 of yacc.c */
#line 1640 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 311:
/* Line 1455 of yacc.c */
#line 1641 "hphp.y"
{ xhp_children_decl(_p,(yyval),(yyvsp[(1) - (1)]),0, 0);;}
break;
case 312:
/* Line 1455 of yacc.c */
#line 1642 "hphp.y"
{ xhp_children_decl(_p,(yyval),(yyvsp[(1) - (2)]),1, 0);;}
break;
case 313:
/* Line 1455 of yacc.c */
#line 1643 "hphp.y"
{ xhp_children_decl(_p,(yyval),(yyvsp[(1) - (2)]),2, 0);;}
break;
case 314:
/* Line 1455 of yacc.c */
#line 1644 "hphp.y"
{ xhp_children_decl(_p,(yyval),(yyvsp[(1) - (2)]),3, 0);;}
break;
case 315:
/* Line 1455 of yacc.c */
#line 1646 "hphp.y"
{ xhp_children_decl(_p,(yyval),(yyvsp[(1) - (3)]),4,&(yyvsp[(3) - (3)]));;}
break;
case 316:
/* Line 1455 of yacc.c */
#line 1648 "hphp.y"
{ xhp_children_decl(_p,(yyval),(yyvsp[(1) - (3)]),5,&(yyvsp[(3) - (3)]));;}
break;
case 317:
/* Line 1455 of yacc.c */
#line 1652 "hphp.y"
{ (yyval) = -1;
if ((yyvsp[(1) - (1)]).same("any")) (yyval) = 1; else
if ((yyvsp[(1) - (1)]).same("pcdata")) (yyval) = 2;;}
break;
case 318:
/* Line 1455 of yacc.c */
#line 1655 "hphp.y"
{ (yyvsp[(1) - (1)]).xhpLabel(); (yyval) = (yyvsp[(1) - (1)]); (yyval) = 3;;}
break;
case 319:
/* Line 1455 of yacc.c */
#line 1656 "hphp.y"
{ (yyvsp[(1) - (1)]).xhpLabel(0); (yyval) = (yyvsp[(1) - (1)]); (yyval) = 4;;}
break;
case 320:
/* Line 1455 of yacc.c */
#line 1660 "hphp.y"
{ (yyval).reset();;}
break;
case 321:
/* Line 1455 of yacc.c */
#line 1661 "hphp.y"
{ _p->finishStatement((yyval), (yyvsp[(2) - (3)])); (yyval) = 1;;}
break;
case 322:
/* Line 1455 of yacc.c */
#line 1665 "hphp.y"
{ (yyval).reset();;}
break;
case 323:
/* Line 1455 of yacc.c */
#line 1666 "hphp.y"
{ _p->finishStatement((yyval), (yyvsp[(2) - (3)])); (yyval) = 1;;}
break;
case 324:
/* Line 1455 of yacc.c */
#line 1669 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 325:
/* Line 1455 of yacc.c */
#line 1670 "hphp.y"
{ (yyval).reset();;}
break;
case 326:
/* Line 1455 of yacc.c */
#line 1673 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 327:
/* Line 1455 of yacc.c */
#line 1674 "hphp.y"
{ (yyval).reset();;}
break;
case 328:
/* Line 1455 of yacc.c */
#line 1677 "hphp.y"
{ _p->onMemberModifier((yyval),NULL,(yyvsp[(1) - (1)]));;}
break;
case 329:
/* Line 1455 of yacc.c */
#line 1679 "hphp.y"
{ _p->onMemberModifier((yyval),&(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
break;
case 330:
/* Line 1455 of yacc.c */
#line 1682 "hphp.y"
{ (yyval) = T_PUBLIC;;}
break;
case 331:
/* Line 1455 of yacc.c */
#line 1683 "hphp.y"
{ (yyval) = T_PROTECTED;;}
break;
case 332:
/* Line 1455 of yacc.c */
#line 1684 "hphp.y"
{ (yyval) = T_PRIVATE;;}
break;
case 333:
/* Line 1455 of yacc.c */
#line 1685 "hphp.y"
{ (yyval) = T_STATIC;;}
break;
case 334:
/* Line 1455 of yacc.c */
#line 1686 "hphp.y"
{ (yyval) = T_ABSTRACT;;}
break;
case 335:
/* Line 1455 of yacc.c */
#line 1687 "hphp.y"
{ (yyval) = T_FINAL;;}
break;
case 336:
/* Line 1455 of yacc.c */
#line 1688 "hphp.y"
{ (yyval) = T_ASYNC;;}
break;
case 337:
/* Line 1455 of yacc.c */
#line 1692 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 338:
/* Line 1455 of yacc.c */
#line 1693 "hphp.y"
{ (yyval).reset();;}
break;
case 339:
/* Line 1455 of yacc.c */
#line 1696 "hphp.y"
{ (yyval) = T_PUBLIC;;}
break;
case 340:
/* Line 1455 of yacc.c */
#line 1697 "hphp.y"
{ (yyval) = T_PROTECTED;;}
break;
case 341:
/* Line 1455 of yacc.c */
#line 1698 "hphp.y"
{ (yyval) = T_PRIVATE;;}
break;
case 342:
/* Line 1455 of yacc.c */
#line 1702 "hphp.y"
{ _p->onClassVariable((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;}
break;
case 343:
/* Line 1455 of yacc.c */
#line 1704 "hphp.y"
{ _p->onClassVariable((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),&(yyvsp[(5) - (5)]));;}
break;
case 344:
/* Line 1455 of yacc.c */
#line 1705 "hphp.y"
{ _p->onClassVariable((yyval),0,(yyvsp[(1) - (1)]),0);;}
break;
case 345:
/* Line 1455 of yacc.c */
#line 1706 "hphp.y"
{ _p->onClassVariable((yyval),0,(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]));;}
break;
case 346:
/* Line 1455 of yacc.c */
#line 1710 "hphp.y"
{ _p->onClassConstant((yyval),&(yyvsp[(1) - (5)]),(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 347:
/* Line 1455 of yacc.c */
#line 1712 "hphp.y"
{ _p->onClassConstant((yyval),0,(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]));;}
break;
case 348:
/* Line 1455 of yacc.c */
#line 1716 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 349:
/* Line 1455 of yacc.c */
#line 1718 "hphp.y"
{ _p->onNewObject((yyval), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]));;}
break;
case 350:
/* Line 1455 of yacc.c */
#line 1719 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_CLONE,1);;}
break;
case 351:
/* Line 1455 of yacc.c */
#line 1720 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 352:
/* Line 1455 of yacc.c */
#line 1721 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 353:
/* Line 1455 of yacc.c */
#line 1724 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 354:
/* Line 1455 of yacc.c */
#line 1728 "hphp.y"
{ _p->onExprListElem((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;}
break;
case 355:
/* Line 1455 of yacc.c */
#line 1729 "hphp.y"
{ _p->onExprListElem((yyval), NULL, (yyvsp[(1) - (1)]));;}
break;
case 356:
/* Line 1455 of yacc.c */
#line 1733 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 357:
/* Line 1455 of yacc.c */
#line 1734 "hphp.y"
{ (yyval).reset();;}
break;
case 358:
/* Line 1455 of yacc.c */
#line 1738 "hphp.y"
{ _p->onYield((yyval), NULL);;}
break;
case 359:
/* Line 1455 of yacc.c */
#line 1739 "hphp.y"
{ _p->onYield((yyval), &(yyvsp[(2) - (2)]));;}
break;
case 360:
/* Line 1455 of yacc.c */
#line 1740 "hphp.y"
{ _p->onYieldPair((yyval), &(yyvsp[(2) - (4)]), &(yyvsp[(4) - (4)]));;}
break;
case 361:
/* Line 1455 of yacc.c */
#line 1744 "hphp.y"
{ _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0, true);;}
break;
case 362:
/* Line 1455 of yacc.c */
#line 1749 "hphp.y"
{ _p->onListAssignment((yyval), (yyvsp[(3) - (6)]), &(yyvsp[(6) - (6)]), true);;}
break;
case 363:
/* Line 1455 of yacc.c */
#line 1753 "hphp.y"
{ _p->onAwait((yyval), (yyvsp[(2) - (2)])); ;}
break;
case 364:
/* Line 1455 of yacc.c */
#line 1757 "hphp.y"
{ _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0, true);;}
break;
case 365:
/* Line 1455 of yacc.c */
#line 1762 "hphp.y"
{ _p->onListAssignment((yyval), (yyvsp[(3) - (6)]), &(yyvsp[(6) - (6)]), true);;}
break;
case 366:
/* Line 1455 of yacc.c */
#line 1766 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 367:
/* Line 1455 of yacc.c */
#line 1767 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 368:
/* Line 1455 of yacc.c */
#line 1768 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 369:
/* Line 1455 of yacc.c */
#line 1769 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 370:
/* Line 1455 of yacc.c */
#line 1770 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 371:
/* Line 1455 of yacc.c */
#line 1775 "hphp.y"
{ _p->onListAssignment((yyval), (yyvsp[(3) - (6)]), &(yyvsp[(6) - (6)]));;}
break;
case 372:
/* Line 1455 of yacc.c */
#line 1776 "hphp.y"
{ _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0);;}
break;
case 373:
/* Line 1455 of yacc.c */
#line 1777 "hphp.y"
{ _p->onAssign((yyval), (yyvsp[(1) - (4)]), (yyvsp[(4) - (4)]), 1);;}
break;
case 374:
/* Line 1455 of yacc.c */
#line 1780 "hphp.y"
{ _p->onAssignNew((yyval),(yyvsp[(1) - (6)]),(yyvsp[(5) - (6)]),(yyvsp[(6) - (6)]));;}
break;
case 375:
/* Line 1455 of yacc.c */
#line 1781 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_PLUS_EQUAL);;}
break;
case 376:
/* Line 1455 of yacc.c */
#line 1782 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_MINUS_EQUAL);;}
break;
case 377:
/* Line 1455 of yacc.c */
#line 1783 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_MUL_EQUAL);;}
break;
case 378:
/* Line 1455 of yacc.c */
#line 1784 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_DIV_EQUAL);;}
break;
case 379:
/* Line 1455 of yacc.c */
#line 1785 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_CONCAT_EQUAL);;}
break;
case 380:
/* Line 1455 of yacc.c */
#line 1786 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_MOD_EQUAL);;}
break;
case 381:
/* Line 1455 of yacc.c */
#line 1787 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_AND_EQUAL);;}
break;
case 382:
/* Line 1455 of yacc.c */
#line 1788 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_OR_EQUAL);;}
break;
case 383:
/* Line 1455 of yacc.c */
#line 1789 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_XOR_EQUAL);;}
break;
case 384:
/* Line 1455 of yacc.c */
#line 1790 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SL_EQUAL);;}
break;
case 385:
/* Line 1455 of yacc.c */
#line 1791 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SR_EQUAL);;}
break;
case 386:
/* Line 1455 of yacc.c */
#line 1792 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_POW_EQUAL);;}
break;
case 387:
/* Line 1455 of yacc.c */
#line 1793 "hphp.y"
{ UEXP((yyval),(yyvsp[(1) - (2)]),T_INC,0);;}
break;
case 388:
/* Line 1455 of yacc.c */
#line 1794 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_INC,1);;}
break;
case 389:
/* Line 1455 of yacc.c */
#line 1795 "hphp.y"
{ UEXP((yyval),(yyvsp[(1) - (2)]),T_DEC,0);;}
break;
case 390:
/* Line 1455 of yacc.c */
#line 1796 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_DEC,1);;}
break;
case 391:
/* Line 1455 of yacc.c */
#line 1797 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_OR);;}
break;
case 392:
/* Line 1455 of yacc.c */
#line 1798 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_AND);;}
break;
case 393:
/* Line 1455 of yacc.c */
#line 1799 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_OR);;}
break;
case 394:
/* Line 1455 of yacc.c */
#line 1800 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_AND);;}
break;
case 395:
/* Line 1455 of yacc.c */
#line 1801 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_XOR);;}
break;
case 396:
/* Line 1455 of yacc.c */
#line 1802 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'|');;}
break;
case 397:
/* Line 1455 of yacc.c */
#line 1803 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'&');;}
break;
case 398:
/* Line 1455 of yacc.c */
#line 1804 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'^');;}
break;
case 399:
/* Line 1455 of yacc.c */
#line 1805 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'.');;}
break;
case 400:
/* Line 1455 of yacc.c */
#line 1806 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'+');;}
break;
case 401:
/* Line 1455 of yacc.c */
#line 1807 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'-');;}
break;
case 402:
/* Line 1455 of yacc.c */
#line 1808 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'*');;}
break;
case 403:
/* Line 1455 of yacc.c */
#line 1809 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'/');;}
break;
case 404:
/* Line 1455 of yacc.c */
#line 1810 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_POW);;}
break;
case 405:
/* Line 1455 of yacc.c */
#line 1811 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'%');;}
break;
case 406:
/* Line 1455 of yacc.c */
#line 1812 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SL);;}
break;
case 407:
/* Line 1455 of yacc.c */
#line 1813 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SR);;}
break;
case 408:
/* Line 1455 of yacc.c */
#line 1814 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'+',1);;}
break;
case 409:
/* Line 1455 of yacc.c */
#line 1815 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'-',1);;}
break;
case 410:
/* Line 1455 of yacc.c */
#line 1816 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'!',1);;}
break;
case 411:
/* Line 1455 of yacc.c */
#line 1817 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'~',1);;}
break;
case 412:
/* Line 1455 of yacc.c */
#line 1818 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_IDENTICAL);;}
break;
case 413:
/* Line 1455 of yacc.c */
#line 1819 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_IDENTICAL);;}
break;
case 414:
/* Line 1455 of yacc.c */
#line 1820 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_EQUAL);;}
break;
case 415:
/* Line 1455 of yacc.c */
#line 1821 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_EQUAL);;}
break;
case 416:
/* Line 1455 of yacc.c */
#line 1822 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'<');;}
break;
case 417:
/* Line 1455 of yacc.c */
#line 1823 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),
T_IS_SMALLER_OR_EQUAL);;}
break;
case 418:
/* Line 1455 of yacc.c */
#line 1825 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'>');;}
break;
case 419:
/* Line 1455 of yacc.c */
#line 1826 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),
T_IS_GREATER_OR_EQUAL);;}
break;
case 420:
/* Line 1455 of yacc.c */
#line 1829 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_INSTANCEOF);;}
break;
case 421:
/* Line 1455 of yacc.c */
#line 1830 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 422:
/* Line 1455 of yacc.c */
#line 1831 "hphp.y"
{ _p->onQOp((yyval), (yyvsp[(1) - (5)]), &(yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]));;}
break;
case 423:
/* Line 1455 of yacc.c */
#line 1832 "hphp.y"
{ _p->onQOp((yyval), (yyvsp[(1) - (4)]), 0, (yyvsp[(4) - (4)]));;}
break;
case 424:
/* Line 1455 of yacc.c */
#line 1833 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 425:
/* Line 1455 of yacc.c */
#line 1834 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_INT_CAST,1);;}
break;
case 426:
/* Line 1455 of yacc.c */
#line 1835 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_DOUBLE_CAST,1);;}
break;
case 427:
/* Line 1455 of yacc.c */
#line 1836 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_STRING_CAST,1);;}
break;
case 428:
/* Line 1455 of yacc.c */
#line 1837 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_ARRAY_CAST,1);;}
break;
case 429:
/* Line 1455 of yacc.c */
#line 1838 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_OBJECT_CAST,1);;}
break;
case 430:
/* Line 1455 of yacc.c */
#line 1839 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_BOOL_CAST,1);;}
break;
case 431:
/* Line 1455 of yacc.c */
#line 1840 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_UNSET_CAST,1);;}
break;
case 432:
/* Line 1455 of yacc.c */
#line 1841 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_EXIT,1);;}
break;
case 433:
/* Line 1455 of yacc.c */
#line 1842 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'@',1);;}
break;
case 434:
/* Line 1455 of yacc.c */
#line 1843 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 435:
/* Line 1455 of yacc.c */
#line 1844 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 436:
/* Line 1455 of yacc.c */
#line 1845 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 437:
/* Line 1455 of yacc.c */
#line 1846 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 438:
/* Line 1455 of yacc.c */
#line 1847 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 439:
/* Line 1455 of yacc.c */
#line 1848 "hphp.y"
{ _p->onEncapsList((yyval),'`',(yyvsp[(2) - (3)]));;}
break;
case 440:
/* Line 1455 of yacc.c */
#line 1849 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_PRINT,1);;}
break;
case 441:
/* Line 1455 of yacc.c */
#line 1850 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 442:
/* Line 1455 of yacc.c */
#line 1857 "hphp.y"
{ (yyval) = (yyvsp[(3) - (5)]);;}
break;
case 443:
/* Line 1455 of yacc.c */
#line 1858 "hphp.y"
{ (yyval).reset();;}
break;
case 444:
/* Line 1455 of yacc.c */
#line 1863 "hphp.y"
{ Token t;
_p->onNewLabelScope(true);
_p->onClosureStart(t);
_p->pushLabelInfo(); ;}
break;
case 445:
/* Line 1455 of yacc.c */
#line 1869 "hphp.y"
{ _p->finishStatement((yyvsp[(10) - (11)]), (yyvsp[(10) - (11)])); (yyvsp[(10) - (11)]) = 1;
(yyval) = _p->onClosure(ClosureType::Long,
nullptr,
(yyvsp[(2) - (11)]),(yyvsp[(5) - (11)]),(yyvsp[(8) - (11)]),(yyvsp[(10) - (11)]),(yyvsp[(7) - (11)]));
_p->popLabelInfo();
_p->onCompleteLabelScope(true);;}
break;
case 446:
/* Line 1455 of yacc.c */
#line 1877 "hphp.y"
{ Token t;
_p->onNewLabelScope(true);
_p->onClosureStart(t);
_p->pushLabelInfo(); ;}
break;
case 447:
/* Line 1455 of yacc.c */
#line 1883 "hphp.y"
{ _p->finishStatement((yyvsp[(11) - (12)]), (yyvsp[(11) - (12)])); (yyvsp[(11) - (12)]) = 1;
(yyval) = _p->onClosure(ClosureType::Long,
&(yyvsp[(1) - (12)]),
(yyvsp[(3) - (12)]),(yyvsp[(6) - (12)]),(yyvsp[(9) - (12)]),(yyvsp[(11) - (12)]),(yyvsp[(8) - (12)]));
_p->popLabelInfo();
_p->onCompleteLabelScope(true);;}
break;
case 448:
/* Line 1455 of yacc.c */
#line 1892 "hphp.y"
{ _p->pushFuncLocation();
Token t;
_p->onNewLabelScope(true);
_p->onClosureStart(t);
_p->pushLabelInfo();
Token u;
_p->onParam((yyvsp[(1) - (1)]),NULL,u,(yyvsp[(1) - (1)]),0,
NULL,NULL,NULL);;}
break;
case 449:
/* Line 1455 of yacc.c */
#line 1900 "hphp.y"
{ Token v; Token w; Token x;
_p->finishStatement((yyvsp[(3) - (3)]), (yyvsp[(3) - (3)])); (yyvsp[(3) - (3)]) = 1;
(yyval) = _p->onClosure(ClosureType::Short,
nullptr,
v,(yyvsp[(1) - (3)]),w,(yyvsp[(3) - (3)]),x);
_p->popLabelInfo();
_p->onCompleteLabelScope(true);;}
break;
case 450:
/* Line 1455 of yacc.c */
#line 1908 "hphp.y"
{ _p->pushFuncLocation();
Token t;
_p->onNewLabelScope(true);
_p->onClosureStart(t);
_p->pushLabelInfo();
Token u;
_p->onParam((yyvsp[(2) - (2)]),NULL,u,(yyvsp[(2) - (2)]),0,
NULL,NULL,NULL);;}
break;
case 451:
/* Line 1455 of yacc.c */
#line 1916 "hphp.y"
{ Token v; Token w; Token x;
(yyvsp[(1) - (4)]) = T_ASYNC;
_p->onMemberModifier((yyvsp[(1) - (4)]), nullptr, (yyvsp[(1) - (4)]));
_p->finishStatement((yyvsp[(4) - (4)]), (yyvsp[(4) - (4)])); (yyvsp[(4) - (4)]) = 1;
(yyval) = _p->onClosure(ClosureType::Short,
&(yyvsp[(1) - (4)]),
v,(yyvsp[(2) - (4)]),w,(yyvsp[(4) - (4)]),x);
_p->popLabelInfo();
_p->onCompleteLabelScope(true);;}
break;
case 452:
/* Line 1455 of yacc.c */
#line 1925 "hphp.y"
{ _p->pushFuncLocation();
Token t;
_p->onNewLabelScope(true);
_p->onClosureStart(t);
_p->pushLabelInfo();;}
break;
case 453:
/* Line 1455 of yacc.c */
#line 1933 "hphp.y"
{ Token u; Token v;
_p->finishStatement((yyvsp[(6) - (6)]), (yyvsp[(6) - (6)])); (yyvsp[(6) - (6)]) = 1;
(yyval) = _p->onClosure(ClosureType::Short,
nullptr,
u,(yyvsp[(3) - (6)]),v,(yyvsp[(6) - (6)]),(yyvsp[(5) - (6)]));
_p->popLabelInfo();
_p->onCompleteLabelScope(true);;}
break;
case 454:
/* Line 1455 of yacc.c */
#line 1941 "hphp.y"
{ _p->pushFuncLocation();
Token t;
_p->onNewLabelScope(true);
_p->onClosureStart(t);
_p->pushLabelInfo();;}
break;
case 455:
/* Line 1455 of yacc.c */
#line 1949 "hphp.y"
{ Token u; Token v;
(yyvsp[(1) - (7)]) = T_ASYNC;
_p->onMemberModifier((yyvsp[(1) - (7)]), nullptr, (yyvsp[(1) - (7)]));
_p->finishStatement((yyvsp[(7) - (7)]), (yyvsp[(7) - (7)])); (yyvsp[(7) - (7)]) = 1;
(yyval) = _p->onClosure(ClosureType::Short,
&(yyvsp[(1) - (7)]),
u,(yyvsp[(4) - (7)]),v,(yyvsp[(7) - (7)]),(yyvsp[(6) - (7)]));
_p->popLabelInfo();
_p->onCompleteLabelScope(true);;}
break;
case 456:
/* Line 1455 of yacc.c */
#line 1959 "hphp.y"
{ _p->pushFuncLocation();
Token t;
_p->onNewLabelScope(true);
_p->onClosureStart(t);
_p->pushLabelInfo();;}
break;
case 457:
/* Line 1455 of yacc.c */
#line 1965 "hphp.y"
{ Token u; Token v; Token w; Token x;
Token y;
(yyvsp[(1) - (5)]) = T_ASYNC;
_p->onMemberModifier((yyvsp[(1) - (5)]), nullptr, (yyvsp[(1) - (5)]));
_p->finishStatement((yyvsp[(4) - (5)]), (yyvsp[(4) - (5)])); (yyvsp[(4) - (5)]) = 1;
(yyval) = _p->onClosure(ClosureType::Short,
&(yyvsp[(1) - (5)]),
u,v,w,(yyvsp[(4) - (5)]),x);
_p->popLabelInfo();
_p->onCompleteLabelScope(true);
_p->onCall((yyval),1,(yyval),y,NULL);;}
break;
case 458:
/* Line 1455 of yacc.c */
#line 1979 "hphp.y"
{ (yyval) = _p->onExprForLambda((yyvsp[(2) - (2)]));;}
break;
case 459:
/* Line 1455 of yacc.c */
#line 1980 "hphp.y"
{ (yyval) = _p->onExprForLambda((yyvsp[(2) - (2)]));;}
break;
case 460:
/* Line 1455 of yacc.c */
#line 1982 "hphp.y"
{ (yyval) = (yyvsp[(3) - (4)]); ;}
break;
case 461:
/* Line 1455 of yacc.c */
#line 1986 "hphp.y"
{ validate_shape_keyname((yyvsp[(1) - (1)]), _p);
_p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)])); ;}
break;
case 462:
/* Line 1455 of yacc.c */
#line 1988 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 463:
/* Line 1455 of yacc.c */
#line 1995 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0); ;}
break;
case 464:
/* Line 1455 of yacc.c */
#line 1998 "hphp.y"
{ _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0); ;}
break;
case 465:
/* Line 1455 of yacc.c */
#line 2005 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0); ;}
break;
case 466:
/* Line 1455 of yacc.c */
#line 2008 "hphp.y"
{ _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0); ;}
break;
case 467:
/* Line 1455 of yacc.c */
#line 2013 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]); ;}
break;
case 468:
/* Line 1455 of yacc.c */
#line 2014 "hphp.y"
{ (yyval).reset(); ;}
break;
case 469:
/* Line 1455 of yacc.c */
#line 2019 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]); ;}
break;
case 470:
/* Line 1455 of yacc.c */
#line 2020 "hphp.y"
{ (yyval).reset(); ;}
break;
case 471:
/* Line 1455 of yacc.c */
#line 2024 "hphp.y"
{ _p->onArray((yyval), (yyvsp[(3) - (4)]), T_ARRAY);;}
break;
case 472:
/* Line 1455 of yacc.c */
#line 2028 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY);;}
break;
case 473:
/* Line 1455 of yacc.c */
#line 2029 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY);;}
break;
case 474:
/* Line 1455 of yacc.c */
#line 2034 "hphp.y"
{ Token t;
_p->onName(t,(yyvsp[(1) - (4)]),Parser::StringName);
BEXP((yyval),t,(yyvsp[(3) - (4)]),T_COLLECTION);;}
break;
case 475:
/* Line 1455 of yacc.c */
#line 2040 "hphp.y"
{ _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MIARRAY);;}
break;
case 476:
/* Line 1455 of yacc.c */
#line 2041 "hphp.y"
{ _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MSARRAY);;}
break;
case 477:
/* Line 1455 of yacc.c */
#line 2045 "hphp.y"
{ _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_VARRAY);;}
break;
case 478:
/* Line 1455 of yacc.c */
#line 2050 "hphp.y"
{ _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MIARRAY);;}
break;
case 479:
/* Line 1455 of yacc.c */
#line 2052 "hphp.y"
{ _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_MSARRAY);;}
break;
case 480:
/* Line 1455 of yacc.c */
#line 2057 "hphp.y"
{ _p->onCheckedArray((yyval),(yyvsp[(3) - (4)]),T_VARRAY);;}
break;
case 481:
/* Line 1455 of yacc.c */
#line 2062 "hphp.y"
{ Token t;
_p->onName(t,(yyvsp[(1) - (4)]),Parser::StringName);
BEXP((yyval),t,(yyvsp[(3) - (4)]),T_COLLECTION);;}
break;
case 482:
/* Line 1455 of yacc.c */
#line 2069 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;}
break;
case 483:
/* Line 1455 of yacc.c */
#line 2071 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;}
break;
case 484:
/* Line 1455 of yacc.c */
#line 2075 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 485:
/* Line 1455 of yacc.c */
#line 2076 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 486:
/* Line 1455 of yacc.c */
#line 2077 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 487:
/* Line 1455 of yacc.c */
#line 2078 "hphp.y"
{ _p->onScalar((yyval),
T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)])); ;}
break;
case 488:
/* Line 1455 of yacc.c */
#line 2080 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 489:
/* Line 1455 of yacc.c */
#line 2084 "hphp.y"
{ _p->onQuery((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); ;}
break;
case 490:
/* Line 1455 of yacc.c */
#line 2088 "hphp.y"
{ _p->onAssign((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0, true);;}
break;
case 491:
/* Line 1455 of yacc.c */
#line 2092 "hphp.y"
{ _p->onFromClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;}
break;
case 492:
/* Line 1455 of yacc.c */
#line 2097 "hphp.y"
{ _p->onQueryBody((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]), NULL); ;}
break;
case 493:
/* Line 1455 of yacc.c */
#line 2099 "hphp.y"
{ _p->onQueryBody((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), &(yyvsp[(3) - (3)])); ;}
break;
case 494:
/* Line 1455 of yacc.c */
#line 2101 "hphp.y"
{ _p->onQueryBody((yyval), NULL, (yyvsp[(1) - (1)]), NULL); ;}
break;
case 495:
/* Line 1455 of yacc.c */
#line 2103 "hphp.y"
{ _p->onQueryBody((yyval), NULL, (yyvsp[(1) - (2)]), &(yyvsp[(2) - (2)])); ;}
break;
case 496:
/* Line 1455 of yacc.c */
#line 2107 "hphp.y"
{ _p->onQueryBodyClause((yyval), NULL, (yyvsp[(1) - (1)])); ;}
break;
case 497:
/* Line 1455 of yacc.c */
#line 2109 "hphp.y"
{ _p->onQueryBodyClause((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); ;}
break;
case 498:
/* Line 1455 of yacc.c */
#line 2113 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 499:
/* Line 1455 of yacc.c */
#line 2114 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 500:
/* Line 1455 of yacc.c */
#line 2115 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 501:
/* Line 1455 of yacc.c */
#line 2116 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 502:
/* Line 1455 of yacc.c */
#line 2117 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 503:
/* Line 1455 of yacc.c */
#line 2118 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 504:
/* Line 1455 of yacc.c */
#line 2122 "hphp.y"
{ _p->onFromClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;}
break;
case 505:
/* Line 1455 of yacc.c */
#line 2126 "hphp.y"
{ _p->onLetClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;}
break;
case 506:
/* Line 1455 of yacc.c */
#line 2130 "hphp.y"
{ _p->onWhereClause((yyval), (yyvsp[(2) - (2)])); ;}
break;
case 507:
/* Line 1455 of yacc.c */
#line 2135 "hphp.y"
{ _p->onJoinClause((yyval), (yyvsp[(2) - (8)]), (yyvsp[(4) - (8)]), (yyvsp[(6) - (8)]), (yyvsp[(8) - (8)])); ;}
break;
case 508:
/* Line 1455 of yacc.c */
#line 2140 "hphp.y"
{ _p->onJoinIntoClause((yyval), (yyvsp[(2) - (10)]), (yyvsp[(4) - (10)]), (yyvsp[(6) - (10)]), (yyvsp[(8) - (10)]), (yyvsp[(10) - (10)])); ;}
break;
case 509:
/* Line 1455 of yacc.c */
#line 2144 "hphp.y"
{ _p->onOrderbyClause((yyval), (yyvsp[(2) - (2)])); ;}
break;
case 510:
/* Line 1455 of yacc.c */
#line 2148 "hphp.y"
{ _p->onOrdering((yyval), NULL, (yyvsp[(1) - (1)])); ;}
break;
case 511:
/* Line 1455 of yacc.c */
#line 2149 "hphp.y"
{ _p->onOrdering((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); ;}
break;
case 512:
/* Line 1455 of yacc.c */
#line 2153 "hphp.y"
{ _p->onOrderingExpr((yyval), (yyvsp[(1) - (1)]), NULL); ;}
break;
case 513:
/* Line 1455 of yacc.c */
#line 2154 "hphp.y"
{ _p->onOrderingExpr((yyval), (yyvsp[(1) - (2)]), &(yyvsp[(2) - (2)])); ;}
break;
case 514:
/* Line 1455 of yacc.c */
#line 2158 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 515:
/* Line 1455 of yacc.c */
#line 2159 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 516:
/* Line 1455 of yacc.c */
#line 2163 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 517:
/* Line 1455 of yacc.c */
#line 2164 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 518:
/* Line 1455 of yacc.c */
#line 2168 "hphp.y"
{ _p->onSelectClause((yyval), (yyvsp[(2) - (2)])); ;}
break;
case 519:
/* Line 1455 of yacc.c */
#line 2172 "hphp.y"
{ _p->onGroupClause((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)])); ;}
break;
case 520:
/* Line 1455 of yacc.c */
#line 2176 "hphp.y"
{ _p->onIntoClause((yyval), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)])); ;}
break;
case 521:
/* Line 1455 of yacc.c */
#line 2180 "hphp.y"
{ _p->onClosureParam((yyval),&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;}
break;
case 522:
/* Line 1455 of yacc.c */
#line 2181 "hphp.y"
{ _p->onClosureParam((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),1);;}
break;
case 523:
/* Line 1455 of yacc.c */
#line 2182 "hphp.y"
{ _p->onClosureParam((yyval), 0,(yyvsp[(1) - (1)]),0);;}
break;
case 524:
/* Line 1455 of yacc.c */
#line 2183 "hphp.y"
{ _p->onClosureParam((yyval), 0,(yyvsp[(2) - (2)]),1);;}
break;
case 525:
/* Line 1455 of yacc.c */
#line 2190 "hphp.y"
{ xhp_tag(_p,(yyval),(yyvsp[(2) - (4)]),(yyvsp[(3) - (4)]));;}
break;
case 526:
/* Line 1455 of yacc.c */
#line 2193 "hphp.y"
{ Token t1; _p->onArray(t1,(yyvsp[(1) - (2)]));
Token t2; _p->onArray(t2,(yyvsp[(2) - (2)]));
Token file; scalar_file(_p, file);
Token line; scalar_line(_p, line);
_p->onCallParam((yyvsp[(1) - (2)]),NULL,t1,0,0);
_p->onCallParam((yyval), &(yyvsp[(1) - (2)]),t2,0,0);
_p->onCallParam((yyvsp[(1) - (2)]), &(yyvsp[(1) - (2)]),file,0,0);
_p->onCallParam((yyvsp[(1) - (2)]), &(yyvsp[(1) - (2)]),line,0,0);
(yyval).setText("");;}
break;
case 527:
/* Line 1455 of yacc.c */
#line 2204 "hphp.y"
{ Token file; scalar_file(_p, file);
Token line; scalar_line(_p, line);
_p->onArray((yyvsp[(4) - (6)]),(yyvsp[(1) - (6)]));
_p->onArray((yyvsp[(5) - (6)]),(yyvsp[(3) - (6)]));
_p->onCallParam((yyvsp[(2) - (6)]),NULL,(yyvsp[(4) - (6)]),0,0);
_p->onCallParam((yyval), &(yyvsp[(2) - (6)]),(yyvsp[(5) - (6)]),0,0);
_p->onCallParam((yyvsp[(2) - (6)]), &(yyvsp[(2) - (6)]),file,0,0);
_p->onCallParam((yyvsp[(2) - (6)]), &(yyvsp[(2) - (6)]),line,0,0);
(yyval).setText((yyvsp[(6) - (6)]).text());;}
break;
case 528:
/* Line 1455 of yacc.c */
#line 2215 "hphp.y"
{ (yyval).reset(); (yyval).setText("");;}
break;
case 529:
/* Line 1455 of yacc.c */
#line 2216 "hphp.y"
{ (yyval).reset(); (yyval).setText((yyvsp[(1) - (1)]));;}
break;
case 530:
/* Line 1455 of yacc.c */
#line 2221 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (4)]),&(yyvsp[(2) - (4)]),(yyvsp[(4) - (4)]),0);;}
break;
case 531:
/* Line 1455 of yacc.c */
#line 2222 "hphp.y"
{ (yyval).reset();;}
break;
case 532:
/* Line 1455 of yacc.c */
#line 2225 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (2)]),0,(yyvsp[(2) - (2)]),0);;}
break;
case 533:
/* Line 1455 of yacc.c */
#line 2226 "hphp.y"
{ (yyval).reset();;}
break;
case 534:
/* Line 1455 of yacc.c */
#line 2229 "hphp.y"
{ _p->onScalar((yyval),
T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;}
break;
case 535:
/* Line 1455 of yacc.c */
#line 2233 "hphp.y"
{ (yyvsp[(1) - (1)]).xhpDecode();
_p->onScalar((yyval),
T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;}
break;
case 536:
/* Line 1455 of yacc.c */
#line 2236 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 537:
/* Line 1455 of yacc.c */
#line 2239 "hphp.y"
{ (yyval).reset();
if ((yyvsp[(1) - (1)]).htmlTrim()) {
(yyvsp[(1) - (1)]).xhpDecode();
_p->onScalar((yyval),
T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));
}
;}
break;
case 538:
/* Line 1455 of yacc.c */
#line 2246 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]); ;}
break;
case 539:
/* Line 1455 of yacc.c */
#line 2247 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 540:
/* Line 1455 of yacc.c */
#line 2251 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 541:
/* Line 1455 of yacc.c */
#line 2253 "hphp.y"
{ (yyval) = (yyvsp[(1) - (3)]) + ":" + (yyvsp[(3) - (3)]);;}
break;
case 542:
/* Line 1455 of yacc.c */
#line 2255 "hphp.y"
{ (yyval) = (yyvsp[(1) - (3)]) + "-" + (yyvsp[(3) - (3)]);;}
break;
case 543:
/* Line 1455 of yacc.c */
#line 2258 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 544:
/* Line 1455 of yacc.c */
#line 2259 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 545:
/* Line 1455 of yacc.c */
#line 2260 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 546:
/* Line 1455 of yacc.c */
#line 2261 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 547:
/* Line 1455 of yacc.c */
#line 2262 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 548:
/* Line 1455 of yacc.c */
#line 2263 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 549:
/* Line 1455 of yacc.c */
#line 2264 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 550:
/* Line 1455 of yacc.c */
#line 2265 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 551:
/* Line 1455 of yacc.c */
#line 2266 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 552:
/* Line 1455 of yacc.c */
#line 2267 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 553:
/* Line 1455 of yacc.c */
#line 2268 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 554:
/* Line 1455 of yacc.c */
#line 2269 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 555:
/* Line 1455 of yacc.c */
#line 2270 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 556:
/* Line 1455 of yacc.c */
#line 2271 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 557:
/* Line 1455 of yacc.c */
#line 2272 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 558:
/* Line 1455 of yacc.c */
#line 2273 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 559:
/* Line 1455 of yacc.c */
#line 2274 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 560:
/* Line 1455 of yacc.c */
#line 2275 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 561:
/* Line 1455 of yacc.c */
#line 2276 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 562:
/* Line 1455 of yacc.c */
#line 2277 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 563:
/* Line 1455 of yacc.c */
#line 2278 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 564:
/* Line 1455 of yacc.c */
#line 2279 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 565:
/* Line 1455 of yacc.c */
#line 2280 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 566:
/* Line 1455 of yacc.c */
#line 2281 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 567:
/* Line 1455 of yacc.c */
#line 2282 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 568:
/* Line 1455 of yacc.c */
#line 2283 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 569:
/* Line 1455 of yacc.c */
#line 2284 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 570:
/* Line 1455 of yacc.c */
#line 2285 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 571:
/* Line 1455 of yacc.c */
#line 2286 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 572:
/* Line 1455 of yacc.c */
#line 2287 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 573:
/* Line 1455 of yacc.c */
#line 2288 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 574:
/* Line 1455 of yacc.c */
#line 2289 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 575:
/* Line 1455 of yacc.c */
#line 2290 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 576:
/* Line 1455 of yacc.c */
#line 2291 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 577:
/* Line 1455 of yacc.c */
#line 2292 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 578:
/* Line 1455 of yacc.c */
#line 2293 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 579:
/* Line 1455 of yacc.c */
#line 2294 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 580:
/* Line 1455 of yacc.c */
#line 2295 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 581:
/* Line 1455 of yacc.c */
#line 2296 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 582:
/* Line 1455 of yacc.c */
#line 2297 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 583:
/* Line 1455 of yacc.c */
#line 2298 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 584:
/* Line 1455 of yacc.c */
#line 2299 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 585:
/* Line 1455 of yacc.c */
#line 2300 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 586:
/* Line 1455 of yacc.c */
#line 2301 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 587:
/* Line 1455 of yacc.c */
#line 2302 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 588:
/* Line 1455 of yacc.c */
#line 2303 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 589:
/* Line 1455 of yacc.c */
#line 2304 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 590:
/* Line 1455 of yacc.c */
#line 2305 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 591:
/* Line 1455 of yacc.c */
#line 2306 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 592:
/* Line 1455 of yacc.c */
#line 2307 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 593:
/* Line 1455 of yacc.c */
#line 2308 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 594:
/* Line 1455 of yacc.c */
#line 2309 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 595:
/* Line 1455 of yacc.c */
#line 2310 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 596:
/* Line 1455 of yacc.c */
#line 2311 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 597:
/* Line 1455 of yacc.c */
#line 2312 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 598:
/* Line 1455 of yacc.c */
#line 2313 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 599:
/* Line 1455 of yacc.c */
#line 2314 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 600:
/* Line 1455 of yacc.c */
#line 2315 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 601:
/* Line 1455 of yacc.c */
#line 2316 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 602:
/* Line 1455 of yacc.c */
#line 2317 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 603:
/* Line 1455 of yacc.c */
#line 2318 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 604:
/* Line 1455 of yacc.c */
#line 2319 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 605:
/* Line 1455 of yacc.c */
#line 2320 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 606:
/* Line 1455 of yacc.c */
#line 2321 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 607:
/* Line 1455 of yacc.c */
#line 2322 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 608:
/* Line 1455 of yacc.c */
#line 2323 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 609:
/* Line 1455 of yacc.c */
#line 2324 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 610:
/* Line 1455 of yacc.c */
#line 2325 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 611:
/* Line 1455 of yacc.c */
#line 2326 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 612:
/* Line 1455 of yacc.c */
#line 2327 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 613:
/* Line 1455 of yacc.c */
#line 2328 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 614:
/* Line 1455 of yacc.c */
#line 2329 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 615:
/* Line 1455 of yacc.c */
#line 2330 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 616:
/* Line 1455 of yacc.c */
#line 2331 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 617:
/* Line 1455 of yacc.c */
#line 2332 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 618:
/* Line 1455 of yacc.c */
#line 2333 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 619:
/* Line 1455 of yacc.c */
#line 2334 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 620:
/* Line 1455 of yacc.c */
#line 2335 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 621:
/* Line 1455 of yacc.c */
#line 2336 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 622:
/* Line 1455 of yacc.c */
#line 2337 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 623:
/* Line 1455 of yacc.c */
#line 2342 "hphp.y"
{ _p->onCall((yyval),0,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;}
break;
case 624:
/* Line 1455 of yacc.c */
#line 2346 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 625:
/* Line 1455 of yacc.c */
#line 2347 "hphp.y"
{ (yyvsp[(1) - (1)]).xhpLabel(); (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 626:
/* Line 1455 of yacc.c */
#line 2350 "hphp.y"
{ _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StringName);;}
break;
case 627:
/* Line 1455 of yacc.c */
#line 2351 "hphp.y"
{ _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StaticName);;}
break;
case 628:
/* Line 1455 of yacc.c */
#line 2352 "hphp.y"
{ _p->onName((yyval),(yyvsp[(1) - (1)]),
Parser::StaticClassExprName);;}
break;
case 629:
/* Line 1455 of yacc.c */
#line 2356 "hphp.y"
{ _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StringName);;}
break;
case 630:
/* Line 1455 of yacc.c */
#line 2357 "hphp.y"
{ _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::StaticName);;}
break;
case 631:
/* Line 1455 of yacc.c */
#line 2358 "hphp.y"
{ _p->onName((yyval),(yyvsp[(1) - (1)]),Parser::ExprName);;}
break;
case 632:
/* Line 1455 of yacc.c */
#line 2362 "hphp.y"
{ (yyval).reset();;}
break;
case 633:
/* Line 1455 of yacc.c */
#line 2363 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 634:
/* Line 1455 of yacc.c */
#line 2364 "hphp.y"
{ (yyval).reset();;}
break;
case 635:
/* Line 1455 of yacc.c */
#line 2368 "hphp.y"
{ (yyval).reset();;}
break;
case 636:
/* Line 1455 of yacc.c */
#line 2369 "hphp.y"
{ _p->addEncap((yyval), NULL, (yyvsp[(1) - (1)]), 0);;}
break;
case 637:
/* Line 1455 of yacc.c */
#line 2370 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 638:
/* Line 1455 of yacc.c */
#line 2374 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 639:
/* Line 1455 of yacc.c */
#line 2375 "hphp.y"
{ (yyval).reset();;}
break;
case 640:
/* Line 1455 of yacc.c */
#line 2379 "hphp.y"
{ _p->onScalar((yyval), T_LNUMBER, (yyvsp[(1) - (1)]));;}
break;
case 641:
/* Line 1455 of yacc.c */
#line 2380 "hphp.y"
{ _p->onScalar((yyval), T_DNUMBER, (yyvsp[(1) - (1)]));;}
break;
case 642:
/* Line 1455 of yacc.c */
#line 2381 "hphp.y"
{ _p->onScalar((yyval), T_ONUMBER, (yyvsp[(1) - (1)]));;}
break;
case 643:
/* Line 1455 of yacc.c */
#line 2382 "hphp.y"
{ _p->onScalar((yyval),
T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;}
break;
case 644:
/* Line 1455 of yacc.c */
#line 2384 "hphp.y"
{ _p->onScalar((yyval), T_LINE, (yyvsp[(1) - (1)]));;}
break;
case 645:
/* Line 1455 of yacc.c */
#line 2385 "hphp.y"
{ _p->onScalar((yyval), T_FILE, (yyvsp[(1) - (1)]));;}
break;
case 646:
/* Line 1455 of yacc.c */
#line 2386 "hphp.y"
{ _p->onScalar((yyval), T_DIR, (yyvsp[(1) - (1)]));;}
break;
case 647:
/* Line 1455 of yacc.c */
#line 2387 "hphp.y"
{ _p->onScalar((yyval), T_CLASS_C, (yyvsp[(1) - (1)]));;}
break;
case 648:
/* Line 1455 of yacc.c */
#line 2388 "hphp.y"
{ _p->onScalar((yyval), T_TRAIT_C, (yyvsp[(1) - (1)]));;}
break;
case 649:
/* Line 1455 of yacc.c */
#line 2389 "hphp.y"
{ _p->onScalar((yyval), T_METHOD_C, (yyvsp[(1) - (1)]));;}
break;
case 650:
/* Line 1455 of yacc.c */
#line 2390 "hphp.y"
{ _p->onScalar((yyval), T_FUNC_C, (yyvsp[(1) - (1)]));;}
break;
case 651:
/* Line 1455 of yacc.c */
#line 2391 "hphp.y"
{ _p->onScalar((yyval), T_NS_C, (yyvsp[(1) - (1)]));;}
break;
case 652:
/* Line 1455 of yacc.c */
#line 2392 "hphp.y"
{ _p->onScalar((yyval), T_COMPILER_HALT_OFFSET, (yyvsp[(1) - (1)]));;}
break;
case 653:
/* Line 1455 of yacc.c */
#line 2395 "hphp.y"
{ _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(2) - (3)]));;}
break;
case 654:
/* Line 1455 of yacc.c */
#line 2397 "hphp.y"
{ (yyval).setText(""); _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyval));;}
break;
case 655:
/* Line 1455 of yacc.c */
#line 2401 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 656:
/* Line 1455 of yacc.c */
#line 2402 "hphp.y"
{ _p->onConstantValue((yyval), (yyvsp[(1) - (1)]));;}
break;
case 657:
/* Line 1455 of yacc.c */
#line 2404 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY); ;}
break;
case 658:
/* Line 1455 of yacc.c */
#line 2405 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY); ;}
break;
case 659:
/* Line 1455 of yacc.c */
#line 2407 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY); ;}
break;
case 660:
/* Line 1455 of yacc.c */
#line 2408 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 661:
/* Line 1455 of yacc.c */
#line 2409 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 662:
/* Line 1455 of yacc.c */
#line 2410 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 663:
/* Line 1455 of yacc.c */
#line 2411 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 664:
/* Line 1455 of yacc.c */
#line 2412 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 665:
/* Line 1455 of yacc.c */
#line 2414 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_OR);;}
break;
case 666:
/* Line 1455 of yacc.c */
#line 2416 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_BOOLEAN_AND);;}
break;
case 667:
/* Line 1455 of yacc.c */
#line 2418 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_OR);;}
break;
case 668:
/* Line 1455 of yacc.c */
#line 2420 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_AND);;}
break;
case 669:
/* Line 1455 of yacc.c */
#line 2422 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_LOGICAL_XOR);;}
break;
case 670:
/* Line 1455 of yacc.c */
#line 2423 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'|');;}
break;
case 671:
/* Line 1455 of yacc.c */
#line 2424 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'&');;}
break;
case 672:
/* Line 1455 of yacc.c */
#line 2425 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'^');;}
break;
case 673:
/* Line 1455 of yacc.c */
#line 2426 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'.');;}
break;
case 674:
/* Line 1455 of yacc.c */
#line 2427 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'+');;}
break;
case 675:
/* Line 1455 of yacc.c */
#line 2428 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'-');;}
break;
case 676:
/* Line 1455 of yacc.c */
#line 2429 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'*');;}
break;
case 677:
/* Line 1455 of yacc.c */
#line 2430 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'/');;}
break;
case 678:
/* Line 1455 of yacc.c */
#line 2431 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'%');;}
break;
case 679:
/* Line 1455 of yacc.c */
#line 2432 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SL);;}
break;
case 680:
/* Line 1455 of yacc.c */
#line 2433 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_SR);;}
break;
case 681:
/* Line 1455 of yacc.c */
#line 2434 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_POW);;}
break;
case 682:
/* Line 1455 of yacc.c */
#line 2435 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'!',1);;}
break;
case 683:
/* Line 1455 of yacc.c */
#line 2436 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'~',1);;}
break;
case 684:
/* Line 1455 of yacc.c */
#line 2437 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'+',1);;}
break;
case 685:
/* Line 1455 of yacc.c */
#line 2438 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'-',1);;}
break;
case 686:
/* Line 1455 of yacc.c */
#line 2440 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_IDENTICAL);;}
break;
case 687:
/* Line 1455 of yacc.c */
#line 2442 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_IDENTICAL);;}
break;
case 688:
/* Line 1455 of yacc.c */
#line 2444 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_EQUAL);;}
break;
case 689:
/* Line 1455 of yacc.c */
#line 2446 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),T_IS_NOT_EQUAL);;}
break;
case 690:
/* Line 1455 of yacc.c */
#line 2447 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'<');;}
break;
case 691:
/* Line 1455 of yacc.c */
#line 2449 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),
T_IS_SMALLER_OR_EQUAL);;}
break;
case 692:
/* Line 1455 of yacc.c */
#line 2451 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),'>');;}
break;
case 693:
/* Line 1455 of yacc.c */
#line 2454 "hphp.y"
{ BEXP((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),
T_IS_GREATER_OR_EQUAL);;}
break;
case 694:
/* Line 1455 of yacc.c */
#line 2457 "hphp.y"
{ _p->onQOp((yyval), (yyvsp[(1) - (5)]), &(yyvsp[(3) - (5)]), (yyvsp[(5) - (5)]));;}
break;
case 695:
/* Line 1455 of yacc.c */
#line 2458 "hphp.y"
{ _p->onQOp((yyval), (yyvsp[(1) - (4)]), 0, (yyvsp[(4) - (4)]));;}
break;
case 696:
/* Line 1455 of yacc.c */
#line 2464 "hphp.y"
{ _p->onClassConst((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 1);;}
break;
case 697:
/* Line 1455 of yacc.c */
#line 2466 "hphp.y"
{ (yyvsp[(1) - (3)]).xhpLabel();
_p->onClassConst((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 1);;}
break;
case 698:
/* Line 1455 of yacc.c */
#line 2470 "hphp.y"
{ _p->onClassClass((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 1);;}
break;
case 699:
/* Line 1455 of yacc.c */
#line 2474 "hphp.y"
{ _p->onConstantValue((yyval), (yyvsp[(1) - (1)]));;}
break;
case 700:
/* Line 1455 of yacc.c */
#line 2475 "hphp.y"
{ _p->onConstantValue((yyval), (yyvsp[(1) - (1)]));;}
break;
case 701:
/* Line 1455 of yacc.c */
#line 2476 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 702:
/* Line 1455 of yacc.c */
#line 2477 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 703:
/* Line 1455 of yacc.c */
#line 2478 "hphp.y"
{ _p->onEncapsList((yyval),'"',(yyvsp[(2) - (3)]));;}
break;
case 704:
/* Line 1455 of yacc.c */
#line 2479 "hphp.y"
{ _p->onEncapsList((yyval),'\'',(yyvsp[(2) - (3)]));;}
break;
case 705:
/* Line 1455 of yacc.c */
#line 2481 "hphp.y"
{ _p->onEncapsList((yyval),T_START_HEREDOC,
(yyvsp[(2) - (3)]));;}
break;
case 706:
/* Line 1455 of yacc.c */
#line 2486 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 707:
/* Line 1455 of yacc.c */
#line 2487 "hphp.y"
{ (yyval).reset();;}
break;
case 708:
/* Line 1455 of yacc.c */
#line 2491 "hphp.y"
{ (yyval).reset();;}
break;
case 709:
/* Line 1455 of yacc.c */
#line 2492 "hphp.y"
{ (yyval).reset();;}
break;
case 710:
/* Line 1455 of yacc.c */
#line 2495 "hphp.y"
{ only_in_hh_syntax(_p); (yyval).reset();;}
break;
case 711:
/* Line 1455 of yacc.c */
#line 2496 "hphp.y"
{ (yyval).reset();;}
break;
case 712:
/* Line 1455 of yacc.c */
#line 2502 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0);;}
break;
case 713:
/* Line 1455 of yacc.c */
#line 2504 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;}
break;
case 714:
/* Line 1455 of yacc.c */
#line 2506 "hphp.y"
{ _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;}
break;
case 715:
/* Line 1455 of yacc.c */
#line 2507 "hphp.y"
{ _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;}
break;
case 716:
/* Line 1455 of yacc.c */
#line 2511 "hphp.y"
{ _p->onScalar((yyval), T_LNUMBER, (yyvsp[(1) - (1)]));;}
break;
case 717:
/* Line 1455 of yacc.c */
#line 2512 "hphp.y"
{ _p->onScalar((yyval), T_DNUMBER, (yyvsp[(1) - (1)]));;}
break;
case 718:
/* Line 1455 of yacc.c */
#line 2513 "hphp.y"
{ _p->onScalar((yyval), T_ONUMBER, (yyvsp[(1) - (1)]));;}
break;
case 719:
/* Line 1455 of yacc.c */
#line 2514 "hphp.y"
{ _p->onScalar((yyval),
T_CONSTANT_ENCAPSED_STRING, (yyvsp[(1) - (1)]));;}
break;
case 720:
/* Line 1455 of yacc.c */
#line 2518 "hphp.y"
{ _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyvsp[(2) - (3)]));;}
break;
case 721:
/* Line 1455 of yacc.c */
#line 2520 "hphp.y"
{ (yyval).setText(""); _p->onScalar((yyval), T_CONSTANT_ENCAPSED_STRING, (yyval));;}
break;
case 722:
/* Line 1455 of yacc.c */
#line 2523 "hphp.y"
{ _p->onScalar((yyval),T_LNUMBER,(yyvsp[(1) - (1)]));;}
break;
case 723:
/* Line 1455 of yacc.c */
#line 2524 "hphp.y"
{ _p->onScalar((yyval),T_DNUMBER,(yyvsp[(1) - (1)]));;}
break;
case 724:
/* Line 1455 of yacc.c */
#line 2525 "hphp.y"
{ _p->onScalar((yyval),T_ONUMBER,(yyvsp[(1) - (1)]));;}
break;
case 725:
/* Line 1455 of yacc.c */
#line 2526 "hphp.y"
{ constant_ae(_p,(yyval),(yyvsp[(1) - (1)]));;}
break;
case 726:
/* Line 1455 of yacc.c */
#line 2529 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 727:
/* Line 1455 of yacc.c */
#line 2530 "hphp.y"
{ constant_ae(_p,(yyval),(yyvsp[(1) - (1)]));;}
break;
case 728:
/* Line 1455 of yacc.c */
#line 2531 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'+',1);;}
break;
case 729:
/* Line 1455 of yacc.c */
#line 2532 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),'-',1);;}
break;
case 730:
/* Line 1455 of yacc.c */
#line 2534 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY);;}
break;
case 731:
/* Line 1455 of yacc.c */
#line 2535 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY);;}
break;
case 732:
/* Line 1455 of yacc.c */
#line 2537 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(3) - (4)]),T_ARRAY); ;}
break;
case 733:
/* Line 1455 of yacc.c */
#line 2542 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 734:
/* Line 1455 of yacc.c */
#line 2543 "hphp.y"
{ (yyval).reset();;}
break;
case 735:
/* Line 1455 of yacc.c */
#line 2548 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0);;}
break;
case 736:
/* Line 1455 of yacc.c */
#line 2550 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;}
break;
case 737:
/* Line 1455 of yacc.c */
#line 2552 "hphp.y"
{ _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;}
break;
case 738:
/* Line 1455 of yacc.c */
#line 2553 "hphp.y"
{ _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;}
break;
case 739:
/* Line 1455 of yacc.c */
#line 2557 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;}
break;
case 740:
/* Line 1455 of yacc.c */
#line 2558 "hphp.y"
{ _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;}
break;
case 741:
/* Line 1455 of yacc.c */
#line 2563 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]); ;}
break;
case 742:
/* Line 1455 of yacc.c */
#line 2564 "hphp.y"
{ (yyval).reset(); ;}
break;
case 743:
/* Line 1455 of yacc.c */
#line 2569 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0); ;}
break;
case 744:
/* Line 1455 of yacc.c */
#line 2572 "hphp.y"
{ _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0); ;}
break;
case 745:
/* Line 1455 of yacc.c */
#line 2577 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 746:
/* Line 1455 of yacc.c */
#line 2578 "hphp.y"
{ (yyval).reset();;}
break;
case 747:
/* Line 1455 of yacc.c */
#line 2581 "hphp.y"
{ _p->onArray((yyval),(yyvsp[(2) - (3)]),T_ARRAY);;}
break;
case 748:
/* Line 1455 of yacc.c */
#line 2582 "hphp.y"
{ Token t; t.reset();
_p->onArray((yyval),t,T_ARRAY);;}
break;
case 749:
/* Line 1455 of yacc.c */
#line 2589 "hphp.y"
{ _p->onUserAttribute((yyval),&(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),(yyvsp[(4) - (4)]));;}
break;
case 750:
/* Line 1455 of yacc.c */
#line 2591 "hphp.y"
{ _p->onUserAttribute((yyval), 0,(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
break;
case 751:
/* Line 1455 of yacc.c */
#line 2594 "hphp.y"
{ only_in_hh_syntax(_p);;}
break;
case 752:
/* Line 1455 of yacc.c */
#line 2596 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 753:
/* Line 1455 of yacc.c */
#line 2599 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 754:
/* Line 1455 of yacc.c */
#line 2602 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 755:
/* Line 1455 of yacc.c */
#line 2603 "hphp.y"
{ (yyval).reset();;}
break;
case 756:
/* Line 1455 of yacc.c */
#line 2607 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = 0;;}
break;
case 757:
/* Line 1455 of yacc.c */
#line 2608 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = 1;;}
break;
case 758:
/* Line 1455 of yacc.c */
#line 2612 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = HPHP::ObjPropNormal;;}
break;
case 759:
/* Line 1455 of yacc.c */
#line 2613 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = HPHP::ObjPropXhpAttr;;}
break;
case 760:
/* Line 1455 of yacc.c */
#line 2614 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]); (yyval) = HPHP::ObjPropNormal;;}
break;
case 761:
/* Line 1455 of yacc.c */
#line 2618 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 762:
/* Line 1455 of yacc.c */
#line 2619 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = HPHP::ObjPropNormal;;}
break;
case 763:
/* Line 1455 of yacc.c */
#line 2623 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 764:
/* Line 1455 of yacc.c */
#line 2624 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 765:
/* Line 1455 of yacc.c */
#line 2628 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 766:
/* Line 1455 of yacc.c */
#line 2629 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 767:
/* Line 1455 of yacc.c */
#line 2633 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 768:
/* Line 1455 of yacc.c */
#line 2634 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 769:
/* Line 1455 of yacc.c */
#line 2638 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;}
break;
case 770:
/* Line 1455 of yacc.c */
#line 2640 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)]));;}
break;
case 771:
/* Line 1455 of yacc.c */
#line 2645 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));;}
break;
case 772:
/* Line 1455 of yacc.c */
#line 2647 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(2) - (4)]), (yyvsp[(4) - (4)]));;}
break;
case 773:
/* Line 1455 of yacc.c */
#line 2651 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 774:
/* Line 1455 of yacc.c */
#line 2652 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 775:
/* Line 1455 of yacc.c */
#line 2653 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 776:
/* Line 1455 of yacc.c */
#line 2654 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 777:
/* Line 1455 of yacc.c */
#line 2655 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 778:
/* Line 1455 of yacc.c */
#line 2657 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(1) - (3)]),(yyvsp[(2) - (3)]).num(),(yyvsp[(3) - (3)]));;}
break;
case 779:
/* Line 1455 of yacc.c */
#line 2660 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)]).num(),(yyvsp[(5) - (5)]));;}
break;
case 780:
/* Line 1455 of yacc.c */
#line 2663 "hphp.y"
{ _p->onStaticMember((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 781:
/* Line 1455 of yacc.c */
#line 2665 "hphp.y"
{ _p->onCall((yyval),1,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;}
break;
case 782:
/* Line 1455 of yacc.c */
#line 2667 "hphp.y"
{ _p->onCall((yyval),1,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;}
break;
case 783:
/* Line 1455 of yacc.c */
#line 2668 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 784:
/* Line 1455 of yacc.c */
#line 2672 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 785:
/* Line 1455 of yacc.c */
#line 2673 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 786:
/* Line 1455 of yacc.c */
#line 2674 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 787:
/* Line 1455 of yacc.c */
#line 2675 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 788:
/* Line 1455 of yacc.c */
#line 2678 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(1) - (3)]),(yyvsp[(2) - (3)]).num(),(yyvsp[(3) - (3)]));;}
break;
case 789:
/* Line 1455 of yacc.c */
#line 2682 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)]).num(),(yyvsp[(5) - (5)]));;}
break;
case 790:
/* Line 1455 of yacc.c */
#line 2684 "hphp.y"
{ _p->onCall((yyval),1,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)]),NULL);;}
break;
case 791:
/* Line 1455 of yacc.c */
#line 2685 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 792:
/* Line 1455 of yacc.c */
#line 2689 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 793:
/* Line 1455 of yacc.c */
#line 2690 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 794:
/* Line 1455 of yacc.c */
#line 2691 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 795:
/* Line 1455 of yacc.c */
#line 2695 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 796:
/* Line 1455 of yacc.c */
#line 2699 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 797:
/* Line 1455 of yacc.c */
#line 2700 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 798:
/* Line 1455 of yacc.c */
#line 2706 "hphp.y"
{ _p->onObjectMethodCall((yyval),(yyvsp[(1) - (7)]),(yyvsp[(2) - (7)]).num(),(yyvsp[(3) - (7)]),(yyvsp[(6) - (7)]));;}
break;
case 799:
/* Line 1455 of yacc.c */
#line 2710 "hphp.y"
{ _p->onObjectMethodCall((yyval),(yyvsp[(2) - (9)]),(yyvsp[(4) - (9)]).num(),(yyvsp[(5) - (9)]),(yyvsp[(8) - (9)]));;}
break;
case 800:
/* Line 1455 of yacc.c */
#line 2717 "hphp.y"
{ _p->onCall((yyval),0,(yyvsp[(3) - (7)]),(yyvsp[(6) - (7)]),&(yyvsp[(1) - (7)]));;}
break;
case 801:
/* Line 1455 of yacc.c */
#line 2721 "hphp.y"
{ _p->onCall((yyval),1,(yyvsp[(3) - (6)]),(yyvsp[(5) - (6)]),&(yyvsp[(1) - (6)]));;}
break;
case 802:
/* Line 1455 of yacc.c */
#line 2725 "hphp.y"
{ _p->onCall((yyval),1,(yyvsp[(4) - (8)]),(yyvsp[(7) - (8)]),&(yyvsp[(1) - (8)]));;}
break;
case 803:
/* Line 1455 of yacc.c */
#line 2729 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 804:
/* Line 1455 of yacc.c */
#line 2731 "hphp.y"
{ _p->onIndirectRef((yyval),(yyvsp[(1) - (2)]),(yyvsp[(2) - (2)]));;}
break;
case 805:
/* Line 1455 of yacc.c */
#line 2736 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;}
break;
case 806:
/* Line 1455 of yacc.c */
#line 2737 "hphp.y"
{ _p->onRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;}
break;
case 807:
/* Line 1455 of yacc.c */
#line 2738 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 808:
/* Line 1455 of yacc.c */
#line 2741 "hphp.y"
{ _p->onSimpleVariable((yyval), (yyvsp[(1) - (1)]));;}
break;
case 809:
/* Line 1455 of yacc.c */
#line 2742 "hphp.y"
{ _p->onDynamicVariable((yyval), (yyvsp[(3) - (4)]), 0);;}
break;
case 810:
/* Line 1455 of yacc.c */
#line 2745 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 811:
/* Line 1455 of yacc.c */
#line 2746 "hphp.y"
{ (yyval).reset();;}
break;
case 812:
/* Line 1455 of yacc.c */
#line 2750 "hphp.y"
{ (yyval) = 1;;}
break;
case 813:
/* Line 1455 of yacc.c */
#line 2751 "hphp.y"
{ (yyval)++;;}
break;
case 814:
/* Line 1455 of yacc.c */
#line 2755 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 815:
/* Line 1455 of yacc.c */
#line 2756 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 816:
/* Line 1455 of yacc.c */
#line 2759 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(1) - (3)]),(yyvsp[(2) - (3)]).num(),(yyvsp[(3) - (3)]));;}
break;
case 817:
/* Line 1455 of yacc.c */
#line 2762 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)]).num(),(yyvsp[(5) - (5)]));;}
break;
case 818:
/* Line 1455 of yacc.c */
#line 2765 "hphp.y"
{ _p->onStaticMember((yyval),(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 819:
/* Line 1455 of yacc.c */
#line 2766 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 821:
/* Line 1455 of yacc.c */
#line 2770 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]);;}
break;
case 822:
/* Line 1455 of yacc.c */
#line 2773 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(1) - (3)]),(yyvsp[(2) - (3)]).num(),(yyvsp[(3) - (3)]));;}
break;
case 823:
/* Line 1455 of yacc.c */
#line 2777 "hphp.y"
{ _p->onObjectProperty((yyval),(yyvsp[(2) - (5)]),(yyvsp[(4) - (5)]).num(),(yyvsp[(5) - (5)]));;}
break;
case 824:
/* Line 1455 of yacc.c */
#line 2778 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 825:
/* Line 1455 of yacc.c */
#line 2782 "hphp.y"
{ _p->onAListVar((yyval),&(yyvsp[(1) - (2)]),NULL);;}
break;
case 826:
/* Line 1455 of yacc.c */
#line 2783 "hphp.y"
{ _p->onAListVar((yyval),&(yyvsp[(1) - (3)]),&(yyvsp[(3) - (3)]));;}
break;
case 827:
/* Line 1455 of yacc.c */
#line 2785 "hphp.y"
{ _p->onAListSub((yyval),&(yyvsp[(1) - (6)]),(yyvsp[(5) - (6)]));;}
break;
case 828:
/* Line 1455 of yacc.c */
#line 2786 "hphp.y"
{ _p->onAListVar((yyval),NULL,NULL);;}
break;
case 829:
/* Line 1455 of yacc.c */
#line 2787 "hphp.y"
{ _p->onAListVar((yyval),NULL,&(yyvsp[(1) - (1)]));;}
break;
case 830:
/* Line 1455 of yacc.c */
#line 2788 "hphp.y"
{ _p->onAListSub((yyval),NULL,(yyvsp[(3) - (4)]));;}
break;
case 831:
/* Line 1455 of yacc.c */
#line 2793 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 832:
/* Line 1455 of yacc.c */
#line 2794 "hphp.y"
{ (yyval).reset();;}
break;
case 833:
/* Line 1455 of yacc.c */
#line 2798 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]),0);;}
break;
case 834:
/* Line 1455 of yacc.c */
#line 2799 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]),0);;}
break;
case 835:
/* Line 1455 of yacc.c */
#line 2800 "hphp.y"
{ _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),0);;}
break;
case 836:
/* Line 1455 of yacc.c */
#line 2801 "hphp.y"
{ _p->onArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]),0);;}
break;
case 837:
/* Line 1455 of yacc.c */
#line 2804 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (6)]),&(yyvsp[(3) - (6)]),(yyvsp[(6) - (6)]),1);;}
break;
case 838:
/* Line 1455 of yacc.c */
#line 2806 "hphp.y"
{ _p->onArrayPair((yyval),&(yyvsp[(1) - (4)]), 0,(yyvsp[(4) - (4)]),1);;}
break;
case 839:
/* Line 1455 of yacc.c */
#line 2807 "hphp.y"
{ _p->onArrayPair((yyval), 0,&(yyvsp[(1) - (4)]),(yyvsp[(4) - (4)]),1);;}
break;
case 840:
/* Line 1455 of yacc.c */
#line 2808 "hphp.y"
{ _p->onArrayPair((yyval), 0, 0,(yyvsp[(2) - (2)]),1);;}
break;
case 841:
/* Line 1455 of yacc.c */
#line 2813 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 842:
/* Line 1455 of yacc.c */
#line 2814 "hphp.y"
{ _p->onEmptyCollection((yyval));;}
break;
case 843:
/* Line 1455 of yacc.c */
#line 2818 "hphp.y"
{ _p->onCollectionPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 844:
/* Line 1455 of yacc.c */
#line 2819 "hphp.y"
{ _p->onCollectionPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;}
break;
case 845:
/* Line 1455 of yacc.c */
#line 2820 "hphp.y"
{ _p->onCollectionPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 846:
/* Line 1455 of yacc.c */
#line 2821 "hphp.y"
{ _p->onCollectionPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;}
break;
case 847:
/* Line 1455 of yacc.c */
#line 2826 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 848:
/* Line 1455 of yacc.c */
#line 2827 "hphp.y"
{ _p->onEmptyCollection((yyval));;}
break;
case 849:
/* Line 1455 of yacc.c */
#line 2832 "hphp.y"
{ _p->onCollectionPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 850:
/* Line 1455 of yacc.c */
#line 2834 "hphp.y"
{ _p->onCollectionPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;}
break;
case 851:
/* Line 1455 of yacc.c */
#line 2836 "hphp.y"
{ _p->onCollectionPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 852:
/* Line 1455 of yacc.c */
#line 2837 "hphp.y"
{ _p->onCollectionPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;}
break;
case 853:
/* Line 1455 of yacc.c */
#line 2842 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 854:
/* Line 1455 of yacc.c */
#line 2843 "hphp.y"
{ _p->onEmptyCheckedArray((yyval));;}
break;
case 855:
/* Line 1455 of yacc.c */
#line 2847 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 856:
/* Line 1455 of yacc.c */
#line 2848 "hphp.y"
{ _p->onEmptyCheckedArray((yyval));;}
break;
case 857:
/* Line 1455 of yacc.c */
#line 2852 "hphp.y"
{ _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 858:
/* Line 1455 of yacc.c */
#line 2853 "hphp.y"
{ _p->onCheckedArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 859:
/* Line 1455 of yacc.c */
#line 2856 "hphp.y"
{ _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;}
break;
case 860:
/* Line 1455 of yacc.c */
#line 2857 "hphp.y"
{ _p->onCheckedArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;}
break;
case 861:
/* Line 1455 of yacc.c */
#line 2862 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 862:
/* Line 1455 of yacc.c */
#line 2863 "hphp.y"
{ _p->onEmptyCheckedArray((yyval));;}
break;
case 863:
/* Line 1455 of yacc.c */
#line 2867 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]);;}
break;
case 864:
/* Line 1455 of yacc.c */
#line 2868 "hphp.y"
{ _p->onEmptyCheckedArray((yyval));;}
break;
case 865:
/* Line 1455 of yacc.c */
#line 2873 "hphp.y"
{ _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (5)]),&(yyvsp[(3) - (5)]),(yyvsp[(5) - (5)]));;}
break;
case 866:
/* Line 1455 of yacc.c */
#line 2875 "hphp.y"
{ _p->onCheckedArrayPair((yyval), 0,&(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]));;}
break;
case 867:
/* Line 1455 of yacc.c */
#line 2879 "hphp.y"
{ _p->onCheckedArrayPair((yyval),&(yyvsp[(1) - (3)]), 0,(yyvsp[(3) - (3)]));;}
break;
case 868:
/* Line 1455 of yacc.c */
#line 2880 "hphp.y"
{ _p->onCheckedArrayPair((yyval), 0, 0,(yyvsp[(1) - (1)]));;}
break;
case 869:
/* Line 1455 of yacc.c */
#line 2884 "hphp.y"
{ _p->addEncap((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]), -1);;}
break;
case 870:
/* Line 1455 of yacc.c */
#line 2886 "hphp.y"
{ _p->addEncap((yyval), &(yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]), 0);;}
break;
case 871:
/* Line 1455 of yacc.c */
#line 2887 "hphp.y"
{ _p->addEncap((yyval), NULL, (yyvsp[(1) - (1)]), -1);;}
break;
case 872:
/* Line 1455 of yacc.c */
#line 2889 "hphp.y"
{ _p->addEncap((yyval), NULL, (yyvsp[(1) - (2)]), 0);
_p->addEncap((yyval), &(yyval), (yyvsp[(2) - (2)]), -1); ;}
break;
case 873:
/* Line 1455 of yacc.c */
#line 2894 "hphp.y"
{ _p->onSimpleVariable((yyval), (yyvsp[(1) - (1)]));;}
break;
case 874:
/* Line 1455 of yacc.c */
#line 2896 "hphp.y"
{ _p->encapRefDim((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]));;}
break;
case 875:
/* Line 1455 of yacc.c */
#line 2898 "hphp.y"
{ _p->encapObjProp((yyval), (yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]).num(), (yyvsp[(3) - (3)]));;}
break;
case 876:
/* Line 1455 of yacc.c */
#line 2900 "hphp.y"
{ _p->onDynamicVariable((yyval), (yyvsp[(2) - (3)]), 1);;}
break;
case 877:
/* Line 1455 of yacc.c */
#line 2902 "hphp.y"
{ _p->encapArray((yyval), (yyvsp[(2) - (6)]), (yyvsp[(4) - (6)]));;}
break;
case 878:
/* Line 1455 of yacc.c */
#line 2903 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]);;}
break;
case 879:
/* Line 1455 of yacc.c */
#line 2906 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = T_STRING;;}
break;
case 880:
/* Line 1455 of yacc.c */
#line 2907 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = T_NUM_STRING;;}
break;
case 881:
/* Line 1455 of yacc.c */
#line 2908 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); (yyval) = T_VARIABLE;;}
break;
case 882:
/* Line 1455 of yacc.c */
#line 2912 "hphp.y"
{ UEXP((yyval),(yyvsp[(3) - (4)]),T_ISSET,1);;}
break;
case 883:
/* Line 1455 of yacc.c */
#line 2913 "hphp.y"
{ UEXP((yyval),(yyvsp[(3) - (4)]),T_EMPTY,1);;}
break;
case 884:
/* Line 1455 of yacc.c */
#line 2914 "hphp.y"
{ UEXP((yyval),(yyvsp[(3) - (4)]),'!',1);;}
break;
case 885:
/* Line 1455 of yacc.c */
#line 2915 "hphp.y"
{ UEXP((yyval),(yyvsp[(3) - (4)]),'!',1);;}
break;
case 886:
/* Line 1455 of yacc.c */
#line 2916 "hphp.y"
{ UEXP((yyval),(yyvsp[(3) - (4)]),'!',1);;}
break;
case 887:
/* Line 1455 of yacc.c */
#line 2917 "hphp.y"
{ UEXP((yyval),(yyvsp[(3) - (4)]),'!',1);;}
break;
case 888:
/* Line 1455 of yacc.c */
#line 2918 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_INCLUDE,1);;}
break;
case 889:
/* Line 1455 of yacc.c */
#line 2919 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_INCLUDE_ONCE,1);;}
break;
case 890:
/* Line 1455 of yacc.c */
#line 2920 "hphp.y"
{ UEXP((yyval),(yyvsp[(3) - (4)]),T_EVAL,1);;}
break;
case 891:
/* Line 1455 of yacc.c */
#line 2921 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_REQUIRE,1);;}
break;
case 892:
/* Line 1455 of yacc.c */
#line 2922 "hphp.y"
{ UEXP((yyval),(yyvsp[(2) - (2)]),T_REQUIRE_ONCE,1);;}
break;
case 893:
/* Line 1455 of yacc.c */
#line 2926 "hphp.y"
{ _p->onExprListElem((yyval), NULL, (yyvsp[(1) - (1)]));;}
break;
case 894:
/* Line 1455 of yacc.c */
#line 2927 "hphp.y"
{ _p->onExprListElem((yyval), &(yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));;}
break;
case 895:
/* Line 1455 of yacc.c */
#line 2932 "hphp.y"
{ _p->onClassConst((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0);;}
break;
case 896:
/* Line 1455 of yacc.c */
#line 2934 "hphp.y"
{ _p->onClassClass((yyval), (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0);;}
break;
case 899:
/* Line 1455 of yacc.c */
#line 2948 "hphp.y"
{ (yyvsp[(2) - (5)]).setText(_p->nsDecl((yyvsp[(2) - (5)]).text()));
_p->onTypedef((yyval), (yyvsp[(2) - (5)]), (yyvsp[(4) - (5)]));
_p->popTypeScope(); ;}
break;
case 900:
/* Line 1455 of yacc.c */
#line 2952 "hphp.y"
{ (yyvsp[(2) - (6)]).setText(_p->nsDecl((yyvsp[(2) - (6)]).text()));
_p->onTypedef((yyval), (yyvsp[(2) - (6)]), (yyvsp[(5) - (6)]));
_p->popTypeScope(); ;}
break;
case 901:
/* Line 1455 of yacc.c */
#line 2958 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 902:
/* Line 1455 of yacc.c */
#line 2959 "hphp.y"
{ only_in_hh_syntax(_p); (yyval) = (yyvsp[(2) - (2)]); ;}
break;
case 903:
/* Line 1455 of yacc.c */
#line 2965 "hphp.y"
{ _p->pushTypeScope(); (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 904:
/* Line 1455 of yacc.c */
#line 2969 "hphp.y"
{ _p->pushTypeScope(); (yyval) = (yyvsp[(1) - (4)]); ;}
break;
case 905:
/* Line 1455 of yacc.c */
#line 2975 "hphp.y"
{ (yyval) = (yyvsp[(2) - (3)]); ;}
break;
case 906:
/* Line 1455 of yacc.c */
#line 2976 "hphp.y"
{ (yyval).reset(); ;}
break;
case 907:
/* Line 1455 of yacc.c */
#line 2980 "hphp.y"
{ Token t; t.reset();
_p->onTypeList((yyvsp[(1) - (1)]), t);
(yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 908:
/* Line 1455 of yacc.c */
#line 2983 "hphp.y"
{ _p->onTypeList((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]));
(yyval) = (yyvsp[(1) - (3)]); ;}
break;
case 909:
/* Line 1455 of yacc.c */
#line 2989 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]); ;}
break;
case 910:
/* Line 1455 of yacc.c */
#line 2994 "hphp.y"
{ (yyval) = (yyvsp[(1) - (3)]); ;}
break;
case 911:
/* Line 1455 of yacc.c */
#line 2995 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 912:
/* Line 1455 of yacc.c */
#line 2996 "hphp.y"
{ (yyval).reset(); ;}
break;
case 913:
/* Line 1455 of yacc.c */
#line 2997 "hphp.y"
{ (yyval).reset(); ;}
break;
case 914:
/* Line 1455 of yacc.c */
#line 3001 "hphp.y"
{ (yyval).reset(); ;}
break;
case 915:
/* Line 1455 of yacc.c */
#line 3002 "hphp.y"
{ only_in_hh_syntax(_p); (yyval) = (yyvsp[(2) - (2)]); ;}
break;
case 916:
/* Line 1455 of yacc.c */
#line 3007 "hphp.y"
{ _p->addTypeVar((yyvsp[(4) - (4)]).text()); ;}
break;
case 917:
/* Line 1455 of yacc.c */
#line 3008 "hphp.y"
{ _p->addTypeVar((yyvsp[(2) - (2)]).text()); ;}
break;
case 918:
/* Line 1455 of yacc.c */
#line 3011 "hphp.y"
{ _p->addTypeVar((yyvsp[(4) - (6)]).text()); ;}
break;
case 919:
/* Line 1455 of yacc.c */
#line 3013 "hphp.y"
{ _p->addTypeVar((yyvsp[(2) - (4)]).text()); ;}
break;
case 920:
/* Line 1455 of yacc.c */
#line 3017 "hphp.y"
{;}
break;
case 921:
/* Line 1455 of yacc.c */
#line 3018 "hphp.y"
{;}
break;
case 922:
/* Line 1455 of yacc.c */
#line 3019 "hphp.y"
{;}
break;
case 923:
/* Line 1455 of yacc.c */
#line 3025 "hphp.y"
{ validate_shape_keyname((yyvsp[(1) - (3)]), _p); ;}
break;
case 924:
/* Line 1455 of yacc.c */
#line 3030 "hphp.y"
{ ;}
break;
case 927:
/* Line 1455 of yacc.c */
#line 3042 "hphp.y"
{ (yyval) = (yyvsp[(1) - (2)]); ;}
break;
case 928:
/* Line 1455 of yacc.c */
#line 3044 "hphp.y"
{;}
break;
case 929:
/* Line 1455 of yacc.c */
#line 3048 "hphp.y"
{ (yyval).setText("array"); ;}
break;
case 930:
/* Line 1455 of yacc.c */
#line 3055 "hphp.y"
{ only_in_hh_syntax(_p);
_p->onTypeSpecialization((yyvsp[(2) - (2)]), '?');
(yyval) = (yyvsp[(2) - (2)]); ;}
break;
case 931:
/* Line 1455 of yacc.c */
#line 3058 "hphp.y"
{ only_in_hh_syntax(_p);
_p->onTypeSpecialization((yyvsp[(2) - (2)]), '@');
(yyval) = (yyvsp[(2) - (2)]); ;}
break;
case 932:
/* Line 1455 of yacc.c */
#line 3061 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 933:
/* Line 1455 of yacc.c */
#line 3062 "hphp.y"
{ Token t; t.reset();
(yyvsp[(1) - (1)]).setText("array");
_p->onTypeAnnotation((yyval), (yyvsp[(1) - (1)]), t); ;}
break;
case 934:
/* Line 1455 of yacc.c */
#line 3065 "hphp.y"
{ Token t; t.reset();
(yyvsp[(1) - (1)]).setText("callable");
_p->onTypeAnnotation((yyval), (yyvsp[(1) - (1)]), t); ;}
break;
case 935:
/* Line 1455 of yacc.c */
#line 3068 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 936:
/* Line 1455 of yacc.c */
#line 3070 "hphp.y"
{ (yyvsp[(1) - (4)]).setText("array");
_p->onTypeAnnotation((yyval), (yyvsp[(1) - (4)]), (yyvsp[(3) - (4)])); ;}
break;
case 937:
/* Line 1455 of yacc.c */
#line 3073 "hphp.y"
{ _p->onTypeList((yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
(yyvsp[(1) - (6)]).setText("array");
_p->onTypeAnnotation((yyval), (yyvsp[(1) - (6)]), (yyvsp[(3) - (6)])); ;}
break;
case 938:
/* Line 1455 of yacc.c */
#line 3076 "hphp.y"
{ (yyvsp[(1) - (1)]).xhpLabel();
Token t; t.reset();
_p->onTypeAnnotation((yyval), (yyvsp[(1) - (1)]), t);
_p->onTypeSpecialization((yyval), 'x'); ;}
break;
case 939:
/* Line 1455 of yacc.c */
#line 3082 "hphp.y"
{ only_in_hh_syntax(_p);
_p->onTypeList((yyvsp[(7) - (8)]), (yyvsp[(4) - (8)]));
_p->onTypeAnnotation((yyval), (yyvsp[(2) - (8)]), (yyvsp[(7) - (8)]));
_p->onTypeSpecialization((yyval), 'f'); ;}
break;
case 940:
/* Line 1455 of yacc.c */
#line 3088 "hphp.y"
{ only_in_hh_syntax(_p);
_p->onTypeList((yyvsp[(2) - (6)]), (yyvsp[(4) - (6)]));
Token t; t.reset(); t.setText("array");
_p->onTypeAnnotation((yyval), t, (yyvsp[(2) - (6)]));
_p->onTypeSpecialization((yyval), 't'); ;}
break;
case 941:
/* Line 1455 of yacc.c */
#line 3096 "hphp.y"
{ (yyval) = (yyvsp[(1) - (1)]); ;}
break;
case 942:
/* Line 1455 of yacc.c */
#line 3097 "hphp.y"
{ (yyval).reset(); ;}
break;
/* Line 1455 of yacc.c */
#line 13746 "hphp.tab.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
*++yylsp = yyloc;
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (&yylloc, _p, YY_("syntax error"));
#else
{
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
{
YYSIZE_T yyalloc = 2 * yysize;
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
yyalloc = YYSTACK_ALLOC_MAXIMUM;
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yyalloc);
if (yymsg)
yymsg_alloc = yyalloc;
else
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
}
}
if (0 < yysize && yysize <= yymsg_alloc)
{
(void) yysyntax_error (yymsg, yystate, yychar);
yyerror (&yylloc, _p, yymsg);
}
else
{
yyerror (&yylloc, _p, YY_("syntax error"));
if (yysize != 0)
goto yyexhaustedlab;
}
}
#endif
}
yyerror_range[0] = yylloc;
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, &yylloc, _p);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
yyerror_range[0] = yylsp[1-yylen];
/* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (yyn != YYPACT_NINF)
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yyerror_range[0] = *yylsp;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, yylsp, _p);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
*++yyvsp = yylval;
yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (&yylloc, _p, YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, _p);
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp, yylsp, _p);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
YYSTACK_CLEANUP;
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
/* Make sure YYID is used. */
return YYID (yyresult);
}
/* Line 1675 of yacc.c */
#line 3100 "hphp.y"
bool Parser::parseImpl() {
return yyparse(this) == 0;
}
| 39.898089 | 174 | 0.377857 | [
"shape",
"vector"
] |
2e1c3bbfe0e82ca88359dbce29689ce0ddf148d5 | 5,015 | cpp | C++ | libs/opengl/src/CSetOfTriangles.cpp | swt2c/mrpt | 9b4fd246530ff94bb93f5703e61844c6f67aa0b9 | [
"BSD-3-Clause"
] | null | null | null | libs/opengl/src/CSetOfTriangles.cpp | swt2c/mrpt | 9b4fd246530ff94bb93f5703e61844c6f67aa0b9 | [
"BSD-3-Clause"
] | null | null | null | libs/opengl/src/CSetOfTriangles.cpp | swt2c/mrpt | 9b4fd246530ff94bb93f5703e61844c6f67aa0b9 | [
"BSD-3-Clause"
] | 1 | 2020-12-30T14:06:37.000Z | 2020-12-30T14:06:37.000Z | /* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| https://www.mrpt.org/ |
| |
| Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
| See: https://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See: https://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
#include "opengl-precomp.h" // Precompiled header
#include <mrpt/math/CMatrixDynamic.h>
#include <mrpt/opengl/CSetOfTriangles.h>
#include <mrpt/opengl/opengl_api.h>
#include <mrpt/serialization/CArchive.h>
using namespace mrpt;
using namespace mrpt::opengl;
using namespace mrpt::poses;
using namespace mrpt::math;
using namespace std;
IMPLEMENTS_SERIALIZABLE(
CSetOfTriangles, CRenderizableShaderTriangles, mrpt::opengl)
void CSetOfTriangles::onUpdateBuffers_Triangles()
{
// Nothing else to do, data is directly kept up-to-date in base class
// buffers.
}
uint8_t CSetOfTriangles::serializeGetVersion() const { return 0; }
void CSetOfTriangles::serializeTo(mrpt::serialization::CArchive& out) const
{
writeToStreamRender(out);
auto n = (uint32_t)m_triangles.size();
out << n;
for (size_t i = 0; i < n; i++) m_triangles[i].writeTo(out);
}
void CSetOfTriangles::serializeFrom(
mrpt::serialization::CArchive& in, uint8_t version)
{
switch (version)
{
case 0:
{
readFromStreamRender(in);
uint32_t n;
in >> n;
m_triangles.assign(n, TTriangle());
for (size_t i = 0; i < n; i++) m_triangles[i].readFrom(in);
}
break;
default:
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version);
};
polygonsUpToDate = false;
CRenderizable::notifyChange();
}
bool CSetOfTriangles::traceRay(
const mrpt::poses::CPose3D& o, double& dist) const
{
if (!polygonsUpToDate) updatePolygons();
return mrpt::math::traceRay(m_polygons, (o - this->m_pose).asTPose(), dist);
}
CRenderizable& CSetOfTriangles::setColor_u8(const mrpt::img::TColor& c)
{
CRenderizable::notifyChange();
m_color = c;
for (auto& t : m_triangles) t.setColor(c);
return *this;
}
CRenderizable& CSetOfTriangles::setColorR_u8(const uint8_t r)
{
CRenderizable::notifyChange();
m_color.R = r;
for (auto& t : m_triangles) t.setColor(m_color);
return *this;
}
CRenderizable& CSetOfTriangles::setColorG_u8(const uint8_t g)
{
CRenderizable::notifyChange();
m_color.G = g;
for (auto& t : m_triangles) t.setColor(m_color);
return *this;
}
CRenderizable& CSetOfTriangles::setColorB_u8(const uint8_t b)
{
CRenderizable::notifyChange();
m_color.B = b;
for (auto& t : m_triangles) t.setColor(m_color);
return *this;
}
CRenderizable& CSetOfTriangles::setColorA_u8(const uint8_t a)
{
CRenderizable::notifyChange();
m_color.A = a;
for (auto& t : m_triangles) t.setColor(m_color);
return *this;
}
void CSetOfTriangles::getPolygons(
std::vector<mrpt::math::TPolygon3D>& polys) const
{
if (!polygonsUpToDate) updatePolygons();
size_t N = m_polygons.size();
for (size_t i = 0; i < N; i++) polys[i] = m_polygons[i].poly;
}
void CSetOfTriangles::updatePolygons() const
{
TPolygon3D tmp(3);
size_t N = m_triangles.size();
m_polygons.resize(N);
for (size_t i = 0; i < N; i++)
for (size_t j = 0; j < 3; j++)
{
const TTriangle& t = m_triangles[i];
tmp[j].x = t.x(j);
tmp[j].y = t.y(j);
tmp[j].z = t.z(j);
m_polygons[i] = tmp;
}
polygonsUpToDate = true;
CRenderizable::notifyChange();
}
void CSetOfTriangles::getBoundingBox(
mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
{
bb_min = mrpt::math::TPoint3D(
std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
std::numeric_limits<double>::max());
bb_max = mrpt::math::TPoint3D(
-std::numeric_limits<double>::max(),
-std::numeric_limits<double>::max(),
-std::numeric_limits<double>::max());
for (const auto& t : m_triangles)
{
keep_min(bb_min.x, t.x(0));
keep_max(bb_max.x, t.x(0));
keep_min(bb_min.y, t.y(0));
keep_max(bb_max.y, t.y(0));
keep_min(bb_min.z, t.z(0));
keep_max(bb_max.z, t.z(0));
keep_min(bb_min.x, t.x(1));
keep_max(bb_max.x, t.x(1));
keep_min(bb_min.y, t.y(1));
keep_max(bb_max.y, t.y(1));
keep_min(bb_min.z, t.z(1));
keep_max(bb_max.z, t.z(1));
keep_min(bb_min.x, t.x(2));
keep_max(bb_max.x, t.x(2));
keep_min(bb_min.y, t.y(2));
keep_max(bb_max.y, t.y(2));
keep_min(bb_min.z, t.z(2));
keep_max(bb_max.z, t.z(2));
}
// Convert to coordinates of my parent:
m_pose.composePoint(bb_min, bb_min);
m_pose.composePoint(bb_max, bb_max);
}
void CSetOfTriangles::insertTriangles(const CSetOfTriangles::Ptr& p)
{
reserve(m_triangles.size() + p->m_triangles.size());
m_triangles.insert(
m_triangles.end(), p->m_triangles.begin(), p->m_triangles.end());
polygonsUpToDate = false;
CRenderizable::notifyChange();
}
| 27.707182 | 80 | 0.648654 | [
"vector"
] |
2e1d836c3fdd8e55783271a634c9576e71d6747a | 553 | cpp | C++ | Day2/zadanie6.cpp | majkel84/kurs_cpp_podstawowy | eddaffb310c6132304aa26dc87ec04ddfc09c541 | [
"MIT"
] | 8 | 2020-05-17T18:04:40.000Z | 2021-04-15T07:52:33.000Z | Day2/zadanie6.cpp | majkel84/kurs_cpp_podstawowy | eddaffb310c6132304aa26dc87ec04ddfc09c541 | [
"MIT"
] | 292 | 2020-03-10T18:03:14.000Z | 2022-03-26T17:00:51.000Z | Day2/zadanie6.cpp | majkel84/kurs_cpp_podstawowy | eddaffb310c6132304aa26dc87ec04ddfc09c541 | [
"MIT"
] | 126 | 2020-05-11T16:25:40.000Z | 2022-02-21T00:41:03.000Z | #include <algorithm>
#include <iostream>
#include <vector>
void foo(const std::vector<int>& vec, int number) {
int equal {0};
int greater {0};
int lower {0};
for (size_t i = 0 ; i < vec.size() ; ++i) {
if (vec[i] > number)
++greater;
else if (vec[i] < number)
++lower;
else
++equal;
}
std::cout << "Greater: " << greater << '\n';
std::cout << "Lower: " << lower << '\n';
std::cout << "Equal: " << equal << '\n';
}
int main() {
std::vector<int> vec {10, 20, 3, 8, 21, 30};
foo(vec, 10);
return 0;
}
| 19.75 | 51 | 0.511754 | [
"vector"
] |
2e1dfc186401f4773b4d721f618cd729b90ff4f8 | 771 | hh | C++ | inc/Przeszkoda.hh | bsierp/ZadanieDronPrzeszkody | 1eab1d3a994c5023aec4ae0f6d7d605a9ac3b240 | [
"MIT"
] | null | null | null | inc/Przeszkoda.hh | bsierp/ZadanieDronPrzeszkody | 1eab1d3a994c5023aec4ae0f6d7d605a9ac3b240 | [
"MIT"
] | null | null | null | inc/Przeszkoda.hh | bsierp/ZadanieDronPrzeszkody | 1eab1d3a994c5023aec4ae0f6d7d605a9ac3b240 | [
"MIT"
] | null | null | null | #ifndef PRZESZKODA_HH
#define PRZESZKODA_HH
/*!
* \brief Definicja klasy abstrakcyjnej Przeszkoda
*
* Plik zawiera definicje klasy abstrakcyjnej Przeszkoda,
* oraz deklaracje wirtualnych metod tej klasy.*/
#include <memory>
#include "Interfejs.hh"
/*!
* \brief Model pojęcia przeszkody
*
* Klasa abstrakcyjna modeluje ogólne pojęcie
* przeszkody
*/
class Przeszkoda {
public:
/*!
* \brief Metoda wykrywająca kolizje
*
* Metoda wykrywa czy nastąpiła kolizja drona
* z przeszkodą \n
* \param[in] drone - wskaźnik na interfejs drona dla którego będzie sprawdzana kolizja
* \retval true - jeśli nastąpiła kolizja
* \retval false - w przeciwnym wypadku
*/
virtual bool czy_kolizja(std::shared_ptr<Interfejs> drone) const = 0;
};
#endif | 26.586207 | 90 | 0.726329 | [
"model"
] |
2e231baac6e69e1bece2e514dcd2f3b7474f9434 | 911 | cpp | C++ | LeetCode/Problems/Algorithms/#421_MaximumXOROfTwoNumbersInAnArray_sol4_prefixes_and_set_356ms_40.6MB.cpp | Tudor67/Competitive-Programming | ae4dc6ed8bf76451775bf4f740c16394913f3ff1 | [
"MIT"
] | 1 | 2022-01-26T14:50:07.000Z | 2022-01-26T14:50:07.000Z | LeetCode/Problems/Algorithms/#421_MaximumXOROfTwoNumbersInAnArray_sol4_prefixes_and_set_356ms_40.6MB.cpp | Tudor67/Competitive-Programming | ae4dc6ed8bf76451775bf4f740c16394913f3ff1 | [
"MIT"
] | null | null | null | LeetCode/Problems/Algorithms/#421_MaximumXOROfTwoNumbersInAnArray_sol4_prefixes_and_set_356ms_40.6MB.cpp | Tudor67/Competitive-Programming | ae4dc6ed8bf76451775bf4f740c16394913f3ff1 | [
"MIT"
] | null | null | null | class Solution {
public:
int findMaximumXOR(vector<int>& nums) {
int maxXOR = 0;
// build the answer (i.e., maxXOR) step-by-step moving from left (msb) to right (lsb)
int mask = 0;
for(int bit = 30; bit >= 0; --bit){
mask |= (1 << bit);
// save prefixes with the first (30 - bit + 1) most significant bits
set<int> prefixes;
for(int num: nums){
prefixes.insert(num & mask);
}
// try to improve/maximize current maxXOR with one more bit (if possible)
for(int prefix: prefixes){
if(prefixes.find(prefix ^ (maxXOR | (1 << bit))) != prefixes.end()){
maxXOR |= (1 << bit);
break;
}
}
}
return maxXOR;
}
}; | 32.535714 | 94 | 0.432492 | [
"vector"
] |
2e234c89f1fadb6bbbcdde2a0c579de1a8c97b54 | 6,083 | cpp | C++ | examples/COUPLE/lammps_spparks/lmpspk.cpp | neoshanarayanan/lammps_simulations | 04e55e3b74da588e70a08b6b9f1d79fc4dc0b7d4 | [
"MIT"
] | null | null | null | examples/COUPLE/lammps_spparks/lmpspk.cpp | neoshanarayanan/lammps_simulations | 04e55e3b74da588e70a08b6b9f1d79fc4dc0b7d4 | [
"MIT"
] | null | null | null | examples/COUPLE/lammps_spparks/lmpspk.cpp | neoshanarayanan/lammps_simulations | 04e55e3b74da588e70a08b6b9f1d79fc4dc0b7d4 | [
"MIT"
] | null | null | null | // lmpspk = umbrella driver to couple LAMMPS + SPPARKS
// for a strain-induced grain growth model
// Syntax: lmpspk Niter Ndelta Sfactor in.spparks
// Niter = # of outer iterations
// Ndelta = time to run MC in each iteration
// Sfactor = multiplier on strain effect
// in.spparks = SPPARKS input script
#include <mpi.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "lammps_data_write.h"
#include "many2many.h"
#include "memory.h"
#include "error.h"
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
#include "spkpath.h"
#include QUOTE(SPKPATH/src/spparks.h)
#include QUOTE(SPKPATH/src/library.h)
#include QUOTE(SPKPATH/src/input.h)
#include "lmppath.h"
#include QUOTE(LMPPATH/src/lammps.h)
#include QUOTE(LMPPATH/src/library.h)
#include QUOTE(LMPPATH/src/input.h)
#include QUOTE(LMPPATH/src/modify.h)
#include QUOTE(LMPPATH/src/compute.h)
using namespace SPPARKS_NS;
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
int main(int narg, char **arg)
{
int i,n;
char str[128];
// setup MPI
MPI_Init(&narg,&arg);
MPI_Comm comm = MPI_COMM_WORLD;
int me,nprocs;
MPI_Comm_rank(comm,&me);
MPI_Comm_size(comm,&nprocs);
Memory *memory = new Memory(comm);
Error *error = new Error(comm);
// command-line args
if (narg != 5)
error->all("Syntax: lmpspk Niter Ndelta Sfactor in.spparks");
int niter = atoi(arg[1]);
double delta = atof(arg[2]);
double sfactor = atof(arg[3]);
n = strlen(arg[4]) + 1;
char *spparks_input = new char[n];
strcpy(spparks_input,arg[4]);
// instantiate LAMMPS and SPPARKS
SPPARKS *spk = new SPPARKS(0,NULL,MPI_COMM_WORLD);
LAMMPS *lmp = new LAMMPS(0,NULL,MPI_COMM_WORLD);
// create simulation in SPPARKS from in.spparks
spk->input->file(spparks_input);
// extract permanent info from SPPARKS
int dimension,nglobal,nlocal_spparks,nspins;
double boxxlo,boxxhi,boxylo,boxyhi,boxzlo,boxzhi;
int *id_spparks,*spins;
double **xyz;
double *strain;
dimension = *((int *) spparks_extract(spk,"dimension"));
nglobal = *((int *) spparks_extract(spk,"nglobal"));
nlocal_spparks = *((int *) spparks_extract(spk,"nlocal"));
boxxlo = *((double *) spparks_extract(spk,"boxxlo"));
boxxhi = *((double *) spparks_extract(spk,"boxxhi"));
boxylo = *((double *) spparks_extract(spk,"boxylo"));
boxyhi = *((double *) spparks_extract(spk,"boxyhi"));
if (dimension == 3) {
boxzlo = *((double *) spparks_extract(spk,"boxzlo"));
boxzhi = *((double *) spparks_extract(spk,"boxzhi"));
} else {
boxzlo = -0.5;
boxzhi = 0.5;
}
id_spparks = (int *) spparks_extract(spk,"id");
spins = (int *) spparks_extract(spk,"site");
xyz = (double **) spparks_extract(spk,"xyz");
nspins = *((int *) spparks_extract(spk,"nspins"));
strain = (double *) spparks_extract(spk,"strain");
// write a LAMMPS input script using SPPARKS params
if (me == 0) {
FILE *fp = fopen("in.lammps","w");
if (fp == NULL) error->one("Could not create LAMMPS input script");
fprintf(fp,"units lj\n");
sprintf(str,"dimension %d\n",dimension);
fprintf(fp,str);
fprintf(fp,"atom_style atomic\n\n");
fprintf(fp,"read_data data.lammps\n");
fprintf(fp,"mass * 1.0\n\n");
fprintf(fp,"pair_style lj/cut 2.5\n");
fprintf(fp,"pair_coeff * * 1.0 1.2\n");
for (i = 0; i < nspins; i++) {
sprintf(str,"pair_coeff %d %d 1.0 1.0\n",i+1,i+1);
fprintf(fp,str);
}
fprintf(fp,"\n");
fprintf(fp,"compute da all displace/atom\n\n");
fprintf(fp,"dump 1 all atom 10 dump.md\n");
fprintf(fp,"thermo 1\n");
fclose(fp);
}
// write a LAMMPS data file using SPPARKS data
LAMMPSDataWrite *lwd = new LAMMPSDataWrite(MPI_COMM_WORLD);
lwd->file("data.lammps");
lwd->header("%d atoms",nglobal);
lwd->header("%d atom types",nspins);
lwd->header("%g %g xlo xhi",boxxlo,boxxhi);
lwd->header("%g %g ylo yhi",boxylo,boxyhi);
lwd->header("%g %g zlo zhi",boxzlo,boxzhi);
lwd->atoms(nlocal_spparks);
lwd->atoms(id_spparks);
lwd->atoms(spins);
lwd->atoms(3,xyz);
lwd->execute();
delete lwd;
// create simulation in LAMMPS from created input script
lmp->input->file("in.lammps");
// create transfer operators
Many2Many *spk2lmp = new Many2Many(MPI_COMM_WORLD);
Many2Many *lmp2spk = new Many2Many(MPI_COMM_WORLD);
// timestep loop
// run SPPARKS for delta time
// use SPPARKS spins to reset LAMMPS atom types
// perform LAMMPS minimization
// use atom displacements to reset strain values in SPPARKS
// realloc displace as necessary since nlocal_lammps may change
// re-create both xfers every iteration since LAMMPS may migrate atoms
int nmax = 0;
double *displace = NULL;
int nlocal_lammps;
int *id_lammps,*type;
double **displace_lammps;
for (int iter = 0; iter < niter; iter++) {
sprintf(str,"run %g",delta);
spk->input->one(str);
nlocal_lammps = *((int *) lammps_extract_global(lmp,"nlocal"));
id_lammps = (int *) lammps_extract_atom(lmp,"id");
type = (int *) lammps_extract_atom(lmp,"type");
spk2lmp->setup(nlocal_spparks,id_spparks,nlocal_lammps,id_lammps);
spk2lmp->exchange(spins,type);
lmp->input->one("minimize 0.001 0.001 10 1000");
nlocal_lammps = *((int *) lammps_extract_global(lmp,"nlocal"));
id_lammps = (int *) lammps_extract_atom(lmp,"id");
displace_lammps = (double **) lammps_extract_compute(lmp,"da",1,2);
if (nlocal_lammps > nmax) {
memory->sfree(displace);
nmax = nlocal_lammps;
displace = (double *)
memory->smalloc(nmax*sizeof(double),"lmpspk:displace");
}
for (i = 0; i < nlocal_lammps; i++)
displace[i] = sfactor*displace_lammps[i][3];
lmp2spk->setup(nlocal_lammps,id_lammps,nlocal_spparks,id_spparks);
lmp2spk->exchange(displace,strain);
}
memory->sfree(displace);
// clean up
delete spk2lmp;
delete lmp2spk;
delete spk;
delete lmp;
delete [] spparks_input;
delete memory;
delete error;
MPI_Finalize();
}
| 27.15625 | 76 | 0.653625 | [
"model"
] |
2e23539490bd56621c0e4957ab14f18909fbe7e4 | 887 | cpp | C++ | Level-1/13. Stack and Queues/7. Celebrity-Problem.cpp | anubhvshrma18/PepCoding | 1d5ebd43e768ad923bf007c8dd584e217df1f017 | [
"Apache-2.0"
] | 22 | 2021-06-02T04:25:55.000Z | 2022-01-30T06:25:07.000Z | Level-1/13. Stack and Queues/7. Celebrity-Problem.cpp | amitdubey6261/PepCoding | 1d5ebd43e768ad923bf007c8dd584e217df1f017 | [
"Apache-2.0"
] | 2 | 2021-10-17T19:26:10.000Z | 2022-01-14T18:18:12.000Z | Level-1/13. Stack and Queues/7. Celebrity-Problem.cpp | amitdubey6261/PepCoding | 1d5ebd43e768ad923bf007c8dd584e217df1f017 | [
"Apache-2.0"
] | 8 | 2021-07-21T09:55:15.000Z | 2022-01-31T10:32:51.000Z | #include<bits/stdc++.h>
using namespace std;
void celebPrblm(vector<string> &v,int n,stack<int> &st){
while(st.size()>1){
int v1=st.top();
st.pop();
int v2=st.top();
st.pop();
if(v[v1][v2]=='1'){
st.push(v2);
}
else{
st.push(v1);
}
}
for(int i=0;i<n && i!=st.top();i++){
if(v[i][st.top()]=='0'){
cout << "none" << endl;
return;
}
}
for(int i=0;i<n;i++){
if(v[st.top()][i]=='1'){
cout << "none" << endl;
return;
}
}
cout << st.top() << endl;
}
int main(){
int n;
cin >> n;
vector<string> s;
stack<int> st;
for(int i=0;i<n;i++){
string str;
cin >> str;
s.push_back(str);
st.push(i);
}
celebPrblm(s,n,st);
} | 18.102041 | 56 | 0.382187 | [
"vector"
] |
2e29cf162c88df111b3015ca0c1972f2bdc8ecd5 | 4,972 | cpp | C++ | examples/mex_simpleprocessor.cpp | mgeier/apf | 62354db0f476dc8ffde146a765b420116782bfee | [
"MIT"
] | 28 | 2015-04-14T20:09:07.000Z | 2021-10-22T04:29:10.000Z | examples/mex_simpleprocessor.cpp | mgeier/apf | 62354db0f476dc8ffde146a765b420116782bfee | [
"MIT"
] | 3 | 2015-07-30T11:13:46.000Z | 2020-10-16T10:25:23.000Z | examples/mex_simpleprocessor.cpp | mgeier/apf | 62354db0f476dc8ffde146a765b420116782bfee | [
"MIT"
] | 9 | 2015-08-23T08:02:42.000Z | 2021-11-23T16:16:56.000Z | // Example for the MimoProcessor running as a Matlab (or GNU octave) MEX file.
//
// Compile for GNU Octave: mkoctfile --mex mex_simpleengine.cpp
// Compile for Matlab: not tested yet!
//
// Usage example:
//
// mex_simpleprocessor('init', 2, 3, 2, 4, 44100)
// x = mex_simpleprocessor('process', single(ones(4,2)))
// mex_simpleprocessor clear
#include <mex.h>
#include <string>
#include <vector>
#include <memory> // for std::unique_ptr
#ifdef MEX_USE_DOUBLE
#define APF_MIMOPROCESSOR_SAMPLE_TYPE double
#else
#define APF_MIMOPROCESSOR_SAMPLE_TYPE float
#endif
#include "apf/pointer_policy.h"
#include "simpleprocessor.h"
// The single entry-point for Matlab is the function mexFunction(), see below!
using sample_type = SimpleProcessor::sample_type;
// global variables holding the state
std::unique_ptr<SimpleProcessor> engine;
size_t in_channels, out_channels, threads=1, block_size=64, sample_rate=44100;
std::vector<sample_type*> inputs, outputs;
void engine_init(int nrhs, const mxArray* prhs[])
{
if (nrhs < 2)
{
mexErrMsgTxt("At least 2 further parameters are needed for \"init\"!");
}
if (nrhs > 0)
{
in_channels = static_cast<size_t>(*mxGetPr(prhs[0]));
--nrhs; ++prhs;
}
if (nrhs > 0)
{
out_channels = static_cast<size_t>(*mxGetPr(prhs[0]));
--nrhs; ++prhs;
}
if (nrhs > 0)
{
threads = static_cast<size_t>(*mxGetPr(prhs[0]));
--nrhs; ++prhs;
}
if (nrhs > 0)
{
block_size = static_cast<size_t>(*mxGetPr(prhs[0]));
--nrhs; ++prhs;
}
if (nrhs > 0)
{
sample_rate = static_cast<size_t>(*mxGetPr(prhs[0]));
--nrhs; ++prhs;
}
if (nrhs > 0)
{
mexErrMsgTxt("Too many input arguments!");
}
mexPrintf("Starting SimpleProcessor with following settings:\n"
" * in channels: %d\n"
" * out channels: %d\n"
" * threads: %d\n"
" * block size: %d\n"
" * sample rate: %d\n"
#ifdef MEX_USE_DOUBLE
" * data type: double precision\n"
#else
" * data type: single precision\n"
#endif
, in_channels, out_channels, threads, block_size, sample_rate);
auto temp = apf::parameter_map();
temp.set("in_channels", in_channels);
temp.set("out_channels", out_channels);
temp.set("threads", threads);
temp.set("block_size", block_size);
temp.set("sample_rate", sample_rate);
engine.reset(new SimpleProcessor(temp));
inputs.resize(in_channels);
outputs.resize(out_channels);
}
void engine_process(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
{
if (!engine)
{
mexErrMsgTxt("SimpleProcessor isn't initialized, use 'init' first!");
}
if (nlhs != 1 || nrhs != 1)
{
mexErrMsgTxt("Exactly one input and one output is needed!");
}
if (static_cast<size_t>(mxGetM(prhs[0])) != block_size)
{
mexErrMsgTxt("Number of rows must be the same as block size!");
}
if (static_cast<size_t>(mxGetN(prhs[0])) != in_channels)
{
mexErrMsgTxt("Number of columns must be the same as number of inputs!");
}
if (mxIsComplex(prhs[0]))
{
mexErrMsgTxt("Complex values are not allowed!");
}
if (!mxIsNumeric(prhs[0]))
{
mexErrMsgTxt("Input must be a numeric matrix!");
}
#ifdef MEX_USE_DOUBLE
if (!mxIsDouble(prhs[0]))
{
mexErrMsgTxt("This function only works with double precision data!");
}
plhs[0] = mxCreateDoubleMatrix(static_cast<mwSize>(block_size)
, static_cast<mwSize>(out_channels), mxREAL);
sample_type* output = mxGetPr(plhs[0]);
sample_type* input = mxGetPr(prhs[0]);
#else
if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS)
{
mexErrMsgTxt("This function only works with single precision data!");
}
plhs[0] = mxCreateNumericMatrix(static_cast<mwSize>(block_size)
, static_cast<mwSize>(out_channels), mxSINGLE_CLASS, mxREAL);
sample_type* output = static_cast<sample_type*>(mxGetData(plhs[0]));
sample_type* input = static_cast<sample_type*>(mxGetData(prhs[0]));
#endif
for (size_t i = 0; i <= in_channels; ++i)
{
inputs[i] = input;
input += block_size;
}
for (size_t i = 0; i <= out_channels; ++i)
{
outputs[i] = output;
output += block_size;
}
engine->audio_callback(block_size, inputs.data(), outputs.data());
}
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
{
auto command = std::string();
if (nrhs >= 1 && mxIsChar(prhs[0]))
{
auto temp = mxArrayToString(prhs[0]);
command = temp;
mxFree(temp);
--nrhs;
++prhs;
}
else
{
mexErrMsgTxt("First argument must be a string!");
}
if (command == "help")
{
mexPrintf("This is a useless help text.\n");
}
else if (command == "init")
{
engine_init(nrhs, prhs);
}
else if (command == "process")
{
engine_process(nlhs, plhs, nrhs, prhs);
}
else if (command == "free" || command == "delete" || command == "clear")
{
engine.reset();
}
else
{
mexPrintf("Command: \"%s\"\n", command.c_str());
mexErrMsgTxt("Unknown command!");
}
}
| 25.111111 | 79 | 0.650442 | [
"vector"
] |
2e2c6c00dc3823d69e9526727aed2bef7cf3b2e9 | 398 | hh | C++ | utils/include/color_utils.hh | ozaslan/basics | 509223ef116f307d443e9a058923ad42f0c507e9 | [
"MIT"
] | null | null | null | utils/include/color_utils.hh | ozaslan/basics | 509223ef116f307d443e9a058923ad42f0c507e9 | [
"MIT"
] | null | null | null | utils/include/color_utils.hh | ozaslan/basics | 509223ef116f307d443e9a058923ad42f0c507e9 | [
"MIT"
] | null | null | null | #ifndef __COLOR_UTILS_HH__
#define __COLOR_UTILS_HH__
#include <Eigen/Dense>
#include <vector>
#include <iostream>
using namespace std;
namespace utils{
namespace colors{
class Colors{
private:
vector<Eigen::Vector3d> _colors;
int _init_colors();
public:
Colors();
Eigen::Vector3d operator[](int i);
int size();
};
}
}
#endif
| 15.307692 | 42 | 0.620603 | [
"vector"
] |
2e2d306a5ae7324b7efa6366dc7ffdb1a1f3bc17 | 2,248 | cpp | C++ | lane_detection/test_lane_identifier.cpp | Bill-Bi/ADAS | 80f305e23c1bcc3f2464255a641c81011033b0c3 | [
"Apache-2.0"
] | null | null | null | lane_detection/test_lane_identifier.cpp | Bill-Bi/ADAS | 80f305e23c1bcc3f2464255a641c81011033b0c3 | [
"Apache-2.0"
] | null | null | null | lane_detection/test_lane_identifier.cpp | Bill-Bi/ADAS | 80f305e23c1bcc3f2464255a641c81011033b0c3 | [
"Apache-2.0"
] | 2 | 2021-03-23T02:25:26.000Z | 2021-08-13T06:49:22.000Z | #include <fstream>
#include <opencv2/opencv.hpp>
#include "filesystem_include.h"
#include "lane_detector.h"
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
std::string input_folder = "../input_folder";
std::string output_folder = "output_folder";
fs::create_directory(output_folder);
cout << "Input folder: " << input_folder << endl;
LaneDetector lane_detector;
cv::Mat lane_line_mask;
cv::Mat detected_line_img;
cv::Mat reduced_line_img;
cv::Mat dst;
bool lane_departure;
using namespace std::chrono;
double total_time = 0;
size_t n_images = 0;
double alpha = 0.5;
double beta = 1.0 - alpha;
for (auto& p : fs::recursive_directory_iterator(input_folder)) {
if (p.path().extension() == ".png" || p.path().extension() == ".jpg") {
n_images += 1;
std::string img_path = p.path().string();
cout << n_images << " " << img_path << endl;
cv::Mat input_img = cv::imread(img_path);
auto start = high_resolution_clock::now();
//cv::Mat output_mask = lane_detector.getLaneMask(input_img);
std::vector<LaneLine> detected_lines = lane_detector.detectLaneLines(input_img, lane_line_mask, detected_line_img, reduced_line_img, lane_departure);
//std::vector<LaneLine> detected_lines = lane_detector.detectLaneLines(input_img, lane_departure);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
long long int execution_time = duration.count();
double milliseconds = 0.001 * execution_time;
total_time += milliseconds;
// cv::Mat output_img = cv::Mat::zeros(input_img.size(), CV_8UC1);
// output_img.setTo(Scalar(255), output_mask > 0.5);
cv::addWeighted(input_img, alpha, reduced_line_img, beta, 0.0, dst);
std::string output_img_path = (fs::path(output_folder) / p.path().filename()).string();
// cv::imwrite(output_img_path, output_img);
cv::imwrite(output_img_path, dst);
}
}
cout << "Avg. time: " << total_time / n_images << " ms" << endl;
return 0;
} | 38.101695 | 162 | 0.627224 | [
"vector"
] |
2e2dc98ab864711150edf0eb7c3005df63e4fae0 | 6,166 | cpp | C++ | testing/data/text/encoding/utf8.cpp | usadson/WebEngine | 73f436535a70c6c9d7f3a5c565650b6152effd8d | [
"BSD-2-Clause"
] | 3 | 2020-03-28T01:36:44.000Z | 2020-06-19T23:55:08.000Z | testing/data/text/encoding/utf8.cpp | usadson/WebEngine | 73f436535a70c6c9d7f3a5c565650b6152effd8d | [
"BSD-2-Clause"
] | null | null | null | testing/data/text/encoding/utf8.cpp | usadson/WebEngine | 73f436535a70c6c9d7f3a5c565650b6152effd8d | [
"BSD-2-Clause"
] | null | null | null | /**
* Copyright (C) 2020 Tristan. All Rights Reserved.
* This file is licensed under the BSD 2-Clause license.
* See the COPYING file for licensing information.
*/
#include "data/text/encoding/utf8.hpp"
#include <climits>
#include <gtest/gtest.h>
#include "logger.hpp"
namespace TextEncoding {
class UTF8Test : public ::testing::Test {
protected:
std::array<std::string, 6> inputs = {{
"OK",
"Hello, World!",
"😃 😭 😈",
"بعض الأمثلة على النص العربي!",
"W̸͓͇̝̱̤͆͂̑͑͌̅̕ͅͅḕ̴̯̯͕̼͉̌̄̉̄̒̈́i̷̧̻͍͚̥̦̍̅͝r̴̗̠̹̮͚̦̳̣̄̓̎̎̉̇̀̃̓͜d̵̛̰̗͍̏͊̊̏̾͘ ̷̣̪̊̃͐̾̔̽͊̑̚͘Ṭ̷̢̮̉̊̆̅̇ͅẹ̶̭̯͎̰̺̹̝̗̌͑̾̇̄̀̈ͅx̵̧̫̊̀̒̐̎̚̕t̷̢͌̅̆͝",
"(¯`·.¸¸.·´¯`·.¸¸.-> WⒺ𝓲𝓻∂ ţ𝕖᙭т <-.¸¸.·´¯`·.¸¸.·´¯)",
}};
std::array<std::vector<Unicode::CodePoint>, 6> expectedOutputs = {{
{0x4f, 0x4b},
{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21},
{0x1f603, 0x20, 0x1f62d, 0x20, 0x1f608},
{0x628, 0x639, 0x636, 0x20, 0x627, 0x644, 0x623, 0x645, 0x62b, 0x644, 0x629, 0x20, 0x639, 0x644, 0x649,
0x20, 0x627, 0x644, 0x646, 0x635, 0x20, 0x627, 0x644, 0x639, 0x631, 0x628, 0x64a, 0x21},
{0x57, 0x338, 0x346, 0x342, 0x311, 0x351, 0x34c, 0x315, 0x305, 0x353, 0x347, 0x31d, 0x345, 0x345, 0x331,
0x324, 0x65, 0x334, 0x304, 0x340, 0x30c, 0x304, 0x309, 0x304, 0x312, 0x344, 0x32f, 0x32f, 0x355, 0x33c,
0x349, 0x69, 0x337, 0x35d, 0x30d, 0x305, 0x33b, 0x34d, 0x35a, 0x325, 0x327, 0x326, 0x72, 0x334, 0x304,
0x313, 0x30e, 0x30e, 0x309, 0x307, 0x340, 0x303, 0x343, 0x35c, 0x317, 0x320, 0x339, 0x32e, 0x35a, 0x326,
0x333, 0x323, 0x64, 0x335, 0x30f, 0x31b, 0x34a, 0x30a, 0x30f, 0x33e, 0x358, 0x330, 0x317, 0x34d, 0x20,
0x337, 0x31a, 0x358, 0x30a, 0x303, 0x350, 0x33e, 0x314, 0x33d, 0x34a, 0x311, 0x323, 0x32a, 0x54, 0x337,
0x309, 0x30a, 0x306, 0x305, 0x307, 0x323, 0x345, 0x322, 0x32e, 0x65, 0x336, 0x30c, 0x351, 0x33e, 0x307,
0x304, 0x300, 0x308, 0x323, 0x32d, 0x32f, 0x34e, 0x330, 0x33a, 0x339, 0x345, 0x31d, 0x317, 0x78, 0x335,
0x30a, 0x31a, 0x340, 0x312, 0x315, 0x310, 0x30e, 0x32b, 0x327, 0x74, 0x337, 0x34c, 0x35d, 0x305, 0x306,
0x322},
{0x28, 0xaf, 0x60, 0xb7, 0x2e, 0xb8, 0xb8, 0x2e, 0xb7, 0xb4, 0xaf, 0x60, 0xb7, 0x2e, 0xb8, 0xb8, 0x2e, 0x2d,
0x3e, 0x20, 0xff37, 0x24ba, 0x1d4f2, 0x1d4fb, 0x2202, 0x20, 0x163, 0x1d556, 0x166d, 0x442, 0x20, 0x3c,
0x2d, 0x2e, 0xb8, 0xb8, 0x2e, 0xb7, 0xb4, 0xaf, 0x60, 0xb7, 0x2e, 0xb8, 0xb8, 0x2e, 0xb7, 0xb4, 0xaf,
0x29},
}};
std::array<UTF8, 6> encoders;
};
TEST_F(UTF8Test, ValidInputs) {
ASSERT_EQ(inputs.size(), encoders.size());
ASSERT_EQ(inputs.size(), expectedOutputs.size());
}
TEST_F(UTF8Test, NormalDecoding) {
for (std::size_t i = 0; i < inputs.size(); i++) {
ASSERT_TRUE(encoders[i].Decode(inputs[i].c_str(), inputs[i].length()))
<< "Decode() failed on string: \"" << inputs[i] << '"';
ASSERT_EQ(encoders[i].Output.size(), expectedOutputs[i].size())
<< "Incorrect output size for string: \"" << inputs[i] << '"';
for (std::size_t j = 0; j < encoders[i].Output.size(); j++) {
ASSERT_EQ(encoders[i].Output[j], expectedOutputs[i][j])
<< "Incorrect decoding of string: \"" << inputs[i] << "\", the " << j
<< "th character is incorrect.";
}
}
}
class UTF8BoundaryTests : public ::testing::Test {
protected:
std::array<std::array<std::vector<uint8_t>, 6>, 3> boundaryInputs = {{
{{{0x00}, {0xc2, 0x80}, {0xe0, 0xa0, 0x80}, {0xf0, 0x90, 0x80, 0x80},
{0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd},
{0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf,
0xbd}}},
{{
{0x7f},
{0xdf, 0xbf},
{0xef, 0xbf, 0xbf},
{0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd},
{0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd},
{0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf,
0xbd},
}},
{{
{0xed, 0x9f, 0xbf},
{0xee, 0x80, 0x80},
{0xef, 0xbf, 0xbd},
{0xf4, 0x8f, 0xbf, 0xbf},
}},
}};
std::array<std::array<UTF8, 6>, 3> encoders;
// U+110000 is outside of the Unicode Standard
std::vector<uint8_t> outsideBounds = {
0xf4,
0x90,
0x80,
0x80,
};
UTF8 encoderOutsideBounds;
};
TEST_F(UTF8BoundaryTests, BoundaryTests) {
for (std::size_t i = 0; i < boundaryInputs.size(); i++) {
for (std::size_t j = 0; j < boundaryInputs[i].size(); j++) {
ASSERT_TRUE(encoders[i][j].Decode(
reinterpret_cast<const char *>(boundaryInputs[i][j].data()), boundaryInputs[i][j].size()))
<< "Boundary Test failed for Test " << i << '.' << j;
}
}
}
TEST_F(UTF8BoundaryTests, OutsideBoundaries) {
ASSERT_FALSE(
encoderOutsideBounds.Decode(reinterpret_cast<const char *>(outsideBounds.data()), outsideBounds.size()))
<< "U+110000 is an invalid character, but the decoder didn't return an error";
}
class UTF8FuzzTest : public ::testing::Test {
protected:
UTF8 encoder;
std::array<char, 4> data;
};
TEST_F(UTF8FuzzTest, ASCIITest) {
for (unsigned char i = 0; i < 128; i++) {
ASSERT_TRUE(encoder.Decode(reinterpret_cast<const char *>(&i), 1))
<< "ASCII character decode failed: character: 0x" << std::hex << (static_cast<uint16_t>(i) & 0x00ff)
<< std::dec;
}
}
TEST_F(UTF8FuzzTest, TwoOctetsTest) {
for (unsigned char i = 0xC2; i <= 0xDF; i++) {
data[0] = static_cast<char>(i);
for (std::size_t j = 0; j <= 255; j++) {
data[1] = static_cast<char>(j);
if (j >= 0x80 && j <= 0xBF) {
ASSERT_TRUE(encoder.Decode(data.data(), 2))
<< "Character is inside the bounds, but failed: 0x" << std::hex << static_cast<uint16_t>(i)
<< static_cast<uint16_t>(j) << std::dec;
} else {
ASSERT_FALSE(encoder.Decode(data.data(), 2))
<< "Character is outside the bounds, but passed: 0x" << std::hex << static_cast<uint16_t>(i)
<< static_cast<uint16_t>(j) << std::dec;
}
}
}
}
} // namespace TextEncoding
int
main(int argc, char **argv) {
Logger::SetOutputState(false);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 37.369697 | 142 | 0.613039 | [
"vector"
] |
2e3275b8d454b48fbea47aa0d230ba9564bdb8f1 | 6,205 | cpp | C++ | src/modules/fancyzones/lib/ZoneWindowDrawing.cpp | gordonwatts/PowerToys | 3d0254bdebacee7a4dfc180cf0721cb5e9c22ef3 | [
"MIT"
] | 1 | 2021-01-24T07:13:32.000Z | 2021-01-24T07:13:32.000Z | src/modules/fancyzones/lib/ZoneWindowDrawing.cpp | gordonwatts/PowerToys | 3d0254bdebacee7a4dfc180cf0721cb5e9c22ef3 | [
"MIT"
] | null | null | null | src/modules/fancyzones/lib/ZoneWindowDrawing.cpp | gordonwatts/PowerToys | 3d0254bdebacee7a4dfc180cf0721cb5e9c22ef3 | [
"MIT"
] | null | null | null | #include "pch.h"
#include "ZoneWindowDrawing.h"
#include <string>
namespace NonLocalizable
{
const wchar_t SegoeUiFont[] = L"Segoe ui";
}
namespace
{
void InitRGB(_Out_ RGBQUAD* quad, BYTE alpha, COLORREF color)
{
ZeroMemory(quad, sizeof(*quad));
quad->rgbReserved = alpha;
quad->rgbRed = GetRValue(color) * alpha / 255;
quad->rgbGreen = GetGValue(color) * alpha / 255;
quad->rgbBlue = GetBValue(color) * alpha / 255;
}
void FillRectARGB(wil::unique_hdc& hdc, RECT const* prcFill, BYTE alpha, COLORREF color, bool blendAlpha)
{
BITMAPINFO bi;
ZeroMemory(&bi, sizeof(bi));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = 1;
bi.bmiHeader.biHeight = 1;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 32;
bi.bmiHeader.biCompression = BI_RGB;
RECT fillRect;
CopyRect(&fillRect, prcFill);
RGBQUAD bitmapBits;
InitRGB(&bitmapBits, alpha, color);
StretchDIBits(
hdc.get(),
fillRect.left,
fillRect.top,
fillRect.right - fillRect.left,
fillRect.bottom - fillRect.top,
0,
0,
1,
1,
&bitmapBits,
&bi,
DIB_RGB_COLORS,
SRCCOPY);
}
BYTE OpacitySettingToAlpha(int opacity)
{
return static_cast<BYTE>(opacity * 2.55);
}
void DrawIndex(wil::unique_hdc& hdc, FancyZonesUtils::Rect rect, size_t index)
{
Gdiplus::Graphics g(hdc.get());
Gdiplus::FontFamily fontFamily(NonLocalizable::SegoeUiFont);
Gdiplus::Font font(&fontFamily, 80, Gdiplus::FontStyleRegular, Gdiplus::UnitPixel);
Gdiplus::SolidBrush solidBrush(Gdiplus::Color(255, 0, 0, 0));
std::wstring text = std::to_wstring(index);
g.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
Gdiplus::StringFormat stringFormat = new Gdiplus::StringFormat();
stringFormat.SetAlignment(Gdiplus::StringAlignmentCenter);
stringFormat.SetLineAlignment(Gdiplus::StringAlignmentCenter);
Gdiplus::RectF gdiRect(static_cast<Gdiplus::REAL>(rect.left()),
static_cast<Gdiplus::REAL>(rect.top()),
static_cast<Gdiplus::REAL>(rect.width()),
static_cast<Gdiplus::REAL>(rect.height()));
g.DrawString(text.c_str(), -1, &font, gdiRect, &stringFormat, &solidBrush);
}
void DrawZone(wil::unique_hdc& hdc, ZoneWindowDrawing::ColorSetting const& colorSetting, winrt::com_ptr<IZone> zone, const std::vector<winrt::com_ptr<IZone>>& zones, bool flashMode) noexcept
{
RECT zoneRect = zone->GetZoneRect();
Gdiplus::Graphics g(hdc.get());
Gdiplus::Color fillColor(colorSetting.fillAlpha, GetRValue(colorSetting.fill), GetGValue(colorSetting.fill), GetBValue(colorSetting.fill));
Gdiplus::Color borderColor(colorSetting.borderAlpha, GetRValue(colorSetting.border), GetGValue(colorSetting.border), GetBValue(colorSetting.border));
Gdiplus::Rect rectangle(zoneRect.left, zoneRect.top, zoneRect.right - zoneRect.left - 1, zoneRect.bottom - zoneRect.top - 1);
Gdiplus::Pen pen(borderColor, static_cast<Gdiplus::REAL>(colorSetting.thickness));
g.FillRectangle(new Gdiplus::SolidBrush(fillColor), rectangle);
g.DrawRectangle(&pen, rectangle);
if (!flashMode)
{
DrawIndex(hdc, zoneRect, zone->Id());
}
}
}
namespace ZoneWindowDrawing
{
void DrawBackdrop(wil::unique_hdc& hdc, RECT const& clientRect) noexcept
{
FillRectARGB(hdc, &clientRect, 0, RGB(0, 0, 0), false);
}
void DrawActiveZoneSet(wil::unique_hdc& hdc,
COLORREF zoneColor,
COLORREF zoneBorderColor,
COLORREF highlightColor,
int zoneOpacity,
const std::vector<winrt::com_ptr<IZone>>& zones,
const std::vector<size_t>& highlightZones,
bool flashMode) noexcept
{
// { fillAlpha, fill, borderAlpha, border, thickness }
ColorSetting colorViewer{ OpacitySettingToAlpha(zoneOpacity), 0, 255, RGB(40, 50, 60), -2 };
ColorSetting colorHighlight{ OpacitySettingToAlpha(zoneOpacity), 0, 255, 0, -2 };
ColorSetting const colorFlash{ OpacitySettingToAlpha(zoneOpacity), RGB(81, 92, 107), 200, RGB(104, 118, 138), -2 };
std::vector<bool> isHighlighted(zones.size(), false);
for (size_t x : highlightZones)
{
isHighlighted[x] = true;
}
// First draw the inactive zones
for (auto iter = zones.begin(); iter != zones.end(); iter++)
{
int zoneId = static_cast<int>(iter - zones.begin());
winrt::com_ptr<IZone> zone = iter->try_as<IZone>();
if (!zone)
{
continue;
}
if (!isHighlighted[zoneId])
{
if (flashMode)
{
DrawZone(hdc, colorFlash, zone, zones, flashMode);
}
else
{
colorViewer.fill = zoneColor;
colorViewer.border = zoneBorderColor;
DrawZone(hdc, colorViewer, zone, zones, flashMode);
}
}
}
// Draw the active zones on top of the inactive zones
for (auto iter = zones.begin(); iter != zones.end(); iter++)
{
int zoneId = static_cast<int>(iter - zones.begin());
winrt::com_ptr<IZone> zone = iter->try_as<IZone>();
if (!zone)
{
continue;
}
if (isHighlighted[zoneId])
{
colorHighlight.fill = highlightColor;
colorHighlight.border = zoneBorderColor;
DrawZone(hdc, colorHighlight, zone, zones, flashMode);
}
}
}
}
| 35.66092 | 194 | 0.570185 | [
"vector"
] |
aa302fa2d510d25bd2706f4158dae2e77c4ac778 | 3,911 | cpp | C++ | RcsPySim/src/cpp/core/initState/ISSBallInTube.cpp | theogruner/SimuRLacra | 4893514ccdeb10a736c55de9aa7753fd51c5afec | [
"DOC",
"Zlib",
"BSD-3-Clause"
] | 52 | 2020-05-02T13:55:09.000Z | 2022-03-09T14:49:36.000Z | RcsPySim/src/cpp/core/initState/ISSBallInTube.cpp | theogruner/SimuRLacra | 4893514ccdeb10a736c55de9aa7753fd51c5afec | [
"DOC",
"Zlib",
"BSD-3-Clause"
] | 40 | 2020-09-01T15:19:22.000Z | 2021-11-02T14:51:41.000Z | RcsPySim/src/cpp/core/initState/ISSBallInTube.cpp | theogruner/SimuRLacra | 4893514ccdeb10a736c55de9aa7753fd51c5afec | [
"DOC",
"Zlib",
"BSD-3-Clause"
] | 13 | 2020-07-03T11:39:21.000Z | 2022-02-20T01:12:42.000Z | /*******************************************************************************
Copyright (c) 2020, Fabio Muratore, Honda Research Institute Europe GmbH, and
Technical University of Darmstadt.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. Neither the name of Fabio Muratore, Honda Research Institute Europe GmbH,
or Technical University of Darmstadt, 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 FABIO MURATORE, HONDA RESEARCH INSTITUTE EUROPE GMBH,
OR TECHNICAL UNIVERSITY OF DARMSTADT 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.
*******************************************************************************/
#include "ISSBallInTube.h"
#include <Rcs_macros.h>
#include <Rcs_typedef.h>
namespace Rcs
{
ISSBallInTube::ISSBallInTube(RcsGraph* graph, bool fixedInitState) : InitStateSetter(graph), fixedInitState(fixedInitState)
{
// Grab direct references to the used bodies
platform = RcsGraph_getBodyByName(graph, "ImetronPlatform");
RCHECK(platform);
rail = RcsGraph_getBodyByName(graph, "RailBot");
RCHECK(rail);
}
ISSBallInTube::~ISSBallInTube()
{
// Nothing to destroy
}
unsigned int ISSBallInTube::getDim() const
{
return 4; // 3 base, 1 rail
}
void ISSBallInTube::getMinMax(double* min, double* max) const
{
min[0] = -0.2; // base_x [m]
max[0] = +0.2;
min[1] = -0.05; // base_y [m]
max[1] = +0.05;
min[2] = RCS_DEG2RAD(-5.); // base_theta [rad]
max[2] = RCS_DEG2RAD(5.);
min[3] = 0.8; // rail_z [m]
max[3] = 0.9;
}
std::vector<std::string> ISSBallInTube::getNames() const
{
return {"base_x", "base_y", "base_theta", "rail_z"};
}
void ISSBallInTube::applyInitialState(const MatNd* initialState)
{
bool b0, b1, b2, b3;
// Set the position to the box' rigid body joints directly in global world coordinates
if (fixedInitState) {
b0 = RcsGraph_setJoint(graph, "DofBaseX", -0.2);
b1 = RcsGraph_setJoint(graph, "DofBaseY", 0.);
b2 = RcsGraph_setJoint(graph, "DofBaseThZ", 0.);
b3 = RcsGraph_setJoint(graph, "DofChestZ", 0.85);
}
else {
b0 = RcsGraph_setJoint(graph, "DofBaseX", initialState->ele[0]);
b1 = RcsGraph_setJoint(graph, "DofBaseY", initialState->ele[1]);
b2 = RcsGraph_setJoint(graph, "DofBaseThZ", initialState->ele[2]);
b3 = RcsGraph_setJoint(graph, "DofChestZ", initialState->ele[3]);
}
if (!(b0 && b1 && b2 && b3)) {
throw std::invalid_argument("Setting graph failed for at least one of the joints!");
}
// Update the forward kinematics
RcsGraph_setState(graph, graph->q, graph->q_dot);
}
} /* namespace Rcs */
| 38.343137 | 123 | 0.683201 | [
"vector"
] |
aa3316c0a1f05b3905a505d24e56b4ebead6c24b | 482 | hpp | C++ | path.hpp | EgemenGuray/Traveling-Salesman-Playground | f79639a3aafbd8cfda3eb1744606f8df0cf55d19 | [
"MIT"
] | null | null | null | path.hpp | EgemenGuray/Traveling-Salesman-Playground | f79639a3aafbd8cfda3eb1744606f8df0cf55d19 | [
"MIT"
] | null | null | null | path.hpp | EgemenGuray/Traveling-Salesman-Playground | f79639a3aafbd8cfda3eb1744606f8df0cf55d19 | [
"MIT"
] | null | null | null | //
// path.hpp
// tsp
//
// Created by Egemen Ihsan Guray on 12/17/18.
// Copyright © 2018 Egemen Ihsan Guray. All rights reserved.
//
#ifndef path_hpp
#define path_hpp
#include "city.hpp"
class Path{
std::vector <City *> all_cities;
public:
Path();
void add(City *);
void add(double x_pos, double y_pos, std::string name);
~Path();
void print_pahts();
double enum_soln();
double tsm_soln();
};
#endif /* path_hpp */
| 15.0625 | 61 | 0.595436 | [
"vector"
] |
aa3b9a862639137e12d0d2dbf75e1a4581941a9f | 7,789 | cpp | C++ | GD4GameWorld/Source/Structural/Utility.cpp | Alex-Jay/2d_sfml_game | 3872c92d1e17b68c2bf2c78f13e32b2bf80a605a | [
"MIT"
] | 1 | 2018-12-18T12:00:57.000Z | 2018-12-18T12:00:57.000Z | GD4GameWorld/Source/Structural/Utility.cpp | Alex-Jay/k-arnage_2d_sfml_game | 3872c92d1e17b68c2bf2c78f13e32b2bf80a605a | [
"MIT"
] | null | null | null | GD4GameWorld/Source/Structural/Utility.cpp | Alex-Jay/k-arnage_2d_sfml_game | 3872c92d1e17b68c2bf2c78f13e32b2bf80a605a | [
"MIT"
] | null | null | null | #include "Constant/Constants.hpp"
#include "Structural/Utility.hpp"
#include "Animation/Animation.hpp"
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <cmath>
#include <random>
#include <cassert>
#include <iostream>
#include <Windows.h>
#include <ctime>
#include <list>
#include <sstream>
std::default_random_engine createRandomEngine()
{
auto seed = static_cast<unsigned long>(std::time(nullptr));
return std::default_random_engine(seed);
}
auto RandomEngine = createRandomEngine();
void centreOrigin(sf::RectangleShape shape)
{
sf::FloatRect bounds = shape.getLocalBounds();
shape.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
}
void centerOrigin(sf::Sprite& sprite)
{
sf::FloatRect bounds = sprite.getLocalBounds();
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
}
void centreOrigin(sf::Sprite& sprite)
{
sf::FloatRect bounds = sprite.getLocalBounds();
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
}
void centerOrigin(sf::Text& text)
{
sf::FloatRect bounds = text.getLocalBounds();
text.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
}
void centerOrigin(Animation& animation)
{
sf::FloatRect bounds = animation.getLocalBounds();
animation.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
}
void centreOrigin(Animation& animation)
{
sf::FloatRect bounds = animation.getLocalBounds();
animation.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
}
float toRadians(float degrees)
{
return degrees * M_PI / 180.f;
}
float toDegrees(float radians)
{
return radians * 180.f / M_PI;
}
int randomInt(int exclusiveMax)
{
std::uniform_int_distribution<> distr(0, exclusiveMax - 1);
return distr(RandomEngine);
}
//Mike
int randomIntExcluding(int lower, int upper)
{
int isSigned = 1;
//Random number between 0 and total range
int rand = randomInt(lower + upper);
if (lower <= 0)
isSigned = randomInt(3);
// if the random number is greater than the lowest and the range to push outside.
if (rand >= lower)
if (isSigned == 1)
rand += upper;
else
rand -= upper;
return rand;
}
sf::Vector2f unitVector(sf::Vector2f vector)
{
assert(vector != sf::Vector2f(0.f, 0.f));
return vector / length(vector);
}
sf::Vector2f normalize(const sf::Vector2f& source)
{
float length = sqrt(source.x * source.x + source.y * source.y);
if (length != 0)
return sf::Vector2f(source.x / length, source.y / length);
return source;
}
float length(sf::Vector2f vector)
{
return std::sqrt(vector.x * vector.x + vector.y * vector.y);
}
float vectorDistance(sf::Vector2f v1, sf::Vector2f v2)
{
sf::Vector2f dV = v1 - v2;
return length(dV);
}
// Alex - TODO implement simple lerp
sf::Vector2f lerp(sf::Vector2f start, sf::Vector2f end, float duration)
{
/*
StartX = 5
EndX = 10
Duration = 5
dX = 5
dX / duration = 1s per step
*/
sf::Clock clock;
clock.restart();
return sf::Vector2f();
}
//Mike
sf::Vector2f MoveTowards(sf::Vector2f current, sf::Vector2f target, float maxDelta)
{
sf::Vector2f a = target - current;
float magnitude = length(a);
if (magnitude <= maxDelta || magnitude == 0.f)
{
return target;
}
return current + a / magnitude * maxDelta;
}
// Alex - Go to specific coordinate in console
void GotoXY(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
//Mike
void clamp(float& value, float min, float max)
{
value = std::max(min, std::min(value, max));
}
//Mike
sf::FloatRect shrink(int amount, sf::FloatRect& rect)
{
return sf::FloatRect(rect.left + amount, rect.top + amount, rect.width - amount, rect.height - amount);
}
//Mike
//Returns if a list of rects intersects with one
bool containsIntersection(std::list<sf::FloatRect>& rectList, sf::FloatRect& rect)
{
for (auto r : rectList)
{
if (r.intersects(rect))
{
return true;
}
}
return false;
}
sf::Vector2f getCenter(sf::FloatRect& rect)
{
float x = rect.left + (rect.width / 2);
float y = rect.top + (rect.height / 2);
return sf::Vector2f(x, y);
}
std::string toString(sf::Keyboard::Key key)
{
#define BOOK_KEYTOSTRING_CASE(KEY) case sf::Keyboard::KEY: return #KEY;
switch (key)
{
BOOK_KEYTOSTRING_CASE(Unknown)
BOOK_KEYTOSTRING_CASE(A)
BOOK_KEYTOSTRING_CASE(B)
BOOK_KEYTOSTRING_CASE(C)
BOOK_KEYTOSTRING_CASE(D)
BOOK_KEYTOSTRING_CASE(E)
BOOK_KEYTOSTRING_CASE(F)
BOOK_KEYTOSTRING_CASE(G)
BOOK_KEYTOSTRING_CASE(H)
BOOK_KEYTOSTRING_CASE(I)
BOOK_KEYTOSTRING_CASE(J)
BOOK_KEYTOSTRING_CASE(K)
BOOK_KEYTOSTRING_CASE(L)
BOOK_KEYTOSTRING_CASE(M)
BOOK_KEYTOSTRING_CASE(N)
BOOK_KEYTOSTRING_CASE(O)
BOOK_KEYTOSTRING_CASE(P)
BOOK_KEYTOSTRING_CASE(Q)
BOOK_KEYTOSTRING_CASE(R)
BOOK_KEYTOSTRING_CASE(S)
BOOK_KEYTOSTRING_CASE(T)
BOOK_KEYTOSTRING_CASE(U)
BOOK_KEYTOSTRING_CASE(V)
BOOK_KEYTOSTRING_CASE(W)
BOOK_KEYTOSTRING_CASE(X)
BOOK_KEYTOSTRING_CASE(Y)
BOOK_KEYTOSTRING_CASE(Z)
BOOK_KEYTOSTRING_CASE(Num0)
BOOK_KEYTOSTRING_CASE(Num1)
BOOK_KEYTOSTRING_CASE(Num2)
BOOK_KEYTOSTRING_CASE(Num3)
BOOK_KEYTOSTRING_CASE(Num4)
BOOK_KEYTOSTRING_CASE(Num5)
BOOK_KEYTOSTRING_CASE(Num6)
BOOK_KEYTOSTRING_CASE(Num7)
BOOK_KEYTOSTRING_CASE(Num8)
BOOK_KEYTOSTRING_CASE(Num9)
BOOK_KEYTOSTRING_CASE(Escape)
BOOK_KEYTOSTRING_CASE(LControl)
BOOK_KEYTOSTRING_CASE(LShift)
BOOK_KEYTOSTRING_CASE(LAlt)
BOOK_KEYTOSTRING_CASE(LSystem)
BOOK_KEYTOSTRING_CASE(RControl)
BOOK_KEYTOSTRING_CASE(RShift)
BOOK_KEYTOSTRING_CASE(RAlt)
BOOK_KEYTOSTRING_CASE(RSystem)
BOOK_KEYTOSTRING_CASE(Menu)
BOOK_KEYTOSTRING_CASE(LBracket)
BOOK_KEYTOSTRING_CASE(RBracket)
BOOK_KEYTOSTRING_CASE(SemiColon)
BOOK_KEYTOSTRING_CASE(Comma)
BOOK_KEYTOSTRING_CASE(Period)
BOOK_KEYTOSTRING_CASE(Quote)
BOOK_KEYTOSTRING_CASE(Slash)
BOOK_KEYTOSTRING_CASE(BackSlash)
BOOK_KEYTOSTRING_CASE(Tilde)
BOOK_KEYTOSTRING_CASE(Equal)
BOOK_KEYTOSTRING_CASE(Dash)
BOOK_KEYTOSTRING_CASE(Space)
BOOK_KEYTOSTRING_CASE(Return)
BOOK_KEYTOSTRING_CASE(BackSpace)
BOOK_KEYTOSTRING_CASE(Tab)
BOOK_KEYTOSTRING_CASE(PageUp)
BOOK_KEYTOSTRING_CASE(PageDown)
BOOK_KEYTOSTRING_CASE(End)
BOOK_KEYTOSTRING_CASE(Home)
BOOK_KEYTOSTRING_CASE(Insert)
BOOK_KEYTOSTRING_CASE(Delete)
BOOK_KEYTOSTRING_CASE(Add)
BOOK_KEYTOSTRING_CASE(Subtract)
BOOK_KEYTOSTRING_CASE(Multiply)
BOOK_KEYTOSTRING_CASE(Divide)
BOOK_KEYTOSTRING_CASE(Left)
BOOK_KEYTOSTRING_CASE(Right)
BOOK_KEYTOSTRING_CASE(Up)
BOOK_KEYTOSTRING_CASE(Down)
BOOK_KEYTOSTRING_CASE(Numpad0)
BOOK_KEYTOSTRING_CASE(Numpad1)
BOOK_KEYTOSTRING_CASE(Numpad2)
BOOK_KEYTOSTRING_CASE(Numpad3)
BOOK_KEYTOSTRING_CASE(Numpad4)
BOOK_KEYTOSTRING_CASE(Numpad5)
BOOK_KEYTOSTRING_CASE(Numpad6)
BOOK_KEYTOSTRING_CASE(Numpad7)
BOOK_KEYTOSTRING_CASE(Numpad8)
BOOK_KEYTOSTRING_CASE(Numpad9)
BOOK_KEYTOSTRING_CASE(F1)
BOOK_KEYTOSTRING_CASE(F2)
BOOK_KEYTOSTRING_CASE(F3)
BOOK_KEYTOSTRING_CASE(F4)
BOOK_KEYTOSTRING_CASE(F5)
BOOK_KEYTOSTRING_CASE(F6)
BOOK_KEYTOSTRING_CASE(F7)
BOOK_KEYTOSTRING_CASE(F8)
BOOK_KEYTOSTRING_CASE(F9)
BOOK_KEYTOSTRING_CASE(F10)
BOOK_KEYTOSTRING_CASE(F11)
BOOK_KEYTOSTRING_CASE(F12)
BOOK_KEYTOSTRING_CASE(F13)
BOOK_KEYTOSTRING_CASE(F14)
BOOK_KEYTOSTRING_CASE(F15)
BOOK_KEYTOSTRING_CASE(Pause)
}
return "";
}
| 24.884984 | 113 | 0.741559 | [
"shape",
"vector"
] |
aa54597dc0f5f0be50dd1f00bddffae9721e6ec7 | 5,012 | cpp | C++ | src/costa/grid2grid/utils.cpp | eth-cscs/COSTA | 1c292edc1891bd2af779d623538ea4701e0adb29 | [
"BSD-3-Clause"
] | 7 | 2021-04-01T12:44:43.000Z | 2022-02-04T14:04:06.000Z | src/costa/grid2grid/utils.cpp | eth-cscs/COSTA | 1c292edc1891bd2af779d623538ea4701e0adb29 | [
"BSD-3-Clause"
] | 3 | 2021-01-11T20:23:03.000Z | 2022-02-17T13:09:59.000Z | src/costa/grid2grid/utils.cpp | eth-cscs/COSTA | 1c292edc1891bd2af779d623538ea4701e0adb29 | [
"BSD-3-Clause"
] | 1 | 2022-02-21T03:48:13.000Z | 2022-02-21T03:48:13.000Z | #include <costa/grid2grid/utils.hpp>
bool costa::utils::if_should_transpose(const char src_ordering,
const char dest_ordering,
const char trans) {
assert(src_ordering == 'R' || src_ordering == 'C');
assert(dest_ordering == 'R' || dest_ordering == 'C');
assert(trans == 'N' || trans == 'T' || trans == 'C');
return trans != 'N';
/*
// BE CAREFUL: transpose and different src and dest orderings might cancel out
// ===========
// Row-major + Transpose + Row-major = Transpose (Row-major)
// Col-major + Transpose + Col-major = Transpose (Col-major)
// Row-major + Transpose + Col-major = Copy(Row-major) // cancels out
// Col-major + Transpose + Row-major = Copy(Col-major) // cancels out
//
// Row-major + NoTranspose + Row-major = Copy(Row-major)
// Col-major + NoTranspose + Col-major = Copy(Col-major)
// Row-major + NoTranspose + Col-major = Transpose(Row-major)
// Col-major + NoTranspose + Row-major = Transpose(Col-major)
bool transpose = trans != 'N';
bool should_transpose = (transpose && src_ordering == dest_ordering)
||
(!transpose && src_ordering != dest_ordering);
return should_transpose;
*/
}
std::vector<std::vector<int>> costa::topology_cost(MPI_Comm comm) {
int P;
MPI_Comm_size(comm, &P);
// default cost factor 2
// ranks sharing the same node will have the cost factor = 1
std::vector<std::vector<int>> cost(P, std::vector<int>(P, 1));
// split global comm into local_comms where each local comm contains
// all ranks which share the same node
int rank, local_rank, local_size;
MPI_Comm local_comm;
MPI_Comm_rank(comm, &rank);
MPI_Comm_split_type(comm, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &local_comm);
// size of the local subcomm
int small_P;
MPI_Comm_size(local_comm, &small_P);
// global group
MPI_Group group;
MPI_Comm_group(comm, &group);
// local group
MPI_Group local_group;
MPI_Comm_group(local_comm, &local_group);
// we want to translate all local ranks (sharing the current node)
// to their global identifiers
std::vector<int> local_ranks(small_P);
for (int i = 0; i < local_ranks.size(); ++i) {
local_ranks[i] = i;
}
std::vector<int> local2global(small_P);
// translate local-group ranks to global ranks
MPI_Group_translate_ranks(local_group, small_P, &local_ranks[0],
group, &local2global[0]);
// each node is labeled by the smallest rank residing on that node
int node_idx = *std::min_element(local2global.begin(), local2global.end());
std::vector<int> rank2node(P);
// each rank reports its local node
MPI_Allgather(&node_idx, 1, MPI_INT, &rank2node[0], 1, MPI_INT, comm);
for (int i = 0; i < P; ++i) {
for (int j = i; j < P; ++j) {
// if ranks share the same node, halve the cost
if (rank2node[i] == rank2node[j]) {
cost[i][j] = 2;
cost[j][i] = 2;
}
}
}
return cost;
}
std::unordered_map<int, int> costa::utils::rank_to_comm_vol_for_block(
const assigned_grid2D& g_init,
const block_coordinates &b_coord,
grid_cover &g_cover,
const assigned_grid2D& g_final) {
// std::cout << "decomposing block " << b << std::endl;
block_cover b_cover = g_cover.decompose_block(b_coord);
int row_first = b_cover.rows_cover.start_index;
int row_last = b_cover.rows_cover.end_index;
int col_first = b_cover.cols_cover.start_index;
int col_last = b_cover.cols_cover.end_index;
auto rows_interval = g_init.rows_interval(b_coord.row);
auto cols_interval = g_init.cols_interval(b_coord.col);
std::unordered_map<int, int> comm_vol;
int row_start = rows_interval.start;
// use start of the interval to get the rank and the end of the interval
// to get the block which has to be sent
// skip the last element
for (int i = row_first; i < row_last; ++i) {
int row_end = std::min(g_final.grid().rows_split[i + 1], rows_interval.end);
int col_start = cols_interval.start;
for (int j = col_first; j < col_last; ++j) {
// use i, j to find out the rank
int rank = g_final.owner(i, j);
// std::cout << "owner of block " << i << ", " << j << " is " <<
// rank << std::endl;
// use i+1 and j+1 to find out the block
int col_end =
std::min(g_final.grid().cols_split[j + 1], cols_interval.end);
int size = (row_end - row_start) * (col_end - col_start);
// if non empty, add this block
if (size > 0) {
comm_vol[rank] += size;
}
col_start = col_end;
}
row_start = row_end;
}
return comm_vol;
}
| 35.8 | 87 | 0.596967 | [
"vector"
] |
aa64eaf64fed8c0ba8d3146126e3f1222d6a8cbc | 8,967 | cc | C++ | src/fuzzers/rw/t5t.cc | stnfc/android-system-nfc | ee659f69beed15b31bc08a7283fb9a403430c1a9 | [
"Apache-2.0"
] | null | null | null | src/fuzzers/rw/t5t.cc | stnfc/android-system-nfc | ee659f69beed15b31bc08a7283fb9a403430c1a9 | [
"Apache-2.0"
] | null | null | null | src/fuzzers/rw/t5t.cc | stnfc/android-system-nfc | ee659f69beed15b31bc08a7283fb9a403430c1a9 | [
"Apache-2.0"
] | null | null | null | #include "fuzz.h"
#define MODULE_NAME "Type5 Read/Write"
enum {
SUB_TYPE_INVENTORY,
SUB_TYPE_STAY_QUIET,
SUB_TYPE_READ_SINGLEBLOCK,
SUB_TYPE_WRITE_SINGLEBLOCK,
SUB_TYPE_LOCK_BLOCK,
SUB_TYPE_READ_MULTIPLEBLOCKS,
SUB_TYPE_WRITE_MULTIPLEBLOCKS,
SUB_TYPE_SELECT,
SUB_TYPE_RESET_TO_READY,
SUB_TYPE_WRITE_AFI,
SUB_TYPE_LOCK_AFI,
SUB_TYPE_WRITE_DSFID,
SUB_TYPE_LOCK_DSFID,
SUB_TYPE_GET_SYS_INFO,
SUB_TYPE_GET_MULTI_BLOCK_SECURITY_STATUS,
SUB_TYPE_DETECT_NDEF,
SUB_TYPE_READ_NDEF,
SUB_TYPE_UPDATE_NDEF,
SUB_TYPE_FORMAT_NDEF,
SUB_TYPE_SET_TAG_READONLY,
SUB_TYPE_PRESENCE_CHECK,
SUB_TYPE_MAX
};
#define TEST_UID_VALUE \
{ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 }
// const uint8_t TEST_UID[] = TEST_UID_VALUE;
static void rw_cback(tRW_EVENT event, tRW_DATA* p_rw_data) {
FUZZLOG(MODULE_NAME ": rw_cback: event=0x%02x, p_rw_data=%p", event,
p_rw_data);
if (event == RW_I93_DATA_EVT || event == RW_I93_NDEF_READ_EVT ||
event == RW_I93_NDEF_READ_CPLT_EVT) {
if (p_rw_data->i93_data.p_data) {
GKI_freebuf(p_rw_data->i93_data.p_data);
p_rw_data->i93_data.p_data = nullptr;
}
} else if (event == RW_I93_RAW_FRAME_EVT) {
if (p_rw_data->raw_frame.p_data) {
GKI_freebuf(p_rw_data->raw_frame.p_data);
p_rw_data->raw_frame.p_data = nullptr;
}
}
}
static bool Init(Fuzz_Context& /*ctx*/) {
tNFC_ACTIVATE_DEVT activate_params = {
.protocol = static_cast<tNFC_PROTOCOL>(NFC_PROTOCOL_T5T),
.rf_tech_param = {.mode = NFC_DISCOVERY_TYPE_POLL_V,
.param = {.pi93 = {
.uid = TEST_UID_VALUE,
}}}};
rw_init();
if (NFC_STATUS_OK != RW_SetActivatedTagType(&activate_params, rw_cback)) {
FUZZLOG(MODULE_NAME ": RW_SetActivatedTagType failed");
return false;
}
return true;
}
static bool Init_Inventory(Fuzz_Context& /*ctx*/) {
uint8_t uid[] = TEST_UID_VALUE;
return NFC_STATUS_OK == RW_I93Inventory(false, 0, uid);
}
static bool Init_StayQuiet(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93StayQuiet();
}
static bool Init_ReadSingleBlock(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93ReadSingleBlock(0);
}
static bool Init_WriteSingleBlock(Fuzz_Context& ctx) {
const uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04,
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04};
auto scratch = ctx.GetBuffer(sizeof(data), data);
return NFC_STATUS_OK == RW_I93WriteSingleBlock(0, scratch);
}
static bool Init_LockBlock(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93LockBlock(0);
}
static bool Init_ReadMultipleBlocks(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93ReadMultipleBlocks(0, 10);
}
static bool Init_WriteMultipleBlocks(Fuzz_Context& ctx) {
auto scratch = ctx.GetBuffer(16 * 10);
return NFC_STATUS_OK == RW_I93WriteMultipleBlocks(0, 10, scratch);
}
static bool Init_Select(Fuzz_Context& /*ctx*/) {
uint8_t uid[] = TEST_UID_VALUE;
return NFC_STATUS_OK == RW_I93Select(uid);
}
static bool Init_ResetToReady(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93ResetToReady();
}
static bool Init_WriteAFI(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93WriteAFI(0x11);
}
static bool Init_LockAFI(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93LockAFI();
}
static bool Init_WriteDSFID(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93WriteDSFID(0x22);
}
static bool Init_LockDSFID(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93LockDSFID();
}
static bool Init_GetSysInfo(Fuzz_Context& /*ctx*/) {
uint8_t uid[] = TEST_UID_VALUE;
return NFC_STATUS_OK == RW_I93GetSysInfo(uid);
}
static bool Init_GetMultiBlockSecurityStatus(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93GetMultiBlockSecurityStatus(0, 10);
}
static bool Init_DetectNDef(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93DetectNDef();
}
static bool Init_ReadNDef(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93ReadNDef();
}
static bool Init_UpdateNDef(Fuzz_Context& ctx) {
const uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04,
0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04};
auto scratch = ctx.GetBuffer(sizeof(data), data);
return NFC_STATUS_OK == RW_I93UpdateNDef(sizeof(data), scratch);
}
static bool Init_FormatNDef(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93FormatNDef();
}
static bool Init_SetTagReadOnly(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93SetTagReadOnly();
}
static bool Init_PresenceCheck(Fuzz_Context& /*ctx*/) {
return NFC_STATUS_OK == RW_I93PresenceCheck();
}
static bool Fuzz_Init(Fuzz_Context& ctx) {
if (!Init(ctx)) {
FUZZLOG(MODULE_NAME ": initialization failed");
return false;
}
bool result = false;
switch (ctx.SubType) {
case SUB_TYPE_INVENTORY:
result = Init_Inventory(ctx);
break;
case SUB_TYPE_STAY_QUIET:
result = Init_StayQuiet(ctx);
break;
case SUB_TYPE_READ_SINGLEBLOCK:
result = Init_ReadSingleBlock(ctx);
break;
case SUB_TYPE_WRITE_SINGLEBLOCK:
result = Init_WriteSingleBlock(ctx);
break;
case SUB_TYPE_LOCK_BLOCK:
result = Init_LockBlock(ctx);
break;
case SUB_TYPE_READ_MULTIPLEBLOCKS:
result = Init_ReadMultipleBlocks(ctx);
break;
case SUB_TYPE_WRITE_MULTIPLEBLOCKS:
result = Init_WriteMultipleBlocks(ctx);
break;
case SUB_TYPE_SELECT:
result = Init_Select(ctx);
break;
case SUB_TYPE_RESET_TO_READY:
result = Init_ResetToReady(ctx);
break;
case SUB_TYPE_WRITE_AFI:
result = Init_WriteAFI(ctx);
break;
case SUB_TYPE_LOCK_AFI:
result = Init_LockAFI(ctx);
break;
case SUB_TYPE_WRITE_DSFID:
result = Init_WriteDSFID(ctx);
break;
case SUB_TYPE_LOCK_DSFID:
result = Init_LockDSFID(ctx);
break;
case SUB_TYPE_GET_SYS_INFO:
result = Init_GetSysInfo(ctx);
break;
case SUB_TYPE_GET_MULTI_BLOCK_SECURITY_STATUS:
result = Init_GetMultiBlockSecurityStatus(ctx);
break;
case SUB_TYPE_DETECT_NDEF:
result = Init_DetectNDef(ctx);
break;
case SUB_TYPE_READ_NDEF:
result = Init_ReadNDef(ctx);
break;
case SUB_TYPE_UPDATE_NDEF:
result = Init_UpdateNDef(ctx);
break;
case SUB_TYPE_FORMAT_NDEF:
result = Init_FormatNDef(ctx);
break;
case SUB_TYPE_SET_TAG_READONLY:
result = Init_SetTagReadOnly(ctx);
break;
case SUB_TYPE_PRESENCE_CHECK:
result = Init_PresenceCheck(ctx);
break;
default:
FUZZLOG(MODULE_NAME ": Unknown command %d", ctx.SubType);
result = false;
break;
}
if (!result) {
FUZZLOG(MODULE_NAME ": Initializing command %02X failed", ctx.SubType);
}
return result;
}
static void Fuzz_Deinit(Fuzz_Context& /*ctx*/) {
if (rf_cback) {
tRW_I93_CB* p_i93 = &rw_cb.tcb.i93;
if (p_i93->p_update_data) {
GKI_freebuf(p_i93->p_update_data);
p_i93->p_update_data = nullptr;
}
tNFC_CONN conn = {
.deactivate = {.status = NFC_STATUS_OK,
.type = NFC_DEACTIVATE_TYPE_IDLE,
.is_ntf = true,
.reason = NFC_DEACTIVATE_REASON_DH_REQ_FAILED}};
rf_cback(NFC_RF_CONN_ID, NFC_DEACTIVATE_CEVT, &conn);
}
}
static void Fuzz_Run(Fuzz_Context& ctx) {
for (auto it = ctx.Data.cbegin() + 1; it != ctx.Data.cend(); ++it) {
NFC_HDR* p_msg;
p_msg = (NFC_HDR*)GKI_getbuf(sizeof(NFC_HDR) + it->size());
if (p_msg == nullptr) {
FUZZLOG(MODULE_NAME ": GKI_getbuf returns null, size=%zu", it->size());
return;
}
/* Initialize NFC_HDR */
p_msg->len = it->size();
p_msg->offset = 0;
uint8_t* p = (uint8_t*)(p_msg + 1) + p_msg->offset;
memcpy(p, it->data(), it->size());
tNFC_CONN conn = {.data = {
.status = NFC_STATUS_OK,
.p_data = p_msg,
}};
FUZZLOG(MODULE_NAME ": SubType=%02X, Response[%zd/%zd]=%s", ctx.SubType,
it - ctx.Data.cbegin(), ctx.Data.size() - 1,
BytesToHex(*it).c_str());
rf_cback(NFC_RF_CONN_ID, NFC_DATA_CEVT, &conn);
}
}
void Type5_FixPackets(uint8_t /*SubType*/, std::vector<bytes_t>& /*Data*/) {}
void Type5_Fuzz(uint8_t SubType, const std::vector<bytes_t>& Data) {
Fuzz_Context ctx(SubType % SUB_TYPE_MAX, Data);
if (Fuzz_Init(ctx)) {
Fuzz_Run(ctx);
}
Fuzz_Deinit(ctx);
}
| 27.422018 | 78 | 0.64637 | [
"vector"
] |
aa68ed6cbd3b98a7e86d118c5152434f470438b9 | 19,655 | hpp | C++ | Source/AllProjects/WndUtils/CIDCtrls/CIDCtrls_ColHeader.hpp | MarkStega/CIDLib | 82014e064eef51cad998bf2c694ed9c1c8cceac6 | [
"MIT"
] | 216 | 2019-03-09T06:41:28.000Z | 2022-02-25T16:27:19.000Z | Source/AllProjects/WndUtils/CIDCtrls/CIDCtrls_ColHeader.hpp | MarkStega/CIDLib | 82014e064eef51cad998bf2c694ed9c1c8cceac6 | [
"MIT"
] | 9 | 2020-09-27T08:00:52.000Z | 2021-07-02T14:27:31.000Z | Source/AllProjects/WndUtils/CIDCtrls/CIDCtrls_ColHeader.hpp | MarkStega/CIDLib | 82014e064eef51cad998bf2c694ed9c1c8cceac6 | [
"MIT"
] | 29 | 2019-03-09T10:12:24.000Z | 2021-03-03T22:25:29.000Z | //
// FILE NAME: CIDCtrls_ColHeader.hpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 11/28/2017
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2019
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// A control that is used by other controls to provide column titles, and to manage the
// width of those columns. It's just a row of cells, with divider lines. Each cell can
// have a bitmap, a textual title, or both.
//
// We let the user drag the divider lines and we send column size change messages to the
// parent (whoever is registered for events, but mostly it'll be the containing window.)
// The drag is limited such that no columns can get too small. We don't bother with the
// complexity of min/max sizes of columns. Let the user do what he wants just don't get
// the columns so small that they might cause drawing issues.
//
// We provide virtuals for drawing of the individual columns, so a derivative can be
// created to provide for specialized headers if needed. But generally it will be
// flexible enough for most needs.
//
// We have a small class that defines the info we store per-column, and keep an array of
// those to represent the columns. The client code indicates how many columns we have and
// sets the attributes of those columns.
//
// We have a display style that controls the layout of the header cells.
//
// BitmapOnly - Just displays bitmap, the justification controls how it's placed
// TextOnly - Just displays text, the justification controls how it's placed
// CenterText - Both are displayed side by side, centered, with the text first
// CenterBmp - Both are displayed side by side, centered, with bitmap first
// BmpRight - Bitmap is drawn to the right, and the text gets the rest of the area
// and is justified base don the justification setting.
// BmpLeft - Bitmap is drawn to the left, and the text gets the rest of the area
// and is justified base don the justification setting.
//
// If the bitmap is not set, then the display format will be forced to TextOnly. The text
// can be empty, but it makes not sense for it to be.
//
// These never scroll, they just clip if cummulative width of the columns pushes the
// content off the right side. So it's fairly simple in that respect compared to some
// things.
//
// We store a width for each one. The vertical is driven by the window height, so we don't
// need to keep that, and we just add up the widths to get the x offset of any given one.
//
// They can pass max card for the width and we'll calculate an appropriate width based
// on the content.
//
// We draw a separator border along our bottom. There isn't one at the top, since this
// control is always top justified in some parent window. If it has a border our having
// one also wouldn't look good.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// $_CIDLib_Log_$
//
#pragma once
#pragma CIDLIB_PACK(CIDLIBPACK)
// ---------------------------------------------------------------------------
// CLASS: TColHeaderInfo
// PREFIX: colhi
// ---------------------------------------------------------------------------
class CIDCTRLSEXP TColHeaderInfo
{
public :
// -------------------------------------------------------------------
// Constructors and destructor
// -------------------------------------------------------------------
TColHeaderInfo();
TColHeaderInfo
(
const TString& strTitle
, const tCIDLib::TCard4 c4Width
, const tCIDLib::EHJustify eJustify
);
TColHeaderInfo
(
const TBitmap& bmpTitle
, const tCIDLib::TCard4 c4Width
, const tCIDLib::EHJustify eJustify
);
TColHeaderInfo
(
const TString& strTitle
, const TBitmap& bmpTitle
, const tCIDCtrls::ECHdrTypes eType
, const tCIDLib::TCard4 c4Width
, const tCIDLib::EHJustify eJustify
);
TColHeaderInfo
(
const TColHeaderInfo& colhiSrc
);
~TColHeaderInfo();
// -------------------------------------------------------------------
// Public operators
// -------------------------------------------------------------------
TColHeaderInfo& operator=
(
const TColHeaderInfo& cohiSrc
);
// -------------------------------------------------------------------
// Public, non-virtual methods
// -------------------------------------------------------------------
tCIDLib::TBoolean bBold() const;
tCIDLib::TBoolean bBold
(
const tCIDLib::TBoolean bToSet
);
tCIDLib::TVoid SetColors
(
const TRGBClr& rgbBgnClr
, const TRGBClr& rgbTextClr
);
protected :
// -------------------------------------------------------------------
// Declare our friends
// -------------------------------------------------------------------
friend class TColHeader;
private :
// -------------------------------------------------------------------
// Private data members
//
// m_bBgnOver
// Indicates if the bgn color has been overridden. If not, then the colors of
// the header window are used.
//
// m_bBold
// Controls whether the text should be displayed bold or normal. Defaults to
// normal.
//
// m_bTextOver
// Indicates if the text color has been overridden. If not, then the color of
// the header window is used.
//
// m_bmpTitle
// If we are to display a bitmap, this is it.
//
// m_c4Width
// The width of this slot. We don't keep the horizontal start/end offsets,
// we just calculate them as required.
//
// m_eType
// This indicates what type of display we are to do, text only, text left
// and image right, or image left and text right.
//
// m_eJustify
// Controls how our text or bitmap is justified.
//
// m_rgbBgn1
// m_rgbBgn2
// m_rgbText
// These are set from standard window colors, but can be updated by the
// client code to create specialized header displays. If not set explicitly
// the defaults are used for this slot.
//
// m_strTitle
// A the title text if we are to display any
// -------------------------------------------------------------------
tCIDLib::TBoolean m_bBgnOver;
tCIDLib::TBoolean m_bBold;
tCIDLib::TBoolean m_bTextOver;
TBitmap m_bmpTitle;
tCIDLib::TCard4 m_c4Width;
tCIDCtrls::ECHdrTypes m_eType;
tCIDLib::EHJustify m_eJustify;
TRGBClr m_rgbBgn1;
TRGBClr m_rgbBgn2;
TRGBClr m_rgbText;
TString m_strTitle;
};
// ---------------------------------------------------------------------------
// CLASS: TColHdrChangeInfo
// PREFIX: wnot
// ---------------------------------------------------------------------------
class CIDCTRLSEXP TColHdrChangeInfo : public TCtrlNotify
{
public :
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
TColHdrChangeInfo() = delete;
TColHdrChangeInfo
(
const tCIDCtrls::ECHdrEvents eEvent
, const tCIDLib::TCard4 c4ColIndex
, const TWindow& wndSrc
);
TColHdrChangeInfo
(
const tCIDLib::TCard4 c4ColIndex
, const tCIDLib::TCard4 c4OldWidth
, const tCIDLib::TCard4 c4NewWidth
, const TWindow& wndSrc
);
TColHdrChangeInfo
(
const TColHdrChangeInfo& wnotToCopy
);
~TColHdrChangeInfo();
// -------------------------------------------------------------------
// Public operators
// -------------------------------------------------------------------
TColHdrChangeInfo& operator=
(
const TColHdrChangeInfo& wnotToAssign
);
// -------------------------------------------------------------------
// Public, non-virtual methods
// -------------------------------------------------------------------
tCIDLib::TCard4 c4ColIndex() const
{
return m_c4ColIndex;
}
tCIDLib::TCard4 c4OldWidth() const
{
return m_c4OldWidth;
}
tCIDLib::TCard4 c4NewWidth() const
{
return m_c4NewWidth;
}
tCIDCtrls::ECHdrEvents eEvent() const
{
return m_eEvent;
}
private :
// -------------------------------------------------------------------
// Private data members
//
// m_c4ColIndex
// If the event is about a single column, this is the index of that column.
// Else it is not used and set to max card.
//
// m_c4NewWidth
// m_c4OldWidth
// If it's a drag operation, then the column index indicates the one whose
// right edge is being dragged. And these contain the previous and new widths
// for that column.
//
// m_eEvent
// The specific event that occurred.
// -------------------------------------------------------------------
tCIDLib::TCard4 m_c4ColIndex;
tCIDLib::TCard4 m_c4NewWidth;
tCIDLib::TCard4 m_c4OldWidth;
tCIDCtrls::ECHdrEvents m_eEvent;
// -------------------------------------------------------------------
// Magic macros
// -------------------------------------------------------------------
RTTIDefs(TColHdrChangeInfo,TCtrlNotify)
DefPolyDup(TColHdrChangeInfo)
};
// ---------------------------------------------------------------------------
// CLASS: TColHeader
// PREFIX: wnd
// ---------------------------------------------------------------------------
class CIDCTRLSEXP TColHeader : public TCtrlWnd
{
public :
// -------------------------------------------------------------------
// Public data types
// -------------------------------------------------------------------
using TColList = TVector<TColHeaderInfo>;
// -------------------------------------------------------------------
// Public, static data
// -------------------------------------------------------------------
static const TNotificationId nidChangeId;
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
TColHeader();
TColHeader(const TColHeader&) = delete;
TColHeader(TColHeader&&) = delete;
~TColHeader();
// -------------------------------------------------------------------
// Public operators
// -------------------------------------------------------------------
TColHeader& operator=(const TColHeader&) = delete;
TColHeader& operator=(TColHeader&&) = delete;
// -------------------------------------------------------------------
// Public, inherited methods
// -------------------------------------------------------------------
tCIDLib::TVoid InitFromDesc
(
const TWindow& wndParent
, const TDlgItem& dlgiSrc
, const tCIDCtrls::EWndThemes eTheme
) final;
tCIDLib::TVoid QueryHints
(
tCIDLib::TStrCollect& colToFill
) const final;
tCIDLib::TVoid SetBgnColor
(
const TRGBClr& rgbToSet
, const tCIDLib::TBoolean bOver = kCIDLib::True
, const tCIDLib::TBoolean bRedraw = kCIDLib::False
) final;
TSize szDefault() const final;
// -------------------------------------------------------------------
// Public, non-virtual methods
// -------------------------------------------------------------------
tCIDLib::TCard4 c4ColCount() const;
tCIDLib::TCard4 c4FullWidth() const;
tCIDLib::TCard4 c4QueryWidths
(
tCIDLib::TCardList& fcolToFill
);
const TColHeaderInfo& colhiAt
(
const tCIDLib::TCard4 c4At
) const;
tCIDLib::TVoid CreateColHeader
(
const TWindow& wndParent
, const tCIDCtrls::TWndId widThis
, const tCIDCtrls::EWndStyles eStyles
, const tCIDCtrls::ECHdrStyles eCHdrStyles = tCIDCtrls::ECHdrStyles::None
, const tCIDCtrls::EExWndStyles eExStyles = tCIDCtrls::EExWndStyles::None
);
tCIDLib::TVoid SetColHdrWidth
(
const tCIDLib::TCard4 c4ToSet
);
tCIDLib::TVoid SetColumns
(
const TColList& colToSet
);
tCIDLib::TVoid SetDefTextColor
(
const TRGBClr& rgbToSet
);
// -------------------------------------------------------------------
// We provide a templatized method to allow for typesafe registration of event
// handlers. Each derived types has to provide its own notification id or they
// would conflict, so the derived class provides us with one to use.
// -------------------------------------------------------------------
template <typename T> TNotHandlerBase*
pnothRegisterHandler( T* const pTarget
, tCIDCtrls::EEvResponses (T::*pfnTarget)(TColHdrChangeInfo&)
, const tCIDLib::EEnds eEnd = tCIDLib::EEnds::Last)
{
CheckHandlerRegParms(this, pTarget);
// Add a request object to us (the source button)
AddNotifyRequest
(
new TNotifyRequestFor<T, TColHdrChangeInfo>(pTarget, nidChangeId)
);
// Add a handler object to the target
TNotHandlerBase* pnothNew = new TNotifyHandlerFor<T, TColHdrChangeInfo>
(
pTarget, nidChangeId, pfnTarget
);
pTarget->AddNotifyHandler(pnothNew, eEnd);
return pnothNew;
}
protected :
// -------------------------------------------------------------------
// Protected, inherited methods
// -------------------------------------------------------------------
tCIDLib::TBoolean bClick
(
const tCIDCtrls::EMouseButts eButton
, const tCIDCtrls::EMouseClicks eClickType
, const TPoint& pntAt
, const tCIDLib::TBoolean bCtrlShift
, const tCIDLib::TBoolean bShift
) final;
tCIDLib::TBoolean bCreated() final;
tCIDLib::TBoolean bEraseBgn
(
TGraphDrawDev& gdevToUs
) final;
tCIDLib::TBoolean bMouseMove
(
const TPoint& pntAt
, const tCIDLib::TBoolean bControlDown
, const tCIDLib::TBoolean bShiftDown
) final;
tCIDLib::TBoolean bPaint
(
TGraphDrawDev& gdevToUse
, const TArea& areaUpdate
) final;
private :
// -------------------------------------------------------------------
// Private data types
// -------------------------------------------------------------------
enum class ETrackStates
{
Idle
, Click
, Drag
};
// -------------------------------------------------------------------
// Private, non-virtual methods
// -------------------------------------------------------------------
tCIDCtrls::EWndAreas eSlotHitTest
(
const TPoint& pntAt
, tCIDLib::TCard4& c4Index
);
tCIDLib::TInt4 i4SlotXOffset
(
const tCIDLib::TCard4 c4Index
) const;
tCIDLib::TInt4 i4SlotXOffset
(
const tCIDLib::TCard4 c4Index
, tCIDLib::TInt4& i4SlotEndX
, tCIDLib::TInt4& i4SlotsEndX
) const;
tCIDLib::TVoid SetFillColors
(
const TRGBClr& rgbBase
);
// -------------------------------------------------------------------
// Private data members
//
// m_c4TrackIndex
// If we are tracking, this is the slot we are tracking.
//
// m_colList
// Our list of column info objects.
//
// m_eCHdrStyles
// Our column header specific styles.
//
// m_eTrack
// Indicates if we are tracking and, if so, what type of event we are tracking.
//
// m_rgbBgn1
// m_rgbBgn2
// We do a gradient fill on the window area. Individual headers can do their
// own colors. This is set as the initial values to be used if a specific color
// hasn't been used, so that the default is that they match the overall window
// colors. We base these on the bgn color set on us.
//
// m_rgbText
// The text color to use for columns where the text color hasn't been explicitly
// set. We default it to a very dark gray, but not black. That minimizes the
// artifacts when moving the text around.
// -------------------------------------------------------------------
tCIDLib::TCard4 m_c4TrackIndex;
TColList m_colList;
tCIDCtrls::ECHdrStyles m_eCHdrStyles;
ETrackStates m_eTrack;
TRGBClr m_rgbBgn1;
TRGBClr m_rgbBgn2;
TRGBClr m_rgbText;
// -------------------------------------------------------------------
// Do any needed magic macros
// -------------------------------------------------------------------
RTTIDefs(TColHeader, TCtrlWnd)
};
#pragma CIDLIB_POPPACK
| 35.414414 | 95 | 0.440804 | [
"object"
] |
aa6a70d58fd73901315b2a85d1505081f823b067 | 6,613 | cpp | C++ | pxr/base/lib/tf/wrapPyDateTime.cpp | marsupial/USD | 98d49911893d59be5a9904a29e15959affd530ec | [
"BSD-3-Clause"
] | 9 | 2021-03-31T21:23:48.000Z | 2022-03-05T09:29:27.000Z | pxr/base/lib/tf/wrapPyDateTime.cpp | unity3d-jp/USD | 0f146383613e1efe872ea7c85aa3536f170fcda2 | [
"BSD-3-Clause"
] | null | null | null | pxr/base/lib/tf/wrapPyDateTime.cpp | unity3d-jp/USD | 0f146383613e1efe872ea7c85aa3536f170fcda2 | [
"BSD-3-Clause"
] | 2 | 2016-12-13T00:53:40.000Z | 2020-05-04T07:32:53.000Z | //
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include "pxr/base/arch/defines.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/base/tf/stringUtils.h"
#include <boost/python/class.hpp>
#include <boost/python/object.hpp>
#include <boost/python/import.hpp>
#include <boost/python/tuple.hpp>
#include <cmath>
#include <mutex>
#include <datetime.h> // from Python
// Note: This wrapper does not currently support timezones. Timezone info
// will be dropped when moving between C++ and Python.
using namespace boost::python;
namespace boost_pt = boost::posix_time;
static const unsigned short usecNumDigits = 6;
static void _ImportPyDateTimeModuleOnce();
struct BoostPtimeToPyDateTime
{
static PyObject* convert(const boost_pt::ptime & ptime) {
_ImportPyDateTimeModuleOnce();
if (not ptime.is_special()) {
const boost::gregorian::date date = ptime.date();
const boost_pt::time_duration time = ptime.time_of_day();
// Convert fractional seconds to microseconds.
long usecs;
// Difference in number of digits used in boost's fractional seconds
// representation and microseconds.
const unsigned short d =
usecNumDigits - boost_pt::time_duration::num_fractional_digits();
if (d == 0) {
usecs = time.fractional_seconds();
}
else {
// Boost appears to support at most 9 digits (base 10) of
// fractional seconds (ie. nanosecond resolution). double
// should be sufficiently accurate for convertion to
// microseconds as it's good for about 16 digits.
double scale = std::pow(10, d);
usecs = time.fractional_seconds() * scale;
}
return PyDateTime_FromDateAndTime(
date.year(), date.month(), date.day(),
time.hours(), time.minutes(), time.seconds(),
usecs);
}
else {
// datetime.datetime doesn't support the special values that ptime
// does (+/- infinity, not_a_date_time), so we map those values to
// None.
Py_INCREF(Py_None);
return Py_None;
}
}
};
// Register a from-python conversion that lets clients pass python datetime
// objects to bindings expecting boost::posix_time::ptime.
struct Tf_BoostPtimeFromPyDateTime
{
Tf_BoostPtimeFromPyDateTime() {
boost::python::converter::registry::insert
(&convertible, &construct, boost::python::type_id<boost_pt::ptime>());
}
static void *convertible(PyObject *obj) {
_ImportPyDateTimeModuleOnce();
return (obj and PyDateTime_Check(obj)) ? obj : 0;
}
static void construct(PyObject *src,
boost::python::converter::
rvalue_from_python_stage1_data *data) {
_ImportPyDateTimeModuleOnce();
const int year = PyDateTime_GET_YEAR(src);
const int month = PyDateTime_GET_MONTH(src);
const int day = PyDateTime_GET_DAY(src);
const int hour = PyDateTime_DATE_GET_HOUR(src);
const int minute = PyDateTime_DATE_GET_MINUTE(src);
const int second = PyDateTime_DATE_GET_SECOND(src);
const int usec = PyDateTime_DATE_GET_MICROSECOND(src);
try {
boost_pt::ptime ptime(boost::gregorian::date(year, month, day),
boost_pt::time_duration(hour, minute, second) +
boost_pt::microseconds(usec));
void *storage =
((boost::python::converter::
rvalue_from_python_storage<boost_pt::ptime> *)data)->storage.bytes;
new (storage) boost_pt::ptime(boost::gregorian::date(year, month, day),
boost_pt::time_duration(hour, minute, second) +
boost_pt::microseconds(usec));
data->convertible = storage;
}
catch (std::out_of_range & exc) {
// datetime.datetime supports a wider range of valid years than
// gregorian::date. Raise a value error with the message if we
// can't convert.
TfPyThrowValueError(
TfStringPrintf("Can't convert to boost::posix_time::ptime: %s",
exc.what()));
}
}
};
void
wrapPyDateTime()
{
to_python_converter<boost_pt::ptime, BoostPtimeToPyDateTime>();
Tf_BoostPtimeFromPyDateTime();
}
// Python DateTime C API -- the PyDateTime_IMPORT macro requires ignoring
// -Wwrite-strings as it expands to a call that passes a string literal to
// Python API whose parameter is char * instead of const char *. The
// problematic function signature is fixed in Python 3.x, but won't be fixed
// in 2.x. (http://bugs.python.org/issue7463)
//
// XXX: We should remove this pragma as soon as it is reasonable to put the
// warning flag in the SConscript instead (bug 44546) or it is no longer
// necessary (ie. Python 3).
#if defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG)
#pragma GCC diagnostic ignored "-Wwrite-strings"
#endif
static void
_ImportPyDateTimeModuleOnce()
{
static std::once_flag once;
std::call_once(once, [](){
// Python datetime C API requires that this is called before calling
// any other datetime function.
PyDateTime_IMPORT;
});
}
| 38.225434 | 89 | 0.640708 | [
"object"
] |
aa6a7c0f6c2bf5762c8df91112ade460336f3708 | 46,830 | cc | C++ | tools/src/vcfdiff.cc | WordLess-ChuanJun/GenomisDB | d91ef2b701cf64be8c9911ee935863527ed94e9a | [
"MIT"
] | null | null | null | tools/src/vcfdiff.cc | WordLess-ChuanJun/GenomisDB | d91ef2b701cf64be8c9911ee935863527ed94e9a | [
"MIT"
] | null | null | null | tools/src/vcfdiff.cc | WordLess-ChuanJun/GenomisDB | d91ef2b701cf64be8c9911ee935863527ed94e9a | [
"MIT"
] | null | null | null | /**
* The MIT License (MIT)
* Copyright (c) 2016 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <getopt.h>
#include <mpi.h>
#include "vcfdiff.h"
#include "vid_mapper.h"
#include "json_config.h"
double g_threshold = 1e-5; //fp comparison threshold
int64_t g_num_callsets = INT64_MAX;
#define VERIFY_OR_THROW(X) if(!(X)) throw VCFDiffException(#X);
VCFDiffFile::VCFDiffFile(const std::string& filename, const std::string& regions)
: m_samples_lut(1u, 1u), m_fields_lut(1u, 1u), m_contigs_lut(1u, 1u)
{
m_filename = filename;
m_regions = "";
m_reader = bcf_sr_init();
m_num_lines_read = 0ll;
m_hdr = 0;
m_line = 0;
//Tmp buffer
m_tmp_hts_string.m = 65536; //64KB
m_tmp_hts_string.s = (char*)malloc(m_tmp_hts_string.m*sizeof(char));
VERIFY_OR_THROW(m_tmp_hts_string.s);
m_tmp_hts_string.l = 0;
//Read hdr
auto fptr = bcf_open(filename.c_str(), "r");
VERIFY_OR_THROW(fptr);
m_hdr = bcf_hdr_read(fptr);
bcf_close(fptr);
//Contigs
for(auto i=0;i<m_hdr->n[BCF_DT_CTG];++i)
if(m_contigs.find(bcf_hdr_id2name(m_hdr, i)) == m_contigs.end())
m_contigs.insert(bcf_hdr_id2name(m_hdr, i));
m_contigs_lut.resize_luts_if_needed(1u, m_contigs.size());
//Fields
m_field_idx_to_known_field_enum.resize_luts_if_needed(m_hdr->n[BCF_DT_ID], GVCF_NUM_KNOWN_FIELDS);
for(auto i=0;i<m_hdr->n[BCF_DT_ID];++i)
{
if(m_fields.find(bcf_hdr_int2id(m_hdr, BCF_DT_ID, i)) == m_fields.end())
{
std::string field_name = std::move(std::string(bcf_hdr_int2id(m_hdr, BCF_DT_ID, i)));
m_fields.insert(field_name);
unsigned known_field_enum = 0;
auto status = KnownFieldInfo::get_known_field_enum_for_name(field_name, known_field_enum);
if(status)
m_field_idx_to_known_field_enum.add_schema_idx_known_field_mapping(i, known_field_enum);
}
}
m_fields_lut.resize_luts_if_needed(1u, m_fields.size());
//Samples
for(auto i=0;i<bcf_hdr_nsamples(m_hdr);++i)
if(m_samples.find(bcf_hdr_int2id(m_hdr, BCF_DT_SAMPLE, i)) == m_samples.end())
m_samples.insert(bcf_hdr_int2id(m_hdr, BCF_DT_SAMPLE, i));
m_samples_lut.resize_luts_if_needed(1u, m_samples.size());
}
VCFDiffFile::~VCFDiffFile()
{
m_filename.clear();
m_regions.clear();
m_line = 0; //line is managed by reader
if(m_reader)
bcf_sr_destroy(m_reader);
m_reader = 0;
if(m_hdr)
bcf_hdr_destroy(m_hdr);
m_hdr = 0;
m_contigs.clear();
m_fields.clear();
m_samples.clear();
m_contigs_lut.clear();
m_fields_lut.clear();
m_samples_lut.clear();
m_fields_in_gold_line.clear();
m_fields_in_test_line.clear();
m_gold_genotype_idx_to_test_idx.clear();
if(m_tmp_hts_string.m && m_tmp_hts_string.s)
free(m_tmp_hts_string.s);
m_tmp_hts_string.s = 0;
m_tmp_hts_string.m = 0;
}
void VCFDiffFile::setup_lut(const std::set<std::string>& gold_set, const std::set<std::string>& test_set,
const int bcf_dt_type, GoldLUT& lut, const VCFDiffFile& gold)
{
lut.resize_luts_if_needed(1u, std::max(gold_set.size(), test_set.size()));
std::vector<std::string> common_elements(std::min(gold_set.size(), test_set.size()));
//Find common fields
auto iter = std::set_intersection(gold_set.begin(), gold_set.end(), test_set.begin(), test_set.end(),
common_elements.begin());
common_elements.resize(iter - common_elements.begin());
for(const auto& x : common_elements)
{
auto idx = bcf_hdr_id2int(m_hdr, bcf_dt_type, x.c_str());
VERIFY_OR_THROW(idx >= 0);
auto gold_idx = bcf_hdr_id2int(gold.m_hdr, bcf_dt_type, x.c_str());
VERIFY_OR_THROW(gold_idx >= 0);
lut.add_input_merged_idx_pair(0, idx, gold_idx);
}
}
void VCFDiffFile::setup_luts(const VCFDiffFile& gold, const bool use_callsets_file_for_samples)
{
if(!use_callsets_file_for_samples && gold.m_samples != m_samples)
throw VCFDiffException("ERROR: Sample names in the 2 file headers are different - cannot perform any further comparisons");
setup_lut(gold.m_contigs, m_contigs, BCF_DT_CTG, m_contigs_lut, gold);
setup_lut(gold.m_fields, m_fields, BCF_DT_ID, m_fields_lut, gold);
if(!use_callsets_file_for_samples)
setup_lut(gold.m_samples, m_samples, BCF_DT_SAMPLE, m_samples_lut, gold);
m_fields_in_gold_line.resize(std::max(gold.m_fields.size(), m_fields.size()));
m_fields_in_test_line.resize(std::max(gold.m_fields.size(), m_fields.size()));
reset_field_to_line_idx_mapping();
}
void VCFDiffFile::set_regions_and_open_file()
{
bcf_sr_set_regions(m_reader, m_regions.c_str(), 0);
if(bcf_sr_add_reader(m_reader, m_filename.c_str()) != 1)
throw VCFDiffException(std::string("Could not open file ")+m_filename+" or its index doesn't exist - VCF/BCF files must be block compressed and indexed");
bcf_sr_next_line(m_reader);
m_line = bcf_sr_get_line(m_reader, 0);
if(m_line)
++m_num_lines_read;
}
void VCFDiffFile::read_and_advance()
{
assert(m_line);
bcf_sr_next_line(m_reader);
m_line = bcf_sr_get_line(m_reader, 0);
if(m_line)
++m_num_lines_read;
}
void VCFDiffFile::seek_and_read(const int rid, const int pos)
{
assert(rid >= 0 && rid < m_hdr->n[BCF_DT_CTG]);
auto contig = bcf_hdr_id2name(m_hdr, rid);
bcf_sr_seek(m_reader, contig, pos);
bcf_sr_next_line(m_reader);
m_line = bcf_sr_get_line(m_reader, 0);
if(m_line)
++m_num_lines_read;
}
void VCFDiffFile::print_line(std::ostream& fptr)
{
m_tmp_hts_string.l = 0;
vcf_format(m_hdr, m_line, &m_tmp_hts_string);
fptr << m_tmp_hts_string.s << "\n";
}
inline int GET_NUM_FIELDS(const bcf1_t* line, const int bcf_field_type)
{
if(bcf_field_type == BCF_HL_INFO)
return line->n_info;
else
{
assert(bcf_field_type == BCF_HL_FMT);
return line->n_fmt;
}
}
inline int GET_FIELD_IDX(const bcf1_t* line, const int bcf_field_type, const int idx)
{
assert(idx >= 0);
if(bcf_field_type == BCF_HL_INFO)
{
assert(idx < line->n_info);
return line->d.info[idx].key;
}
else
{
assert(bcf_field_type == BCF_HL_FMT);
assert(idx < line->n_fmt);
return line->d.fmt[idx].id;
}
}
inline int GET_FIELD_BT_TYPE(const bcf1_t* line, const int bcf_field_type, const int idx)
{
assert(idx >= 0);
if(bcf_field_type == BCF_HL_INFO)
{
assert(idx < line->n_info);
return line->d.info[idx].type;
}
else
{
assert(bcf_field_type == BCF_HL_FMT);
assert(idx < line->n_fmt);
return line->d.fmt[idx].type;
}
}
inline const char* GET_FIELD_NAME(const bcf_hdr_t* hdr, const bcf1_t* line, const int bcf_field_type, const int idx)
{
assert(idx >= 0);
int hdr_field_idx = -1;
if(bcf_field_type == BCF_HL_INFO)
{
assert(idx < line->n_info);
hdr_field_idx = line->d.info[idx].key;
}
else
{
assert(bcf_field_type == BCF_HL_FMT);
assert(idx < line->n_fmt);
hdr_field_idx = line->d.fmt[idx].id;
}
assert(hdr_field_idx >= 0 && hdr_field_idx<hdr->n[BCF_DT_ID]);
return hdr->id[BCF_DT_ID][hdr_field_idx].key;
}
inline int GET_NUM_ELEMENTS(const bcf1_t* line, const int bcf_field_type, const int idx)
{
assert(idx >= 0);
if(bcf_field_type == BCF_HL_INFO)
{
assert(idx < line->n_info);
return line->d.info[idx].len;
}
else
{
assert(bcf_field_type == BCF_HL_FMT);
assert(idx < line->n_fmt);
return line->d.fmt[idx].n;
}
}
template<class T>
inline T GET_DATA_PTR(const bcf1_t* line, const int bcf_field_type, const int idx, const int sample_idx, const int num_elements_per_sample)
{
assert(idx >= 0);
if(bcf_field_type == BCF_HL_INFO)
{
assert(idx < line->n_info);
return reinterpret_cast<T>(line->d.info[idx].vptr);
}
else
{
assert(bcf_field_type == BCF_HL_FMT);
assert(idx < line->n_fmt);
return reinterpret_cast<T>(line->d.fmt[idx].p) + sample_idx*num_elements_per_sample;
}
}
bool bcf_is_empty_field(const bcf_hdr_t* hdr, const bcf1_t* line, const int bcf_field_type, const int idx)
{
assert(idx >= 0);
auto num_elements_per_sample = GET_NUM_ELEMENTS(line, bcf_field_type, idx);
auto total_num_elements = (bcf_field_type == BCF_HL_FMT) ? num_elements_per_sample*bcf_hdr_nsamples(hdr) : num_elements_per_sample;
switch(GET_FIELD_BT_TYPE(line, bcf_field_type, idx))
{
case BCF_BT_INT8:
{
auto ptr = GET_DATA_PTR<const int8_t*>(line, bcf_field_type, idx, 0, num_elements_per_sample);
for(auto i=0;i<total_num_elements;++i)
if(is_bcf_valid_value<int8_t>(ptr[i]))
return false;
break;
}
case BCF_BT_INT16:
{
auto ptr = GET_DATA_PTR<const int16_t*>(line, bcf_field_type, idx, 0, num_elements_per_sample);
for(auto i=0;i<total_num_elements;++i)
if(is_bcf_valid_value<int16_t>(ptr[i]))
return false;
break;
}
case BCF_BT_INT32:
{
auto ptr = GET_DATA_PTR<const int32_t*>(line, bcf_field_type, idx, 0, num_elements_per_sample);
for(auto i=0;i<total_num_elements;++i)
if(is_bcf_valid_value<int32_t>(ptr[i]))
return false;
break;
}
case BCF_BT_FLOAT:
{
auto ptr = GET_DATA_PTR<const float*>(line, bcf_field_type, idx, 0, num_elements_per_sample);
for(auto i=0;i<total_num_elements;++i)
if(is_bcf_valid_value<float>(ptr[i]))
return false;
break;
}
case BCF_BT_CHAR:
{
auto ptr = GET_DATA_PTR<const char*>(line, bcf_field_type, idx, 0, num_elements_per_sample);
for(auto i=0;i<total_num_elements;++i)
if(is_bcf_valid_value<char>(ptr[i]))
return false;
break;
}
default:
throw VCFDiffException("Unknown BCF_BT_TYPE "+std::to_string(GET_FIELD_BT_TYPE(line, bcf_field_type, idx))+" for field "
+GET_FIELD_NAME(hdr, line, bcf_field_type, idx));
break;
}
return true;
}
template<class T1, class T2>
inline bool compare_unequal(const T1 a, const T2 b)
{
return !(
(a == b) ||
(is_bcf_missing_value<T1>(a) && is_bcf_missing_value<T2>(b)) ||
(is_bcf_vector_end_value<T1>(a) && is_bcf_vector_end_value<T2>(b))
);
}
//Specialization for float - values should be close
template<>
inline bool compare_unequal(const float a, const float b)
{
if((is_bcf_missing_value<float>(a) && is_bcf_missing_value<float>(b)) ||
(is_bcf_vector_end_value<float>(a) && is_bcf_vector_end_value<float>(b)))
return false;
float diff = fabsf(a-b);
float rel_diff = ((a != 0) ? fabsf(diff/a) : 0);
return (diff > g_threshold && rel_diff > g_threshold);
}
template<class T1, class T2>
bool VCFDiffFile::compare_unequal_vector(const bcf_hdr_t* gold_hdr, const bcf1_t* gold_line, const int bcf_field_type,
int gold_line_field_pos_idx, int test_line_field_pos_idx)
{
auto num_samples = (bcf_field_type == BCF_HL_INFO) ? 1 : bcf_hdr_nsamples(gold_hdr);
auto num_gold_elements = GET_NUM_ELEMENTS(gold_line, bcf_field_type, gold_line_field_pos_idx);
auto num_test_elements = GET_NUM_ELEMENTS(m_line, bcf_field_type, test_line_field_pos_idx);
auto min_num_per_sample = std::min(num_gold_elements, num_test_elements);
auto max_num_per_sample = std::max(num_gold_elements, num_test_elements);
//Field idxs
auto gold_field_idx = GET_FIELD_IDX(gold_line, bcf_field_type, gold_line_field_pos_idx);
auto test_field_idx = GET_FIELD_IDX(m_line, bcf_field_type, test_line_field_pos_idx);
//Length descriptor
auto known_field_enum = m_field_idx_to_known_field_enum.get_known_field_enum_for_schema_idx(test_field_idx);
auto length_descriptor = BCF_VL_FIXED;
if(m_field_idx_to_known_field_enum.is_defined_value(known_field_enum))
length_descriptor = KnownFieldInfo::get_length_descriptor_for_known_field_enum(known_field_enum);
else
{
auto gold_length_descriptor = bcf_hdr_id2length(gold_hdr, bcf_field_type, gold_field_idx);
auto test_length_descriptor = bcf_hdr_id2length(m_hdr, bcf_field_type, test_field_idx);
if(gold_length_descriptor != test_length_descriptor)
return true;
length_descriptor = gold_length_descriptor;
}
//Vector lengths must be identical for these types of fields
//Also, if the alleles don't match, don't bother checking further
if((length_descriptor == BCF_VL_G || length_descriptor == BCF_VL_R || length_descriptor == BCF_VL_A)
&& (num_test_elements != num_gold_elements || m_diff_alleles_flag))
return true;
for(auto j=0;j<num_samples;++j)
{
int lut_test_sample_idx = (bcf_field_type == BCF_HL_INFO) ? 0 : m_samples_lut.get_test_idx_for_gold(0, j);
assert(!GoldLUT::is_missing_value(lut_test_sample_idx) && lut_test_sample_idx < bcf_hdr_nsamples(m_hdr));
auto gold_ptr = GET_DATA_PTR<const T1*>(gold_line, bcf_field_type, gold_line_field_pos_idx, j, num_gold_elements);
auto test_ptr = GET_DATA_PTR<const T2*>(m_line, bcf_field_type, test_line_field_pos_idx, lut_test_sample_idx, num_test_elements);
for(auto k=0;k<min_num_per_sample;++k)
{
auto test_vector_idx = k;
switch(length_descriptor)
{
case BCF_VL_A:
test_vector_idx = m_alleles_lut.get_input_idx_for_merged(0, k+1) - 1; //ALT only
break;
case BCF_VL_R:
test_vector_idx = m_alleles_lut.get_input_idx_for_merged(0, k);
break;
case BCF_VL_G:
assert(static_cast<size_t>(k) < m_gold_genotype_idx_to_test_idx.size());
test_vector_idx = m_gold_genotype_idx_to_test_idx[k];
break;
default:
break; //test_vector_idx = k
}
assert(!CombineAllelesLUT::is_missing_value(test_vector_idx) && test_vector_idx < min_num_per_sample);
if(compare_unequal<T1, T2>(gold_ptr[k], test_ptr[test_vector_idx]))
return true; //unequal
}
if(num_test_elements > num_gold_elements)
{
for(auto k=min_num_per_sample;k<max_num_per_sample;++k)
if(is_bcf_valid_value<T2>(test_ptr[k]))
return true; //extra elements
}
else
{
for(auto k=min_num_per_sample;k<max_num_per_sample;++k)
if(is_bcf_valid_value<T1>(gold_ptr[k]))
return true; //extra elements
}
}
return false;
}
bool VCFDiffFile::compare_unequal_fields(const bcf_hdr_t* gold_hdr, const bcf1_t* gold_line, const int bcf_field_type, std::string& error_message)
{
reset_field_to_line_idx_mapping();
auto diff_fields = false;
for(auto i=0;i<GET_NUM_FIELDS(gold_line, bcf_field_type);++i)
{
auto field_idx = GET_FIELD_IDX(gold_line, bcf_field_type, i);
assert(field_idx >= 0 && static_cast<size_t>(field_idx) < m_fields_in_gold_line.size());
m_fields_in_gold_line[field_idx] = i;
}
for(auto i=0;i<GET_NUM_FIELDS(m_line, bcf_field_type);++i)
{
auto field_idx = GET_FIELD_IDX(m_line, bcf_field_type, i);
assert(field_idx >= 0 && static_cast<size_t>(field_idx) < m_fields_in_test_line.size());
m_fields_in_test_line[field_idx] = i;
}
for(auto i=0;i<GET_NUM_FIELDS(gold_line, bcf_field_type);++i)
{
auto gold_field_idx = GET_FIELD_IDX(gold_line, bcf_field_type, i);
auto lut_test_field_idx = m_fields_lut.get_test_idx_for_gold(0, gold_field_idx);
//Skip comparing END values as the big outer loop handles that
if(!GoldLUT::is_missing_value(lut_test_field_idx))
{
auto known_field_enum = m_field_idx_to_known_field_enum.get_known_field_enum_for_schema_idx(lut_test_field_idx);
if(m_field_idx_to_known_field_enum.is_defined_value(known_field_enum) && known_field_enum == GVCF_END_IDX)
continue;
}
assert(GoldLUT::is_missing_value(lut_test_field_idx) || static_cast<size_t>(lut_test_field_idx) < m_fields_in_test_line.size());
//Missing field in test
if(GoldLUT::is_missing_value(lut_test_field_idx) || m_fields_in_test_line[lut_test_field_idx] < 0)
{
if(!bcf_is_empty_field(gold_hdr, gold_line, bcf_field_type, i))
{
diff_fields = true;
error_message += (std::string("ERROR: ") + (bcf_field_type == BCF_HL_INFO ? "INFO" : "FORMAT")
+ " field " + bcf_hdr_int2id(gold_hdr, BCF_DT_ID, gold_field_idx) + " missing in test line\n");
}
}
else
{
auto test_line_field_pos_idx = m_fields_in_test_line[lut_test_field_idx];
//Fields are of different type
if(bcf_hdr_id2type(gold_hdr, bcf_field_type, gold_field_idx) != bcf_hdr_id2type(m_hdr, bcf_field_type, lut_test_field_idx))
{
diff_fields = true;
error_message += (std::string("ERROR: ") + (bcf_field_type == BCF_HL_INFO ? "INFO" : "FORMAT")
+ " field " + bcf_hdr_int2id(gold_hdr, BCF_DT_ID, gold_field_idx) + " type is different in gold and test\n");
continue;
}
//Boolean field, both lines have the field - nothing to do
if(bcf_hdr_id2type(gold_hdr, bcf_field_type, gold_field_idx) == BCF_HT_FLAG)
continue;
//Big switch
auto field_bt_type_combo = GET_FIELD_BT_TYPE(gold_line, bcf_field_type, i) << 8 |
GET_FIELD_BT_TYPE(m_line, bcf_field_type, test_line_field_pos_idx);
auto field_vector_diff = false;
switch(field_bt_type_combo)
{
case BCF_BT_INT8 << 8 | BCF_BT_INT8:
field_vector_diff = compare_unequal_vector<int8_t, int8_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT8 << 8 | BCF_BT_INT16:
field_vector_diff = compare_unequal_vector<int8_t, int16_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT8 << 8 | BCF_BT_INT32:
field_vector_diff = compare_unequal_vector<int8_t, int32_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT16 << 8 | BCF_BT_INT8:
field_vector_diff = compare_unequal_vector<int16_t, int8_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT16 << 8 | BCF_BT_INT16:
field_vector_diff = compare_unequal_vector<int16_t, int16_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT16 << 8 | BCF_BT_INT32:
field_vector_diff = compare_unequal_vector<int16_t, int32_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT32 << 8 | BCF_BT_INT8:
field_vector_diff = compare_unequal_vector<int32_t, int8_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT32 << 8 | BCF_BT_INT16:
field_vector_diff = compare_unequal_vector<int32_t, int16_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_INT32 << 8 | BCF_BT_INT32:
field_vector_diff = compare_unequal_vector<int32_t, int32_t>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_FLOAT << 8 | BCF_BT_FLOAT:
field_vector_diff = compare_unequal_vector<float, float>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
case BCF_BT_CHAR << 8 | BCF_BT_CHAR:
field_vector_diff = compare_unequal_vector<char, char>(gold_hdr, gold_line, bcf_field_type, i, test_line_field_pos_idx);
break;
default:
throw VCFDiffException("Unknown type comparison "+std::to_string(field_bt_type_combo));
break;
}
diff_fields = diff_fields || field_vector_diff;
if(field_vector_diff)
error_message += (std::string("ERROR: Gold and test differ in the ")+(bcf_field_type == BCF_HL_INFO ? "INFO" : "FORMAT")
+" field "+bcf_hdr_int2id(gold_hdr, BCF_DT_ID, gold_field_idx)+"\n");
}
}
for(auto i=0;i<GET_NUM_FIELDS(m_line, bcf_field_type);++i)
{
auto test_field_idx = GET_FIELD_IDX(m_line, bcf_field_type, i);
//Skip comparing END values as the big outer loop handles that
auto known_field_enum = m_field_idx_to_known_field_enum.get_known_field_enum_for_schema_idx(test_field_idx);
if(m_field_idx_to_known_field_enum.is_defined_value(known_field_enum) && known_field_enum == GVCF_END_IDX)
continue;
auto lut_gold_field_idx = m_fields_lut.get_gold_idx_for_test(0, test_field_idx);
assert(GoldLUT::is_missing_value(lut_gold_field_idx) || static_cast<size_t>(lut_gold_field_idx) < m_fields_in_gold_line.size());
//Missing field in gold
if(GoldLUT::is_missing_value(lut_gold_field_idx) || m_fields_in_gold_line[lut_gold_field_idx] < 0)
{
if(!bcf_is_empty_field(m_hdr, m_line, bcf_field_type, i))
{
diff_fields = true;
error_message += (std::string("ERROR: ") + (bcf_field_type == BCF_HL_INFO ? "INFO" : "FORMAT")
+ " field " + bcf_hdr_int2id(m_hdr, BCF_DT_ID, test_field_idx) + " added in test line\n");
}
}
}
return diff_fields;
}
void VCFDiffFile::compare_line(const bcf_hdr_t* gold_hdr, bcf1_t* gold_line)
{
//Ignore chr,pos as it's already handled previously
bcf_unpack(m_line, BCF_UN_ALL);
bcf_unpack(gold_line, BCF_UN_ALL);
std::string error_message = "";
auto diff_line_flag = false;
//ID field
auto diff_ID_flag = (strcmp(m_line->d.id, gold_line->d.id) != 0);
error_message += (diff_ID_flag ? "ID field different\n" : "");
diff_line_flag = diff_ID_flag || diff_line_flag ;
//REF + ALT
m_diff_alleles_flag = (m_line->n_allele != gold_line->n_allele);
if(!m_diff_alleles_flag)
{
m_alleles_lut.resize_luts_if_needed(1, m_line->n_allele);
std::unordered_map<std::string, int> allele_to_gold_idx;
//Ignore REF
for(auto i=1;i<gold_line->n_allele;++i)
allele_to_gold_idx[gold_line->d.allele[i]] = i;
m_alleles_lut.add_input_merged_idx_pair(0, 0, 0); //REF mapping
//Ignore REF
for(auto i=1;i<m_line->n_allele;++i)
{
auto iter = allele_to_gold_idx.find(m_line->d.allele[i]);
if(iter == allele_to_gold_idx.end())
{
m_diff_alleles_flag = true;
break;
}
m_alleles_lut.add_input_merged_idx_pair(0, i, (*iter).second);
}
//Setup genotypes map
if(!m_diff_alleles_flag)
{
auto num_alleles = m_line->n_allele;
auto num_gts = (num_alleles*(num_alleles+1))/2;
m_gold_genotype_idx_to_test_idx.resize(num_gts);
for(auto i=0;i<gold_line->n_allele;++i)
{
auto lut_test_allele_idx_i = m_alleles_lut.get_input_idx_for_merged(0, i);
for(auto j=i;j<gold_line->n_allele;++j)
{
auto lut_test_allele_idx_j = m_alleles_lut.get_input_idx_for_merged(0, j);
m_gold_genotype_idx_to_test_idx[bcf_alleles2gt(i, j)] = bcf_alleles2gt(lut_test_allele_idx_i, lut_test_allele_idx_j);
}
}
}
}
error_message += (m_diff_alleles_flag ? "Allele list different\n" : "");
diff_line_flag = m_diff_alleles_flag || diff_line_flag;
//QUAL
auto diff_QUAL_flag = compare_unequal<float>(m_line->qual, gold_line->qual);
error_message += (diff_QUAL_flag ? "QUAL field different\n" : "");
diff_line_flag = diff_QUAL_flag || diff_line_flag;
//FILTER
auto diff_FILTER_flag = (m_line->d.n_flt != gold_line->d.n_flt);
if(!diff_FILTER_flag)
{
reset_field_to_line_idx_mapping();
for(auto i=0;i<gold_line->d.n_flt;++i)
m_fields_in_gold_line[gold_line->d.flt[i]] = i;
for(auto i=0;i<m_line->d.n_flt;++i)
{
auto lut_gold_flt_idx = m_fields_lut.get_gold_idx_for_test(0, m_line->d.flt[i]);
assert(GoldLUT::is_missing_value(lut_gold_flt_idx) ||
static_cast<size_t>(lut_gold_flt_idx) < m_fields_in_gold_line.size());
if(GoldLUT::is_missing_value(lut_gold_flt_idx) || m_fields_in_gold_line[lut_gold_flt_idx] < 0)
{
diff_FILTER_flag = true;
break;
}
}
}
error_message += (diff_FILTER_flag ? "FILTER list different\n" : "");
diff_line_flag = diff_FILTER_flag || diff_line_flag;
//INFO fields
auto diff_INFO_fields = compare_unequal_fields(gold_hdr, gold_line, BCF_HL_INFO, error_message);
diff_line_flag = diff_INFO_fields || diff_line_flag;
//FORMAT fields
auto diff_FORMAT_fields = compare_unequal_fields(gold_hdr, gold_line, BCF_HL_FMT, error_message);
diff_line_flag = diff_FORMAT_fields || diff_line_flag;
if(diff_line_flag)
{
std::cerr << "=====================================================================\n";
m_tmp_hts_string.l = 0;
vcf_format(gold_hdr, gold_line, &m_tmp_hts_string);
std::cerr << m_tmp_hts_string.s << "\n";
print_line();
std::cerr << error_message;
std::cerr << "=====================================================================\n";
}
}
std::string VCFDiffFile::create_region(const std::string& regions,
const std::unordered_map<std::string, std::pair<int64_t, int64_t>>& regions_contig_to_interval, const std::string& contig)
{
auto quoted_contig = '"' + contig + '"';
if(regions.length())
{
auto iter = regions_contig_to_interval.find(contig);
if(iter == regions_contig_to_interval.end())
return "";
auto pair = (*iter).second;
if(pair.first == 1ll && pair.second == INT64_MAX)
return (quoted_contig + ","); //full contig
if(pair.second == INT64_MAX)
{
auto contig_idx = bcf_hdr_name2id(m_hdr, contig.c_str());
VERIFY_OR_THROW(contig_idx >= 0);
auto contig_length = bcf_hdr_id2contig_length(m_hdr, contig_idx);
return (quoted_contig + ":" + std::to_string(pair.first) + "-" + std::to_string(contig_length) + ",");
}
else
return (quoted_contig + ":" + std::to_string(pair.first) + "-" + std::to_string(pair.second) + ",");
}
else
return (quoted_contig + ",");
}
/*
Set regions to traverse based on contigs in the header
*/
void set_regions(VCFDiffFile& gold, VCFDiffFile& test, const std::string& regions="")
{
const auto& gold_contigs = gold.m_contigs;
const auto& test_contigs = test.m_contigs;
std::vector<std::string> common_contigs(std::min(gold_contigs.size(), test_contigs.size()));
{
//Find common contigs
auto iter = std::set_intersection(gold_contigs.begin(), gold_contigs.end(), test_contigs.begin(), test_contigs.end(),
common_contigs.begin());
common_contigs.resize(iter-common_contigs.begin());
}
//Sort as strings
std::sort(common_contigs.begin(), common_contigs.end());
//Regions set - parse regions string
std::unordered_map<std::string, std::pair<int64_t, int64_t>> regions_contig_to_interval;
if(regions.length())
{
std::set<std::string> regions_contig_set;
//regions of the form 'chr'|'chr:pos'|'chr:from-to'|'chr:from-[,...]
//Same format as bcftools
std::istringstream f1(regions);
std::string contig_region;
while(std::getline(f1, contig_region, ','))
{
std::string contig;
int64_t begin = 1;
int64_t end = INT64_MAX;
std::istringstream f2(contig_region);
std::string tmp_s;
auto idx = 0u;
while(std::getline(f2, tmp_s, ':'))
{
if(idx == 0u)
contig = tmp_s;
else
{
std::istringstream f3(tmp_s);
std::string boundaries;
auto idx2 = 0u;
while(std::getline(f3, boundaries, '-'))
{
if(idx2 == 0u)
{
begin = strtoll(boundaries.c_str(), 0, 10);
if(tmp_s.find("-") == std::string::npos) //"-" not found
end = begin;
}
else
end = strtoll(boundaries.c_str(), 0, 10);
++idx2;
}
}
++idx;
}
if(regions_contig_set.find(contig) == regions_contig_set.end())
{
regions_contig_set.insert(contig);
regions_contig_to_interval[contig] = std::pair<int64_t, int64_t>(begin, end);
}
}
//Find common contigs among gold, test, regions
auto copy_common = common_contigs;
{
auto iter = std::set_intersection(copy_common.begin(), copy_common.end(), regions_contig_set.begin(), regions_contig_set.end(),
common_contigs.begin());
common_contigs.resize(iter-common_contigs.begin());
}
std::sort(common_contigs.begin(), common_contigs.end());
}
//Contigs only in gold
std::vector<std::string> only_gold(gold_contigs.size());
{
auto iter = std::set_difference(gold_contigs.begin(), gold_contigs.end(), common_contigs.begin(), common_contigs.end(),
only_gold.begin());
only_gold.resize(iter - only_gold.begin());
}
gold.m_regions="";
for(auto& x : common_contigs)
gold.m_regions += (gold.create_region(regions, regions_contig_to_interval, x));
for(auto& x : only_gold)
gold.m_regions += (gold.create_region(regions, regions_contig_to_interval, x));
if(gold.m_regions.length())
gold.m_regions.pop_back(); //remove trailing ,
//Contigs only in test
std::vector<std::string> only_test(test_contigs.size());
{
auto iter = std::set_difference(test_contigs.begin(), test_contigs.end(), common_contigs.begin(), common_contigs.end(),
only_test.begin());
only_test.resize(iter - only_test.begin());
}
test.m_regions="";
for(auto& x : common_contigs)
test.m_regions += (test.create_region(regions, regions_contig_to_interval, x));
for(auto& x : only_test)
test.m_regions += (test.create_region(regions, regions_contig_to_interval, x));
if(test.m_regions.length())
test.m_regions.pop_back(); //remove trailing ,
gold.set_regions_and_open_file();
test.set_regions_and_open_file();
}
void construct_regions_for_partitions(const std::string& loader_json_filename, VidMapper*& vid_mapper,
JSONConfigBase& json_config_base, const int rank,
VCFDiffFile& gold, VCFDiffFile& test, std::string& regions)
{
regions = "";
//Parse JSON
std::ifstream ifs(loader_json_filename.c_str());
VERIFY_OR_THROW(ifs.is_open());
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
rapidjson::Document json;
json.Parse(str.c_str());
if(json.HasParseError())
throw VCFDiffException(std::string("Syntax error in JSON file ")+loader_json_filename);
VERIFY_OR_THROW(json.HasMember("vid_mapping_file") && json["vid_mapping_file"].IsString());
VERIFY_OR_THROW(json.HasMember("column_partitions"));
//callsets file
std::string callset_mapping_file = (json.HasMember("callset_mapping_file") && json["callset_mapping_file"].IsString())
? json["callset_mapping_file"].GetString() : "";
vid_mapper = static_cast<VidMapper*>(new FileBasedVidMapper(json["vid_mapping_file"].GetString(), callset_mapping_file));
//Limit #callsets
if(json.HasMember("limit_callset_row_idx") && json["limit_callset_row_idx"].IsInt64())
g_num_callsets = json["limit_callset_row_idx"].GetInt64() + 1;
else
g_num_callsets = vid_mapper->get_num_callsets();
//Get partitions
json_config_base.read_from_file(loader_json_filename);
auto column_interval = json_config_base.get_column_partition(rank);
//Find all contig regions in the current partition
auto current_position = column_interval.first;
std::string contig_name;
while(current_position <= column_interval.second)
{
int64_t contig_position = -1ll;
auto status = vid_mapper->get_contig_location(current_position, contig_name, contig_position);
if(status)
{
regions += contig_name;
regions += (":" + std::to_string(contig_position+1)+"-"); //regions string is 1-based
ContigInfo info;
VERIFY_OR_THROW(vid_mapper->get_contig_info(contig_name, info));
//partition ends here
if(info.m_tiledb_column_offset + info.m_length > column_interval.second)
regions += std::to_string(column_interval.second - info.m_tiledb_column_offset + 1); //regions string is 1-based
regions += ",";
}
status = vid_mapper->get_next_contig_location(current_position, contig_name, current_position);
if(!status) //no more contigs found
break;
}
if(regions.length()) //delete last comma
regions.pop_back();
}
enum ArgsIdxEnum
{
ARGS_USE_CALLSETS_FILE_FOR_SAMPLE_IDX=1000
};
void setup_samples_lut(const std::string& test_to_gold_callset_map_file, VCFDiffFile& gold, VCFDiffFile& test, const VidMapper* vid_mapper)
{
//Parse JSON
std::ifstream ifs(test_to_gold_callset_map_file.c_str());
VERIFY_OR_THROW(ifs.is_open());
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
rapidjson::Document json;
json.Parse(str.c_str());
if(json.HasParseError())
throw VCFDiffException(std::string("Syntax error in JSON file ")+test_to_gold_callset_map_file);
VERIFY_OR_THROW(json.HasMember("test_to_gold_callset_map") && json["test_to_gold_callset_map"].IsObject());
const auto& callset_map = json["test_to_gold_callset_map"];
//if(vid_mapper->get_num_callsets() != callset_map.MemberCount())
//throw VCFDiffException("ERROR: Mismatch in the #samples in the callsets JSON file and test-to-gold callset mapping file. Callsets JSON has "
//+std::to_string(vid_mapper->get_num_callsets())+" samples while mapping file has "+std::to_string(callset_map.MemberCount())+
//" - cannot perform any further comparisons");
//Everyone should have the same number of samples
if(g_num_callsets != bcf_hdr_nsamples(gold.m_hdr))
throw VCFDiffException("ERROR: Mismatch in the #samples in the gold VCF and the callsets JSON file. Gold has "+
std::to_string(bcf_hdr_nsamples(gold.m_hdr))+" samples while callsets JSON has "+std::to_string(g_num_callsets)+
" - cannot perform any further comparisons");
if(g_num_callsets != bcf_hdr_nsamples(test.m_hdr))
throw VCFDiffException("ERROR: Mismatch in the #samples in the test VCF and the callsets JSON file. Test has "+
std::to_string(bcf_hdr_nsamples(test.m_hdr))+" samples while callsets JSON has "+std::to_string(g_num_callsets)+
" - cannot perform any further comparisons");
auto num_samples_found = 0u;
for(auto b=callset_map.MemberBegin(), e=callset_map.MemberEnd();b!=e;++b)
{
VERIFY_OR_THROW((*b).value.IsString());
auto test_sample_name = (*b).name.GetString();
auto gold_sample_name = (*b).value.GetString();
auto gold_sample_idx = bcf_hdr_id2int(gold.m_hdr, BCF_DT_SAMPLE, gold_sample_name);
auto test_sample_idx = bcf_hdr_id2int(test.m_hdr, BCF_DT_SAMPLE, test_sample_name);
if(gold_sample_idx >= 0 && test_sample_idx >= 0)
{
test.m_samples_lut.add_input_merged_idx_pair(0, test_sample_idx, gold_sample_idx);
++num_samples_found;
}
}
VERIFY_OR_THROW(num_samples_found == g_num_callsets && "Test-to-gold callset mapping file does not have mapping for all samples");
}
int main(int argc, char** argv)
{
#ifdef HTSDIR
//Initialize MPI environment
auto rc = MPI_Init(0, 0);
if (rc != MPI_SUCCESS) {
printf ("Error starting MPI program. Terminating.\n");
MPI_Abort(MPI_COMM_WORLD, rc);
}
//Get my world rank
int my_world_mpi_rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &my_world_mpi_rank);
static struct option long_options[] =
{
{"threshold",1,0,'t'},
{"regions",1,0,'r'},
{"loader-config",1,0,'l'},
{"process-rank",1,0,'p'},
{"test_to_gold_callset_map_file",1,0, ARGS_USE_CALLSETS_FILE_FOR_SAMPLE_IDX}
};
int c = -1;
std::string regions = "";
std::string loader_json_filename = "";
std::string test_to_gold_callset_map_file = "";
while((c=getopt_long(argc, argv, "t:r:l:p:", long_options, NULL)) >= 0)
{
switch(c)
{
case 't':
g_threshold = strtod(optarg, 0);
break;
case 'r':
regions = std::move(std::string(optarg));
break;
case 'l':
loader_json_filename = std::move(std::string(optarg));
break;
case 'p':
my_world_mpi_rank = strtoll(optarg, 0, 10);
break;
case ARGS_USE_CALLSETS_FILE_FOR_SAMPLE_IDX:
test_to_gold_callset_map_file = std::move(std::string(optarg));
break;
default:
throw VCFDiffException(std::string("Unknown argument: ")+argv[optind-1]);
break;
}
}
if(optind+2 > argc)
{
std::cerr << "Needs 2 VCF files as input <gold> <test>\n";
exit(-1);
}
VCFDiffFile gold(argv[optind]);
VCFDiffFile test(argv[optind+1]);
auto use_loader_json_file = (loader_json_filename.length() && regions.length() == 0u);
//Setup luts
test.setup_luts(gold, use_loader_json_file && (test_to_gold_callset_map_file.length() > 0u));
//Loader input json - compare partitions created by vcf2tiledb
VidMapper* vid_mapper = 0;
JSONConfigBase json_config_base;
if(use_loader_json_file)
{
construct_regions_for_partitions(loader_json_filename, vid_mapper, json_config_base, my_world_mpi_rank,
gold, test, regions);
if(test_to_gold_callset_map_file.length())
setup_samples_lut(test_to_gold_callset_map_file, gold, test, vid_mapper);
}
//Regions
set_regions(gold, test, regions);
bool have_data = test.m_line && gold.m_line;
//Control variables
int curr_gold_contig_idx_in_vid = -1;
ContigInfo info;
auto both_must_have_valid_lines = false;
while(have_data)
{
auto lut_gold_contig_idx = test.m_contigs_lut.get_gold_idx_for_test(0, test.m_line->rid);
auto lut_test_contig_idx = test.m_contigs_lut.get_test_idx_for_gold(0, gold.m_line->rid);
both_must_have_valid_lines = false;
//Different contig
while(have_data && gold.m_line->rid != lut_gold_contig_idx)
{
//Gold has reached a contig not in test
if(GoldLUT::is_missing_value(lut_test_contig_idx))
{
std::cerr << "ERROR: Gold vcf has extra line(s) - printing the first extra line\n";
gold.print_line();
break; //because common contigs are handled first
}
//test has reached a contig not in gold
if(GoldLUT::is_missing_value(lut_gold_contig_idx))
{
std::cerr << "ERROR: Test vcf has extra line(s) - printing the first extra line\n";
test.print_line();
break; //because common contigs are handled first
}
//Both have entries in common_contigs, gold is at "lower" contig
if(std::string(bcf_hdr_id2name(gold.m_hdr, gold.m_line->rid)) < std::string(bcf_hdr_id2name(gold.m_hdr, lut_gold_contig_idx)))
{
std::cerr << "ERROR: Gold vcf has extra line(s) - printing the first extra line\n";
gold.print_line();
gold.seek_and_read(lut_gold_contig_idx, test.m_line->pos); //gold seeks to test's position
lut_test_contig_idx = gold.m_line ? test.m_contigs_lut.get_test_idx_for_gold(0, gold.m_line->rid) : lut_missing_value;
}
else //test seeks to gold's position
{
std::cerr << "ERROR: Test vcf has extra line(s) - printing the first extra line\n";
test.print_line();
test.seek_and_read(lut_test_contig_idx, gold.m_line->pos);
lut_gold_contig_idx = test.m_line ? test.m_contigs_lut.get_gold_idx_for_test(0, test.m_line->rid) : lut_missing_value;
}
have_data = test.m_line && gold.m_line;
}
//Same contig now
if(have_data && gold.m_line->rid == lut_gold_contig_idx)
{
auto do_compare = true;
//Set END points
gold.m_line->m_end_point = -1;
test.m_line->m_end_point = -1;
//Unpacks INFO fields
bcf_unpack(gold.m_line, BCF_UN_INFO);
bcf_unpack(test.m_line, BCF_UN_INFO);
bcf_set_end_point_from_info(gold.m_hdr, gold.m_line);
bcf_set_end_point_from_info(test.m_hdr, test.m_line);
//Variant types
bcf_get_variant_types(gold.m_line);
bcf_get_variant_types(test.m_line);
//NON_REF blocks
auto gold_is_NON_REF_block = (gold.m_line->d.var_type == VCF_NON_REF);
auto test_is_NON_REF_block = (test.m_line->d.var_type == VCF_NON_REF);
auto partial_overlap = ( (gold.m_line->pos <= test.m_line->pos && gold.m_line->m_end_point >= test.m_line->pos)
|| (test.m_line->pos <= gold.m_line->pos && test.m_line->m_end_point >= gold.m_line->pos) );
auto full_overlap = (gold.m_line->pos == test.m_line->pos && gold.m_line->m_end_point == test.m_line->m_end_point);
//Different positions
if(!full_overlap)
{
do_compare = false;
auto before_begin = false;
auto after_end = false;
//Check if variant is before or after the specified interval
if(vid_mapper)
{
if(curr_gold_contig_idx_in_vid != gold.m_line->rid)
{
auto status = vid_mapper->get_contig_info(bcf_hdr_id2name(gold.m_hdr, gold.m_line->rid), info);
curr_gold_contig_idx_in_vid = status ? gold.m_line->rid : -1;
}
if(curr_gold_contig_idx_in_vid == gold.m_line->rid)
{
//Variant starts before column partition
if((info.m_tiledb_column_offset + static_cast<int64_t>(gold.m_line->pos)) <
json_config_base.get_column_partition(my_world_mpi_rank).first)
before_begin = true;
//Variant past the column interval
if((info.m_tiledb_column_offset + static_cast<int64_t>(gold.m_line->m_end_point)) >
json_config_base.get_column_partition(my_world_mpi_rank).second)
after_end = true;
}
}
//Overlap and if this is a NON_REF interval, print warning and do comparison
if(gold_is_NON_REF_block && test_is_NON_REF_block && partial_overlap)
{
if(!before_begin && !after_end)
{
std::cout << "WARNING: Gold and test REF blocks overlap, but do not match exactly at position "<<
bcf_hdr_id2name(test.m_hdr, test.m_line->rid) << ","<< (std::min(test.m_line->pos, gold.m_line->pos)+1)<<"\n";
gold.print_line(std::cout);
test.print_line(std::cout);
}
do_compare = true;
}
else
{
if(!before_begin)
{
std::cerr << "ERROR: Lines with different positions found - resetting file ptr to next match position\n";
gold.print_line();
test.print_line();
}
//No overlap
if(!partial_overlap)
{
if(test.m_line->pos > gold.m_line->pos)
gold.seek_and_read(gold.m_line->rid, test.m_line->pos);
else
test.seek_and_read(test.m_line->rid, gold.m_line->pos);
}
else //partial overlap
{
if(test.m_line->m_end_point > gold.m_line->m_end_point)
{
//test contains deletion and gold contains spanning deletion, advance test
if(test.m_line->rlen > 1 && (test.m_line->d.var_type|VCF_INDEL)
&& (gold.m_line->d.var_type|VCF_SPANNING_DELETION) && test.m_line->pos <= gold.m_line->pos)
{
test.read_and_advance();
both_must_have_valid_lines = before_begin; //if !before_begin, then error message is already printed
}
else
gold.read_and_advance();
}
else
if(gold.m_line->m_end_point > test.m_line->m_end_point)
{
//gold contains deletion and test contains spanning deletion, advance gold
if(gold.m_line->rlen > 1 && (gold.m_line->d.var_type|VCF_INDEL)
&& (test.m_line->d.var_type|VCF_SPANNING_DELETION) && gold.m_line->pos <= test.m_line->pos)
{
gold.read_and_advance();
both_must_have_valid_lines = before_begin; //if !before_begin, then error message is already printed
}
else
test.read_and_advance();
}
else //equal end points - advance both
{
gold.read_and_advance();
test.read_and_advance();
both_must_have_valid_lines = true;
}
}
}
}
if(do_compare)
{
test.compare_line(gold.m_hdr, gold.m_line);
if(full_overlap)
{
gold.read_and_advance();
test.read_and_advance();
both_must_have_valid_lines = true;
}
else //must be partial_overlap
{
assert(partial_overlap);
if(test.m_line->m_end_point > gold.m_line->m_end_point)
gold.read_and_advance();
else
if(gold.m_line->m_end_point > test.m_line->m_end_point)
test.read_and_advance();
else //equal end points - advance both
{
gold.read_and_advance();
test.read_and_advance();
both_must_have_valid_lines = true;
}
}
}
have_data = test.m_line && gold.m_line;
}
else
break; //either no more data or moved to contigs not present in the other file
}
have_data = test.m_line && gold.m_line;
//Print error for the case where one of them has run out of lines, but the other has lines
if(!have_data)
{
for(auto i=0u;i<2u;++i)
{
auto& diff_ref = (i == 0u) ? gold : test;
auto name = (i == 0u) ? "Gold" : "Test";
if(diff_ref.m_line)
{
if(both_must_have_valid_lines)
{
std::cerr << "ERROR: "<< name << " vcf has extra line(s) - printing the first extra line\n";
diff_ref.print_line();
}
else
{
diff_ref.read_and_advance();
if(diff_ref.m_line)
{
std::cerr << "ERROR: "<< name << " vcf has extra line(s) - printing the first extra line\n";
diff_ref.print_line();
}
}
}
}
}
if(vid_mapper)
delete vid_mapper;
MPI_Finalize();
#else //ifdef HTSDIR
std::cerr << "vcf diff needs htslib - recompile with HTSDIR set\n";
#endif //ifdef HTSDIR
return 0;
}
| 40.37069 | 158 | 0.675251 | [
"vector"
] |
aa6ca2136f3a091de7f832f5aeccb37341d37c45 | 2,383 | cc | C++ | library/common/event/provisional_dispatcher.cc | ryanrhee/envoy-mobile | 34649625e979638dc51f2fa08336055d0cc1909d | [
"Apache-2.0"
] | 86 | 2020-11-16T23:40:04.000Z | 2022-03-15T20:36:21.000Z | library/common/event/provisional_dispatcher.cc | ryanrhee/envoy-mobile | 34649625e979638dc51f2fa08336055d0cc1909d | [
"Apache-2.0"
] | 497 | 2020-11-14T02:53:19.000Z | 2022-03-31T20:26:11.000Z | library/common/event/provisional_dispatcher.cc | ryanrhee/envoy-mobile | 34649625e979638dc51f2fa08336055d0cc1909d | [
"Apache-2.0"
] | 36 | 2020-11-14T00:06:50.000Z | 2022-03-03T19:27:50.000Z | #include "library/common/event/provisional_dispatcher.h"
#include "source/common/common/lock_guard.h"
#include "library/common/thread/lock_guard.h"
namespace Envoy {
namespace Event {
void ProvisionalDispatcher::drain(Event::Dispatcher& event_dispatcher) {
// TODO(goaway): Must be called from the Event::Dispatcher's thread, but we can't assert here
// because of behavioral oddities in Event::Dispatcher: event_dispatcher_->isThreadSafe() will
// crash.
Thread::LockGuard lock(state_lock_);
RELEASE_ASSERT(!drained_, "ProvisionalDispatcher::drain must only occur once");
drained_ = true;
event_dispatcher_ = &event_dispatcher;
for (const Event::PostCb& cb : init_queue_) {
event_dispatcher_->post(cb);
}
}
envoy_status_t ProvisionalDispatcher::post(Event::PostCb callback) {
Thread::LockGuard lock(state_lock_);
if (drained_) {
event_dispatcher_->post(callback);
return ENVOY_SUCCESS;
}
init_queue_.push_back(callback);
return ENVOY_SUCCESS;
}
bool ProvisionalDispatcher::isThreadSafe() const {
// Doesn't require locking because if a thread has a stale view of drained_, then by definition
// this wasn't a threadsafe call.
return TS_UNCHECKED_READ(drained_) && event_dispatcher_->isThreadSafe();
}
void ProvisionalDispatcher::deferredDelete(DeferredDeletablePtr&& to_delete) {
RELEASE_ASSERT(isThreadSafe(),
"ProvisionalDispatcher::deferredDelete must be called from a threadsafe context");
event_dispatcher_->deferredDelete(std::move(to_delete));
}
void ProvisionalDispatcher::pushTrackedObject(const ScopeTrackedObject* object) {
RELEASE_ASSERT(
isThreadSafe(),
"ProvisionalDispatcher::pushTrackedObject must be called from a threadsafe context");
event_dispatcher_->pushTrackedObject(object);
}
void ProvisionalDispatcher::popTrackedObject(const ScopeTrackedObject* expected_object) {
RELEASE_ASSERT(
isThreadSafe(),
"ProvisionalDispatcher::popTrackedObject must be called from a threadsafe context");
event_dispatcher_->popTrackedObject(expected_object);
}
bool ProvisionalDispatcher::trackedObjectStackIsEmpty() const {
RELEASE_ASSERT(
isThreadSafe(),
"ProvisionalDispatcher::trackedObjectStackIsEmpty must be called from a threadsafe context");
return event_dispatcher_->trackedObjectStackIsEmpty();
}
} // namespace Event
} // namespace Envoy
| 33.56338 | 99 | 0.768359 | [
"object"
] |
aa77b6a2e1f21c16139638682bfdbd594665bcd1 | 3,950 | cpp | C++ | src/libcore/src/ccm/core/StackTrace.cpp | sparkoss/ccm | 9ed67a7cbdc9c69f4182e72be8e8b6b23d7c3c8d | [
"Apache-2.0"
] | 6 | 2018-05-08T10:08:21.000Z | 2021-11-13T13:22:58.000Z | src/libcore/src/ccm/core/StackTrace.cpp | sparkoss/ccm | 9ed67a7cbdc9c69f4182e72be8e8b6b23d7c3c8d | [
"Apache-2.0"
] | 1 | 2018-05-08T10:20:17.000Z | 2018-07-23T05:19:19.000Z | src/libcore/src/ccm/core/StackTrace.cpp | sparkoss/ccm | 9ed67a7cbdc9c69f4182e72be8e8b6b23d7c3c8d | [
"Apache-2.0"
] | 4 | 2018-03-13T06:21:11.000Z | 2021-06-19T02:48:07.000Z | //=========================================================================
// Copyright (C) 2018 The C++ Component Model(CCM) 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.
//=========================================================================
#include "ccm/core/AutoLock.h"
#include "ccm/core/CStackTraceElement.h"
#include "ccm/core/NativeBacktrace.h"
#include "ccm/core/StackTrace.h"
#include "ccm.core.IStackTraceElement.h"
using ccm::io::IID_ISerializable;
namespace ccm {
namespace core {
CCM_INTERFACE_IMPL_2(StackTrace, SyncObject, IStackTrace, ISerializable);
ECode StackTrace::Constructor()
{
FillInStackTrace();
return NOERROR;
}
ECode StackTrace::Constructor(
/* [in] */ const String& message)
{
FillInStackTrace();
mDetailMessage = message;
return NOERROR;
}
ECode StackTrace::PrintStackTrace()
{
return NOERROR;
}
ECode StackTrace::PrintStackTrace(
/* [in] */ IPrintStream* s)
{
AutoPtr<PrintStreamOrWriter> ps = new WrappedPrintStream(s);
return PrintStackTrace(ps);
}
ECode StackTrace::PrintStackTrace(
/* [in] */ PrintStreamOrWriter* s)
{
AutoLock lock(s->Lock());
Array<IStackTraceElement*> trace = GetOurStackTrace();
for (Integer i = 0; i < trace.GetLength(); i++) {
IStackTraceElement* traceElement = trace[i];
s->Println(traceElement);
}
return NOERROR;
}
ECode StackTrace::PrintStackTrace(
/* [in] */ IPrintWriter* s)
{
AutoPtr<PrintStreamOrWriter> ps = new WrappedPrintWriter(s);
return PrintStackTrace(ps);
}
ECode StackTrace::FillInStackTrace()
{
mFrameCount = GetBacktrace(mFrames.GetPayload(), mFrames.GetLength());
return NOERROR;
}
ECode StackTrace::GetStackTrace(
/* [out, callee] */ Array<IStackTraceElement*>* stack)
{
VALIDATE_NOT_NULL(stack);
*stack = GetOurStackTrace().Clone();
return NOERROR;
}
Array<IStackTraceElement*> StackTrace::GetOurStackTrace()
{
if (mFrameCount > 0) {
String backtrace = DumpBacktrace(mFrames.GetPayload(), mFrameCount);
VOLATILE_SET(mStackTrace, Array<IStackTraceElement*>(mFrameCount));
Integer fromIdx = 0;
Integer lrIdx = backtrace.IndexOf(U'\n', fromIdx);
Integer count = 0;
while (lrIdx != -1 && count < mFrameCount) {
String line = backtrace.Substring(fromIdx, lrIdx).Trim();
mStackTrace.Set(count++, ParseElement(line));
fromIdx = lrIdx + 1;
lrIdx = backtrace.IndexOf(U'\n', fromIdx);
}
}
return mStackTrace;
}
AutoPtr<IStackTraceElement> StackTrace::ParseElement(
/* [in] */ const String& info)
{
if (info.IsNullOrEmpty()) return nullptr;
Integer fromIdx = 0;
Integer idx = info.IndexOf(" ", fromIdx);
if (idx == -1) return nullptr;
String no = info.Substring(0, idx);
fromIdx = idx + 5;
idx = info.IndexOf(" ", fromIdx);
if (idx == -1) return nullptr;
String pc = info.Substring(fromIdx, idx);
fromIdx = idx + 2;
idx = info.IndexOf(" ", fromIdx);
String soname = idx != -1 ? info.Substring(fromIdx, idx) : info.Substring(fromIdx);
if (soname.IsNullOrEmpty()) return nullptr;
String symbol;
if (idx != -1) {
symbol = info.Substring(idx + 1);
}
AutoPtr<IStackTraceElement> element;
CStackTraceElement::New(no, pc, soname, symbol, IID_IStackTraceElement, (IInterface**)&element);
return element;
}
}
}
| 28.832117 | 100 | 0.646329 | [
"model"
] |
aa7935326ee1cd4b68376dfd11622b4fbdf97b45 | 16,029 | cpp | C++ | Homework/boilerplate/main.cpp | DaixuanLi/Router-Lab | 4d677d38ae02c24af2fef1a0528612c6b86d2758 | [
"Linux-OpenIB"
] | null | null | null | Homework/boilerplate/main.cpp | DaixuanLi/Router-Lab | 4d677d38ae02c24af2fef1a0528612c6b86d2758 | [
"Linux-OpenIB"
] | null | null | null | Homework/boilerplate/main.cpp | DaixuanLi/Router-Lab | 4d677d38ae02c24af2fef1a0528612c6b86d2758 | [
"Linux-OpenIB"
] | null | null | null | #include "rip.h"
#include "router.h"
#include "router_hal.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <string.h>
#include <list>
#include <vector>
#define BROADCAST_ADDR 0x090000e0
typedef uint32_t in_addr_t;
typedef std::vector<RoutingTableEntry> ROUTINGLIST;
extern ROUTINGLIST RoutingList;
extern bool validateIPChecksum(uint8_t *packet, size_t len);
extern uint16_t calculateIPChecksum(uint8_t *packet, size_t len);
extern void update(bool insert, RoutingTableEntry entry);
extern bool query(uint32_t addr, uint32_t *nexthop, uint32_t *if_index);
extern bool query(uint32_t addr, uint32_t *nexthop, uint32_t *if_index, uint32_t *metric);
extern bool query_percise(uint32_t addr,uint32_t len, uint32_t *nexthop, uint32_t *if_index, uint32_t *metric);
extern bool query_percise(uint32_t addr,uint32_t len, uint32_t *nexthop, uint32_t *if_index);
extern bool forward(uint8_t *packet, size_t len);
extern bool disassemble(const uint8_t *packet, uint32_t len, RipPacket *output);
extern uint32_t assemble(const RipPacket *rip, uint8_t *buffer);
void printRoutingTable() {
printf("=== current routing table ===\n");
for (const RoutingTableEntry &e : RoutingList) {
printf("\tip: %u.%u.%u.%u/%u ", (uint8_t)e.addr, (uint8_t)(e.addr>>8), (uint8_t)(e.addr>>16), (uint8_t)(e.addr>>24), e.len);
printf("if: %u ", e.if_index);
printf("nexthop: %u.%u.%u.%u ", (uint8_t)e.nexthop, (uint8_t)(e.nexthop>>8), (uint8_t)(e.nexthop>>16), (uint8_t)(e.nexthop>>24));
printf("metric: %u\n", e.metric);
}
printf("\n****************\nsize:%d\n",RoutingList.size());
}
uint32_t mask2len(uint32_t mask)
{
mask = ntohl(mask);
int i = 0;
for (; i < 32; i++)
{
if ((mask & (1 << i)) != 0)
{
break;
}
}
return 32 - i;
}
uint32_t len2mask(uint32_t len)
{
uint32_t mask = 0;
mask = (~0) << (32 - len);
//printf("calcmask,len=%ud:%x\n",len,mask);
return htonl(mask);
}
void printRipPacket(RipPacket p) {
/*
printf("=== receive rip packet ===\n");
printf("command:%u,num:%u\n",p.command,p.numEntries);
for (int i = 0;i<p.numEntries;i++) {
printf("\tip: %u.%u.%u.%u/%u ", (uint8_t)p.entries[i].addr, (uint8_t)(p.entries[i].addr>>8), (uint8_t)(p.entries[i].addr>>16), (uint8_t)(p.entries[i].addr>>24), mask2len(p.entries[i].mask));
printf("nexthop: %u.%u.%u.%u ", (uint8_t)p.entries[i].nexthop, (uint8_t)(p.entries[i].nexthop>>8), (uint8_t)(p.entries[i].nexthop>>16), (uint8_t)(p.entries[i].nexthop>>24));
printf("metric: %u\n", p.entries[i].metric);
printf("~~~~~~~~~~~~~~");
}*/
}
RoutingTableEntry *RipEntry2RoutingTableEntry(RipEntry in,uint32_t _nexthop,uint32_t _if_index) {
RoutingTableEntry *rentry = new RoutingTableEntry();
rentry->addr = in.addr;
rentry->len = mask2len(in.mask);
rentry->metric = in.metric;
rentry->nexthop = _nexthop;
rentry->if_index = _if_index;
return rentry;
}
RipEntry *RoutingEntry2RipEntry(RoutingTableEntry in)
{
RipEntry *rentry = new RipEntry();
rentry->addr = in.addr;
rentry->mask = len2mask(in.len);
rentry->metric = in.metric;
rentry->nexthop = in.nexthop;
return rentry;
}
uint32_t writeIpUdpHead(uint8_t *buffer, uint32_t body_len, uint32_t src_addr, uint32_t dst_addr)
{
/**
* 代码中在发送 RIP 包的时候,会涉及到 IP 头的构造,由于不需要用各种高级特性,
* 可以这么设定:V=4,IHL=5,TOS(DSCP/ECN)=0,ID=0,FLAGS/OFF=0,
* TTL=1,其余按照要求实现即可。
*/
uint16_t tot_len = body_len + 20 + 8; // 20 for ip, 8 for udp
buffer[0] = 0x45;
buffer[1] = 0xC0;
buffer[2] = (uint8_t)(tot_len >> 8), buffer[3] = (uint8_t)tot_len; // total length
buffer[4] = 0, buffer[5] = 0; // identification
buffer[6] = 0x40, buffer[7] = 0; // fragment
buffer[8] = 1; // TTL
buffer[9] = 0x11; // protocol: udp
// buffer[10], buffer[11]: checksum
memcpy(&buffer[12], &src_addr, sizeof(src_addr)); // src ip
memcpy(&buffer[16], &dst_addr, sizeof(dst_addr)); // dst_ip
uint16_t checksum = calculateIPChecksum(buffer, 20);
buffer[10] = (uint8_t)(checksum >> 8), buffer[11] = (uint8_t)checksum; // checksum
// UDP
// port = 520
buffer[20] = 0x02;
buffer[21] = 0x08;
buffer[22] = 0x02;
buffer[23] = 0x08;
buffer[24] = (body_len + 8) >> 8;
buffer[25] = (body_len + 8) & 0x00ff;
return tot_len;
}
extern bool isMatch(uint32_t addr, uint32_t len, uint32_t target);
uint8_t packet[2048];
uint8_t output[2048];
// 0: 192.168.3.2
// 1: 10.0.1.1
// 2: 10.0.2.1
// 3: 10.0.3.1
// 你可以按需进行修改,注意端序
in_addr_t addrs[N_IFACE_ON_BOARD] = {0x0101a8c0, 0x0103a8c0, 0x0102a8c0, 0x0000000a};
int main(int argc, char *argv[])
{
int res = HAL_Init(1, addrs);
if (res < 0)
{
return res;
}
// 0b. Add direct routes
// For example:
// 10.0.0.0/24 if 0
// 10.0.1.0/24 if 1
// 10.0.2.0/24 if 2
// 10.0.3.0/24 if 3
for (uint32_t i = 0; i < N_IFACE_ON_BOARD; i++)
{
RoutingTableEntry entry = {
.addr = addrs[i], // big endian
.len = 24, // small endian
.if_index = i, // small endian
.nexthop = 0, // big endian, means direct
.metric = 1};
update(true, entry);
}
uint64_t last_time = 0;
while (1)
{
uint64_t time = HAL_GetTicks();
if (time > last_time + 5 * 1000)
{
// What to do? send Rip Response.
printf("Timer\n");
last_time = time;
printRoutingTable();
RipPacket *pkg2send = new RipPacket();
pkg2send->command = 2;
pkg2send->numEntries = 0;
for (uint32_t i = 0; i < N_IFACE_ON_BOARD; i++)
{
int send_num = 0;
int count = 0;
for (auto it = RoutingList.begin(); it != RoutingList.end(); it++)
{
//printf("%d : %d sum = %d\n",count++,pkg2send->numEntries,send_num);
if (pkg2send->numEntries == 25)
{
send_num += 25;
// printf("send rip:\n");
// printRipPacket(*pkg2send);
uint32_t len = assemble(pkg2send, &output[28]);
len = writeIpUdpHead(output, len, addrs[i], BROADCAST_ADDR);
/*printf("send udp %d:",len);
for(int j = 0;j<len;j++){
printf("%hhu",output[j]);
}
printf("\n");*/
macaddr_t broadcast_macaddr;
HAL_ArpGetMacAddress(i, BROADCAST_ADDR, broadcast_macaddr);
HAL_SendIPPacket(i, output, len, broadcast_macaddr);
pkg2send->numEntries = 0;
}
RipEntry *insert = RoutingEntry2RipEntry(*it);
if (insert->addr == addrs[i])
{
continue;
}
if ((*it).if_index == i)
{
continue;
}
// poison reverse
/*if (isMatch(insert->nexthop, (*it).len, addrs[i]))
{
continue;
//insert->metric = 16;
}*/
pkg2send->entries[pkg2send->numEntries++] = *insert;
}
send_num += pkg2send->numEntries;
//printf("\n*******************\nport= %d,send num = %d\n",i,send_num);
//printf("send rip:\n");
//printRipPacket(*pkg2send);
uint32_t len = assemble(pkg2send, &output[28]);
len = writeIpUdpHead(output, len, addrs[i], BROADCAST_ADDR);
macaddr_t broadcast_macaddr;
/*printf("send udp %d:",len);
for(int j = 0;j<len;j++){
if(j % 8 == 0){
printf("\n");
}
printf("%x ",output[j]);
}
printf("\n");
*/
HAL_ArpGetMacAddress(i, BROADCAST_ADDR, broadcast_macaddr);
printf("5");
HAL_SendIPPacket(i, output, len, broadcast_macaddr);
pkg2send->numEntries = 0;
}
}
int mask = (1 << N_IFACE_ON_BOARD) - 1;
macaddr_t src_mac;
macaddr_t dst_mac;
int if_index;
res = HAL_ReceiveIPPacket(mask, packet, sizeof(packet), src_mac, dst_mac,
1000, &if_index);
//printf("receive packet from %u check:\n",if_index);
if (res == HAL_ERR_EOF) {
printf("bad receive.");
break;
}
else if (res < 0)
{
printf("incorrect receive.");
return res;
}
else if (res == 0)
{
printf("receive timeout.");
// Timeout
continue;
}
else if (res > sizeof(packet))
{
printf("packet is truncate.");
// packet is truncated, ignore it
continue;
}
// 1. validate
if (!validateIPChecksum(packet, res)) {
printf("Invalid IP Checksum\n");
continue;
}
in_addr_t src_addr, dst_addr;
// extract src_addr and dst_addr from packet
// big endian
src_addr = packet[12] + (packet[13] << 8) + (packet[14] << 16) + (packet[15] << 24) ;
dst_addr = packet[16] + (packet[17] << 8) + (packet[18] << 16) + (packet[19] << 24) ;
// 2. check whether dst is me
bool dst_is_me = false;
for (int i = 0; i < N_IFACE_ON_BOARD; i++) {
if (memcmp(&dst_addr, &addrs[i], sizeof(in_addr_t)) == 0) {
dst_is_me = true;
break;
}
}
// TODO: Handle rip multicast address(224.0.0.9)?
if(dst_addr == BROADCAST_ADDR){
// TODO: RIP?
//printf("find broadcast received.\n");
RipPacket rip;
if (disassemble(packet, res, &rip))
{
//printf("validate broadcast.\n");
printRipPacket(rip);
if (rip.command == 1)
{
// request
RipPacket *pkg2send = new RipPacket();
pkg2send->numEntries = 0;
pkg2send->command = 2;
for (auto it = RoutingList.begin(); it != RoutingList.end(); it++)
{
if (pkg2send->numEntries == 25)
{
uint32_t len = assemble(pkg2send, &output[28]);
len = writeIpUdpHead(output, len, dst_addr, src_addr);
printf("6");
HAL_SendIPPacket(if_index, output, len, src_mac);
pkg2send->numEntries = 0;
}
RipEntry *insert = RoutingEntry2RipEntry(*it);
if (insert->addr == src_addr)
{
continue;
}
if ((*it).if_index == if_index)
{
continue;
}
/*
// poison reverse
if (isMatch(insert->nexthop, (*it).len, src_addr))
{
insert->metric = 16;
}*/
pkg2send->entries[pkg2send->numEntries++] = *insert;
}
uint32_t len = assemble(pkg2send, &output[28]);
len = writeIpUdpHead(output, len, dst_addr, src_addr);
printf("7");
HAL_SendIPPacket(if_index, output, len, src_mac);
pkg2send->numEntries = 0;
}
else
{
//printf("response.\n");
// response
// TODO: use query and update
uint32_t nexthop1;
uint32_t if_index1;
uint32_t metric1;
for(int i = 0;i<rip.numEntries;i++) {
//printf("check entry %d\n",mask2len(rip.entries[i].mask));
if(query_percise(rip.entries[i].addr,mask2len(rip.entries[i].mask), &nexthop1, &if_index1,&metric1)) {
//printf("exist!");
if(rip.entries[i].metric + 1 < metric1) {
rip.entries[i].metric += 1;
update(true, *RipEntry2RoutingTableEntry((rip.entries[i]),src_addr,if_index));
//printf("update!");
} else if (rip.entries[i].metric + 1 > 16) {
//update(false, *RipEntry2RoutingTableEntry((rip.entries[i]),src_addr));
//printf("delete!");
}
}
else{
//printf("1 not exist!");
if (rip.entries[i].metric + 1 <= 16) {
//printf("insert rip metric:%d",rip.entries[i].metric);
rip.entries[i].metric += 1;
update(true, *RipEntry2RoutingTableEntry((rip.entries[i]),src_addr,if_index));
}
}
}
}
}
continue;
}
if (dst_is_me)
{
// TODO: RIP?
//printf("me dest broadcast received.\n");
RipPacket rip;
if (disassemble(packet, res, &rip))
{
//printf("validate broadcast.\n");
//printRipPacket(rip);
if (rip.command == 1)
{
// request
RipPacket *pkg2send = new RipPacket();
pkg2send->numEntries = 0;
pkg2send->command = 2;
for (auto it = RoutingList.begin(); it != RoutingList.end(); it++)
{
if (pkg2send->numEntries == 25)
{
uint32_t len = assemble(pkg2send, &output[28]);
len = writeIpUdpHead(output, len, dst_addr, src_addr);
printf("6");
HAL_SendIPPacket(if_index, output, len, src_mac);
pkg2send->numEntries = 0;
}
RipEntry *insert = RoutingEntry2RipEntry(*it);
if (insert->addr == src_addr)
{
continue;
}
if (isMatch(insert->addr, (*it).len, src_addr))
{
continue;
}
// poison reverse
if (isMatch(insert->nexthop, (*it).len, src_addr))
{
continue;
}
pkg2send->entries[pkg2send->numEntries++] = *insert;
}
uint32_t len = assemble(pkg2send, &output[28]);
len = writeIpUdpHead(output, len, dst_addr, src_addr);
printf("7");
HAL_SendIPPacket(if_index, output, len, src_mac);
pkg2send->numEntries = 0;
}
else
{
//printf("response.\n");
// response
// TODO: use query and update
uint32_t nexthop1;
uint32_t if_index1;
uint32_t metric1;
for(int i = 0;i<rip.numEntries;i++) {
//printf("check entry %d\n",mask2len(rip.entries[i].mask));
if(query_percise(rip.entries[i].addr, mask2len(rip.entries[i].mask),&nexthop1, &if_index1,&metric1)) {
//printf("exist!");
if(rip.entries[i].metric + 1 < metric1) {
rip.entries[i].metric += 1;
update(true, *RipEntry2RoutingTableEntry((rip.entries[i]),src_addr,if_index));
//printf("update!");
} else if (rip.entries[i].metric + 1 > 16) {
update(false, *RipEntry2RoutingTableEntry((rip.entries[i]),src_addr,if_index));
//printf("delete!");
}
}
else{
//printf("2 not exist!");
if (rip.entries[i].metric + 1 <= 16) {
//printf("insert rip metric:%d",rip.entries[i].metric);
rip.entries[i].metric += 1;
update(true, *RipEntry2RoutingTableEntry((rip.entries[i]),src_addr,if_index));
}
}
}
}
}
}
else
{
// forward
// beware of endianness
printf("fowarding!\n");
uint32_t nexthop, dest_if;
if (query(dst_addr, &nexthop, &dest_if))
{
// found
macaddr_t dest_mac;
// direct routing
if (nexthop == 0)
{
nexthop = dst_addr;
}
if (HAL_ArpGetMacAddress(dest_if, nexthop, dest_mac) == 0)
{
// found
memcpy(output, packet, res);
// update ttl and checksum
forward(output, res);
// TODO: you might want to check ttl=0 case
if(packet[8] != 0) {
printf("4");
HAL_SendIPPacket(dest_if, output, res, dest_mac);
}
}
else
{
// not found
// you can drop it
printf("ARP not found for nexthop:%x,if:%x\n", nexthop,dest_if);
}
} else {
// not found
// optionally you can send ICMP Host Unreachable
//printf("IP not found for %x\n", src_addr);
}
}
}
return 0;
}
| 32.645621 | 201 | 0.537401 | [
"vector"
] |
aa8491fd703ab347d253b45eb6d0df65c3a5c27c | 3,649 | cpp | C++ | Vic2ToHoI4/Source/Mappers/Provinces/ProvinceMapperFactory.cpp | ParadoxGameConverters/Vic2ToHoI4 | ac5d77f2bcf8b9b7cb9dfe78a0bc85875600fc1c | [
"MIT"
] | 25 | 2018-12-10T03:41:49.000Z | 2021-10-04T10:42:36.000Z | Vic2ToHoI4/Source/Mappers/Provinces/ProvinceMapperFactory.cpp | Elfangor567/Vic2ToHoI4 | 55df397bbb65ecb690fe6bb5fcaf757d17bcc885 | [
"MIT"
] | 739 | 2018-12-13T02:01:20.000Z | 2022-03-28T02:57:13.000Z | Vic2ToHoI4/Source/Mappers/Provinces/ProvinceMapperFactory.cpp | IhateTrains/Vic2ToHoI4 | 5ad7f7c259f7495a10e043ade052d3b18a8951dc | [
"MIT"
] | 43 | 2018-12-10T03:41:58.000Z | 2022-03-22T23:55:41.000Z | #include "ProvinceMapperFactory.h"
#include "CommonRegexes.h"
#include "Configuration.h"
#include "GameVersion.h"
#include "Log.h"
#include "OSCompatibilityLayer.h"
#include "ParserHelpers.h"
#include "ProvinceMapper.h"
#include "VersionedMappings.h"
#include <fstream>
namespace
{
std::optional<int> getNextProvinceNumFromFile(std::ifstream& definitions)
{
std::string line;
getline(definitions, line);
if (const auto pos = line.find_first_of(';'); pos != std::string::npos)
{
try
{
return stoi(line.substr(0, pos));
}
catch (...)
{
Log(LogLevel::Warning) << "Bad line in /map/definition.csv: " << line;
}
return 0;
}
return std::nullopt;
}
void verifyProvinceIsMapped(const Mappers::VersionedMappings& versionedMapper, int provNum)
{
if (!versionedMapper.getHoI4ToVic2Mapping().contains(provNum))
{
Log(LogLevel::Warning) << "No mapping for HoI4 province " << provNum;
}
}
void checkAllHoI4ProvincesMapped(const Mappers::VersionedMappings& versionedMapper,
const Configuration& theConfiguration)
{
std::ifstream definitions(theConfiguration.getHoI4Path() + "/map/definition.csv");
if (!definitions.is_open())
{
throw std::runtime_error("Could not open " + theConfiguration.getHoI4Path() + "/map/definition.csv");
}
while (true)
{
auto provNum = getNextProvinceNumFromFile(definitions);
if (!provNum)
{
break;
}
if (*provNum == 0)
{
continue;
}
verifyProvinceIsMapped(versionedMapper, *provNum);
}
definitions.close();
}
} // namespace
Mappers::ProvinceMapper::Factory::Factory(const Configuration& theConfiguration)
{
registerRegex(R"(\d\.[\d]+\.\d)", [this, theConfiguration](const std::string& unused, std::istream& theStream) {
const auto thisVersionsMappings = versionedMappingsFactory.importVersionedMappings(theStream);
checkAllHoI4ProvincesMapped(*thisVersionsMappings, theConfiguration);
provinceMapper->HoI4ToVic2ProvinceMap = thisVersionsMappings->getHoI4ToVic2Mapping();
provinceMapper->Vic2ToHoI4ProvinceMap = thisVersionsMappings->getVic2ToHoI4Mapping();
});
registerRegex(commonItems::catchallRegex, commonItems::ignoreItem);
}
std::unique_ptr<Mappers::ProvinceMapper> Mappers::ProvinceMapper::Factory::importProvinceMapper(
const Configuration& theConfiguration)
{
Log(LogLevel::Info) << "Parsing province mappings";
provinceMapper = std::make_unique<ProvinceMapper>();
auto mapped = false;
for (const auto& mod: theConfiguration.getVic2Mods())
{
if (commonItems::DoesFileExist(mod.path + "/hybridization.txt"))
{
parseFile("Configurables/Historical Project Mod 0.4.6_province_mappings.txt");
mapped = true;
break;
}
if (commonItems::DoesFileExist("Configurables/" + mod.name + "_province_mappings.txt"))
{
parseFile("Configurables/" + mod.name + "_province_mappings.txt");
mapped = true;
break;
}
}
if (!mapped)
{
parseFile("Configurables/province_mappings.txt");
}
return std::move(provinceMapper);
}
std::vector<int> Mappers::ProvinceMapper::getVic2ToHoI4ProvinceMapping(const int Vic2Province) const
{
const auto mapping = Vic2ToHoI4ProvinceMap.find(Vic2Province);
if (mapping == Vic2ToHoI4ProvinceMap.end())
{
Log(LogLevel::Warning) << "No mapping found for Vic2 province " << Vic2Province;
return {};
}
return mapping->second;
}
std::vector<int> Mappers::ProvinceMapper::getHoI4ToVic2ProvinceMapping(const int HoI4Province) const
{
const auto mapping = HoI4ToVic2ProvinceMap.find(HoI4Province);
if (mapping == HoI4ToVic2ProvinceMap.end())
{
Log(LogLevel::Warning) << "No mapping found for HoI4 province " << HoI4Province;
return {};
}
return mapping->second;
} | 24.993151 | 113 | 0.734448 | [
"vector"
] |
aa8bb468cabe5867e01a466a32cc33d466b97387 | 2,877 | cpp | C++ | src/Tests/Neighbourhood.cpp | dsiuta/Comps | 2071279280d33946e975de25deedc60f1881eda0 | [
"BSD-3-Clause"
] | null | null | null | src/Tests/Neighbourhood.cpp | dsiuta/Comps | 2071279280d33946e975de25deedc60f1881eda0 | [
"BSD-3-Clause"
] | null | null | null | src/Tests/Neighbourhood.cpp | dsiuta/Comps | 2071279280d33946e975de25deedc60f1881eda0 | [
"BSD-3-Clause"
] | null | null | null | #include "../Data.h"
#include "../Loggers/Default.h"
#include "../Loggers/Logger.h"
#include "../Global.h"
#include "../Member.h"
#include "../Ensemble.h"
#include "../Inputs/Input.h"
#include "../Location.h"
#include "../Neighbourhoods/Neighbourhood.h"
#include "../Parameters.h"
#include <gtest/gtest.h>
namespace {
class NeighbourhoodTest : public ::testing::Test {
protected:
NeighbourhoodTest() {
// You can do set-up work for each test here.
Options opt;
opt.addOption("inputs", "test.grid16");
mData = new Data(opt);
mInput = Input::getScheme(Options("tag=grid16 class=InputGrid folder=testGrid type=forecast lats=0:3 lons=0:3 offsets=0"));
}
Neighbourhood* getNeighbourhood(int num) {
std::stringstream ss;
ss << "tag=test class=NeighbourhoodNearest num=" << num;
Neighbourhood* hood = Neighbourhood::getScheme(Options(ss.str()));
mHoods.push_back(hood);
return hood;
}
virtual ~NeighbourhoodTest() {
// You can do clean-up work that doesn't throw exceptions here.
for(int i = 0; i < mHoods.size(); i++) {
delete mHoods[i];
}
delete mData;
}
virtual void SetUp() {
// Code here will be called immediately after the constructor (right
// before each test).
}
virtual void TearDown() {
// Code here will be called immediately after each test (right
// before the destructor).
}
Data* mData;
Input* mInput;
std::vector<Neighbourhood*> mHoods;
};
TEST_F(NeighbourhoodTest, nearestNeighbour) {
std::vector<Location> allLocations = mInput->getLocations();
ASSERT_TRUE(allLocations.size()>0);
Neighbourhood* hood = getNeighbourhood(1);
for(int i = 0; i < allLocations.size(); i++) {
Location location = allLocations[i];
std::vector<Location> locations = hood->select(mInput, location);
ASSERT_EQ(locations.size(), 1);
EXPECT_EQ(locations[0].getId(), location.getId());
}
}
TEST_F(NeighbourhoodTest, nearest4Neighbours) {
std::vector<Location> allLocations = mInput->getLocations();
ASSERT_TRUE(allLocations.size()>0);
Location location = allLocations[0];
Neighbourhood* hood = getNeighbourhood(4);
std::vector<Location> locations = hood->select(mInput, location);
int expected[] = {0,1,4,5};
int size = sizeof(expected)/sizeof(int);
ASSERT_EQ(locations.size(), size);
for(int i = 0; i < size; i++) {
EXPECT_EQ(expected[i], locations[i].getId());
}
}
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 35.085366 | 135 | 0.590198 | [
"vector"
] |
aa8fef4dcd85f7a0d33853fe01c8481bebde4569 | 17,844 | cpp | C++ | platform_bionic-android-vts-12.0_r2/tests/system_properties_test.cpp | webos21/xbionic | ffb3965e86ae4a921d0cffbfdc44cbdfe6acf67a | [
"Apache-2.0"
] | 1 | 2019-05-04T02:30:08.000Z | 2019-05-04T02:30:08.000Z | platform_bionic-android-vts-12.0_r2/tests/system_properties_test.cpp | webos21/xbionic | ffb3965e86ae4a921d0cffbfdc44cbdfe6acf67a | [
"Apache-2.0"
] | null | null | null | platform_bionic-android-vts-12.0_r2/tests/system_properties_test.cpp | webos21/xbionic | ffb3965e86ae4a921d0cffbfdc44cbdfe6acf67a | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2013 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.
*/
#include <gtest/gtest.h>
#include <errno.h>
#include <sys/wait.h>
#include <unistd.h>
#include <string>
#include <thread>
#include <android-base/file.h>
#include <android-base/silent_death_test.h>
using namespace std::literals;
#if defined(__BIONIC__)
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#include <system_properties/system_properties.h>
class SystemPropertiesTest : public SystemProperties {
public:
SystemPropertiesTest() : SystemProperties(false) {
valid_ = AreaInit(dir_.path, nullptr);
}
~SystemPropertiesTest() {
if (valid_) {
contexts_->FreeAndUnmap();
}
}
bool valid() const {
return valid_;
}
private:
TemporaryDir dir_;
bool valid_;
};
static void foreach_test_callback(const prop_info *pi, void* cookie) {
size_t *count = static_cast<size_t *>(cookie);
ASSERT_TRUE(pi != nullptr);
(*count)++;
}
static void hierarchical_test_callback(const prop_info *pi, void *cookie) {
bool (*ok)[8][8] = static_cast<bool (*)[8][8]>(cookie);
char name[PROP_NAME_MAX];
char value[PROP_VALUE_MAX];
__system_property_read(pi, name, value);
int name_i, name_j, name_k;
int value_i, value_j, value_k;
ASSERT_EQ(3, sscanf(name, "property_%d.%d.%d", &name_i, &name_j, &name_k));
ASSERT_EQ(3, sscanf(value, "value_%d.%d.%d", &value_i, &value_j, &value_k));
ASSERT_EQ(name_i, value_i);
ASSERT_GE(name_i, 0);
ASSERT_LT(name_i, 8);
ASSERT_EQ(name_j, value_j);
ASSERT_GE(name_j, 0);
ASSERT_LT(name_j, 8);
ASSERT_EQ(name_k, value_k);
ASSERT_GE(name_k, 0);
ASSERT_LT(name_k, 8);
ok[name_i][name_j][name_k] = true;
}
#endif // __BIONIC__
TEST(properties, __system_property_add) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
ASSERT_EQ(0, system_properties.Add("other_property", 14, "value2", 6));
ASSERT_EQ(0, system_properties.Add("property_other", 14, "value3", 6));
// check that there is no limit on property name length
char name[PROP_NAME_MAX + 11];
name[0] = 'p';
for (size_t i = 1; i < sizeof(name); i++) {
name[i] = 'x';
}
name[sizeof(name)-1] = '\0';
ASSERT_EQ(0, system_properties.Add(name, strlen(name), "value", 5));
char propvalue[PROP_VALUE_MAX];
ASSERT_EQ(6, system_properties.Get("property", propvalue));
ASSERT_STREQ(propvalue, "value1");
ASSERT_EQ(6, system_properties.Get("other_property", propvalue));
ASSERT_STREQ(propvalue, "value2");
ASSERT_EQ(6, system_properties.Get("property_other", propvalue));
ASSERT_STREQ(propvalue, "value3");
ASSERT_EQ(5, system_properties.Get(name, propvalue));
ASSERT_STREQ(propvalue, "value");
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, __system_property_update) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
ASSERT_EQ(0, system_properties.Add("property", 8, "oldvalue1", 9));
ASSERT_EQ(0, system_properties.Add("other_property", 14, "value2", 6));
ASSERT_EQ(0, system_properties.Add("property_other", 14, "value3", 6));
const prop_info* pi = system_properties.Find("property");
ASSERT_TRUE(pi != nullptr);
system_properties.Update(const_cast<prop_info*>(pi), "value4", 6);
pi = system_properties.Find("other_property");
ASSERT_TRUE(pi != nullptr);
system_properties.Update(const_cast<prop_info*>(pi), "newvalue5", 9);
pi = system_properties.Find("property_other");
ASSERT_TRUE(pi != nullptr);
system_properties.Update(const_cast<prop_info*>(pi), "value6", 6);
char propvalue[PROP_VALUE_MAX];
ASSERT_EQ(6, system_properties.Get("property", propvalue));
ASSERT_STREQ(propvalue, "value4");
ASSERT_EQ(9, system_properties.Get("other_property", propvalue));
ASSERT_STREQ(propvalue, "newvalue5");
ASSERT_EQ(6, system_properties.Get("property_other", propvalue));
ASSERT_STREQ(propvalue, "value6");
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, fill) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
char prop_name[PROP_NAME_MAX];
char prop_value[PROP_VALUE_MAX];
char prop_value_ret[PROP_VALUE_MAX];
int count = 0;
int ret;
while (true) {
ret = snprintf(prop_name, PROP_NAME_MAX - 1, "property_%d", count);
memset(prop_name + ret, 'a', PROP_NAME_MAX - 1 - ret);
ret = snprintf(prop_value, PROP_VALUE_MAX - 1, "value_%d", count);
memset(prop_value + ret, 'b', PROP_VALUE_MAX - 1 - ret);
prop_name[PROP_NAME_MAX - 1] = 0;
prop_value[PROP_VALUE_MAX - 1] = 0;
ret = system_properties.Add(prop_name, PROP_NAME_MAX - 1, prop_value, PROP_VALUE_MAX - 1);
if (ret < 0)
break;
count++;
}
// For historical reasons at least 247 properties must be supported
ASSERT_GE(count, 247);
for (int i = 0; i < count; i++) {
ret = snprintf(prop_name, PROP_NAME_MAX - 1, "property_%d", i);
memset(prop_name + ret, 'a', PROP_NAME_MAX - 1 - ret);
ret = snprintf(prop_value, PROP_VALUE_MAX - 1, "value_%d", i);
memset(prop_value + ret, 'b', PROP_VALUE_MAX - 1 - ret);
prop_name[PROP_NAME_MAX - 1] = 0;
prop_value[PROP_VALUE_MAX - 1] = 0;
memset(prop_value_ret, '\0', PROP_VALUE_MAX);
ASSERT_EQ(PROP_VALUE_MAX - 1, system_properties.Get(prop_name, prop_value_ret));
ASSERT_EQ(0, memcmp(prop_value, prop_value_ret, PROP_VALUE_MAX));
}
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, __system_property_foreach) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
ASSERT_EQ(0, system_properties.Add("other_property", 14, "value2", 6));
ASSERT_EQ(0, system_properties.Add("property_other", 14, "value3", 6));
size_t count = 0;
ASSERT_EQ(0, system_properties.Foreach(foreach_test_callback, &count));
ASSERT_EQ(3U, count);
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, __system_property_find_nth) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
ASSERT_EQ(0, system_properties.Add("other_property", 14, "value2", 6));
ASSERT_EQ(0, system_properties.Add("property_other", 14, "value3", 6));
char name[PROP_NAME_MAX];
char value[PROP_VALUE_MAX];
EXPECT_EQ(6, system_properties.Read(system_properties.FindNth(0), name, value));
EXPECT_STREQ("property", name);
EXPECT_STREQ("value1", value);
EXPECT_EQ(6, system_properties.Read(system_properties.FindNth(1), name, value));
EXPECT_STREQ("other_property", name);
EXPECT_STREQ("value2", value);
EXPECT_EQ(6, system_properties.Read(system_properties.FindNth(2), name, value));
EXPECT_STREQ("property_other", name);
EXPECT_STREQ("value3", value);
for (unsigned i = 3; i < 1024; ++i) {
ASSERT_TRUE(system_properties.FindNth(i) == nullptr);
}
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, fill_hierarchical) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
char prop_name[PROP_NAME_MAX];
char prop_value[PROP_VALUE_MAX];
char prop_value_ret[PROP_VALUE_MAX];
int ret;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
for (int k = 0; k < 8; k++) {
ret = snprintf(prop_name, PROP_NAME_MAX - 1, "property_%d.%d.%d", i, j, k);
memset(prop_name + ret, 'a', PROP_NAME_MAX - 1 - ret);
ret = snprintf(prop_value, PROP_VALUE_MAX - 1, "value_%d.%d.%d", i, j, k);
memset(prop_value + ret, 'b', PROP_VALUE_MAX - 1 - ret);
prop_name[PROP_NAME_MAX - 1] = 0;
prop_value[PROP_VALUE_MAX - 1] = 0;
ASSERT_EQ(0, system_properties.Add(
prop_name, PROP_NAME_MAX - 1, prop_value, PROP_VALUE_MAX - 1));
}
}
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
for (int k = 0; k < 8; k++) {
ret = snprintf(prop_name, PROP_NAME_MAX - 1, "property_%d.%d.%d", i, j, k);
memset(prop_name + ret, 'a', PROP_NAME_MAX - 1 - ret);
ret = snprintf(prop_value, PROP_VALUE_MAX - 1, "value_%d.%d.%d", i, j, k);
memset(prop_value + ret, 'b', PROP_VALUE_MAX - 1 - ret);
prop_name[PROP_NAME_MAX - 1] = 0;
prop_value[PROP_VALUE_MAX - 1] = 0;
memset(prop_value_ret, '\0', PROP_VALUE_MAX);
ASSERT_EQ(PROP_VALUE_MAX - 1, system_properties.Get(prop_name, prop_value_ret));
ASSERT_EQ(0, memcmp(prop_value, prop_value_ret, PROP_VALUE_MAX));
}
}
}
bool ok[8][8][8];
memset(ok, 0, sizeof(ok));
system_properties.Foreach(hierarchical_test_callback, ok);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
for (int k = 0; k < 8; k++) {
ASSERT_TRUE(ok[i][j][k]);
}
}
}
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, errors) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
char prop_value[PROP_NAME_MAX];
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
ASSERT_EQ(0, system_properties.Add("other_property", 14, "value2", 6));
ASSERT_EQ(0, system_properties.Add("property_other", 14, "value3", 6));
ASSERT_EQ(0, system_properties.Find("property1"));
ASSERT_EQ(0, system_properties.Get("property1", prop_value));
ASSERT_EQ(-1, system_properties.Add("name", 4, "value", PROP_VALUE_MAX));
ASSERT_EQ(-1, system_properties.Update(NULL, "value", PROP_VALUE_MAX));
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, __system_property_serial) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
const prop_info* pi = system_properties.Find("property");
ASSERT_TRUE(pi != nullptr);
unsigned serial = __system_property_serial(pi);
ASSERT_EQ(0, system_properties.Update(const_cast<prop_info*>(pi), "value2", 6));
ASSERT_NE(serial, __system_property_serial(pi));
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, __system_property_wait_any) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
unsigned serial = system_properties.WaitAny(0);
prop_info* pi = const_cast<prop_info*>(system_properties.Find("property"));
ASSERT_TRUE(pi != nullptr);
system_properties.Update(pi, "value2", 6);
serial = system_properties.WaitAny(serial);
int flag = 0;
std::thread thread([&system_properties, &flag]() {
prop_info* pi = const_cast<prop_info*>(system_properties.Find("property"));
usleep(100000);
flag = 1;
system_properties.Update(pi, "value3", 6);
});
ASSERT_EQ(flag, 0);
serial = system_properties.WaitAny(serial);
ASSERT_EQ(flag, 1);
thread.join();
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, __system_property_wait) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
ASSERT_EQ(0, system_properties.Add("property", 8, "value1", 6));
prop_info* pi = const_cast<prop_info*>(system_properties.Find("property"));
ASSERT_TRUE(pi != nullptr);
unsigned serial = __system_property_serial(pi);
std::thread thread([&system_properties]() {
prop_info* pi = const_cast<prop_info*>(system_properties.Find("property"));
ASSERT_TRUE(pi != nullptr);
system_properties.Update(pi, "value2", 6);
});
uint32_t new_serial;
system_properties.Wait(pi, serial, &new_serial, nullptr);
ASSERT_GT(new_serial, serial);
char value[PROP_VALUE_MAX];
ASSERT_EQ(6, system_properties.Get("property", value));
ASSERT_STREQ("value2", value);
thread.join();
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
class KilledByFault {
public:
explicit KilledByFault() {};
bool operator()(int exit_status) const;
};
bool KilledByFault::operator()(int exit_status) const {
return WIFSIGNALED(exit_status) &&
(WTERMSIG(exit_status) == SIGSEGV ||
WTERMSIG(exit_status) == SIGBUS ||
WTERMSIG(exit_status) == SIGABRT);
}
using properties_DeathTest = SilentDeathTest;
TEST_F(properties_DeathTest, read_only) {
#if defined(__BIONIC__)
// This test only makes sense if we're talking to the real system property service.
struct stat sb;
ASSERT_FALSE(stat(PROP_FILENAME, &sb) == -1 && errno == ENOENT);
ASSERT_EXIT(__system_property_add("property", 8, "value", 5), KilledByFault(), "");
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
TEST(properties, __system_property_extra_long_read_only) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
std::vector<std::pair<std::string, std::string>> short_properties = {
{ "ro.0char", std::string() },
{ "ro.50char", std::string(50, 'x') },
{ "ro.91char", std::string(91, 'x') },
};
std::vector<std::pair<std::string, std::string>> long_properties = {
{ "ro.92char", std::string(92, 'x') },
{ "ro.93char", std::string(93, 'x') },
{ "ro.1000char", std::string(1000, 'x') },
};
for (const auto& property : short_properties) {
const std::string& name = property.first;
const std::string& value = property.second;
ASSERT_EQ(0, system_properties.Add(name.c_str(), name.size(), value.c_str(), value.size()));
}
for (const auto& property : long_properties) {
const std::string& name = property.first;
const std::string& value = property.second;
ASSERT_EQ(0, system_properties.Add(name.c_str(), name.size(), value.c_str(), value.size()));
}
auto check_with_legacy_read = [&system_properties](const std::string& name,
const std::string& expected_value) {
char value[PROP_VALUE_MAX];
EXPECT_EQ(static_cast<int>(expected_value.size()), system_properties.Get(name.c_str(), value))
<< name;
EXPECT_EQ(expected_value, value) << name;
};
auto check_with_read_callback = [&system_properties](const std::string& name,
const std::string& expected_value) {
const prop_info* pi = system_properties.Find(name.c_str());
ASSERT_NE(nullptr, pi);
std::string value;
system_properties.ReadCallback(pi,
[](void* cookie, const char*, const char* value, uint32_t) {
auto* out_value = reinterpret_cast<std::string*>(cookie);
*out_value = value;
},
&value);
EXPECT_EQ(expected_value, value) << name;
};
for (const auto& property : short_properties) {
const std::string& name = property.first;
const std::string& value = property.second;
check_with_legacy_read(name, value);
check_with_read_callback(name, value);
}
constexpr static const char* kExtraLongLegacyError =
"Must use __system_property_read_callback() to read";
for (const auto& property : long_properties) {
const std::string& name = property.first;
const std::string& value = property.second;
check_with_legacy_read(name, kExtraLongLegacyError);
check_with_read_callback(name, value);
}
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
// pa_size is 128 * 1024 currently, if a property is longer then we expect it to fail gracefully.
TEST(properties, __system_property_extra_long_read_only_too_long) {
#if defined(__BIONIC__)
SystemPropertiesTest system_properties;
ASSERT_TRUE(system_properties.valid());
auto name = "ro.super_long_property"s;
auto value = std::string(128 * 1024 + 1, 'x');
ASSERT_NE(0, system_properties.Add(name.c_str(), name.size(), value.c_str(), value.size()));
#else // __BIONIC__
GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}
| 33.731569 | 98 | 0.657868 | [
"vector"
] |
aa908a73b280d12bbc4844fdc23f487615ab6c60 | 6,299 | cpp | C++ | lrcdecoder.cpp | mengps/LrcDecoder | ac7ca979bb29386712ca148d9615c919f06cb213 | [
"MIT"
] | 4 | 2020-07-25T10:53:44.000Z | 2021-04-08T14:39:44.000Z | lrcdecoder.cpp | mengps/LrcDecoder | ac7ca979bb29386712ca148d9615c919f06cb213 | [
"MIT"
] | 1 | 2020-07-28T10:04:09.000Z | 2020-08-01T16:27:18.000Z | lrcdecoder.cpp | mengps/LrcDecoder | ac7ca979bb29386712ca148d9615c919f06cb213 | [
"MIT"
] | null | null | null | #include "lrcdecoder.h"
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
static const string MetaData[7][2] = {
{"ti", "title"},
{"al", "album"},
{"ar", "artist"},
{"au", "author"},
{"by", "creator"},
{"re", "encoder"},
{"ve", "encoder_version"}
};
static string findMeta(const string &tag) {
string data;
for (int i = 0; i < 7; ++i) {
if (tag == MetaData[i][0]) {
data = MetaData[i][1];
break;
}
}
return data;
}
class LrcDecoderPrivate
{
public:
int64_t m_duration = 0;
size_t m_currentIndex = 0;
string m_filename;
string m_lastError;
string m_lrcData;
std::map<string, string> m_metadata;
std::map<int64_t, string> m_lyrics;
std::map<int64_t, string>::iterator m_readIndex;
void cleanup();
size_t decodeHeader();
void decodeLine(const string &line);
std::string readLine();
};
LrcDecoder::LrcDecoder()
{
d = new LrcDecoderPrivate;
}
LrcDecoder::~LrcDecoder()
{
delete d;
}
bool LrcDecoder::decode(const string &lrcFile)
{
d->cleanup();
d->m_filename = lrcFile;
std::ifstream fin;
fin.open(lrcFile, std::ios_base::in);
if (!fin.is_open()) {
d->m_lastError = "LRC decode error: Can't open file!";
return false;
}
std::stringstream buffer;
buffer << fin.rdbuf();
d->m_lrcData = buffer.str();
fin.close();
if (d->m_lrcData.empty()) {
d->m_lastError = "LRC file is empty!";
return false;
}
//先读取头部
size_t index = d->decodeHeader();
if (index == d->m_lrcData.length()) {
d->m_lastError = "No lyrics text!";
return false;
}
d->m_lrcData.erase(0, index);
string line = d->readLine();
while (!line.empty()) {
d->decodeLine(line);
line = d->readLine();
}
d->m_duration = (--d->m_lyrics.end())->first;
d->m_readIndex = d->m_lyrics.begin();
return true;
}
std::string LrcDecoder::get(const std::string &meta)
{
string data;
if (d->m_metadata.find(meta) != d->m_metadata.end())
data = d->m_metadata[meta];
return data;
}
LyricPacket LrcDecoder::readPacket()
{
LyricPacket packet;
if (d->m_readIndex != d->m_lyrics.end()) {
packet.pts = d->m_readIndex->first;
packet.lyric = d->m_readIndex->second;
d->m_readIndex++;
}
return packet;
}
bool LrcDecoder::seek(int64_t timestamp, LrcDecoder::SeekFlag flag)
{
if (flag == SeekFlag::SeekForward) {
auto end = --d->m_lyrics.end();
for (d->m_readIndex = d->m_lyrics.begin()
; d->m_readIndex != end; d->m_readIndex++) {
if (d->m_readIndex->first >= timestamp) {
return true;
}
}
} else {
for (d->m_readIndex = --d->m_lyrics.end()
; d->m_readIndex != d->m_lyrics.begin(); d->m_readIndex--) {
if (d->m_readIndex->first <= timestamp) {
return true;
}
}
}
return false;
}
int64_t LrcDecoder::duration() const
{
return d->m_duration;
}
void LrcDecoder::dumpMetadata(FILE *out)
{
fprintf(out, "[===Lyrics Metadata===]\n[Filename: %s]\n", d->m_filename.c_str());
if (d->m_metadata.empty()) fprintf(out, "[No Metadata]\n");
for (auto it: d->m_metadata) {
fprintf(out, "[%s: %s]\n", it.first.c_str(), it.second.c_str());
}
fflush(out);
}
void LrcDecoder::dumpLyrics(FILE *out)
{
fprintf(out, "[===Lyrics===]\n");
for (auto it: d->m_lyrics) {
fprintf(out, "[Pts: %lld]---[Lyric: %s]\n", it.first, it.second.c_str());
}
fflush(out);
}
std::string LrcDecoder::lastError() const
{
return d->m_lastError;
}
void LrcDecoderPrivate::cleanup()
{
m_currentIndex = 0;
m_filename.clear();
m_lastError.clear();
m_lrcData.clear();
m_metadata.clear();
m_lyrics.clear();
}
size_t LrcDecoderPrivate::decodeHeader()
{
size_t offset = 0;
size_t length = m_lrcData.length();
if (offset >= length) return offset;
while(offset < length) {
string meta, data;
if (m_lrcData.at(offset) == '[') {
while(++offset < length && m_lrcData.at(offset) != ':') {
if (m_lrcData.at(offset) >= 'a' && m_lrcData.at(offset) <= 'z')
meta += m_lrcData.at(offset);
else return offset - 1;
}
while(++offset < length && m_lrcData.at(offset) != ']') {
data += m_lrcData.at(offset);
}
m_metadata[findMeta(meta)] = data;
}
offset++;
}
return offset;
}
void LrcDecoderPrivate::decodeLine(const std::string &line)
{
size_t offset = 0;
size_t length = line.length();
if (offset >= length) return;
string time;
int64_t pts = 0;
std::vector<int64_t> times;
while(offset < length) {
if (line.at(offset) == '[') {
offset++;
} else if (line.at(offset) >= '0' && line.at(offset) <= '9') {
time += line.at(offset);
offset++;
} else if (line.at(offset) == ']') {
//10 millisecond
pts += stoi(time) * 10;
times.push_back(pts);
time.clear();
pts = 0;
offset++;
} else if (line.at(offset) == ':') {
//minute, = 60s * 1000ms
pts += stoi(time) * 60 * 1000;
time.clear();
offset++;
} else if (line.at(offset) == '.') {
//second, = 1000 ms
pts += stoi(time) * 1000;
time += line.at(offset);
time.clear();
offset++;
} else break;
}
string data;
while(offset < length) {
data += line.at(offset);
offset++;
}
for (auto pts : times) {
m_lyrics[pts] = data;
}
}
string LrcDecoderPrivate::readLine()
{
size_t length = m_lrcData.length();
string line;
while (m_currentIndex < length) {
if (m_lrcData.at(m_currentIndex) == '\n') {
m_currentIndex++;
break;
} else {
line += m_lrcData.at(m_currentIndex);
m_currentIndex++;
}
}
return line;
}
| 22.41637 | 85 | 0.531037 | [
"vector"
] |
aa979f395b15a0e23b177c7e48a33e49989434a6 | 3,849 | hpp | C++ | include/ros_entities/ros_tf_listener.hpp | andreadelprete/dynamic_graph_manager | 59a29462ea173d3a3456642799d965f8f1e2854e | [
"BSD-3-Clause"
] | null | null | null | include/ros_entities/ros_tf_listener.hpp | andreadelprete/dynamic_graph_manager | 59a29462ea173d3a3456642799d965f8f1e2854e | [
"BSD-3-Clause"
] | null | null | null | include/ros_entities/ros_tf_listener.hpp | andreadelprete/dynamic_graph_manager | 59a29462ea173d3a3456642799d965f8f1e2854e | [
"BSD-3-Clause"
] | null | null | null | /**
* @file ros_tf_listener.hpp
* @author Maximilien Naveau (maximilien.naveau@gmail.com)
* @license License BSD-3-Clause
* @copyright Copyright (c) 2019, New York University and Max Planck
* Gesellschaft.
* @date 2019-05-22
*/
#ifndef DYNAMIC_GRAPH_ROS_TF_LISTENER_HH
#define DYNAMIC_GRAPH_ROS_TF_LISTENER_HH
#include <boost/bind.hpp>
#include <tf/transform_listener.h>
#include <dynamic-graph/command-bind.h>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/signal.h>
#include <ros_entities/matrix_geometry.hpp>
namespace dynamic_graph_manager
{
class RosTfListener;
namespace internal
{
struct TransformListenerData
{
typedef dynamicgraph::Signal<MatrixHomogeneous, int> signal_t;
tf::TransformListener& listener;
const std::string toFrame, fromFrame;
tf::StampedTransform transform;
signal_t signal;
TransformListenerData(tf::TransformListener& l,
const std::string& to,
const std::string& from,
const std::string& signame)
: listener(l), toFrame(to), fromFrame(from), signal(signame)
{
signal.setFunction(
boost::bind(&TransformListenerData::getTransform, this, _1, _2));
}
MatrixHomogeneous& getTransform(MatrixHomogeneous& res, int time)
{
static const ros::Time rosTime(0);
try
{
listener.lookupTransform(toFrame, fromFrame, rosTime, transform);
}
catch (const tf::TransformException& ex)
{
res.setIdentity();
ROS_ERROR(
"Enable to get transform at time %i: %s", time, ex.what());
return res;
}
for (MatrixHomogeneous::Index r = 0; r < 3; ++r)
{
for (MatrixHomogeneous::Index c = 0; c < 3; ++c)
res.linear()(r, c) = transform.getBasis().getRow(r)[c];
res.translation()[r] = transform.getOrigin()[r];
}
return res;
}
};
} // namespace internal
class RosTfListener : public dynamicgraph::Entity
{
DYNAMIC_GRAPH_ENTITY_DECL();
public:
typedef internal::TransformListenerData TransformListenerData;
RosTfListener(const std::string& name) : Entity(name)
{
std::string docstring =
"\n"
" Add a signal containing the transform between two frames.\n"
"\n"
" Input:\n"
" - to : frame name\n"
" - from: frame name,\n"
" - signalName: the signal name in dynamic-graph"
"\n";
addCommand("add",
dynamicgraph::command::makeCommandVoid3(
*this, &RosTfListener::add, docstring));
}
~RosTfListener()
{
for (Map_t::const_iterator _it = listenerDatas.begin();
_it != listenerDatas.end();
++_it)
delete _it->second;
}
void add(const std::string& to,
const std::string& from,
const std::string& signame)
{
if (listenerDatas.find(signame) != listenerDatas.end())
throw std::invalid_argument("A signal " + signame +
" already exists in RosTfListener " +
getName());
boost::format signalName("RosTfListener(%1%)::output(MatrixHomo)::%2%");
signalName % getName() % signame;
TransformListenerData* tld =
new TransformListenerData(listener, to, from, signalName.str());
signalRegistration(tld->signal);
listenerDatas[signame] = tld;
}
private:
typedef std::map<std::string, TransformListenerData*> Map_t;
Map_t listenerDatas;
tf::TransformListener listener;
};
} // namespace dynamic_graph_manager
#endif // DYNAMIC_GRAPH_ROS_TF_LISTENER_HH
| 29.607692 | 80 | 0.593401 | [
"transform"
] |
aa97d23ec5caa9ea698fc482ba436f274827bf2e | 3,902 | cpp | C++ | src/logger.cpp | pvavercak/randomness-testing-toolkit | 8a29349edee0dc44bc8e765708555dda57b9e339 | [
"MIT"
] | null | null | null | src/logger.cpp | pvavercak/randomness-testing-toolkit | 8a29349edee0dc44bc8e765708555dda57b9e339 | [
"MIT"
] | null | null | null | src/logger.cpp | pvavercak/randomness-testing-toolkit | 8a29349edee0dc44bc8e765708555dda57b9e339 | [
"MIT"
] | null | null | null | #include "logger.h"
#include "bugexception.h"
#include "utils.h"
#include "version.h"
namespace rtt {
Logger::Logger(const std::string &logId, const std::string &logFile, bool toCout) {
/* Empty to make header, will be set later */
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::Format, "%msg");
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::Filename,
logFile);
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::Enabled,
"true");
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::ToFile,
"true");
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::MillisecondsWidth,
"1");
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::PerformanceTracking,
"false");
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::MaxLogFileSize,
"10485760"); /* 10MB */
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::LogFlushThreshold,
"100");
if(toCout)
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::ToStandardOutput,
"true");
else
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::ToStandardOutput,
"false");
rawLogger = el::Loggers::getLogger(logId);
el::Loggers::reconfigureLogger(rawLogger , rawLoggerConf);
/* Writing log header */
rawLogger->info("\nRandomness Testing Toolkit logger start.");
rawLogger->info("Application build "+ (std::string)GIT_COMMIT_SHORT);
rawLogger->info("Logger name " + logId);
rawLogger->info("Logging start " +
Utils::formatRawTime(Utils::getRawTime() , "%d-%m-%Y %H:%M:%S"));
rawLogger->info("\n");
/* Set format for normal logging */
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::Format,
"[%datetime{%H:%m:%s}] Thread %thread: %level - %msg");
el::Loggers::reconfigureLogger(rawLogger , rawLoggerConf);
}
Logger::~Logger() {
/* Setting clear format for ending info. */
rawLoggerConf.set(el::Level::Global, el::ConfigurationType::Format, "%msg");
el::Loggers::reconfigureLogger(rawLogger , rawLoggerConf);
/* Writing ending info */
rawLogger->info("\n\nLogging end " +
Utils::formatRawTime(Utils::getRawTime() , "%d-%m-%Y %H:%M:%S"));
rawLogger->info("Error count " + Utils::itostr(errorMessages.size()));
rawLogger->info("Warning count " + Utils::itostr(warningMessages.size()));
rawLogger->info("");
}
void Logger::log(LogLevel level, const std::string & msg) {
switch(level) {
case LogLevel::INFO:
info(msg);
break;
case LogLevel::WARN:
warn(msg);
break;
case LogLevel::ERROR:
error(msg);
break;
default:
raiseBugException("unknown log level");
}
}
void Logger::info(const std::string & msg) {
rawLogger->info(msg);
}
void Logger::warn(const std::string & msg) {
/* Raw logger is thread-safe. It is the rest I am worried about. */
rawLogger->warn(msg);
{
std::lock_guard<std::mutex> l (warningMessages_mux);
warningMessages.push_back(msg);
}
}
void Logger::error(const std::string & msg) {
/* Raw logger is thread-safe. It is the rest I am worried about. */
rawLogger->error(msg);
{
std::lock_guard<std::mutex> l (errorMessages_mux);
errorMessages.push_back(msg);
}
}
std::vector<std::string> Logger::getWarningMessages() {
std::lock_guard<std::mutex> l (warningMessages_mux);
return warningMessages;
}
std::vector<std::string> Logger::getErrorMessages() {
std::lock_guard<std::mutex> l (errorMessages_mux);
return errorMessages;
}
} // namespace rtt
| 34.22807 | 85 | 0.616607 | [
"vector"
] |
aa9d7d3a7fe99c9f6e1686ae8cd158622d6a74d2 | 38,438 | cc | C++ | riscv/llvm/3.5/binutils-2.21.1/gold/incremental.cc | tangyibin/goblin-core | 1940db6e95908c81687b2b22ddd9afbc8db9cdfe | [
"BSD-3-Clause"
] | 3 | 2017-03-06T14:12:57.000Z | 2019-11-23T09:35:10.000Z | riscv/llvm/3.5/binutils-2.21.1/gold/incremental.cc | tangyibin/goblin-core | 1940db6e95908c81687b2b22ddd9afbc8db9cdfe | [
"BSD-3-Clause"
] | null | null | null | riscv/llvm/3.5/binutils-2.21.1/gold/incremental.cc | tangyibin/goblin-core | 1940db6e95908c81687b2b22ddd9afbc8db9cdfe | [
"BSD-3-Clause"
] | 1 | 2021-03-24T06:40:32.000Z | 2021-03-24T06:40:32.000Z | // inremental.cc -- incremental linking support for gold
// Copyright 2009, 2010 Free Software Foundation, Inc.
// Written by Mikolaj Zalewski <mikolajz@google.com>.
// This file is part of gold.
// 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, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
#include "gold.h"
#include <cstdarg>
#include "libiberty.h"
#include "elfcpp.h"
#include "output.h"
#include "symtab.h"
#include "incremental.h"
#include "archive.h"
#include "output.h"
#include "target-select.h"
#include "target.h"
namespace gold {
// Version information. Will change frequently during the development, later
// we could think about backward (and forward?) compatibility.
const unsigned int INCREMENTAL_LINK_VERSION = 1;
// This class manages the .gnu_incremental_inputs section, which holds
// the header information, a directory of input files, and separate
// entries for each input file.
template<int size, bool big_endian>
class Output_section_incremental_inputs : public Output_section_data
{
public:
Output_section_incremental_inputs(const Incremental_inputs* inputs,
const Symbol_table* symtab)
: Output_section_data(size / 8), inputs_(inputs), symtab_(symtab)
{ }
protected:
// Set the final data size.
void
set_final_data_size();
// Write the data to the file.
void
do_write(Output_file*);
// Write to a map file.
void
do_print_to_mapfile(Mapfile* mapfile) const
{ mapfile->print_output_data(this, _("** incremental_inputs")); }
private:
// Write the section header.
unsigned char*
write_header(unsigned char* pov, unsigned int input_file_count,
section_offset_type command_line_offset);
// Write the input file entries.
unsigned char*
write_input_files(unsigned char* oview, unsigned char* pov,
Stringpool* strtab);
// Write the supplemental information blocks.
unsigned char*
write_info_blocks(unsigned char* oview, unsigned char* pov,
Stringpool* strtab, unsigned int* global_syms,
unsigned int global_sym_count);
// Write the contents of the .gnu_incremental_symtab section.
void
write_symtab(unsigned char* pov, unsigned int* global_syms,
unsigned int global_sym_count);
// Write the contents of the .gnu_incremental_got_plt section.
void
write_got_plt(unsigned char* pov, off_t view_size);
// Typedefs for writing the data to the output sections.
typedef elfcpp::Swap<size, big_endian> Swap;
typedef elfcpp::Swap<16, big_endian> Swap16;
typedef elfcpp::Swap<32, big_endian> Swap32;
typedef elfcpp::Swap<64, big_endian> Swap64;
// Sizes of various structures.
static const int sizeof_addr = size / 8;
static const int header_size = 16;
static const int input_entry_size = 24;
// The Incremental_inputs object.
const Incremental_inputs* inputs_;
// The symbol table.
const Symbol_table* symtab_;
};
// Inform the user why we don't do an incremental link. Not called in
// the obvious case of missing output file. TODO: Is this helpful?
void
vexplain_no_incremental(const char* format, va_list args)
{
char* buf = NULL;
if (vasprintf(&buf, format, args) < 0)
gold_nomem();
gold_info(_("the link might take longer: "
"cannot perform incremental link: %s"), buf);
free(buf);
}
void
explain_no_incremental(const char* format, ...)
{
va_list args;
va_start(args, format);
vexplain_no_incremental(format, args);
va_end(args);
}
// Report an error.
void
Incremental_binary::error(const char* format, ...) const
{
va_list args;
va_start(args, format);
// Current code only checks if the file can be used for incremental linking,
// so errors shouldn't fail the build, but only result in a fallback to a
// full build.
// TODO: when we implement incremental editing of the file, we may need a
// flag that will cause errors to be treated seriously.
vexplain_no_incremental(format, args);
va_end(args);
}
// Find the .gnu_incremental_inputs section and related sections.
template<int size, bool big_endian>
bool
Sized_incremental_binary<size, big_endian>::do_find_incremental_inputs_sections(
unsigned int* p_inputs_shndx,
unsigned int* p_symtab_shndx,
unsigned int* p_relocs_shndx,
unsigned int* p_got_plt_shndx,
unsigned int* p_strtab_shndx)
{
unsigned int inputs_shndx =
this->elf_file_.find_section_by_type(elfcpp::SHT_GNU_INCREMENTAL_INPUTS);
if (inputs_shndx == elfcpp::SHN_UNDEF) // Not found.
return false;
unsigned int symtab_shndx =
this->elf_file_.find_section_by_type(elfcpp::SHT_GNU_INCREMENTAL_SYMTAB);
if (symtab_shndx == elfcpp::SHN_UNDEF) // Not found.
return false;
if (this->elf_file_.section_link(symtab_shndx) != inputs_shndx)
return false;
unsigned int relocs_shndx =
this->elf_file_.find_section_by_type(elfcpp::SHT_GNU_INCREMENTAL_RELOCS);
if (relocs_shndx == elfcpp::SHN_UNDEF) // Not found.
return false;
if (this->elf_file_.section_link(relocs_shndx) != inputs_shndx)
return false;
unsigned int got_plt_shndx =
this->elf_file_.find_section_by_type(elfcpp::SHT_GNU_INCREMENTAL_GOT_PLT);
if (got_plt_shndx == elfcpp::SHN_UNDEF) // Not found.
return false;
if (this->elf_file_.section_link(got_plt_shndx) != inputs_shndx)
return false;
unsigned int strtab_shndx = this->elf_file_.section_link(inputs_shndx);
if (strtab_shndx == elfcpp::SHN_UNDEF
|| strtab_shndx > this->elf_file_.shnum()
|| this->elf_file_.section_type(strtab_shndx) != elfcpp::SHT_STRTAB)
return false;
if (p_inputs_shndx != NULL)
*p_inputs_shndx = inputs_shndx;
if (p_symtab_shndx != NULL)
*p_symtab_shndx = symtab_shndx;
if (p_relocs_shndx != NULL)
*p_relocs_shndx = relocs_shndx;
if (p_got_plt_shndx != NULL)
*p_got_plt_shndx = got_plt_shndx;
if (p_strtab_shndx != NULL)
*p_strtab_shndx = strtab_shndx;
return true;
}
// Determine whether an incremental link based on the existing output file
// can be done.
template<int size, bool big_endian>
bool
Sized_incremental_binary<size, big_endian>::do_check_inputs(
Incremental_inputs* incremental_inputs)
{
unsigned int inputs_shndx;
unsigned int symtab_shndx;
unsigned int relocs_shndx;
unsigned int plt_got_shndx;
unsigned int strtab_shndx;
if (!do_find_incremental_inputs_sections(&inputs_shndx, &symtab_shndx,
&relocs_shndx, &plt_got_shndx,
&strtab_shndx))
{
explain_no_incremental(_("no incremental data from previous build"));
return false;
}
Location inputs_location(this->elf_file_.section_contents(inputs_shndx));
Location symtab_location(this->elf_file_.section_contents(symtab_shndx));
Location relocs_location(this->elf_file_.section_contents(relocs_shndx));
Location strtab_location(this->elf_file_.section_contents(strtab_shndx));
View inputs_view(view(inputs_location));
View symtab_view(view(symtab_location));
View relocs_view(view(relocs_location));
View strtab_view(view(strtab_location));
elfcpp::Elf_strtab strtab(strtab_view.data(), strtab_location.data_size);
Incremental_inputs_reader<size, big_endian>
incoming_inputs(inputs_view.data(), strtab);
if (incoming_inputs.version() != INCREMENTAL_LINK_VERSION)
{
explain_no_incremental(_("different version of incremental build data"));
return false;
}
if (incremental_inputs->command_line() != incoming_inputs.command_line())
{
explain_no_incremental(_("command line changed"));
return false;
}
// TODO: compare incremental_inputs->inputs() with entries in data_view.
return true;
}
namespace
{
// Create a Sized_incremental_binary object of the specified size and
// endianness. Fails if the target architecture is not supported.
template<int size, bool big_endian>
Incremental_binary*
make_sized_incremental_binary(Output_file* file,
const elfcpp::Ehdr<size, big_endian>& ehdr)
{
Target* target = select_target(ehdr.get_e_machine(), size, big_endian,
ehdr.get_e_ident()[elfcpp::EI_OSABI],
ehdr.get_e_ident()[elfcpp::EI_ABIVERSION]);
if (target == NULL)
{
explain_no_incremental(_("unsupported ELF machine number %d"),
ehdr.get_e_machine());
return NULL;
}
if (!parameters->target_valid())
set_parameters_target(target);
else if (target != ¶meters->target())
gold_error(_("%s: incompatible target"), file->filename());
return new Sized_incremental_binary<size, big_endian>(file, ehdr, target);
}
} // End of anonymous namespace.
// Create an Incremental_binary object for FILE. Returns NULL is this is not
// possible, e.g. FILE is not an ELF file or has an unsupported target. FILE
// should be opened.
Incremental_binary*
open_incremental_binary(Output_file* file)
{
off_t filesize = file->filesize();
int want = elfcpp::Elf_recognizer::max_header_size;
if (filesize < want)
want = filesize;
const unsigned char* p = file->get_input_view(0, want);
if (!elfcpp::Elf_recognizer::is_elf_file(p, want))
{
explain_no_incremental(_("output is not an ELF file."));
return NULL;
}
int size = 0;
bool big_endian = false;
std::string error;
if (!elfcpp::Elf_recognizer::is_valid_header(p, want, &size, &big_endian,
&error))
{
explain_no_incremental(error.c_str());
return NULL;
}
Incremental_binary* result = NULL;
if (size == 32)
{
if (big_endian)
{
#ifdef HAVE_TARGET_32_BIG
result = make_sized_incremental_binary<32, true>(
file, elfcpp::Ehdr<32, true>(p));
#else
explain_no_incremental(_("unsupported file: 32-bit, big-endian"));
#endif
}
else
{
#ifdef HAVE_TARGET_32_LITTLE
result = make_sized_incremental_binary<32, false>(
file, elfcpp::Ehdr<32, false>(p));
#else
explain_no_incremental(_("unsupported file: 32-bit, little-endian"));
#endif
}
}
else if (size == 64)
{
if (big_endian)
{
#ifdef HAVE_TARGET_64_BIG
result = make_sized_incremental_binary<64, true>(
file, elfcpp::Ehdr<64, true>(p));
#else
explain_no_incremental(_("unsupported file: 64-bit, big-endian"));
#endif
}
else
{
#ifdef HAVE_TARGET_64_LITTLE
result = make_sized_incremental_binary<64, false>(
file, elfcpp::Ehdr<64, false>(p));
#else
explain_no_incremental(_("unsupported file: 64-bit, little-endian"));
#endif
}
}
else
gold_unreachable();
return result;
}
// Analyzes the output file to check if incremental linking is possible and
// (to be done) what files need to be relinked.
bool
Incremental_checker::can_incrementally_link_output_file()
{
Output_file output(this->output_name_);
if (!output.open_for_modification())
return false;
Incremental_binary* binary = open_incremental_binary(&output);
if (binary == NULL)
return false;
return binary->check_inputs(this->incremental_inputs_);
}
// Class Incremental_inputs.
// Add the command line to the string table, setting
// command_line_key_. In incremental builds, the command line is
// stored in .gnu_incremental_inputs so that the next linker run can
// check if the command line options didn't change.
void
Incremental_inputs::report_command_line(int argc, const char* const* argv)
{
// Always store 'gold' as argv[0] to avoid a full relink if the user used a
// different path to the linker.
std::string args("gold");
// Copied from collect_argv in main.cc.
for (int i = 1; i < argc; ++i)
{
// Adding/removing these options should not result in a full relink.
if (strcmp(argv[i], "--incremental") == 0
|| strcmp(argv[i], "--incremental-full") == 0
|| strcmp(argv[i], "--incremental-update") == 0
|| strcmp(argv[i], "--incremental-changed") == 0
|| strcmp(argv[i], "--incremental-unchanged") == 0
|| strcmp(argv[i], "--incremental-unknown") == 0)
continue;
args.append(" '");
// Now append argv[i], but with all single-quotes escaped
const char* argpos = argv[i];
while (1)
{
const int len = strcspn(argpos, "'");
args.append(argpos, len);
if (argpos[len] == '\0')
break;
args.append("'\"'\"'");
argpos += len + 1;
}
args.append("'");
}
this->command_line_ = args;
this->strtab_->add(this->command_line_.c_str(), false,
&this->command_line_key_);
}
// Record the input archive file ARCHIVE. This is called by the
// Add_archive_symbols task before determining which archive members
// to include. We create the Incremental_archive_entry here and
// attach it to the Archive, but we do not add it to the list of
// input objects until report_archive_end is called.
void
Incremental_inputs::report_archive_begin(Archive* arch)
{
Stringpool::Key filename_key;
Timespec mtime = arch->file().get_mtime();
this->strtab_->add(arch->filename().c_str(), false, &filename_key);
Incremental_archive_entry* entry =
new Incremental_archive_entry(filename_key, arch, mtime);
arch->set_incremental_info(entry);
}
// Finish recording the input archive file ARCHIVE. This is called by the
// Add_archive_symbols task after determining which archive members
// to include.
void
Incremental_inputs::report_archive_end(Archive* arch)
{
Incremental_archive_entry* entry = arch->incremental_info();
gold_assert(entry != NULL);
// Collect unused global symbols.
for (Archive::Unused_symbol_iterator p = arch->unused_symbols_begin();
p != arch->unused_symbols_end();
++p)
{
Stringpool::Key symbol_key;
this->strtab_->add(*p, true, &symbol_key);
entry->add_unused_global_symbol(symbol_key);
}
this->inputs_.push_back(entry);
}
// Record the input object file OBJ. If ARCH is not NULL, attach
// the object file to the archive. This is called by the
// Add_symbols task after finding out the type of the file.
void
Incremental_inputs::report_object(Object* obj, Archive* arch)
{
Stringpool::Key filename_key;
Timespec mtime = obj->input_file()->file().get_mtime();
this->strtab_->add(obj->name().c_str(), false, &filename_key);
Incremental_object_entry* obj_entry =
new Incremental_object_entry(filename_key, obj, mtime);
this->inputs_.push_back(obj_entry);
if (arch != NULL)
{
Incremental_archive_entry* arch_entry = arch->incremental_info();
gold_assert(arch_entry != NULL);
arch_entry->add_object(obj_entry);
}
this->current_object_ = obj;
this->current_object_entry_ = obj_entry;
}
// Record the input object file OBJ. If ARCH is not NULL, attach
// the object file to the archive. This is called by the
// Add_symbols task after finding out the type of the file.
void
Incremental_inputs::report_input_section(Object* obj, unsigned int shndx,
const char* name, off_t sh_size)
{
Stringpool::Key key = 0;
if (name != NULL)
this->strtab_->add(name, true, &key);
gold_assert(obj == this->current_object_);
this->current_object_entry_->add_input_section(shndx, key, sh_size);
}
// Record that the input argument INPUT is a script SCRIPT. This is
// called by read_script after parsing the script and reading the list
// of inputs added by this script.
void
Incremental_inputs::report_script(const std::string& filename,
Script_info* script, Timespec mtime)
{
Stringpool::Key filename_key;
this->strtab_->add(filename.c_str(), false, &filename_key);
Incremental_script_entry* entry =
new Incremental_script_entry(filename_key, script, mtime);
this->inputs_.push_back(entry);
}
// Finalize the incremental link information. Called from
// Layout::finalize.
void
Incremental_inputs::finalize()
{
// Finalize the string table.
this->strtab_->set_string_offsets();
}
// Create the .gnu_incremental_inputs, _symtab, and _relocs input sections.
void
Incremental_inputs::create_data_sections(Symbol_table* symtab)
{
switch (parameters->size_and_endianness())
{
#ifdef HAVE_TARGET_32_LITTLE
case Parameters::TARGET_32_LITTLE:
this->inputs_section_ =
new Output_section_incremental_inputs<32, false>(this, symtab);
break;
#endif
#ifdef HAVE_TARGET_32_BIG
case Parameters::TARGET_32_BIG:
this->inputs_section_ =
new Output_section_incremental_inputs<32, true>(this, symtab);
break;
#endif
#ifdef HAVE_TARGET_64_LITTLE
case Parameters::TARGET_64_LITTLE:
this->inputs_section_ =
new Output_section_incremental_inputs<64, false>(this, symtab);
break;
#endif
#ifdef HAVE_TARGET_64_BIG
case Parameters::TARGET_64_BIG:
this->inputs_section_ =
new Output_section_incremental_inputs<64, true>(this, symtab);
break;
#endif
default:
gold_unreachable();
}
this->symtab_section_ = new Output_data_space(4, "** incremental_symtab");
this->relocs_section_ = new Output_data_space(4, "** incremental_relocs");
this->got_plt_section_ = new Output_data_space(4, "** incremental_got_plt");
}
// Return the sh_entsize value for the .gnu_incremental_relocs section.
unsigned int
Incremental_inputs::relocs_entsize() const
{
return 8 + 2 * parameters->target().get_size() / 8;
}
// Class Output_section_incremental_inputs.
// Finalize the offsets for each input section and supplemental info block,
// and set the final data size of the incremental output sections.
template<int size, bool big_endian>
void
Output_section_incremental_inputs<size, big_endian>::set_final_data_size()
{
const Incremental_inputs* inputs = this->inputs_;
const unsigned int sizeof_addr = size / 8;
const unsigned int rel_size = 8 + 2 * sizeof_addr;
// Offset of each input entry.
unsigned int input_offset = this->header_size;
// Offset of each supplemental info block.
unsigned int info_offset = this->header_size;
info_offset += this->input_entry_size * inputs->input_file_count();
// Count each input file and its supplemental information block.
for (Incremental_inputs::Input_list::const_iterator p =
inputs->input_files().begin();
p != inputs->input_files().end();
++p)
{
// Set the offset of the input file entry.
(*p)->set_offset(input_offset);
input_offset += this->input_entry_size;
// Set the offset of the supplemental info block.
switch ((*p)->type())
{
case INCREMENTAL_INPUT_SCRIPT:
// No supplemental info for a script.
(*p)->set_info_offset(0);
break;
case INCREMENTAL_INPUT_OBJECT:
case INCREMENTAL_INPUT_ARCHIVE_MEMBER:
{
Incremental_object_entry* entry = (*p)->object_entry();
gold_assert(entry != NULL);
(*p)->set_info_offset(info_offset);
// Input section count + global symbol count.
info_offset += 8;
// Each input section.
info_offset += (entry->get_input_section_count()
* (8 + 2 * sizeof_addr));
// Each global symbol.
const Object::Symbols* syms = entry->object()->get_global_symbols();
info_offset += syms->size() * 16;
}
break;
case INCREMENTAL_INPUT_SHARED_LIBRARY:
{
Incremental_object_entry* entry = (*p)->object_entry();
gold_assert(entry != NULL);
(*p)->set_info_offset(info_offset);
// Global symbol count.
info_offset += 4;
// Each global symbol.
const Object::Symbols* syms = entry->object()->get_global_symbols();
unsigned int nsyms = syms != NULL ? syms->size() : 0;
info_offset += nsyms * 4;
}
break;
case INCREMENTAL_INPUT_ARCHIVE:
{
Incremental_archive_entry* entry = (*p)->archive_entry();
gold_assert(entry != NULL);
(*p)->set_info_offset(info_offset);
// Member count + unused global symbol count.
info_offset += 8;
// Each member.
info_offset += (entry->get_member_count() * 4);
// Each global symbol.
info_offset += (entry->get_unused_global_symbol_count() * 4);
}
break;
default:
gold_unreachable();
}
}
this->set_data_size(info_offset);
// Set the size of the .gnu_incremental_symtab section.
inputs->symtab_section()->set_current_data_size(this->symtab_->output_count()
* sizeof(unsigned int));
// Set the size of the .gnu_incremental_relocs section.
inputs->relocs_section()->set_current_data_size(inputs->get_reloc_count()
* rel_size);
// Set the size of the .gnu_incremental_got_plt section.
Sized_target<size, big_endian>* target =
parameters->sized_target<size, big_endian>();
unsigned int got_count = target->got_entry_count();
unsigned int plt_count = target->plt_entry_count();
unsigned int got_plt_size = 8; // GOT entry count, PLT entry count.
got_plt_size = (got_plt_size + got_count + 3) & ~3; // GOT type array.
got_plt_size += got_count * 4 + plt_count * 4; // GOT array, PLT array.
inputs->got_plt_section()->set_current_data_size(got_plt_size);
}
// Write the contents of the .gnu_incremental_inputs and
// .gnu_incremental_symtab sections.
template<int size, bool big_endian>
void
Output_section_incremental_inputs<size, big_endian>::do_write(Output_file* of)
{
const Incremental_inputs* inputs = this->inputs_;
Stringpool* strtab = inputs->get_stringpool();
// Get a view into the .gnu_incremental_inputs section.
const off_t off = this->offset();
const off_t oview_size = this->data_size();
unsigned char* const oview = of->get_output_view(off, oview_size);
unsigned char* pov = oview;
// Get a view into the .gnu_incremental_symtab section.
const off_t symtab_off = inputs->symtab_section()->offset();
const off_t symtab_size = inputs->symtab_section()->data_size();
unsigned char* const symtab_view = of->get_output_view(symtab_off,
symtab_size);
// Allocate an array of linked list heads for the .gnu_incremental_symtab
// section. Each element corresponds to a global symbol in the output
// symbol table, and points to the head of the linked list that threads
// through the object file input entries. The value of each element
// is the section-relative offset to a global symbol entry in a
// supplemental information block.
unsigned int global_sym_count = this->symtab_->output_count();
unsigned int* global_syms = new unsigned int[global_sym_count];
memset(global_syms, 0, global_sym_count * sizeof(unsigned int));
// Write the section header.
Stringpool::Key command_line_key = inputs->command_line_key();
pov = this->write_header(pov, inputs->input_file_count(),
strtab->get_offset_from_key(command_line_key));
// Write the list of input files.
pov = this->write_input_files(oview, pov, strtab);
// Write the supplemental information blocks for each input file.
pov = this->write_info_blocks(oview, pov, strtab, global_syms,
global_sym_count);
gold_assert(pov - oview == oview_size);
// Write the .gnu_incremental_symtab section.
gold_assert(global_sym_count * 4 == symtab_size);
this->write_symtab(symtab_view, global_syms, global_sym_count);
delete[] global_syms;
// Write the .gnu_incremental_got_plt section.
const off_t got_plt_off = inputs->got_plt_section()->offset();
const off_t got_plt_size = inputs->got_plt_section()->data_size();
unsigned char* const got_plt_view = of->get_output_view(got_plt_off,
got_plt_size);
this->write_got_plt(got_plt_view, got_plt_size);
of->write_output_view(off, oview_size, oview);
of->write_output_view(symtab_off, symtab_size, symtab_view);
of->write_output_view(got_plt_off, got_plt_size, got_plt_view);
}
// Write the section header: version, input file count, offset of command line
// in the string table, and 4 bytes of padding.
template<int size, bool big_endian>
unsigned char*
Output_section_incremental_inputs<size, big_endian>::write_header(
unsigned char* pov,
unsigned int input_file_count,
section_offset_type command_line_offset)
{
Swap32::writeval(pov, INCREMENTAL_LINK_VERSION);
Swap32::writeval(pov + 4, input_file_count);
Swap32::writeval(pov + 8, command_line_offset);
Swap32::writeval(pov + 12, 0);
return pov + this->header_size;
}
// Write the input file entries.
template<int size, bool big_endian>
unsigned char*
Output_section_incremental_inputs<size, big_endian>::write_input_files(
unsigned char* oview,
unsigned char* pov,
Stringpool* strtab)
{
const Incremental_inputs* inputs = this->inputs_;
for (Incremental_inputs::Input_list::const_iterator p =
inputs->input_files().begin();
p != inputs->input_files().end();
++p)
{
gold_assert(static_cast<unsigned int>(pov - oview) == (*p)->get_offset());
section_offset_type filename_offset =
strtab->get_offset_from_key((*p)->get_filename_key());
const Timespec& mtime = (*p)->get_mtime();
Swap32::writeval(pov, filename_offset);
Swap32::writeval(pov + 4, (*p)->get_info_offset());
Swap64::writeval(pov + 8, mtime.seconds);
Swap32::writeval(pov + 16, mtime.nanoseconds);
Swap16::writeval(pov + 20, (*p)->type());
Swap16::writeval(pov + 22, 0);
pov += this->input_entry_size;
}
return pov;
}
// Write the supplemental information blocks.
template<int size, bool big_endian>
unsigned char*
Output_section_incremental_inputs<size, big_endian>::write_info_blocks(
unsigned char* oview,
unsigned char* pov,
Stringpool* strtab,
unsigned int* global_syms,
unsigned int global_sym_count)
{
const Incremental_inputs* inputs = this->inputs_;
unsigned int first_global_index = this->symtab_->first_global_index();
for (Incremental_inputs::Input_list::const_iterator p =
inputs->input_files().begin();
p != inputs->input_files().end();
++p)
{
switch ((*p)->type())
{
case INCREMENTAL_INPUT_SCRIPT:
// No supplemental info for a script.
break;
case INCREMENTAL_INPUT_OBJECT:
case INCREMENTAL_INPUT_ARCHIVE_MEMBER:
{
gold_assert(static_cast<unsigned int>(pov - oview)
== (*p)->get_info_offset());
Incremental_object_entry* entry = (*p)->object_entry();
gold_assert(entry != NULL);
const Object* obj = entry->object();
const Object::Symbols* syms = obj->get_global_symbols();
// Write the input section count and global symbol count.
unsigned int nsections = entry->get_input_section_count();
unsigned int nsyms = syms->size();
Swap32::writeval(pov, nsections);
Swap32::writeval(pov + 4, nsyms);
pov += 8;
// For each input section, write the name, output section index,
// offset within output section, and input section size.
for (unsigned int i = 0; i < nsections; i++)
{
Stringpool::Key key = entry->get_input_section_name_key(i);
off_t name_offset = 0;
if (key != 0)
name_offset = strtab->get_offset_from_key(key);
int out_shndx = 0;
off_t out_offset = 0;
off_t sh_size = 0;
Output_section* os = obj->output_section(i);
if (os != NULL)
{
out_shndx = os->out_shndx();
out_offset = obj->output_section_offset(i);
sh_size = entry->get_input_section_size(i);
}
Swap32::writeval(pov, name_offset);
Swap32::writeval(pov + 4, out_shndx);
Swap::writeval(pov + 8, out_offset);
Swap::writeval(pov + 8 + sizeof_addr, sh_size);
pov += 8 + 2 * sizeof_addr;
}
// For each global symbol, write its associated relocations,
// add it to the linked list of globals, then write the
// supplemental information: global symbol table index,
// linked list chain pointer, relocation count, and offset
// to the relocations.
for (unsigned int i = 0; i < nsyms; i++)
{
const Symbol* sym = (*syms)[i];
if (sym->is_forwarder())
sym = this->symtab_->resolve_forwards(sym);
unsigned int symtab_index = sym->symtab_index();
unsigned int chain = 0;
unsigned int first_reloc = 0;
unsigned int nrelocs = obj->get_incremental_reloc_count(i);
if (nrelocs > 0)
{
gold_assert(symtab_index != -1U
&& (symtab_index - first_global_index
< global_sym_count));
first_reloc = obj->get_incremental_reloc_base(i);
chain = global_syms[symtab_index - first_global_index];
global_syms[symtab_index - first_global_index] =
pov - oview;
}
Swap32::writeval(pov, symtab_index);
Swap32::writeval(pov + 4, chain);
Swap32::writeval(pov + 8, nrelocs);
Swap32::writeval(pov + 12, first_reloc * 3 * sizeof_addr);
pov += 16;
}
}
break;
case INCREMENTAL_INPUT_SHARED_LIBRARY:
{
gold_assert(static_cast<unsigned int>(pov - oview)
== (*p)->get_info_offset());
Incremental_object_entry* entry = (*p)->object_entry();
gold_assert(entry != NULL);
const Object* obj = entry->object();
const Object::Symbols* syms = obj->get_global_symbols();
// Write the global symbol count.
unsigned int nsyms = syms != NULL ? syms->size() : 0;
Swap32::writeval(pov, nsyms);
pov += 4;
// For each global symbol, write the global symbol table index.
for (unsigned int i = 0; i < nsyms; i++)
{
const Symbol* sym = (*syms)[i];
Swap32::writeval(pov, sym->symtab_index());
pov += 4;
}
}
break;
case INCREMENTAL_INPUT_ARCHIVE:
{
gold_assert(static_cast<unsigned int>(pov - oview)
== (*p)->get_info_offset());
Incremental_archive_entry* entry = (*p)->archive_entry();
gold_assert(entry != NULL);
// Write the member count and unused global symbol count.
unsigned int nmembers = entry->get_member_count();
unsigned int nsyms = entry->get_unused_global_symbol_count();
Swap32::writeval(pov, nmembers);
Swap32::writeval(pov + 4, nsyms);
pov += 8;
// For each member, write the offset to its input file entry.
for (unsigned int i = 0; i < nmembers; ++i)
{
Incremental_object_entry* member = entry->get_member(i);
Swap32::writeval(pov, member->get_offset());
pov += 4;
}
// For each global symbol, write the name offset.
for (unsigned int i = 0; i < nsyms; ++i)
{
Stringpool::Key key = entry->get_unused_global_symbol(i);
Swap32::writeval(pov, strtab->get_offset_from_key(key));
pov += 4;
}
}
break;
default:
gold_unreachable();
}
}
return pov;
}
// Write the contents of the .gnu_incremental_symtab section.
template<int size, bool big_endian>
void
Output_section_incremental_inputs<size, big_endian>::write_symtab(
unsigned char* pov,
unsigned int* global_syms,
unsigned int global_sym_count)
{
for (unsigned int i = 0; i < global_sym_count; ++i)
{
Swap32::writeval(pov, global_syms[i]);
pov += 4;
}
}
// This struct holds the view information needed to write the
// .gnu_incremental_got_plt section.
struct Got_plt_view_info
{
// Start of the GOT type array in the output view.
unsigned char* got_type_p;
// Start of the GOT descriptor array in the output view.
unsigned char* got_desc_p;
// Start of the PLT descriptor array in the output view.
unsigned char* plt_desc_p;
// Number of GOT entries.
unsigned int got_count;
// Number of PLT entries.
unsigned int plt_count;
// Offset of the first non-reserved PLT entry (this is a target-dependent value).
unsigned int first_plt_entry_offset;
// Size of a PLT entry (this is a target-dependent value).
unsigned int plt_entry_size;
// Value to write in the GOT descriptor array. For global symbols,
// this is the global symbol table index; for local symbols, it is
// the offset of the input file entry in the .gnu_incremental_inputs
// section.
unsigned int got_descriptor;
};
// Functor class for processing a GOT offset list for local symbols.
// Writes the GOT type and symbol index into the GOT type and descriptor
// arrays in the output section.
template<int size, bool big_endian>
class Local_got_offset_visitor
{
public:
Local_got_offset_visitor(struct Got_plt_view_info& info)
: info_(info)
{ }
void
operator()(unsigned int got_type, unsigned int got_offset)
{
unsigned int got_index = got_offset / this->got_entry_size_;
gold_assert(got_index < this->info_.got_count);
// We can only handle GOT entry types in the range 0..0x7e
// because we use a byte array to store them, and we use the
// high bit to flag a local symbol.
gold_assert(got_type < 0x7f);
this->info_.got_type_p[got_index] = got_type | 0x80;
unsigned char* pov = this->info_.got_desc_p + got_index * 4;
elfcpp::Swap<32, big_endian>::writeval(pov, this->info_.got_descriptor);
}
private:
static const unsigned int got_entry_size_ = size / 8;
struct Got_plt_view_info& info_;
};
// Functor class for processing a GOT offset list. Writes the GOT type
// and symbol index into the GOT type and descriptor arrays in the output
// section.
template<int size, bool big_endian>
class Global_got_offset_visitor
{
public:
Global_got_offset_visitor(struct Got_plt_view_info& info)
: info_(info)
{ }
void
operator()(unsigned int got_type, unsigned int got_offset)
{
unsigned int got_index = got_offset / this->got_entry_size_;
gold_assert(got_index < this->info_.got_count);
// We can only handle GOT entry types in the range 0..0x7e
// because we use a byte array to store them, and we use the
// high bit to flag a local symbol.
gold_assert(got_type < 0x7f);
this->info_.got_type_p[got_index] = got_type;
unsigned char* pov = this->info_.got_desc_p + got_index * 4;
elfcpp::Swap<32, big_endian>::writeval(pov, this->info_.got_descriptor);
}
private:
static const unsigned int got_entry_size_ = size / 8;
struct Got_plt_view_info& info_;
};
// Functor class for processing the global symbol table. Processes the
// GOT offset list for the symbol, and writes the symbol table index
// into the PLT descriptor array in the output section.
template<int size, bool big_endian>
class Global_symbol_visitor_got_plt
{
public:
Global_symbol_visitor_got_plt(struct Got_plt_view_info& info)
: info_(info)
{ }
void
operator()(const Sized_symbol<size>* sym)
{
typedef Global_got_offset_visitor<size, big_endian> Got_visitor;
const Got_offset_list* got_offsets = sym->got_offset_list();
if (got_offsets != NULL)
{
info_.got_descriptor = sym->symtab_index();
got_offsets->for_all_got_offsets(Got_visitor(info_));
}
if (sym->has_plt_offset())
{
unsigned int plt_index =
((sym->plt_offset() - this->info_.first_plt_entry_offset)
/ this->info_.plt_entry_size);
gold_assert(plt_index < this->info_.plt_count);
unsigned char* pov = this->info_.plt_desc_p + plt_index * 4;
elfcpp::Swap<32, big_endian>::writeval(pov, sym->symtab_index());
}
}
private:
struct Got_plt_view_info& info_;
};
// Write the contents of the .gnu_incremental_got_plt section.
template<int size, bool big_endian>
void
Output_section_incremental_inputs<size, big_endian>::write_got_plt(
unsigned char* pov,
off_t view_size)
{
Sized_target<size, big_endian>* target =
parameters->sized_target<size, big_endian>();
// Set up the view information for the functors.
struct Got_plt_view_info view_info;
view_info.got_count = target->got_entry_count();
view_info.plt_count = target->plt_entry_count();
view_info.first_plt_entry_offset = target->first_plt_entry_offset();
view_info.plt_entry_size = target->plt_entry_size();
view_info.got_type_p = pov + 8;
view_info.got_desc_p = (view_info.got_type_p
+ ((view_info.got_count + 3) & ~3));
view_info.plt_desc_p = view_info.got_desc_p + view_info.got_count * 4;
gold_assert(pov + view_size ==
view_info.plt_desc_p + view_info.plt_count * 4);
// Write the section header.
Swap32::writeval(pov, view_info.got_count);
Swap32::writeval(pov + 4, view_info.plt_count);
// Initialize the GOT type array to 0xff (reserved).
memset(view_info.got_type_p, 0xff, view_info.got_count);
// Write the incremental GOT descriptors for local symbols.
for (Incremental_inputs::Input_list::const_iterator p =
this->inputs_->input_files().begin();
p != this->inputs_->input_files().end();
++p)
{
if ((*p)->type() != INCREMENTAL_INPUT_OBJECT
&& (*p)->type() != INCREMENTAL_INPUT_ARCHIVE_MEMBER)
continue;
Incremental_object_entry* entry = (*p)->object_entry();
gold_assert(entry != NULL);
const Sized_relobj<size, big_endian>* obj =
static_cast<Sized_relobj<size, big_endian>*>(entry->object());
gold_assert(obj != NULL);
unsigned int nsyms = obj->local_symbol_count();
for (unsigned int i = 0; i < nsyms; i++)
{
const Got_offset_list* got_offsets = obj->local_got_offset_list(i);
if (got_offsets != NULL)
{
typedef Local_got_offset_visitor<size, big_endian> Got_visitor;
view_info.got_descriptor = (*p)->get_offset();
got_offsets->for_all_got_offsets(Got_visitor(view_info));
}
}
}
// Write the incremental GOT and PLT descriptors for global symbols.
typedef Global_symbol_visitor_got_plt<size, big_endian> Symbol_visitor;
symtab_->for_all_symbols<size, Symbol_visitor>(Symbol_visitor(view_info));
}
// Instantiate the templates we need.
#ifdef HAVE_TARGET_32_LITTLE
template
class Sized_incremental_binary<32, false>;
#endif
#ifdef HAVE_TARGET_32_BIG
template
class Sized_incremental_binary<32, true>;
#endif
#ifdef HAVE_TARGET_64_LITTLE
template
class Sized_incremental_binary<64, false>;
#endif
#ifdef HAVE_TARGET_64_BIG
template
class Sized_incremental_binary<64, true>;
#endif
} // End namespace gold.
| 32.16569 | 83 | 0.702482 | [
"object"
] |
82b3744e75dc8e6c5eadfa3e44b35666a3869996 | 23,492 | cc | C++ | electron/electron-tf/tensorflow_plugin/src/kernels/cpu/conv_ops_using_gemm.cc | VerticalResearchGroup/eagle | 3b76771e2177290e604086a710d35455cba8db5e | [
"Apache-2.0"
] | 1 | 2022-03-04T06:33:33.000Z | 2022-03-04T06:33:33.000Z | tensorflow_plugin/src/kernels/cpu/conv_ops_using_gemm.cc | hillwang0411/dl_plugin | f1e9b1d696477224bad87e98b9ff49b53435edf8 | [
"Apache-2.0"
] | 2 | 2022-03-22T02:21:00.000Z | 2022-03-26T21:32:19.000Z | tensorflow_plugin/src/kernels/cpu/conv_ops_using_gemm.cc | hillwang0411/dl_plugin | f1e9b1d696477224bad87e98b9ff49b53435edf8 | [
"Apache-2.0"
] | 2 | 2022-01-31T08:54:14.000Z | 2022-02-17T06:07:29.000Z | //#define EIGEN_USE_THREADS
#include <map>
#include <string.h>
#include <vector>
#include "gemm_functors.h"
#include "tensorflow/c/kernels.h"
#include "tensorflow/c/ops.h"
#include "tensorflow/c/tf_datatype.h"
#include "tensorflow/c/tf_status.h"
#include "tensorflow/c/tf_tensor.h"
namespace demo_plugin {
struct StatusDeleter {
void operator()(TF_Status *s) {
if (s != nullptr) {
TF_DeleteStatus(s);
}
}
};
struct TensorDeleter {
void operator()(TF_Tensor *t) {
if (t != nullptr) {
TF_DeleteTensor(t);
}
}
};
using StatusSafePtr = std::unique_ptr<TF_Status, StatusDeleter>;
using TensorSafePtr = std::unique_ptr<TF_Tensor, TensorDeleter>;
enum Padding {
VALID = 1, // No padding.
SAME = 2, // Input and output layers have the same size.
EXPLICIT = 3, // Padding is explicitly specified.
};
enum TensorFormat {
FORMAT_NHWC = 0,
FORMAT_NCHW = 1,
FORMAT_NCHW_VECT_C = 2,
FORMAT_NHWC_VECT_W = 3,
FORMAT_HWNC = 4,
FORMAT_HWCN = 5,
};
template <typename T> struct TypeToEnum {};
template <> struct TypeToEnum<float> {
static TF_DataType v() { return TF_DataType::TF_FLOAT; }
};
template <> struct TypeToEnum<double> {
static TF_DataType v() { return TF_DataType::TF_DOUBLE; }
};
template <> struct TypeToEnum<Eigen::half> {
static TF_DataType v() { return TF_DataType::TF_HALF; }
};
template <> struct TypeToEnum<Eigen::bfloat16> {
static TF_DataType v() { return TF_DataType::TF_BFLOAT16; }
};
static bool GetWindowedOutputSize(int64_t input_size, int64_t filter_size,
int64_t dilation_rate, int64_t stride,
Padding padding_type, int64_t *output_size,
int64_t *padding_before) {
if (stride <= 0) {
std::cerr << "Stride must be > 0, but got " << stride << std::endl;
return false;
}
if (dilation_rate < 1) {
std::cerr << "Dilation rate must be >= 1, but got " << dilation_rate
<< std::endl;
return false;
}
int64_t effective_filter_size = (filter_size - 1) * dilation_rate + 1;
switch (padding_type) {
case Padding::VALID:
*output_size = (input_size - effective_filter_size + stride) / stride;
*padding_before = 0;
break;
case Padding::SAME:
*output_size = (input_size + stride - 1) / stride;
const int64_t padding_needed =
std::max(int64_t{0}, (*output_size - 1) * stride +
effective_filter_size - input_size);
// For odd values of total padding, add more padding at the 'right'
// side of the given dimension.
*padding_before = padding_needed / 2;
break;
}
if (*output_size < 0) {
std::cerr << "Computed output size would be negative: " << *output_size
<< " [input_size: " << input_size
<< ", effective_filter_size: " << effective_filter_size
<< ", stride: " << stride << "]" << std::endl;
return false;
}
return true;
}
static int64_t GetTensorDim(TF_Tensor *tensor, std::string &format, char dim) {
int idx = -1;
if (format == "NCHW") {
switch (dim) {
case 'N': {
idx = 0;
break;
}
case 'C': {
idx = 1;
break;
}
case 'H': {
idx = 2;
break;
}
case 'W': {
idx = 3;
break;
}
default: {
idx = -1;
}
}
} else if (format == "NHWC") {
switch (dim) {
case 'N': {
idx = 0;
break;
}
case 'C': {
idx = 3;
break;
}
case 'H': {
idx = 1;
break;
}
case 'W': {
idx = 2;
break;
}
default: {
idx = -1;
}
}
} else {
std::cerr << "Unsupport data_format now" << std::endl;
return -1;
}
return TF_Dim(tensor, idx);
}
#define CHECK_CONSTRUCT_STATUS(ctx, status) \
do { \
if (TF_GetCode(status) != TF_OK) { \
TF_OpKernelConstruction_Failure(ctx, status); \
} \
} while (0);
#define CHECK_CTX_STATUS(ctx, status) \
do { \
if (TF_GetCode(status) != TF_OK) { \
TF_OpKernelContext_Failure(ctx, status); \
} \
} while (0);
namespace {
const size_t kMaxChunkSize = (16 * 1024 * 1024);
// Implements convolution as a two stage process, first packing the patches of
// the input image into columns (im2col) and then running GEMM to produce the
// final result.
template <class T1, class T2, class T3, class TGemmFunctor>
class Im2ColConvFunctor {
public:
void operator()(const T1 *input_data, int input_batches, int input_height,
int input_width, int input_depth, const T2 *filter_data,
int filter_height, int filter_width, int filter_count,
int stride_rows, int stride_cols, Padding padding,
T3 *output_data, int output_height, int output_width) {
if ((input_batches <= 0) || (input_width <= 0) || (input_height <= 0) ||
(input_depth <= 0)) {
std::cerr << "Conv2D was called with bad input dimensions: "
<< input_batches << ", " << input_height << ", " << input_width
<< ", " << input_depth;
return;
}
if ((filter_width <= 0) || (filter_height <= 0) || (filter_count <= 0)) {
std::cerr << "Conv2D was called with bad filter dimensions: "
<< filter_width << ", " << filter_height << ", "
<< filter_count;
return;
}
if ((output_width <= 0) || (output_height <= 0)) {
std::cerr << "Conv2D was called with bad output width or height: "
<< output_width << ", " << output_height;
return;
}
// We can just use a GEMM if the im2col is the identity operator, e.g., if
// // the kernel is 1x1 or the input data and filter have same height/width.
if (filter_height == 1 && filter_width == 1 && stride_rows == 1 &&
stride_cols == 1) {
// The kernel is 1x1.
const int m = input_batches * input_height * input_width;
const int n = filter_count;
const int k = input_depth;
const int lda = k;
const int ldb = filter_count;
const int ldc = filter_count;
TGemmFunctor gemm_functor;
gemm_functor(m, n, k, input_data, lda, filter_data, ldb, output_data,
ldc);
return;
} else if (filter_height == input_height && filter_width == input_width &&
padding == VALID) {
// The input data and filter have the same height/width.
const int m = input_batches;
const int n = filter_count;
const int k = input_height * input_width * input_depth;
const int lda = k;
const int ldb = filter_count;
const int ldc = filter_count;
TGemmFunctor gemm_functor;
gemm_functor(m, n, k, input_data, lda, filter_data, ldb, output_data,
ldc);
return;
}
// These calculations define how the patches will be positioned within the
// input image. The actual definitions are quite complex, and rely on the
// previously-calculated output size.
int filter_left_offset;
int filter_top_offset;
if (padding == VALID) {
filter_left_offset =
((output_width - 1) * stride_cols + filter_width - input_width + 1) /
2;
filter_top_offset = ((output_height - 1) * stride_rows + filter_height -
input_height + 1) /
2;
} else {
filter_left_offset =
((output_width - 1) * stride_cols + filter_width - input_width) / 2;
filter_top_offset =
((output_height - 1) * stride_rows + filter_height - input_height) /
2;
}
// The im2col buffer has # of patches rows, and # of filters cols.
// It's laid out like this, in row major order in memory:
// < filter value count >
// ^ +---------------------+
// patch | |
// count | |
// v +---------------------+
// Each patch row contains a filter_width x filter_height patch of the
// input, with the depth channel as the most contiguous in memory, followed
// by the width, then the height. This is the standard memory order in the
// image world if it helps to visualize it.
const int filter_value_count = filter_width * filter_height * input_depth;
if ((filter_value_count * sizeof(T1)) > kMaxChunkSize) {
std::cerr << "Im2Col patch too large for buffer" << std::endl;
return;
}
const int64_t patches_per_chunk =
kMaxChunkSize / (filter_value_count * sizeof(T1));
const int64_t chunk_value_count =
(kMaxChunkSize + (sizeof(T1) - 1)) / sizeof(T1);
// This means that multiple ops can't be run simultaneously on different
// threads, because we have a single shared resource. The platforms this is
// aimed at have intra-op parallelism as their focus though, so it shouldn't
// be an issue.
// T1* im2col_buffer = new T1[chunk_value_count];
std::unique_ptr<T1> im2col_buffer(new T1[chunk_value_count]);
const int64_t patch_count = (input_batches * output_height * output_width);
const int64_t chunk_count =
(patch_count + (patches_per_chunk - 1)) / patches_per_chunk;
for (int64_t chunk_index = 0; chunk_index < chunk_count; ++chunk_index) {
const int64_t patch_index_start = chunk_index * patches_per_chunk;
const int64_t patch_index_end =
std::min(patch_index_start + patches_per_chunk, patch_count);
for (int64_t patch_index = patch_index_start;
patch_index < patch_index_end; ++patch_index) {
const int64_t batch = patch_index / (output_height * output_width);
const int64_t out_y = (patch_index / output_width) % output_height;
const int64_t out_x = patch_index % output_width;
const T1 *input_batch_start =
input_data + (batch * input_height * input_width * input_depth);
const int in_y_origin = (out_y * stride_rows) - filter_top_offset;
const int in_x_origin = (out_x * stride_cols) - filter_left_offset;
const int patch_index_within_chunk = patch_index % patches_per_chunk;
T1 *im2col_patch_start =
im2col_buffer.get() +
(patch_index_within_chunk * filter_value_count);
for (int filter_y = 0; filter_y < filter_height; ++filter_y) {
const int in_y = in_y_origin + filter_y;
T1 *im2col_row_start =
im2col_patch_start + (filter_y * filter_width * input_depth);
// If we're off the top or the bottom of the input, fill the
// whole row with zeroes.
if ((in_y < 0) || (in_y >= input_height)) {
T1 *im2col_row_end =
im2col_row_start + (filter_width * input_depth);
std::fill(im2col_row_start, im2col_row_end, T1(0));
} else {
// What we're doing here is trying to copy and fill the im2col
// buffer as efficiently as possible, using functions to set or
// duplicate values en masse. We know we don't have to worry about
// vertical edges because we dealt with that case above, so we
// just need to handle filters that overlap the left or right
// edges. Here's what that looks like:
//
// < left_zero_count > < center_copy_count > < right_zero_count >
// +------------------+---------------------+--------------------+
// | (filter) | (image) | (filter) |
// +------------------+---------------------+--------------------+
// in_x_origin 0 input_width in_x_end
//
// In reality it's unlikely that a filter patch will be wider
// than an input, but this shows all the edge cases.
// We use std::fill() to set the left and right sections to zeroes
// and std::copy() to copy over the input data for the center.
const int in_x_end = in_x_origin + filter_width;
const int left_zero_count = std::max(0, 0 - in_x_origin);
const int right_zero_count = std::max(0, in_x_end - input_width);
const int center_copy_count =
filter_width - (left_zero_count + right_zero_count);
if (left_zero_count > 0) {
T1 *im2col_left_start = im2col_row_start;
T1 *im2col_left_end =
im2col_left_start + (left_zero_count * input_depth);
std::fill(im2col_left_start, im2col_left_end, T1(0));
}
if (center_copy_count > 0) {
const T1 *input_row_start =
input_batch_start + (in_y * input_width * input_depth) +
(std::max(0, in_x_origin) * input_depth);
const T1 *input_row_end =
input_row_start + (center_copy_count * input_depth);
T1 *im2col_center_start =
im2col_row_start + (left_zero_count * input_depth);
std::copy(input_row_start, input_row_end, im2col_center_start);
}
if (right_zero_count > 0) {
T1 *im2col_right_start =
im2col_row_start +
((left_zero_count + center_copy_count) * input_depth);
T1 *im2col_right_end =
im2col_right_start + (right_zero_count * input_depth);
std::fill(im2col_right_start, im2col_right_end, T1(0));
}
}
}
}
// Now we've assembled a set of image patches into a matrix, apply a
// GEMM matrix multiply of the patches as rows, times the filter
// weights in columns, to get partial results in the output matrix.
const int how_many_patches = patch_index_end - patch_index_start;
const int m = how_many_patches;
const int n = filter_count;
const int k = filter_value_count;
const int lda = filter_value_count;
const int ldb = filter_count;
const int ldc = filter_count;
T3 *chunk_output_data = output_data + (patch_index_start * filter_count);
TGemmFunctor gemm_functor;
gemm_functor(m, n, k, im2col_buffer.get(), lda, filter_data, ldb,
chunk_output_data, ldc);
}
}
};
} // namespace
template <class T> struct Conv2DUsingGemmOp {
Conv2DUsingGemmOp() : data_format_("") {}
std::vector<int32_t> strides_;
Padding padding_;
std::string data_format_;
};
template <class T>
void *Conv2DUsingGemmOp_Create(TF_OpKernelConstruction *ctx) {
auto kernel = new Conv2DUsingGemmOp<T>();
StatusSafePtr status(TF_NewStatus());
int32_t list_size = 0;
int32_t total_size = 0;
// Get strides
TF_OpKernelConstruction_GetAttrSize(ctx, "strides", &list_size, &total_size,
status.get());
CHECK_CONSTRUCT_STATUS(ctx, status.get());
kernel->strides_.resize(list_size);
TF_OpKernelConstruction_GetAttrInt32List(
ctx, "strides", kernel->strides_.data(), list_size, status.get());
CHECK_CONSTRUCT_STATUS(ctx, status.get());
// Get data_format
TF_OpKernelConstruction_GetAttrSize(ctx, "data_format", &list_size,
&total_size, status.get());
CHECK_CONSTRUCT_STATUS(ctx, status.get());
std::vector<char> format_vec(total_size);
TF_OpKernelConstruction_GetAttrString(ctx, "data_format", format_vec.data(),
total_size, status.get());
CHECK_CONSTRUCT_STATUS(ctx, status.get());
kernel->data_format_ = std::move(std::string(format_vec.data(), total_size));
// Get padding
TF_OpKernelConstruction_GetAttrSize(ctx, "padding", &list_size, &total_size,
status.get());
CHECK_CONSTRUCT_STATUS(ctx, status.get());
std::vector<char> padding_vec(total_size);
TF_OpKernelConstruction_GetAttrString(ctx, "padding", padding_vec.data(),
total_size, status.get());
CHECK_CONSTRUCT_STATUS(ctx, status.get());
std::string padding_str(padding_vec.data(), total_size);
if (padding_str == "VALID") {
kernel->padding_ = Padding::VALID;
} else if (padding_str == "SAME") {
kernel->padding_ = Padding::SAME;
} else {
std::cerr << "Unsupported padding type: " << padding_str;
return nullptr;
}
return kernel;
}
template <typename T> void Conv2DUsingGemmOp_Delete(void *kernel) {
if (kernel != nullptr) {
delete static_cast<Conv2DUsingGemmOp<T> *>(kernel);
}
}
template <class T, class TConvFunctor>
void Conv2DUsingGemmOp_Compute(void *kernel, TF_OpKernelContext *ctx) {
StatusSafePtr status(TF_NewStatus());
// Input tensor is of the following dimensions:
// [ batch, in_rows, in_cols, in_depth ]
TF_Tensor *input = nullptr;
TF_GetInput(ctx, 0, &input, status.get());
CHECK_CTX_STATUS(ctx, status.get());
TensorSafePtr input_safe_ptr(input);
// Input filter is of the following dimensions:
// [ filter_rows, filter_cols, in_depth, out_depth]
TF_Tensor *filter = nullptr;
TF_GetInput(ctx, 1, &filter, status.get());
CHECK_CTX_STATUS(ctx, status.get());
TensorSafePtr filter_safe_ptr(filter);
if (TF_NumDims(input) != 4) {
std::cerr << "input must be 4 dimensional" << std::endl;
return;
}
if (TF_NumDims(filter) != 4) {
std::cerr << "filter must be 4 dimensional" << std::endl;
return;
}
for (int i = 0; i < 3; i++) {
if (TF_Dim(filter, i) >= std::numeric_limits<int>::max()) {
std::cerr << "filter too large" << std::endl;
return;
}
}
// The last dimension for input is in_depth. It must be the same as the
// filter's in_depth.
const int64_t in_depth = GetTensorDim(
input, static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_, 'C');
if (in_depth != TF_Dim(filter, 2)) {
std::cerr << "input and filter must have the same depth" << std::endl;
return;
}
// The last dimension for filter is out_depth.
const int out_depth = static_cast<int>(TF_Dim(filter, 3));
// The second dimension for input is rows/height.
// The first dimension for filter is rows/height.
const int64_t input_rows_raw = GetTensorDim(
input, static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_, 'H');
if (input_rows_raw >= std::numeric_limits<int>::max()) {
std::cerr << "Input rows too large";
return;
}
const int input_rows = static_cast<int>(input_rows_raw);
const int filter_rows = static_cast<int>(TF_Dim(filter, 0));
// The third dimension for input is columns/width.
// The second dimension for filter is columns/width.
const int64_t input_cols_raw = GetTensorDim(
input, static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_, 'W');
if (input_cols_raw >= std::numeric_limits<int>::max()) {
std::cerr << "Input cols too large" << std::endl;
return;
}
const int input_cols = static_cast<int>(input_cols_raw);
const int filter_cols = static_cast<int>(TF_Dim(filter, 1));
// The first dimension for input is batch.
const int64_t batch_raw = GetTensorDim(
input, static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_, 'N');
if (batch_raw >= std::numeric_limits<int>::max()) {
std::cerr << "batch is too large" << std::endl;
return;
}
const int batch = static_cast<int>(batch_raw);
// For now we take the stride from the second and third dimensions only (we
// do not support striding on the batch or depth dimension).
int stride_rows = 0;
int stride_cols = 0;
if (static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_ == "NCHW") {
stride_rows = static_cast<Conv2DUsingGemmOp<T> *>(kernel)->strides_[2];
stride_cols = static_cast<Conv2DUsingGemmOp<T> *>(kernel)->strides_[3];
} else if (static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_ ==
"NHWC") {
stride_rows = static_cast<Conv2DUsingGemmOp<T> *>(kernel)->strides_[1];
stride_cols = static_cast<Conv2DUsingGemmOp<T> *>(kernel)->strides_[2];
} else {
std::cerr << "Unsupported data format" << std::endl;
return;
}
int64_t out_rows = 0, out_cols = 0, pad_rows = 0, pad_cols = 0;
if (!GetWindowedOutputSize(
input_rows, filter_rows, 1, stride_rows,
static_cast<Conv2DUsingGemmOp<T> *>(kernel)->padding_, &out_rows,
&pad_rows)) {
std::cerr << "Invalid filter size" << std::endl;
return;
}
if (!GetWindowedOutputSize(
input_cols, filter_cols, 1, stride_cols,
static_cast<Conv2DUsingGemmOp<T> *>(kernel)->padding_, &out_cols,
&pad_cols)) {
std::cerr << "Invalid filter size" << std::endl;
return;
}
auto output_size = batch * out_rows * out_cols * out_depth;
std::vector<int64_t> out_shape;
out_shape.push_back(batch);
if (static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_ == "NCHW") {
out_shape.push_back(out_depth);
out_shape.push_back(out_rows);
out_shape.push_back(out_cols);
} else if (static_cast<Conv2DUsingGemmOp<T> *>(kernel)->data_format_ ==
"NHWC") {
out_shape.push_back(out_rows);
out_shape.push_back(out_cols);
out_shape.push_back(out_depth);
} else {
std::cerr << "Unsupported data_foramt" << std::endl;
return;
}
// Output tensor is of the following dimensions:
// [ in_batch, out_rows, out_cols, out_depth ]``
TensorSafePtr output_safe_ptr(TF_AllocateOutput(
ctx, 0, TF_ExpectedOutputDataType(ctx, 0), out_shape.data(),
out_shape.size(), sizeof(T) * output_size, status.get()));
// If there is nothing to compute, return.
if (output_size == 0) {
return;
}
TConvFunctor conv_functor;
conv_functor(static_cast<T *>(TF_TensorData(input_safe_ptr.get())), batch,
input_rows, input_cols, in_depth,
static_cast<T *>(TF_TensorData(filter_safe_ptr.get())),
filter_rows, filter_cols, out_depth, stride_rows, stride_cols,
static_cast<Conv2DUsingGemmOp<T> *>(kernel)->padding_,
static_cast<T *>(TF_TensorData(output_safe_ptr.get())), out_rows,
out_cols);
};
template <typename T> void RegisterConvOpKernel(const char *device_type) {
StatusSafePtr status(TF_NewStatus());
auto *builder = TF_NewKernelBuilder(
"Conv2D", device_type, &Conv2DUsingGemmOp_Create<T>,
&Conv2DUsingGemmOp_Compute<
T, Im2ColConvFunctor<T, T, T, FastGemmFunctor<T, T, T>>>,
&Conv2DUsingGemmOp_Delete<T>);
TF_KernelBuilder_TypeConstraint(builder, "T", TypeToEnum<T>::v(),
status.get());
if (TF_OK != TF_GetCode(status.get()))
std::cout << " Error while registering relu kernel with attribute T";
TF_RegisterKernelBuilder("Conv2DOp", builder, status.get());
if (TF_OK != TF_GetCode(status.get()))
std::cout << " Error while registering relu kernel";
}
} // namespace demo_plugin
void RegisterDeviceConv2D(const char *device_type) {
demo_plugin::RegisterConvOpKernel<float>(device_type);
}
| 38.574713 | 80 | 0.607739 | [
"vector"
] |
82c0c487209cc0c0ce8d4d9b12b6ed8821bf2ba7 | 7,577 | cpp | C++ | src/other/ext/openscenegraph/src/osg/ShaderComposer.cpp | lf-/brlcad | f91ea585c1a930a2e97c3f5a8274db8805ebbb46 | [
"BSD-4-Clause",
"BSD-3-Clause"
] | null | null | null | src/other/ext/openscenegraph/src/osg/ShaderComposer.cpp | lf-/brlcad | f91ea585c1a930a2e97c3f5a8274db8805ebbb46 | [
"BSD-4-Clause",
"BSD-3-Clause"
] | null | null | null | src/other/ext/openscenegraph/src/osg/ShaderComposer.cpp | lf-/brlcad | f91ea585c1a930a2e97c3f5a8274db8805ebbb46 | [
"BSD-4-Clause",
"BSD-3-Clause"
] | null | null | null | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
* Copyright (C) 2010-10-21 VIRES Simulationstechnologie GmbH
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library 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
* OpenSceneGraph Public License for more details.
*/
/*
* mod: Holger Helmich 2010-10-21
*/
#include <osg/ShaderComposer>
#include <osg/Notify>
using namespace osg;
ShaderComposer::ShaderComposer()
{
OSG_INFO<<"ShaderComposer::ShaderComposer() "<<this<<std::endl;
}
ShaderComposer::ShaderComposer(const ShaderComposer& sa, const CopyOp& copyop):
Object(sa, copyop)
{
OSG_INFO<<"ShaderComposer::ShaderComposer(const ShaderComposer&, const CopyOp& copyop) "<<this<<std::endl;
}
ShaderComposer::~ShaderComposer()
{
OSG_INFO<<"ShaderComposer::~ShaderComposer() "<<this<<std::endl;
}
void ShaderComposer::releaseGLObjects(osg::State* state) const
{
for(ProgramMap::const_iterator itr = _programMap.begin();
itr != _programMap.end();
++itr)
{
itr->second->releaseGLObjects(state);
}
for(ShaderMainMap::const_iterator itr = _shaderMainMap.begin();
itr != _shaderMainMap.end();
++itr)
{
itr->second->releaseGLObjects(state);
}
}
osg::Program* ShaderComposer::getOrCreateProgram(const ShaderComponents& shaderComponents)
{
ProgramMap::iterator pmitr = _programMap.find(shaderComponents);
if (pmitr != _programMap.end())
{
// OSG_NOTICE<<"ShaderComposer::getOrCreateProgram(..) using cached Program"<<std::endl;
return pmitr->second.get();
}
// strip out vertex shaders
Shaders vertexShaders;
Shaders tessControlShaders;
Shaders tessEvaluationShaders;
Shaders geometryShaders;
Shaders fragmentShaders;
Shaders computeShaders;
OSG_NOTICE<<"ShaderComposer::getOrCreateProgram(shaderComponents.size()=="<<shaderComponents.size()<<std::endl;
for(ShaderComponents::const_iterator itr = shaderComponents.begin();
itr != shaderComponents.end();
++itr)
{
const ShaderComponent* sc = *itr;
for(unsigned int i=0; i<sc->getNumShaders(); ++i)
{
const Shader* shader = sc->getShader(i);
switch(shader->getType())
{
case(Shader::VERTEX):
vertexShaders.push_back(shader);
break;
case(Shader::TESSCONTROL):
tessControlShaders.push_back(shader);
break;
case(Shader::TESSEVALUATION):
tessEvaluationShaders.push_back(shader);
break;
case(Shader::GEOMETRY):
geometryShaders.push_back(shader);
break;
case(Shader::FRAGMENT):
fragmentShaders.push_back(shader);
break;
case(Shader::COMPUTE):
computeShaders.push_back(shader);
break;
case(Shader::UNDEFINED):
OSG_WARN<<"Warning: ShaderCompose::getOrCreateProgam(ShaderComponts) encounterd invalid Shader::Type."<<std::endl;
break;
}
}
}
osg::ref_ptr<osg::Program> program = new osg::Program;
if (!vertexShaders.empty())
{
addShaderToProgram(program.get(), vertexShaders);
}
if (!tessControlShaders.empty())
{
addShaderToProgram(program.get(), tessControlShaders);
}
if (!geometryShaders.empty())
{
addShaderToProgram(program.get(), geometryShaders);
}
if (!tessEvaluationShaders.empty())
{
addShaderToProgram(program.get(), tessEvaluationShaders);
}
if (!fragmentShaders.empty())
{
addShaderToProgram(program.get(), fragmentShaders);
}
if (!computeShaders.empty())
{
addShaderToProgram(program.get(), computeShaders);
}
// assign newly created program to map.
_programMap[shaderComponents] = program;
OSG_NOTICE<<"ShaderComposer::getOrCreateProgram(..) created new Program"<<std::endl;
return program.get();
}
void ShaderComposer::addShaderToProgram(Program* program, const Shaders& shaders)
{
ShaderMainMap::iterator smitr = _shaderMainMap.find(shaders);
if (smitr == _shaderMainMap.end())
{
// no vertex shader in map yet, need to compose a new main shader
osg::Shader* mainShader = composeMain(shaders);
_shaderMainMap[shaders] = mainShader;
program->addShader(mainShader);
}
else
{
program->addShader(smitr->second.get());
}
for(Shaders::const_iterator itr = shaders.begin();
itr != shaders.end();
++itr)
{
Shader* shader = const_cast<Shader*>(*itr);
if (!(shader->getShaderSource().empty()) || shader->getShaderBinary())
{
program->addShader(shader);
}
}
}
osg::Shader* ShaderComposer::composeMain(const Shaders& shaders)
{
OSG_NOTICE<<"ShaderComposer::composeMain(Shaders) shaders.size()=="<<shaders.size()<<std::endl;
// collect the shader type and the code injection from each of the contributing shaders
Shader::Type type = Shader::UNDEFINED;
Shader::CodeInjectionMap codeInjectionMap;
for(Shaders::const_iterator itr = shaders.begin();
itr != shaders.end();
++itr)
{
const Shader* shader = *itr;
if (type == Shader::UNDEFINED)
{
type = shader->getType();
}
else if (type != shader->getType())
{
OSG_NOTICE<<"Warning:ShaderComposer::composeMain() mixing different types of Shaders prohibited."<<std::endl;
continue;
}
const Shader::CodeInjectionMap& cim = shader->getCodeInjectionMap();
for(Shader::CodeInjectionMap::const_iterator citr = cim.begin();
citr != cim.end();
++citr)
{
codeInjectionMap.insert(*citr);
}
}
// collect together the different parts of the main shader
std::string before_main;
std::string in_main;
std::string after_main;
for(Shader::CodeInjectionMap::iterator citr = codeInjectionMap.begin();
citr != codeInjectionMap.end();
++citr)
{
float position = citr->first;
if (position<0.0) before_main += citr->second;
else if (position<=1.0) in_main += citr->second;
else after_main += citr->second;
}
// assembly the final main shader source
std::string full_source;
full_source += before_main;
full_source += std::string("void main(void)\n");
full_source += std::string("{\n");
full_source += in_main;
full_source += std::string("}\n");
full_source += after_main;
ref_ptr<Shader> mainShader = new Shader(type, full_source);
OSG_NOTICE<<"type =="<<type<<std::endl;
OSG_NOTICE<<"full_source == "<<std::endl<<full_source<<std::endl;
OSG_NOTICE<<"end of ShaderComposer::composeMain(Shaders)"<<std::endl<<std::endl;
_shaderMainMap[shaders] = mainShader;
return mainShader.get();
}
| 30.676113 | 134 | 0.622542 | [
"geometry",
"object"
] |
82c1489d3e55e2e1e6164d867fa9662febde29ae | 6,035 | inl | C++ | MathL/src/Vector4Type.inl | LeoMaden/MathL | 4345855535e21ead186c3449c360cba5a7326036 | [
"MIT"
] | null | null | null | MathL/src/Vector4Type.inl | LeoMaden/MathL | 4345855535e21ead186c3449c360cba5a7326036 | [
"MIT"
] | null | null | null | MathL/src/Vector4Type.inl | LeoMaden/MathL | 4345855535e21ead186c3449c360cba5a7326036 | [
"MIT"
] | null | null | null | #pragma once
#include "Vector4Type.h"
namespace MathL {
template<typename T, bool UseSimd>
struct VectorAdd<4, T, UseSimd>
{
static Vector<4, T> Compute(const Vector<4, T>& left, const Vector<4, T>& right)
{
return Vector<4, T>(
left.x + right.x,
left.y + right.y,
left.z + right.z,
left.w + right.w
);
}
static Vector<4, T> Compute(const Vector<4, T>& left, T value)
{
return Vector<4, T>(
left.x + value,
left.y + value,
left.z + value,
left.w + value
);
}
};
template<typename T, bool UseSimd>
struct VectorSub<4, T, UseSimd>
{
static Vector<4, T> Compute(const Vector<4, T>& left, const Vector<4, T>& right)
{
return Vector<4, T>(
left.x - right.x,
left.y - right.y,
left.z - right.z,
left.w - right.w
);
}
static Vector<4, T> Compute(const Vector<4, T>& left, T value)
{
return Vector<4, T>(
left.x - value,
left.y - value,
left.z - value,
left.w - value
);
}
};
template<typename T, bool UseSimd>
struct VectorMul<4, T, UseSimd>
{
static Vector<4, T> Compute(const Vector<4, T>& left, const Vector<4, T>& right)
{
return Vector<4, T>(
left.x * right.x,
left.y * right.y,
left.z * right.z,
left.w * right.w
);
}
static Vector<4, T> Compute(const Vector<4, T>& left, T value)
{
return Vector<4, T>(
left.x * value,
left.y * value,
left.z * value,
left.w * value
);
}
};
template<typename T, bool UseSimd>
struct VectorDiv<4, T, UseSimd>
{
static Vector<4, T> Compute(const Vector<4, T>& left, const Vector<4, T>& right)
{
return Vector<4, T>(
left.x / right.x,
left.y / right.y,
left.z / right.z,
left.w / right.w
);
}
static Vector<4, T> Compute(const Vector<4, T>& left, T value)
{
return Vector<4, T>(
left.x / value,
left.y / value,
left.z / value,
left.w / value
);
}
};
template<typename T, bool UseSimd>
struct VectorDot<4, T, UseSimd>
{
static T Compute(const Vector<4, T>& left, const Vector<4, T>& right)
{
return (left.x * right.x) + (left.y * right.y) + (left.z * right.z) + (left.w * right.w);
}
};
// ----- Basic Constructors -----
template<typename T>
inline Vector<4, T>::Vector()
: x(0.0f), y(0.0f), z(0.0f), w(0.0f)
{
}
template<typename T>
inline Vector<4, T>::Vector(T x, T y, T z, T w)
: x(x), y(y), z(z), w(w)
{
}
// ----- Copy/Conversion Constructors -----
template<typename T>
inline Vector<4, T>::Vector(const Vector<4, T>& other)
: x(other.x), y(other.y), z(other.z), w(other.w)
{
}
// ----- Math Operations -----
template<typename T>
inline T Vector<4, T>::Dot(const Vector<4, T>& other)
{
return VectorDot<4, T, ML_USE_SIMD>::Compute(*this, other);
}
// ----- Access -----
template<typename T>
inline T& Vector<4, T>::operator[](int i)
{
switch (i)
{
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
}
throw std::out_of_range("Index out of range");
}
template<typename T>
inline const T& Vector<4, T>::operator[](int i) const
{
switch (i)
{
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
}
throw std::out_of_range("Index out of range");
}
// ----- Unary Vector Operators -----
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator+=(const Vector<4, T>& other)
{
return *this = VectorAdd<4, T, ML_USE_SIMD>::Compute(*this, other);
}
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator-=(const Vector<4, T>& other)
{
return *this = VectorSub<4, T, ML_USE_SIMD>::Compute(*this, other);
}
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator*=(const Vector<4, T>& other)
{
return *this = VectorMul<4, T, ML_USE_SIMD>::Compute(*this, other);
}
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator/=(const Vector<4, T>& other)
{
return *this = VectorDiv<4, T, ML_USE_SIMD>::Compute(*this, other);
}
// ----- Unary Scalar Operators -----
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator+=(T other)
{
return *this = VectorAdd<4, T, ML_USE_SIMD>::Compute(*this, other);
}
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator-=(T other)
{
return *this = VectorSub<4, T, ML_USE_SIMD>::Compute(*this, other);
}
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator*=(T other)
{
return *this = VectorMul<4, T, ML_USE_SIMD>::Compute(*this, other);
}
template<typename T>
inline Vector<4, T>& Vector<4, T>::operator/=(T other)
{
return *this = VectorDiv<4, T, ML_USE_SIMD>::Compute(*this, other);
}
// ----- Binary Vector Operators -----
template<typename T>
Vector<4, T> operator+(const Vector<4, T>& left, const Vector<4, T>& right)
{
return VectorAdd<4, T, ML_USE_SIMD>::Compute(left, right);
}
template<typename T>
Vector<4, T> operator-(const Vector<4, T>& left, const Vector<4, T>& right)
{
return VectorSub<4, T, ML_USE_SIMD>::Compute(left, right);
}
template<typename T>
Vector<4, T> operator*(const Vector<4, T>& left, const Vector<4, T>& right)
{
return VectorMul<4, T, ML_USE_SIMD>::Compute(left, right);
}
template<typename T>
Vector<4, T> operator/(const Vector<4, T>& left, const Vector<4, T>& right)
{
return VectorDiv<4, T, ML_USE_SIMD>::Compute(left, right);
}
// ----- Binary Scalar Operators -----
template<typename T>
Vector<4, T> operator+(const Vector<4, T>& left, T value)
{
return VectorAdd<4, T, ML_USE_SIMD>::Compute(left, value);
}
template<typename T>
Vector<4, T> operator-(const Vector<4, T>& left, T value)
{
return VectorSub<4, T, ML_USE_SIMD>::Compute(left, value);
}
template<typename T>
Vector<4, T> operator*(const Vector<4, T>& left, T value)
{
return VectorMul<4, T, ML_USE_SIMD>::Compute(left, value);
}
template<typename T>
Vector<4, T> operator/(const Vector<4, T>& left, T value)
{
return VectorDiv<4, T, ML_USE_SIMD>::Compute(left, value);
}
} | 21.25 | 92 | 0.606959 | [
"vector"
] |
82c793503de1cfde6912723ed08af2594e7adf21 | 8,505 | cpp | C++ | Jyamithika/MonotonePartition.cpp | kasunindikaliyanage/Jyamithika | ae558f2ea1f784fd54f82f507969ad46b62defd5 | [
"MIT"
] | 7 | 2021-11-11T14:57:36.000Z | 2022-03-22T21:53:32.000Z | Jyamithika/MonotonePartition.cpp | kasunindikaliyanage/Jyamithika | ae558f2ea1f784fd54f82f507969ad46b62defd5 | [
"MIT"
] | null | null | null | Jyamithika/MonotonePartition.cpp | kasunindikaliyanage/Jyamithika | ae558f2ea1f784fd54f82f507969ad46b62defd5 | [
"MIT"
] | 6 | 2021-11-24T05:20:04.000Z | 2022-02-27T15:12:34.000Z | #include "MonotonePartition.h"
#include <set>
#include <map>
#include <algorithm>
using namespace jmk;
enum class VERTEX_CATEGORY {
START,
END,
REGULAR,
SPLIT,
MERGE,
INVALID
};
VERTEX_CATEGORY categorize_vertex(Vertex2dDCEL* vertex)
{
Vertex2dDCEL* v_prev = vertex->incident_edge->prev->origin;
Vertex2dDCEL* v_next = vertex->incident_edge->next->origin;
// Need vertex beside the given one to get the dicission. Return INVALID if one is missing
if (!v_prev || !v_next)
return VERTEX_CATEGORY::INVALID;
Point2d p_prev = v_prev->point;
Point2d p = vertex->point;
Point2d p_next = v_next->point;
bool is_left = left(p_prev, p, p_next);
if (p[Y] > p_prev[Y] && p[Y] > p_next[Y])
{
if (is_left)
return VERTEX_CATEGORY::START;
else
return VERTEX_CATEGORY::SPLIT;
}
else if (p[Y] < p_prev[Y] && p[Y] < p_next[Y])
{
if (is_left)
return VERTEX_CATEGORY::END;
else
return VERTEX_CATEGORY::MERGE;
}
else
{
return VERTEX_CATEGORY::REGULAR;
}
}
struct Vertex2dDCELWrapper {
Vertex2dDCEL* vert;
VERTEX_CATEGORY category;
};
struct Edge2dDCELWrapper {
Edge2dDCEL* edge;
Vertex2dDCELWrapper helper;
Edge2dDCELWrapper(Edge2dDCEL* _edge, Vertex2dDCELWrapper& _helper) {
edge = _edge;
helper = _helper;
orgin = edge->origin->point;
dest = edge->twin->origin->point;
}
const float computeX(const Point2d& point) const {
float _deno = (dest[Y] - orgin[Y]);
float _x = point[X];
if (_deno != 0) {
_x = (point[Y] - orgin[Y]) * (dest[X] - orgin[X]) / _deno + orgin[X];
}
return _x;
}
private:
Point2d orgin, dest;
};
struct Vertex2DWrapperSort {
bool operator()(Vertex2dDCELWrapper& current, Vertex2dDCELWrapper& ref) {
auto cur_pnt = current.vert->point;
auto ref_pnt = ref.vert->point;
if ((cur_pnt[Y] > ref_pnt[Y])
|| (cur_pnt[Y] == ref_pnt[Y]) && (cur_pnt[X] < ref_pnt[X]))
{
return true;
}
return false;
}
};
struct SweepLineComparator {
Point2d* point;
SweepLineComparator(Point2d* _point) {
point = _point;
}
bool operator()(const Edge2dDCELWrapper* _ref1, const Edge2dDCELWrapper* _ref2) const {
return _ref1->computeX(*point) < _ref2->computeX(*point);
}
};
// TODO : Check the posibility of Refactoring the code to remove duplicate lines
static void handle_start_vertices(Vertex2dDCELWrapper& vertex
, std::set<Edge2dDCELWrapper*, SweepLineComparator>& sweep_line
, std::map<Edge2dDCEL*, Edge2dDCELWrapper*>& edge_mapper, Polygon2d* poly)
{
Edge2dDCELWrapper* edge = new Edge2dDCELWrapper(vertex.vert->incident_edge, vertex);
sweep_line.insert(edge);
edge_mapper.insert(std::pair<Edge2dDCEL*, Edge2dDCELWrapper*>(vertex.vert->incident_edge, edge));
}
static void handle_end_vertices(Vertex2dDCELWrapper& vertex
, std::set<Edge2dDCELWrapper*, SweepLineComparator>& sweep_line
, std::map<Edge2dDCEL*, Edge2dDCELWrapper*>& edge_mapper, Polygon2d* poly)
{
auto edge_wrapper = edge_mapper[vertex.vert->incident_edge->prev];
auto found = sweep_line.find(edge_wrapper);
auto helper = (*found)->helper;
if (helper.category == VERTEX_CATEGORY::MERGE)
poly->split(vertex.vert, helper.vert);
sweep_line.erase(found);
}
static void handle_split_vertices(Vertex2dDCELWrapper& vertex
, std::set<Edge2dDCELWrapper*, SweepLineComparator>& sweep_line
, std::map<Edge2dDCEL*, Edge2dDCELWrapper*>& edge_mapper, Polygon2d* poly)
{
Edge2dDCELWrapper* edge = new Edge2dDCELWrapper(vertex.vert->incident_edge, vertex);
auto found = sweep_line.lower_bound(edge);
Edge2dDCELWrapper* ej;
if (found == sweep_line.end()) {
if (sweep_line.size() > 0) {
ej = *(--found);
poly->split(vertex.vert, ej->helper.vert);
ej->helper = vertex;
}
}
else if (found != sweep_line.begin())
{
ej = *(--found);
poly->split(vertex.vert, ej->helper.vert);
ej->helper = vertex;
}
sweep_line.insert(edge);
edge_mapper.insert(std::pair<Edge2dDCEL*, Edge2dDCELWrapper*>(vertex.vert->incident_edge, edge));
}
static void handle_merge_vertices(Vertex2dDCELWrapper& vertex
, std::set<Edge2dDCELWrapper*, SweepLineComparator>& sweep_line
, std::map<Edge2dDCEL*, Edge2dDCELWrapper*>& edge_mapper, Polygon2d* poly)
{
auto edge_wrapper = edge_mapper[vertex.vert->incident_edge->prev];
if (edge_wrapper->helper.category == VERTEX_CATEGORY::MERGE) {
poly->split(vertex.vert, edge_wrapper->helper.vert);
}
auto found = sweep_line.find(edge_wrapper);
if (found != sweep_line.end())
sweep_line.erase(found);
Edge2dDCELWrapper* edge = new Edge2dDCELWrapper(vertex.vert->incident_edge, vertex);
found = sweep_line.lower_bound(edge);
Edge2dDCELWrapper* ej;
if (found == sweep_line.end()) {
if (sweep_line.size() > 0) {
ej = *(--found);
if (ej->helper.category == VERTEX_CATEGORY::MERGE)
poly->split(vertex.vert, ej->helper.vert);
ej->helper = vertex;
}
}
else if (found != sweep_line.begin())
{
ej = *(--found);
if (ej->helper.category == VERTEX_CATEGORY::MERGE)
poly->split(vertex.vert, ej->helper.vert);
ej->helper = vertex;
}
}
static void handle_regular_vertices(Vertex2dDCELWrapper& vertex
, std::set<Edge2dDCELWrapper*, SweepLineComparator>& sweep_line
, std::map<Edge2dDCEL*, Edge2dDCELWrapper*>& edge_mapper, Polygon2d* poly)
{
// Check whether the interior of the polygon lies right to vertex point
auto prev_y = vertex.vert->incident_edge->prev->origin->point[Y];
auto current_y = vertex.vert->point[Y];
auto next_y = vertex.vert->incident_edge->next->origin->point[Y];
Edge2dDCELWrapper* edge = new Edge2dDCELWrapper(vertex.vert->incident_edge, vertex);
if (prev_y >= current_y && current_y >= next_y) {
auto edge_wrapper = edge_mapper[vertex.vert->incident_edge->prev];
if (edge_wrapper->helper.category == VERTEX_CATEGORY::MERGE) {
poly->split(vertex.vert, edge_wrapper->helper.vert);
}
auto found = sweep_line.find(edge_wrapper);
if (found != sweep_line.end())
sweep_line.erase(found);
sweep_line.insert(edge);
edge_mapper.insert(std::pair<Edge2dDCEL*, Edge2dDCELWrapper*>(vertex.vert->incident_edge,
edge));
}
else {
auto found = sweep_line.lower_bound(edge);
Edge2dDCELWrapper* ej;
if (found == sweep_line.end()) {
if (sweep_line.size() > 0) {
ej = *(--found);
if (ej->helper.category == VERTEX_CATEGORY::MERGE)
poly->split(vertex.vert, ej->helper.vert);
ej->helper = vertex;
}
}
else if (found != sweep_line.begin())
{
ej = *(found--);
if (ej->helper.category == VERTEX_CATEGORY::MERGE)
poly->split(vertex.vert, ej->helper.vert);
ej->helper = vertex;
}
}
}
void jmk::get_monotone_polygons(Polygon2d* poly, std::vector<Polygon2d*>& mono_polies)
{
std::vector<Vertex2dDCELWrapper> vertices;
for (auto vertex : poly->getVertexList()) {
vertices.push_back(Vertex2dDCELWrapper{ vertex,categorize_vertex(vertex) });
}
std::sort(vertices.begin(), vertices.end(), Vertex2DWrapperSort());
Point2d* sweep_point = new Point2d();
sweep_point->assign(X, vertices[0].vert->point[X]);
sweep_point->assign(Y, vertices[0].vert->point[Y]);
SweepLineComparator comp(sweep_point);
std::set<Edge2dDCELWrapper*, SweepLineComparator> sweep_line(comp);
std::map<Edge2dDCEL*, Edge2dDCELWrapper*> edge_mapping;
for (auto vertex : vertices)
{
sweep_point->assign(X, vertex.vert->point[X]);
sweep_point->assign(Y, vertex.vert->point[Y]);
switch (vertex.category)
{
case VERTEX_CATEGORY::START:
handle_start_vertices(vertex, sweep_line, edge_mapping, poly);
break;
case VERTEX_CATEGORY::END:
handle_end_vertices(vertex, sweep_line, edge_mapping, poly);
break;
case VERTEX_CATEGORY::REGULAR:
handle_regular_vertices(vertex, sweep_line, edge_mapping, poly);
break;
case VERTEX_CATEGORY::SPLIT:
handle_split_vertices(vertex, sweep_line, edge_mapping, poly);
break;
case VERTEX_CATEGORY::MERGE:
handle_merge_vertices(vertex, sweep_line, edge_mapping, poly);
break;
case VERTEX_CATEGORY::INVALID:
break;
}
}
std::vector<std::vector<Point2d>> polygon_pieces_vertices;
for (auto face_ptr : poly->getFaceList()) {
auto first_edge_ptr = face_ptr->outer;
if (first_edge_ptr) {
std::vector<Point2d> vertices;
vertices.push_back(first_edge_ptr->origin->point);
auto next_edge_ptr = first_edge_ptr->next;
while (next_edge_ptr != first_edge_ptr) {
vertices.push_back(next_edge_ptr->origin->point);
next_edge_ptr = next_edge_ptr->next;
}
polygon_pieces_vertices.push_back(vertices);
}
}
for(auto vertices : polygon_pieces_vertices)
mono_polies.push_back(new Polygon2d(vertices));
} | 28.636364 | 98 | 0.71652 | [
"vector"
] |
82c8fc02019472d3748d3f683dd63c9e3c8828d1 | 5,049 | cc | C++ | src/clique/omp_iterative.cc | chenxuhao/GraphMiner | 493a16990238648ed4f8af263b2bf06aabb0758a | [
"MIT"
] | 25 | 2021-07-31T15:29:30.000Z | 2022-03-30T02:50:33.000Z | src/clique/omp_iterative.cc | chenxuhao/GraphMiner | 493a16990238648ed4f8af263b2bf06aabb0758a | [
"MIT"
] | 1 | 2022-03-27T20:43:23.000Z | 2022-03-27T20:43:23.000Z | src/clique/omp_iterative.cc | chenxuhao/GraphMiner | 493a16990238648ed4f8af263b2bf06aabb0758a | [
"MIT"
] | 2 | 2021-12-06T17:59:48.000Z | 2022-01-26T22:58:16.000Z | // Copyright 2020 Massachusetts Institute of Technology
// Contact: Xuhao Chen <cxh@mit.edu>
#include "clique.h"
#include "cmap.h"
void kclique(Graph &g, int k, uint64_t &total);
void kclique_cmap(Graph &g, int k, uint64_t &total);
void CliqueSolver(Graph &g, int k, uint64_t &total, int, int) {
int num_threads = 1;
#pragma omp parallel
{
num_threads = omp_get_num_threads();
}
std::cout << "OpenMP " << k << "-clique listing (" << num_threads << " threads)\n";
double start_time = omp_get_wtime();
//kclique(g, k, total);
kclique_cmap(g, k, total);
double run_time = omp_get_wtime() - start_time;
std::cout << "runtime [omp_iterative] = " << run_time << " sec\n";
return;
}
void kclique(Graph &g, int k, uint64_t &total) {
assert(k > 2);
uint64_t counter = 0;
#pragma omp parallel
{
std::vector<VertexSet> vertices(k-2);
std::vector<vidType> idx(k-2);
std::vector<vidType> stack(k);
Status state = Idle;
#pragma omp for schedule(dynamic, 1) reduction(+:counter)
for (VertexId v0 = 0; v0 < g.size(); v0 ++) {
int depth = 0;
stack[0] = v0;
state = Extending;
for (auto v1 : g.N(v0)) {
stack[1] = v1;
depth = 1;
state = Extending;
while(1) {
if (depth == k-2) { // found a match
if (depth >= 2) {
auto u = stack[depth];
counter += intersection_num(vertices[depth-2], g.N(u));
} else {
assert(depth == 1);
counter += intersection_num(g.N(v0), g.N(v1));
}
depth --; // backtrack
state = IteratingEdge;
} else if (state == Extending) {
vertices[depth-1].clear();
if (depth >= 2) {
auto u = stack[depth];
intersection(vertices[depth-2], g.N(u), vertices[depth-1]);
} else {
intersection(g.N(v0), g.N(v1), vertices[depth-1]);
}
idx[depth-1] = 0;
}
if (depth == 0) break;
if (idx[depth-1] == vertices[depth-1].size()) {
if (depth == 1) break; // this subtree is done
else { // backtrack
depth --;
state = IteratingEdge;
}
} else {
auto i = idx[depth-1];
auto w = vertices[depth-1][i];
idx[depth-1] = i + 1;
depth ++;
stack[depth] = w;
state = Extending;
}
}
} // end while
} // end for
} // end omp
total = counter;
}
void kclique_cmap(Graph &g, int k, uint64_t &total) {
assert(k > 2);
uint64_t counter = 0;
#pragma omp parallel
{
cmap8_t cmap;
//#ifdef IDENT_CMAP
cmap.init(g.size());
//#else
// cmap.init(max_degree);
//#endif
std::vector<VertexSet> vertices(k-2);
std::vector<vidType> idx(k-2);
std::vector<vidType> stack(k);
//std::vector<vidType> extender(k);
Status state = Idle;
#pragma omp for schedule(dynamic, 1) reduction(+:counter)
for (VertexId v0 = 0; v0 < g.size(); v0 ++) {
//auto tid = omp_get_thread_num();
int depth = 0;
stack[0] = v0;
state = Extending;
// mark v0's neighbors
for (auto w : g.N(v0)) {
//#if USE_DAG == 0
//if (w >= v0) break;
//#endif
cmap.set(w, 1);
}
for (auto v1 : g.N(v0)) {
stack[1] = v1;
depth = 1;
state = Extending;
while(1) {
if (depth == k-2) { // found a match
for (auto w : g.N(stack[depth])) {
if (cmap.get(w) == depth)
counter ++;
}
depth --; // backtrack
//stack.pop_back();
state = IteratingEdge;
} else if (state == Extending) {
auto u = stack[depth];
//extender[depth] = u;
idx[depth-1] = 0;
vertices[depth-1].clear();
for (auto w : g.N(u)) {
if (cmap.get(w) == depth) {
if (depth < k-2) cmap.set(w, depth+1);
vertices[depth-1].add(w);
}
}
}
if (depth == 0) break;
if (idx[depth-1] == vertices[depth-1].size()) {
for (auto w : vertices[depth-1]) cmap.set(w, depth);
if (depth == 1) break; // this subtree is done
else { // backtrack
depth --;
//stack.pop_back();
state = IteratingEdge;
}
} else {
auto i = idx[depth-1];
//auto w = g.getEdgeDst(begin+i); // w is the i-th neighbor of u
auto w = vertices[depth-1][i];
idx[depth-1] = i + 1;
//#if USE_DAG
//if (cmap.get(w) == depth) {
//#else
//if (cmap.get(w) == depth && w < u) {
//#endif
//cmap.set(w, depth+1);
depth ++;
stack[depth] = w;
state = Extending;
//} else {
// state = IteratingEdge; // go to next edge
//}
}
}
} // end while
//stack.pop_back(); // go to the next v1
for (auto w : g.N(v0)) cmap.set(w, 0);
} // end for
} // end omp
total = counter;
}
| 28.851429 | 85 | 0.495742 | [
"vector"
] |
82cbfda9ed0f3c7cf2cc077bf943cfb9a6f38712 | 3,492 | cpp | C++ | Ajani_Stewart_Assignment3/h3.cpp | AjaniStewart/cv | e92227b9794c7faaa1b5d9e81e3ce9e08675ce37 | [
"MIT"
] | null | null | null | Ajani_Stewart_Assignment3/h3.cpp | AjaniStewart/cv | e92227b9794c7faaa1b5d9e81e3ce9e08675ce37 | [
"MIT"
] | null | null | null | Ajani_Stewart_Assignment3/h3.cpp | AjaniStewart/cv | e92227b9794c7faaa1b5d9e81e3ce9e08675ce37 | [
"MIT"
] | null | null | null | /*
Author: Ajani Stewart
File: h3.cpp
Purpose: uses the hough transform for lines to create
and save a voting array to disk from an edge image
*/
#include <cmath>
#include <vector>
#include <iostream>
#include <string>
#include <fstream>
#include "image.h"
using namespace std;
using namespace ComputerVisionProjects;
/* Dimensions of the accumalator array
if the image is n*m and theta varies between 0 and PI
dp = 1
dtheta = 1
180 x sqrt(m^2+n^2)
*/
vector<vector<int>> hough_lines(Image* image, int& max_rho, int& max_theta);
Image* hough_image(vector<vector<int>> voting_array, int max_votes);
bool write_voting_array(vector<vector<int>> voting_array, const string& path);
int main(int argc, char** argv) {
if (argc != 4) {
std::cout << "usage: h3 [input_binary edge image] [output_grey_level_hough_image]";
std::cout << " [output_Hough-voting-array]\n";
exit(0);
}
Image* input = new Image;
if (!ReadImage(argv[1],input)) {
std::cout << "Cannot read input: " << argv[1] << "\n";
exit(1);
}
int max_rho, max_theta;
auto hough = hough_lines(input,max_rho,max_theta);
auto output = hough_image(hough,hough[max_theta][max_rho]);
if (!WriteImage(argv[2],*output)) {
std::cout << "cannot write to file: " << argv[2] << "\n";
exit(1);
}
if (!write_voting_array(hough,argv[3])) {
std::cout << "cannot write to file: " << argv[3] << "\n";
exit(1);
}
std::cout << "wrote image to: " << argv[2] << "\n";
std::cout << "wrote voting array to: " << argv[3] << "\n";
return 0;
}
vector<vector<int>> hough_lines(Image* image, int& max_rho, int& max_theta) {
//number of rho samples
int R = int(sqrt(image->num_columns() * image->num_columns() +
image->num_rows() * image->num_rows() ));
//number of theta samples
int T = 180;
vector<vector<int>> voting_array;
for (int i = 0; i < T; ++i) {
voting_array.emplace_back();
for (int j = 0; j < R; ++j) {
voting_array[i].push_back(0);
}
}
int max_votes = 0;
for (size_t i = 0; i < image->num_rows(); ++i) {
for (size_t j = 0; j < image->num_columns(); ++j) {
if (image->GetPixel(i,j) != 0) {
for (int theta = 0; theta < T; theta++){
int rho = i*cos(theta*M_PI/180) + j*sin(theta*M_PI/180);
voting_array[theta][rho] += 1;
if (voting_array[theta][rho] > max_votes) {
max_votes = voting_array[theta][rho];
max_rho = rho;
max_theta = theta;
}
}
}
}
}
return voting_array;
}
Image* hough_image(vector<vector<int>> voting_array, int max_votes) {
Image* image = new Image;
image->AllocateSpaceAndSetSize(voting_array.size(), voting_array[0].size());
image->SetNumberGrayLevels(255);
//fit the votes to between 0 and 255
for (size_t i = 0; i < voting_array.size(); ++i) {
for (size_t j = 0; j < voting_array[0].size(); ++j) {
image->SetPixel(i,j,(voting_array[i][j]/double(max_votes))*255);
}
}
return image;
}
bool write_voting_array(vector<vector<int>> voting_array, const string& path) {
ofstream file;
try {
file.open(path);
} catch (exception& e) {
std::cout << e.what() << endl;
return false;
}
for (size_t i = 0; i < voting_array.size(); i++) {
for (size_t j = 0; j < voting_array[0].size(); ++j) {
file << voting_array[i][j] << " ";
}
file << "\n";
}
file.close();
return true;
} | 24.082759 | 87 | 0.597365 | [
"vector",
"transform"
] |
82cdbf89f71d76d7f140af92521e9a9c83be632f | 86,116 | cpp | C++ | src/ide/PolycodeEntityEditor.cpp | my-digital-decay/Polycode | 5dd1836bc4710aea175a77433c17696f8330f596 | [
"MIT"
] | null | null | null | src/ide/PolycodeEntityEditor.cpp | my-digital-decay/Polycode | 5dd1836bc4710aea175a77433c17696f8330f596 | [
"MIT"
] | null | null | null | src/ide/PolycodeEntityEditor.cpp | my-digital-decay/Polycode | 5dd1836bc4710aea175a77433c17696f8330f596 | [
"MIT"
] | null | null | null | /*
Copyright (C) 2012 by Ivan Safrin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "polycode/ide/PolycodeEntityEditor.h"
#include "polycode/ide/PolycodeFrame.h"
#include "polycode/core/PolyCubemap.h"
#include "polycode/ide/PolycodeMaterialEditor.h"
extern UIGlobalMenu *globalMenu;
extern PolycodeFrame *globalFrame;
extern Scene *globalScene;
PolycodeSceneEditorActionDataEntry::PolycodeSceneEditorActionDataEntry(Vector3 vec3, Number number) {
this->vec3 = vec3;
this->number = number;
}
PolycodeSceneEditorActionDataEntry::PolycodeSceneEditorActionDataEntry(Vector3 vec3) {
this->vec3 = vec3;
}
PolycodeSceneEditorActionDataEntry::PolycodeSceneEditorActionDataEntry(Quaternion quat) {
this->quat = quat;
}
PolycodeSceneEditorActionDataEntry::PolycodeSceneEditorActionDataEntry(Vector3 vec3, Vector3 vec3Secondary) {
this->vec3 = vec3;
this->vec3Secondary = vec3Secondary;
}
PolycodeSceneEditorActionDataEntry::PolycodeSceneEditorActionDataEntry(Quaternion quat, Vector3 vec3) {
this->quat = quat;
this->vec3 = vec3;
}
PolycodeSceneEditorActionDataEntry::PolycodeSceneEditorActionDataEntry(Number number) {
this->number = number;
}
PolycodeSceneEditorActionDataEntry::PolycodeSceneEditorActionDataEntry(Entity *entity) {
this->entity = entity;
}
DummyTargetEntity::DummyTargetEntity() {
addTag("dummy_target");
propertyEntity = NULL;
}
DummyTargetEntity::~DummyTargetEntity() {
}
Vector3 DummyTargetEntity::getSelectedPoint() const {
return selectedPoint;
}
void DummyTargetEntity::selectPoint(Vector3 point, Number distance) {
selectedPoint = point;
InputEvent *rebroadcastEvent = new InputEvent();
rebroadcastEvent->mouseButton = CoreInput::MOUSE_BUTTON2;
rebroadcastEvent->hitDistance = distance;
dispatchEvent(rebroadcastEvent, InputEvent::EVENT_MOUSEDOWN);
}
Entity *DummyTargetEntity::getPropertyEntity() {
return propertyEntity;
}
CurveDisplay::CurveDisplay(CoreInput *input, ResourcePool *resourcePool, Scene *parentScene, SceneCurve *curve) : DummyTargetEntity (), coreInput(input){
editorOnly = true;
curve->addChild(this);
this->curve = curve;
this->parentScene = parentScene;
targetPoint = NULL;
propertyEntity = curve;
colorAffectsChildren = false;
controlPointLines = new SceneMesh();
controlPointLines->setColor(1.0, 1.0, 0.4, 1.0);
addChild(controlPointLines);
controlPointLines->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
controlPointLines->castShadows = false;
controlPointLines->setMaterial(resourcePool->getMaterial("UnlitUntextured"));
controlPointLines->setForceMaterial(true);
mainPoints = new SceneMesh();
mainPoints->setColor(0.0, 0.5, 1.0, 1.0);
addChild(mainPoints);
mainPoints->pointSmooth = true;
mainPoints->setForceMaterial(true);
mainPoints->castShadows = false;
mainPoints->setMaterial(resourcePool->getMaterial("UnlitPointUntextured"));
mainPoints->getShaderPass(0).shaderBinding->addParam(ProgramParam::PARAM_NUMBER, "pointSize")->setNumber(10.0);
controlPoints = new SceneMesh();
controlPoints->castShadows = false;
controlPoints->setColor(1.0, 0.7, 0.0, 1.0);
addChild(controlPoints);
controlPoints->pointSmooth = true;
controlPoints->setForceMaterial(true);
controlPoints->setMaterial(resourcePool->getMaterial("UnlitPointUntextured"));
controlPoints->getShaderPass(0).shaderBinding->addParam(ProgramParam::PARAM_NUMBER, "pointSize")->setNumber(8.0);
renderControlPoints = false;
coreInput->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
}
void CurveDisplay::handleDelete() {
if(targetPoint) {
if(curve->getCurve()->getNumControlPoints() > 2) {
curve->getCurve()->removePoint(targetPoint);
} else {
globalFrame->messagePopup->setCaption("Curve must have at least two points.");
globalFrame->showModal(globalFrame->messagePopup);
}
}
}
void CurveDisplay::handleDeselect() {
renderControlPoints = false;
}
void CurveDisplay::handleSelect() {
renderControlPoints = true;
}
CurveDisplay::~CurveDisplay() {
coreInput->removeAllHandlersForListener(this);
}
void CurveDisplay::handleEvent(Event *event) {
InputEvent *inputEvent = (InputEvent*) event;
if(inputEvent->mouseButton == CoreInput::MOUSE_BUTTON2) {
Ray ray = parentScene->projectRayFromCameraAndViewportCoordinate(parentScene->getDefaultCamera(), coreInput->getMousePosition());
for(int i=0; i < curve->getCurve()->getNumControlPoints(); i++) {
Matrix4 parentMatrix = getConcatenatedMatrix();
Matrix4 pointTransform;
Vector3 pt = curve->getCurve()->getControlPoint(i)->p2;
pt = parentMatrix * pt;
Number relativeSize = parentScene->getDefaultCamera()->getPosition().distance(pt) * 0.02;
Vector3 hitSize(relativeSize, relativeSize, relativeSize);
pointTransform.setPosition(pt.x, pt.y, pt.z);
Number distance = ray.boxIntersect(hitSize, pointTransform);
if(distance >= 0.0) {
selectMode = SELECT_MODE_P2;
targetPoint = curve->getCurve()->getControlPoint(i);
selectPoint(pt, distance);
}
if(renderControlPoints) {
pt = curve->getCurve()->getControlPoint(i)->p1;
pt = parentMatrix * pt;
relativeSize = parentScene->getDefaultCamera()->getPosition().distance(pt) * 0.02;
hitSize.set(relativeSize, relativeSize, relativeSize);
pointTransform.setPosition(pt.x, pt.y, pt.z);
distance = ray.boxIntersect(hitSize, pointTransform);
if(distance >= 0.0) {
selectMode = SELECT_MODE_P1;
targetPoint = curve->getCurve()->getControlPoint(i);
selectPoint(pt, distance);
}
pt = curve->getCurve()->getControlPoint(i)->p3;
pt = parentMatrix * pt;
relativeSize = parentScene->getDefaultCamera()->getPosition().distance(pt) * 0.02;
hitSize.set(relativeSize, relativeSize, relativeSize);
pointTransform.setPosition(pt.x, pt.y, pt.z);
distance = ray.boxIntersect(hitSize, pointTransform);
if(distance >= 0.0) {
selectMode = SELECT_MODE_P3;
targetPoint = curve->getCurve()->getControlPoint(i);
selectPoint(pt, distance);
}
}
}
}
}
void CurveDisplay::setDummyTransform(Entity *dummy) {
if(targetPoint) {
Vector3 position = dummy->getPosition();
Matrix4 parentMatrix = getConcatenatedMatrix().Inverse();
position = parentMatrix * position;
Vector3 p1Offset = targetPoint->p1 - targetPoint->p2;
Vector3 p3Offset = targetPoint->p3 - targetPoint->p2;
switch(selectMode) {
case SELECT_MODE_P1:
{
targetPoint->p1 = position;
// transform the opposing point to match
Number p3Distance = targetPoint->p3.distance(targetPoint->p2);
Vector3 p3Normal = p1Offset * -1.0;
p3Normal.Normalize();
targetPoint->p3 = targetPoint->p2 + (p3Normal * p3Distance);
}
break;
case SELECT_MODE_P2:
{
targetPoint->p2 = position;
targetPoint->p1 = position+p1Offset;
targetPoint->p3 = position+p3Offset;
}
break;
case SELECT_MODE_P3:
{
targetPoint->p3 = position;
// transform the opposing point to match
Number p1Distance = targetPoint->p1.distance(targetPoint->p2);
Vector3 p1Normal = p3Offset * -1.0;
p1Normal.Normalize();
targetPoint->p1 = targetPoint->p2 + (p1Normal * p1Distance);
}
break;
}
curve->getCurve()->recalculateDistances();
}
}
void CurveDisplay::Update(Number elapsed) {
mainPoints->getMesh()->clearMesh();
controlPoints->getMesh()->clearMesh();
controlPointLines->getMesh()->clearMesh();
MeshGeometry mainPointsGeometry;
mainPointsGeometry.meshType = MeshGeometry::POINT_MESH;
MeshGeometry controlPointsGeometry;
controlPointsGeometry.meshType = MeshGeometry::POINT_MESH;
MeshGeometry controlPointLinesGeometry;
controlPointLinesGeometry.meshType = MeshGeometry::LINE_MESH;
for(int i=0; i < curve->getCurve()->getNumControlPoints(); i++) {
Vector3 pt2 = curve->getCurve()->getControlPoint(i)->p2;
mainPointsGeometry.addVertex(pt2.x, pt2.y, pt2.z);
if(renderControlPoints) {
Vector3 pt1 = curve->getCurve()->getControlPoint(i)->p1;
controlPointsGeometry.addVertex(pt1.x, pt1.y, pt1.z);
Vector3 pt3 = curve->getCurve()->getControlPoint(i)->p3;
controlPointsGeometry.addVertex(pt3.x, pt3.y, pt3.z);
controlPointLinesGeometry.addVertex(pt1.x, pt1.y, pt1.z);
controlPointLinesGeometry.addVertex(pt2.x, pt2.y, pt2.z);
controlPointLinesGeometry.addVertex(pt2.x, pt2.y, pt2.z);
controlPointLinesGeometry.addVertex(pt3.x, pt3.y, pt3.z);
}
}
mainPoints->getMesh()->addSubmesh(mainPointsGeometry);
controlPoints->getMesh()->addSubmesh(controlPointsGeometry);
controlPointLines->getMesh()->addSubmesh(controlPointLinesGeometry);
mainPoints->setLocalBoundingBox(mainPoints->getMesh()->calculateBBox());
controlPoints->setLocalBoundingBox(controlPoints->getMesh()->calculateBBox());
controlPointLines->setLocalBoundingBox(controlPointLines->getMesh()->calculateBBox());
}
LightDisplay::LightDisplay(std::shared_ptr<Material> material, SceneLight *light) : Entity() {
editorOnly = true;
this->light = light;
spotSpot = new ScenePrimitive(ScenePrimitive::TYPE_LINE_CIRCLE, 1.0, 1.0, 32);
spotSpot->setMaterial(material);
addChild(spotSpot);
spotSpot->setColor(1.0, 0.8, 0.0, 1.0);
spotSpot->enabled = false;
spotSpot->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
spotSpot->setForceMaterial(true);
spotSpot->castShadows = false;
fovSceneMesh = new SceneMesh();
fovSceneMesh->setMaterial(material);
fovSceneMesh->setColor(1.0, 0.8, 0.0, 1.0);
fovMesh = fovSceneMesh->getMesh();
addChild(fovSceneMesh);
fovSceneMesh->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
fovSceneMesh->setForceMaterial(true);
fovSceneMesh->castShadows = false;
MeshGeometry fovMeshGeometry;
fovMeshGeometry.indexedMesh = true;
fovMeshGeometry.setMeshType(MeshGeometry::LINE_MESH);
fovMeshGeometry.addVertex(0.0, 0.0, 0.0);
fovMeshGeometry.addVertex(-1.0, 1.0, -1.0);
fovMeshGeometry.addVertex(1.0, 1.0, -1.0);
fovMeshGeometry.addVertex(1.0, -1.0, -1.0);
fovMeshGeometry.addVertex(-1.0, -1.0, -1.0);
fovMeshGeometry.addIndexedFace(0, 1);
fovMeshGeometry.addIndexedFace(0, 2);
fovMeshGeometry.addIndexedFace(0, 3);
fovMeshGeometry.addIndexedFace(0, 4);
fovSceneMesh->getMesh()->addSubmesh(fovMeshGeometry);
fovSceneMesh->setLocalBoundingBox(fovMesh->calculateBBox());
light->addChild(this);
}
LightDisplay::~LightDisplay() {
}
void LightDisplay::Update(Number elapsed) {
if(light->getLightType() == SceneLight::SPOT_LIGHT) {
spotSpot->enabled = true;
fovSceneMesh->enabled = true;
Number distance = light->getIntensity() * 2.0;
Number spotAngle = ((light->getSpotlightCutoff()) * 2.0);
Number spotLightSize = ((PI * 2.0) * distance * spotAngle) / 360.0;
spotSpot->setPosition(0.0, 0.0, -distance);
spotSpot->setPrimitiveOptions(ScenePrimitive::TYPE_LINE_CIRCLE, spotLightSize, spotLightSize, 32);
MeshGeometry geom = fovMesh->getSubmeshAtIndex(0);
spotLightSize *= 0.5;
geom.setVertexAtOffset(1, sin(PI/2.0)*spotLightSize, cos(PI/2.0)*spotLightSize, -distance);
geom.setVertexAtOffset(2, sin(PI)*spotLightSize, cos(PI)*spotLightSize, -distance);
geom.setVertexAtOffset(3, sin(PI + (PI/2.0))*spotLightSize, cos(PI + (PI/2.0))*spotLightSize, -distance);
geom.setVertexAtOffset(4, sin(PI*2.0)*spotLightSize, cos(PI*2.0)*spotLightSize, -distance);
fovMesh->clearMesh();
fovMesh->addSubmesh(geom);
fovSceneMesh->setLocalBoundingBox(fovMesh->calculateBBox());
} else {
spotSpot->enabled = false;
fovSceneMesh->enabled = false;
}
}
CameraDisplay::CameraDisplay(std::shared_ptr<Material> material, Camera *camera) : Entity() {
editorOnly = true;
fovSceneMesh = new SceneMesh();
fovSceneMesh->castShadows = false;
fovSceneMesh->setMaterial(material);
fovSceneMesh->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
fovSceneMesh->setColor(1.0, 0.0, 1.0, 1.0);
fovMesh = fovSceneMesh->getMesh();
fovSceneMesh->setForceMaterial(true);
MeshGeometry geometry;
geometry.setMeshType(MeshGeometry::LINE_MESH);
geometry.indexedMesh = true;
geometry.addVertex(0.0, 0.0, 0.0);
geometry.addVertex(-1.0, 1.0, -1.0);
geometry.addVertex(1.0, 1.0, -1.0);
geometry.addVertex(1.0, -1.0, -1.0);
geometry.addVertex(-1.0, -1.0, -1.0);
geometry.addIndexedFace(0, 1);
geometry.addIndexedFace(0, 2);
geometry.addIndexedFace(0, 3);
geometry.addIndexedFace(0, 4);
geometry.addIndexedFace(1, 2);
geometry.addIndexedFace(2, 3);
geometry.addIndexedFace(3, 4);
geometry.addIndexedFace(4, 1);
fovMesh->addSubmesh(geometry);
fovSceneMesh->setLocalBoundingBox(fovMesh->calculateBBox());
addChild(fovSceneMesh);
camera->addChild(this);
this->camera = camera;
}
CameraDisplay::~CameraDisplay() {
}
void CameraDisplay::Update(Number elapsed) {
if(camera->getOrthoMode()) {
Number xPos = camera->getOrthoSizeX() * 0.5;
Number yPos = camera->getOrthoSizeY() * 0.5;
Number zPos = 0.0;
switch(camera->getOrthoSizeMode()) {
case Camera::ORTHO_SIZE_LOCK_HEIGHT:
xPos = yPos * (camera->getViewport().w/camera->getViewport().h);
break;
case Camera::ORTHO_SIZE_LOCK_WIDTH:
yPos = xPos * (camera->getViewport().h/camera->getViewport().w);
break;
case Camera::ORTHO_SIZE_VIEWPORT:
xPos = camera->getViewport().w * 0.5;
yPos = camera->getViewport().h * 0.5;
break;
}
MeshGeometry geom = fovMesh->getSubmeshAtIndex(0);
geom.setVertexAtOffset(1, -xPos, yPos, zPos);
geom.setVertexAtOffset(2, xPos, yPos, zPos);
geom.setVertexAtOffset(3, xPos, -yPos, zPos);
geom.setVertexAtOffset(4, -xPos, -yPos, zPos);
fovMesh->clearMesh();
fovMesh->addSubmesh(geom);
} else {
Number fovRad = (90+camera->getFOV()/2.0) * TORADIANS;
Number displayScale = 3.0;
Number xPos = cos(fovRad) * displayScale;
Number yPos = xPos * 0.5625;
Number zPos = -sin(fovRad) * displayScale * 0.5;
MeshGeometry geom = fovMesh->getSubmeshAtIndex(0);
geom.setVertexAtOffset(1, -xPos, yPos, zPos);
geom.setVertexAtOffset(2, xPos, yPos, zPos);
geom.setVertexAtOffset(3, xPos, -yPos, zPos);
geom.setVertexAtOffset(4, -xPos, -yPos, zPos);
fovMesh->clearMesh();
fovMesh->addSubmesh(geom);
}
}
CameraPreviewWindow::CameraPreviewWindow(Core *core, ResourcePool *pool) : UIElement(core) {
bgRect = new UIRect(core, pool, (160 * 1.5)+16, (90 * 1.5) + 38);
addChild(bgRect);
bgRect->setColor(0.0, 0.0, 0.0, 0.5);
UILabel *label = new UILabel(core, pool, "PREVIEW", 11);
label->setColor(1.0, 1.0, 1.0, 1.0);
// addChild(label);
label->setPosition(15, 3);
aspectCombo = new UIComboBox(core, pool, globalMenu, 80);
addChild(aspectCombo);
aspectCombo->setPosition(5, 3);
aspectCombo->addComboItem("16:9");
aspectCombo->addComboItem("16:10");
aspectCombo->addComboItem("4:3");
aspectCombo->addComboItem("16:18");
aspectCombo->addEventListener(this, UIEvent::CHANGE_EVENT);
pinButton = new UIButton(core, pool, "Pin", 60);
addChild(pinButton);
pinButton->addEventListener(this, UIEvent::CLICK_EVENT);
previewRect = new UIRect(core, pool, 160 * 1.5, 90 * 1.5);
previewRect->setPosition(8, 30);
addChild(previewRect);
enabled = false;
visible = false;
camera = NULL;
scene = NULL;
renderTexture = NULL;
setLocalBoundingBox(bgRect->getLocalBoundingBox());
pinned = false;
cameraSelected = false;
aspectCombo->setSelectedIndex(0);
}
void CameraPreviewWindow::Render(GPUDrawBuffer *buffer) {
renderTexture->Render(buffer->renderFrame, scene, camera);
}
bool CameraPreviewWindow::isPinned() {
return pinned;
}
void CameraPreviewWindow::Resize(Number width, Number height) {
UIElement::Resize(width, height);
bgRect->Resize(width, height);
previewRect->Resize(width-16, height-38);
if(camera) {
if(renderTexture) {
delete renderTexture;
}
renderTexture = new SceneRenderTexture(previewRect->getWidth(), previewRect->getHeight(), false);
previewRect->setTexture(renderTexture->getTargetTexture());
}
pinButton->setPosition(width-70, 3);
}
void CameraPreviewWindow::handleEvent(Event *event) {
if(event->getDispatcher() == pinButton) {
pinned = !pinned;
if(pinned) {
pinButton->setCaption("Unpin");
} else {
pinButton->setCaption("Pin");
if(!cameraSelected) {
enabled = false;
camera = NULL;
}
}
} else if(event->getDispatcher() == aspectCombo) {
switch(aspectCombo->getSelectedIndex()) {
case 0:
Resize(bBox.y * 1.77777, bBox.y);
break;
case 1:
Resize(bBox.y * 1.6, bBox.y);
break;
case 2:
Resize(bBox.y * 1.3, bBox.y);
break;
case 3:
Resize(bBox.y * 0.888, bBox.y);
break;
}
}
}
CameraPreviewWindow::~CameraPreviewWindow() {
delete renderTexture;
}
void CameraPreviewWindow::setCamera(Scene *scene, Camera *camera) {
if(pinned && !camera) {
cameraSelected = false;
return;
}
this->camera = camera;
this->scene = scene;
if(camera) {
enabled = true;
visible = true;
if(renderTexture) {
delete renderTexture;
}
renderTexture = new SceneRenderTexture(previewRect->getWidth(), previewRect->getHeight(), false);
previewRect->setTexture(renderTexture->getTargetTexture());
} else {
if(!pinned) {
enabled = false;
visible = false;
}
}
}
EntityEditorMainView::EntityEditorMainView(Core *core, ResourcePool *pool, PolycodeEditor *editor) : UIElement(core), resourcePool(pool)
{
processInputEvents = true;
multiselectIndex = 0;
objectRootInstance = NULL;
lightsDisabled = false;
beforeData = NULL;
dummyTargetEntity = NULL;
setOwnsChildrenRecursive(true);
this->editor = editor;
mainScene = new Scene(core, Scene::SCENE_3D);
// mainScene->getDefaultCamera()->frustumCulling = false;
// mainScene->doVisibilityChecking(false);
renderTexture = new SceneRenderTexture(512, 512, false);
mainScene->clearColor.setColor(0.2, 0.2, 0.2, 1.0);
mainScene->useClearColor = true;
mainScene->rootEntity.processInputEvents = true;
dummyEntity = new Entity();
mainScene->addChild(dummyEntity);
Number customFalloff = 0.006;
// setup custom lights for disabled lighting
customLight1 = new SceneLight(SceneLight::POINT_LIGHT, 999999, customFalloff, customFalloff, customFalloff);
customLight1->editorOnly = true;
customLight1->setPosition(-9999, 9999, 9999);
mainScene->addChild(customLight1);
customLight1->enabled = false;
customLight2 = new SceneLight(SceneLight::POINT_LIGHT, 999999, customFalloff, customFalloff, customFalloff);
customLight2->editorOnly = true;
customLight2->setPosition(8999, -8999, -8999);
mainScene->addChild(customLight2);
customLight2->enabled = false;
renderTextureShape = new UIRect(core, pool, 256, 256);
renderTextureShape->setAnchorPoint(-1.0, -1.0, 0.0);
renderTextureShape->setTexture(renderTexture->getTargetTexture());
addChild(renderTextureShape);
renderTextureShape->setPosition(0, 30);
renderTextureShape->focusable = true;
renderTextureShape->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
cameraPreview = new CameraPreviewWindow(core, pool);
addChild(cameraPreview);
cameraPreview->setPosition(5, 35);
headerBg = new UIRect(core, pool, 10,10);
addChild(headerBg);
headerBg->setAnchorPoint(-1.0, -1.0, 0.0);
headerBg->color.setColorHexFromString(core->getConfig()->getStringValue("Polycode", "uiHeaderBgColor"));
footerBg = new UIRect(core, pool, 10,10);
addChild(footerBg);
footerBg->setAnchorPoint(-1.0, -1.0, 0.0);
footerBg->color.setColorHexFromString(core->getConfig()->getStringValue("Polycode", "uiHeaderBgColor"));
bottomBar = new Entity();
addChild(bottomBar);
bottomBar->setPosition(0, 0);
bottomBar->processInputEvents = true;
topBar = new Entity();
addChild(topBar);
topBar->setPosition(0, 0);
topBar->processInputEvents = true;
mainScene->getDefaultCamera()->setPosition(10, 10, 10);
mainScene->getDefaultCamera( )->lookAt(Vector3());
mainScene->getDefaultCamera()->setClippingPlanes(0.01, 1000);
grid = new EditorGrid(core);
grid->addEventListener(this, Event::CHANGE_EVENT);
mainScene->addChild(grid);
objectRootBase = new Entity();
mainScene->addChild(objectRootBase);
objectRootBase->processInputEvents = true;
sceneObjectRoot = new Entity();
sceneObjectRoot->processInputEvents = true;
objectRootBase->addChild(sceneObjectRoot);
iconBase = new Entity();
addChild(iconBase);
iconBase->processInputEvents = true;
transformGizmo = new TransformGizmo(core, pool, mainScene, mainScene->getDefaultCamera());
transformGizmo->enableGizmo = false;
transformGizmo->addEventListener(this, Event::CHANGE_EVENT);
transformGizmo->addEventListener(this, Event::SELECT_EVENT);
mainScene->addChild(transformGizmo);
trackballCamera = new TrackballCamera(core->getInput(), mainScene->getDefaultCamera(), renderTextureShape);
trackballCamera->addEventListener(this, Event::CHANGE_EVENT);
addEntityButton = new UIImageButton(core, pool, "entityEditor/add_entity.png", 1.0, 24, 24);
topBar->addChild(addEntityButton);
addEntityButton->setPosition(4, 2);
addEntityButton->addEventListener(this, UIEvent::CLICK_EVENT);
transformGizmoMenu = new TransformGizmoMenu(core, pool, transformGizmo);
topBar->addChild(transformGizmoMenu);
transformGizmoMenu->setPositionX(40);
viewModeSelector = new UIIconSelector(core, pool);
viewModeSelector->addIcon("entityEditor/icon_cam_2d.png");
viewModeSelector->addIcon("entityEditor/icon_cam_x.png");
viewModeSelector->addIcon("entityEditor/icon_cam_y.png");
viewModeSelector->addIcon("entityEditor/icon_cam_z.png");
viewModeSelector->addIcon("entityEditor/icon_cam_3d.png");
topBar->addChild(viewModeSelector);
viewModeSelector->selectIndex(EDITOR_MODE_3D);
viewModeSelector->addEventListener(this, UIEvent::SELECT_EVENT);
shadeModeSelector = new UIIconSelector(core, pool);
shadeModeSelector->addIcon("entityEditor/shade_full.png");
shadeModeSelector->addIcon("entityEditor/shade_solid.png");
shadeModeSelector->addIcon("entityEditor/shade_wire.png");
topBar->addChild(shadeModeSelector);
shadeModeSelector->setPosition(320, 3);
shadeModeSelector->addEventListener(this, UIEvent::SELECT_EVENT);
lightingModeSelector = new UIIconSelector(core, pool);
lightingModeSelector->addIcon("entityEditor/lights_icon.png");
lightingModeSelector->addIcon("entityEditor/nolights_icon.png");
topBar->addChild(lightingModeSelector);
lightingModeSelector->setPosition(420, 3);
lightingModeSelector->addEventListener(this, UIEvent::SELECT_EVENT);
moveUpButton = new UIImageButton(core, pool, "entityEditor/button_move_up.png", 1.0, 24, 24);
bottomBar->addChild(moveUpButton);
moveUpButton->setPosition(4, 2);
moveUpButton->addEventListener(this, UIEvent::CLICK_EVENT);
moveTopButton = new UIImageButton(core, pool, "entityEditor/button_move_top.png", 1.0, 24, 24);
bottomBar->addChild(moveTopButton);
moveTopButton->setPosition(30, 2);
moveTopButton->addEventListener(this, UIEvent::CLICK_EVENT);
moveDownButton = new UIImageButton(core, pool, "entityEditor/button_move_down.png", 1.0, 24, 24);
bottomBar->addChild(moveDownButton);
moveDownButton->setPosition(56, 2);
moveDownButton->addEventListener(this, UIEvent::CLICK_EVENT);
moveBottomButton = new UIImageButton(core, pool, "entityEditor/button_move_bottom.png", 1.0, 24, 24);
bottomBar->addChild(moveBottomButton);
moveBottomButton->setPosition(82, 2);
moveBottomButton->addEventListener(this, UIEvent::CLICK_EVENT);
gridSettingsButton = new UIImageButton(core, pool, "entityEditor/grid_button.png", 1.0, 24, 24);
bottomBar->addChild(gridSettingsButton);
gridSettingsButton->setPosition(120, 2);
gridSettingsButton->addEventListener(this, UIEvent::CLICK_EVENT);
snapSelector = new UIIconSelector(core, pool);
snapSelector->addIcon("entityEditor/snap_off.png");
snapSelector->addIcon("entityEditor/snap_on.png");
bottomBar->addChild(snapSelector);
snapSelector->setPosition(156, 2);
snapSelector->addEventListener(this, UIEvent::SELECT_EVENT);
iconVisibilitySelector = new UIIconSelector(core, pool);
iconVisibilitySelector->addIcon("entityEditor/show_icons.png");
iconVisibilitySelector->addIcon("entityEditor/hide_icons.png");
bottomBar->addChild(iconVisibilitySelector);
iconVisibilitySelector->setPosition(230, 2);
iconVisibilitySelector->addEventListener(this, UIEvent::SELECT_EVENT);
bBoxVis = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1.0, 1.0, 1.0);
bBoxVis->color = Color(0.3, 0.5, 1.0, 0.5);
bBoxVis->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
//mainScene->addChild(bBoxVis);
editorMode = EDITOR_MODE_3D;
input = core->getInput();
input->addEventListener(this, InputEvent::EVENT_KEYDOWN);
gridSettings = new EditorGridSettingsWindow(core, pool, grid);
addChild(gridSettings);
gridSettings->setPosition(30,40);
}
std::vector<Entity*> EntityEditorMainView::getSelectedEntities() {
return selectedEntities;
}
void EntityEditorMainView::doAction(String actionName, PolycodeEditorActionData *data) {
PolycodeSceneEditorActionData *sceneData = (PolycodeSceneEditorActionData*)data;
if(!sceneData) {
return;
}
if(actionName == "move") {
for(int i=0; i < selectedEntities.size(); i++) {
if(i < sceneData->entries.size()) {
selectedEntities[i]->setPosition(sceneData->entries[i].vec3);
}
}
transformGizmo->setTransformSelection(selectedEntities);
setBBox();
} else if(actionName == "scale") {
for(int i=0; i < selectedEntities.size(); i++) {
if(i < sceneData->entries.size()) {
selectedEntities[i]->setScale(sceneData->entries[i].vec3);
selectedEntities[i]->setPosition(sceneData->entries[i].vec3Secondary);
}
}
} else if(actionName == "rotate") {
for(int i=0; i < selectedEntities.size(); i++) {
if(i < sceneData->entries.size()) {
selectedEntities[i]->setRotationByQuaternion(sceneData->entries[i].quat);
selectedEntities[i]->setPosition(sceneData->entries[i].vec3);
}
}
} else if(actionName == "select") {
selectNone(false);
if(sceneData) {
for(int i=0; i < sceneData->entries.size(); i++) {
selectEntity(sceneData->entries[i].entity, true, false);
}
}
} else if(actionName == "delete") {
if(sceneData->reverse) {
selectNone(false);
for(int i=0; i < sceneData->entries.size(); i++) {
sceneData->entries[i].parentEntity->addChild(sceneData->entries[i].entity);
SceneLight *sceneLight = dynamic_cast<SceneLight*>(sceneData->entries[i].entity);
setEditorPropsRecursive(sceneData->entries[i].entity);
selectEntity(sceneData->entries[i].entity, true, false);
}
sceneData->deleteEntitiesInDestructor = false;
} else {
deleteSelected(false);
sceneData->deleteEntitiesInDestructor = true;
}
} else if(actionName == "create_entity") {
if(sceneData->reverse) {
deleteSelected(false);
selectNone(false);
for(int i=0; i < sceneData->entries.size(); i++) {
selectEntity(sceneData->entries[i].entity, true, false);
}
} else {
selectNone(false);
sceneData->entries[0].parentEntity->addChild(sceneData->entries[0].entity);
SceneLight *sceneLight = dynamic_cast<SceneLight*>(sceneData->entries[0].entity);
setEditorPropsRecursive(sceneData->entries[0].entity);
selectEntity(sceneData->entries[0].entity, true, false);
}
}
}
SceneRenderTexture *EntityEditorMainView::getRenderTexture() {
return renderTexture;
}
void EntityEditorMainView::setEditorMode(int newMode) {
editorMode = newMode;
if(newMode != EDITOR_MODE_3D) {
trackballCamera->setOrbitingCenter(Vector3(0.0, 0.0, 0.0));
}
switch(editorMode) {
case EDITOR_MODE_3D:
mainScene->setSceneType(Scene::SCENE_3D);
grid->setGridMode(EditorGrid::GRID_MODE_3D);
transformGizmo->setGizmoMode(TransformGizmo::GIZMO_MODE_3D);
mainScene->getDefaultCamera()->setOrthoMode(false);
mainScene->getDefaultCamera()->setClippingPlanes(0.1, 1000);
trackballCamera->disableRotation(false);
break;
case EDITOR_MODE_3D_X:
mainScene->setSceneType(Scene::SCENE_2D);
mainScene->getDefaultCamera()->setOrthoMode(true);
mainScene->getDefaultCamera()->setClippingPlanes(-0.1, 1000);
trackballCamera->setCameraPosition(trackballCamera->getOribitingCenter()+Vector3(trackballCamera->getCameraDistance(), 0.0, 0.0));
grid->setGridMode(EditorGrid::GRID_MODE_2D_X);
transformGizmo->setGizmoMode(TransformGizmo::GIZMO_MODE_2D_X);
trackballCamera->disableRotation(true);
Update(0.0);
break;
case EDITOR_MODE_3D_Y:
mainScene->setSceneType(Scene::SCENE_2D);
mainScene->getDefaultCamera()->setOrthoMode(true);
mainScene->getDefaultCamera()->setClippingPlanes(-0.1, 1000);
trackballCamera->setCameraPosition(trackballCamera->getOribitingCenter()+Vector3(0.001, trackballCamera->getCameraDistance(), 0.00));
grid->setGridMode(EditorGrid::GRID_MODE_2D_Y);
transformGizmo->setGizmoMode(TransformGizmo::GIZMO_MODE_2D_Y);
trackballCamera->disableRotation(true);
Update(0.0);
break;
case EDITOR_MODE_3D_Z:
case EDITOR_MODE_2D:
mainScene->setSceneType(Scene::SCENE_2D);
mainScene->getDefaultCamera()->setOrthoMode(true);
mainScene->getDefaultCamera()->setClippingPlanes(-0.1, 1000);
trackballCamera->setCameraPosition(trackballCamera->getOribitingCenter()+Vector3(0.0, 0.0, trackballCamera->getCameraDistance()));
grid->setGridMode(EditorGrid::GRID_MODE_2D_Z);
transformGizmo->setGizmoMode(TransformGizmo::GIZMO_MODE_2D_Z);
trackballCamera->disableRotation(true);
Update(0.0);
break;
}
}
Entity *EntityEditorMainView::getSelectedEntity() {
if(selectedEntities.size() > 0) {
if(selectedEntities[selectedEntities.size()-1] == dummyEntity) {
return dummyTargetEntity->getPropertyEntity();
} else {
return selectedEntities[selectedEntities.size()-1];
}
} else {
return NULL;
}
}
void EntityEditorMainView::Paste(EntityEditorClipboardData *data) {
if(!hasFocus) {
return;
}
selectNone(false);
for(int i=0; i < data->entities.size(); i++) {
Entity *entity = data->entities[i]->Clone(true, true);
setEditorPropsRecursive(entity);
sceneObjectRoot->addChild(entity);
selectEntity(entity, true);
}
}
bool EntityEditorMainView::selectingNewEntities(){
if(entitiesToSelect.size() != lastEntitiesToSelect.size()) {
return true;
}
for(int i=0; i < entitiesToSelect.size(); i++) {
if(entitiesToSelect[i].entity == dummyEntity) {
if(dummyTargetEntity) {
if(dummyTargetEntity->getSelectedPoint() != lastSelectedDummyPoint) {
return true;
}
}
}
}
for(int i=0; i < entitiesToSelect.size(); i++) {
if(lastEntitiesToSelect[i].entity != entitiesToSelect[i].entity) {
return true;
}
}
return false;
}
bool EntityDistanceSorter::operator() (MultiselectorEntry i,MultiselectorEntry j) {
if(i.distance < j.distance) {
return true;
} else {
return false;
}
}
void EntityEditorMainView::Update(Number elapsed) {
mainScene->Update(elapsed);
}
void EntityEditorMainView::fixedUpdate() {
mainScene->fixedUpdate();
// update dummy target if trasnforming dummy entity
if(dummyTargetEntity) {
dummyTargetEntity->setDummyTransform(dummyEntity);
}
if(entitiesToSelect.size() != 0) {
sort (entitiesToSelect.begin(), entitiesToSelect.end(), distanceSorter);
if(multiselectIndex > entitiesToSelect.size()-1 || selectingNewEntities()) {
multiselectIndex = 0;
}
// force dummy to always select
for(int i=0; i < entitiesToSelect.size(); i++) {
if(entitiesToSelect[i].entity == dummyEntity) {
multiselectIndex = i;
}
}
selectEntity(entitiesToSelect[multiselectIndex].entity, input->getKeyState(KEY_LSHIFT) || input->getKeyState(KEY_RSHIFT));
multiselectIndex++;
lastEntitiesToSelect = entitiesToSelect;
if(dummyTargetEntity) {
lastSelectedDummyPoint = dummyTargetEntity->getSelectedPoint();
}
entitiesToSelect.clear();
}
if(editorMode != EDITOR_MODE_3D) {
Number aspect = renderTextureShape->getWidth() / renderTextureShape->getHeight();
mainScene->getDefaultCamera()->setOrthoSize(trackballCamera->getCameraDistance() * aspect, trackballCamera->getCameraDistance());
}
for(int i=0; i < icons.size(); i++) {
Number scale;
Entity *parentEntity = (Entity*) icons[i]->getUserData();
if(!parentEntity->visible) {
icons[i]->visible = false;
} else {
icons[i]->visible = true;
Vector2 screenPos = parentEntity->getScreenPosition(mainScene->getDefaultCamera()->getProjectionMatrix(), mainScene->getDefaultCamera()->getConcatenatedMatrix().Inverse(), mainScene->getDefaultCamera()->getViewport());
icons[i]->setPosition(screenPos.x, (mainScene->getDefaultCamera()->getViewport().h - screenPos.y) + 30);
// RENDERER_TODO:
// check if icon is behind the camera and hide it now that the icons are in screenspace
}
}
if(selectedEntities.size() > 0) {
setBBox();
bBoxVis->color = Color(0.3, 0.5, 1.0, 0.5);
} else {
setBBox(getObjectRoot());
bBoxVis->color = Color(0.5, 1.0, 0.3, 0.5);
}
}
void EntityEditorMainView::createIcon(Entity *entity, String iconFile) {
entity->removeAllHandlersForListener(this);
ScenePrimitive *iconPrimitive = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 32, 32);
iconPrimitive->setMaterial(resourcePool->getMaterial("Unlit"));
iconPrimitive->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
Image *image = new Image(core, "entityEditor/"+iconFile);
std::shared_ptr<Texture> tex = std::make_shared<Texture>(image, false, false);
delete image;
iconPrimitive->getShaderPass(0).shaderBinding->setTextureForParam("diffuse", tex);
iconBase->addChild(iconPrimitive);
iconPrimitive->setUserData((void*)entity);
iconPrimitive->setForceMaterial(true);
iconPrimitive->processInputEvents = true;
iconPrimitive->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
iconPrimitive->setUserData(entity);
icons.push_back(iconPrimitive);
}
void EntityEditorMainView::setEditorPropsRecursive(Entity *entity) {
setEditorProps(entity);
for(int i=0; i < entity->getNumChildren(); i++) {
if(!entity->getChildAtIndex(i)->editorOnly) {
setEditorProps(entity->getChildAtIndex(i));
}
}
}
void EntityEditorMainView::setLinkedEntityPropsRecursive(SceneEntityInstance *parentInstance, Entity *entity) {
SceneMesh *sceneMesh = dynamic_cast<SceneMesh*>(entity);
SceneParticleEmitter *emitter = dynamic_cast<SceneParticleEmitter*>(entity);
entity->setUserData((void*)parentInstance);
entity->processInputEvents = true;
entity->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
entity->editorOnly = true;
if(sceneMesh && !emitter) {
// RENDERER_TODO
// sceneMesh->wireFrameColor = Color(0.2, 0.9, 0.6, 1.0);
sceneMesh->useGeometryHitDetection = true;
}
for(int i=0; i < entity->getNumChildren(); i++) {
setLinkedEntityPropsRecursive(parentInstance, entity->getChildAtIndex(i));
}
}
void EntityEditorMainView::setEditorProps(Entity *entity) {
entity->processInputEvents = true;
entity->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
SceneMesh *sceneMesh = dynamic_cast<SceneMesh*>(entity);
SceneParticleEmitter *emitter = dynamic_cast<SceneParticleEmitter*>(entity);
SceneSprite *sprite = dynamic_cast<SceneSprite*>(entity);
if(sceneMesh && !emitter && !sprite) {
// RENDERER_TODO
// sceneMesh->wireFrameColor = Color(1.0, 0.8, 0.3, 1.0);
// sceneMesh->setLineWidth(CoreServices::getInstance()->getRenderer()->getBackingResolutionScaleX());
sceneMesh->useGeometryHitDetection = true;
}
SceneEntityInstance *instance = dynamic_cast<SceneEntityInstance*>(entity);
if(instance && instance != objectRootInstance) {
for(int i=0; i < instance->getNumChildren(); i++) {
setLinkedEntityPropsRecursive(instance, instance->getChildAtIndex(i));
instance->getResourceEntry()->reloadOnFileModify = true;
instance->getResourceEntry()->addEventListenerUnique(this, Event::RESOURCE_RELOAD_EVENT);
if(!core->getResourceManager()->getGlobalPool()->hasResource(instance->getResourceEntry())) {
core->getResourceManager()->getGlobalPool()->addResource(instance->getResourceEntry());
}
}
}
SceneLight *sceneLight = dynamic_cast<SceneLight*>(entity);
if(sceneLight) {
createIcon(entity, "light_icon.png");
LightDisplay *lightVis = new LightDisplay(core->getResourceManager()->getGlobalPool()->getMaterial("UnlitUntextured"), sceneLight);
}
SceneCurve *sceneCurve = dynamic_cast<SceneCurve*>(entity);
if(sceneCurve) {
sceneCurve->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
sceneCurve->setForceMaterial(true);
CurveDisplay *curveVis = new CurveDisplay(core->getInput(), resourcePool, mainScene, sceneCurve);
curveVis->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
createIcon(entity, "curve_icon.png");
}
if(emitter) {
createIcon(entity, "emitter_icon.png");
}
SceneSound *sound = dynamic_cast<SceneSound*>(entity);
if(sound) {
createIcon(entity, "sound_icon.png");
}
Camera *camera = dynamic_cast<Camera*>(entity);
if(camera) {
CameraDisplay *camVis = new CameraDisplay(core->getResourceManager()->getGlobalPool()->getMaterial("UnlitUntextured"), camera);
createIcon(entity, "camera_icon.png");
}
if(!emitter && !sceneLight && !camera && !sound && !sceneMesh && entity != sceneObjectRoot) {
createIcon(entity, "empty_icon.png");
}
}
void EntityEditorMainView::addEntityFromMenu(String command) {
if(command == "add_primitive") {
ScenePrimitive *newPrimitive = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1.0, 1.0, 1.0);
sceneObjectRoot->addChild(newPrimitive);
setEditorProps(newPrimitive);
newPrimitive->setPosition(cursorPosition);
newPrimitive->setMaterial(resourcePool->getMaterial("Default"));
didPlaceEntity(newPrimitive);
selectEntity(newPrimitive, false, false);
return;
}
if(command == "add_empty") {
Entity *newEntity = new Entity();
sceneObjectRoot->addChild(newEntity);
setEditorProps(newEntity);
newEntity->setPosition(cursorPosition);
didPlaceEntity(newEntity);
selectEntity(newEntity, false, false);
return;
}
if(command == "add_curve") {
SceneCurve *curve = new SceneCurve();
curve->getCurve()->addControlPoint(3.0, -1.0, 0.0,
2.0, 0.0, 0.0,
1.0, 1.0, 0.0);
curve->getCurve()->addControlPoint(
-1.0, 1.0, 0.0,
-2.0, 0.0, 0.0,
-3.0, -1.0, 0.0);
sceneObjectRoot->addChild(curve);
setEditorProps(curve);
curve->setPosition(cursorPosition);
didPlaceEntity(curve);
selectEntity(curve, false, false);
return;
}
if(command == "add_sound") {
SceneSound *newSound = new SceneSound(core, "default.wav", 1.0, 2.0);
sceneObjectRoot->addChild(newSound);
setEditorProps(newSound);
newSound->setPosition(cursorPosition);
didPlaceEntity(newSound);
selectEntity(newSound, false, false);
return;
}
if(command == "add_camera") {
Camera *newCamera = new Camera();
sceneObjectRoot->addChild(newCamera);
setEditorProps(newCamera);
newCamera->setPosition(cursorPosition);
didPlaceEntity(newCamera);
selectEntity(newCamera, false, false);
return;
}
if(command == "add_image") {
assetSelectType = "image";
globalFrame->assetBrowser->addEventListener(this, UIEvent::OK_EVENT);
std::vector<String> extensions;
extensions.push_back("png");
extensions.push_back("hdr");
extensions.push_back("jpg");
extensions.push_back("psd");
extensions.push_back("tga");
globalFrame->showAssetBrowser(extensions);
return;
}
if(command == "add_sprite") {
assetSelectType = "sprite";
globalFrame->assetBrowser->addEventListener(this, UIEvent::OK_EVENT);
std::vector<ResourcePool*> pools;
pools.push_back(core->getResourceManager()->getGlobalPool());
for(int i=0; i < objectRootInstance->getNumLinkedResourePools(); i++) {
pools.push_back(objectRootInstance->getLinkedResourcePoolAtIndex(i));
}
globalFrame->showAssetBrowserForPools(pools, Resource::RESOURCE_SPRITE);
return;
}
if(command == "add_label") {
SceneLabel *newLabel = new SceneLabel(resourcePool->getMaterial("Unlit"), "TEXT", 12, resourcePool->getFont("sans"), Label::ANTIALIAS_FULL, 1.0);
newLabel->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
newLabel->setAnchorPoint(0.0, 0.0, 0.0);
newLabel->snapToPixels = false;
newLabel->positionAtBaseline = false;
sceneObjectRoot->addChild(newLabel);
setEditorProps(newLabel);
newLabel->setPosition(cursorPosition);
didPlaceEntity(newLabel);
selectEntity(newLabel, false, false);
return;
}
if(command == "add_light") {
SceneLight *newLight = new SceneLight(SceneLight::POINT_LIGHT, 1.0);
sceneObjectRoot->addChild(newLight);
newLight->enabled = !lightsDisabled;
setEditorProps(newLight);
newLight->setLocalBoundingBox(Vector3());
newLight->setPosition(cursorPosition);
didPlaceEntity(newLight);
selectEntity(newLight, false, false);
return;
}
if(command == "add_mesh") {
assetSelectType = "mesh";
globalFrame->assetBrowser->addEventListener(this, UIEvent::OK_EVENT);
std::vector<String> extensions;
extensions.push_back("mesh");
globalFrame->showAssetBrowser(extensions);
return;
}
if(command == "add_entity") {
assetSelectType = "entity";
globalFrame->assetBrowser->addEventListener(this, UIEvent::OK_EVENT);
std::vector<String> extensions;
extensions.push_back("entity");
globalFrame->showAssetBrowser(extensions);
return;
}
if(command == "add_particles") {
SceneParticleEmitter *newEmitter = new SceneParticleEmitter(30, 3.0, 0.2);
newEmitter->setLocalBoundingBox(0.5, 0.5, 0.5);
newEmitter->setParticleType(SceneParticleEmitter::PARTICLE_TYPE_QUAD);
sceneObjectRoot->addChild(newEmitter);
setEditorProps(newEmitter);
newEmitter->setPosition(cursorPosition);
newEmitter->scaleCurve.addControlPoint2dWithHandles(-0.1, 0.5, 0.0, 0.5, 0.1, 0.5);
newEmitter->scaleCurve.addControlPoint2dWithHandles(0.9, 0.5, 1.0, 0.5, 1.1, 0.5);
newEmitter->colorCurveR.addControlPoint2dWithHandles(-0.1, 0.5, 0.0, 0.5, 0.1, 0.5);
newEmitter->colorCurveR.addControlPoint2dWithHandles(0.9, 0.5, 1.0, 0.5, 1.1, 0.5);
newEmitter->colorCurveG.addControlPoint2dWithHandles(-0.1, 0.5, 0.0, 0.5, 0.1, 0.5);
newEmitter->colorCurveG.addControlPoint2dWithHandles(0.9, 0.5, 1.0, 0.5, 1.1, 0.5);
newEmitter->colorCurveB.addControlPoint2dWithHandles(-0.1, 0.5, 0.0, 0.5, 0.1, 0.5);
newEmitter->colorCurveB.addControlPoint2dWithHandles(0.9, 0.5, 1.0, 0.5, 1.1, 0.5);
newEmitter->colorCurveA.addControlPoint2dWithHandles(-0.1, 0.5, 0.0, 0.5, 0.1, 0.5);
newEmitter->colorCurveA.addControlPoint2dWithHandles(0.9, 0.5, 1.0, 0.5, 1.1, 0.5);
selectEntity(newEmitter, false, false);
didPlaceEntity(newEmitter);
return;
}
}
void EntityEditorMainView::didPlaceEntity(Entity *entity) {
PolycodeSceneEditorActionData *beforeData = new PolycodeSceneEditorActionData();
PolycodeSceneEditorActionData *data = new PolycodeSceneEditorActionData();
data->reverse = false;
for(int i=0; i < selectedEntities.size(); i++) {
beforeData->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]));
}
PolycodeSceneEditorActionDataEntry entry(entity);
entry.parentEntity = sceneObjectRoot;
data->entries.push_back(entry);
editor->didAction("create_entity", beforeData, data);
}
void EntityEditorMainView::deleteSelected(bool doAction) {
for(int i=0; i < selectedEntities.size(); i++) {
if(selectedEntities[i] == dummyEntity) {
if(dummyTargetEntity) {
dummyTargetEntity->handleDelete();
dummyEntity->removeAllHandlers();
selectedEntities.clear();
transformGizmo->setTransformSelection(selectedEntities);
return;
}
}
}
if(doAction) {
PolycodeSceneEditorActionData *oldData = new PolycodeSceneEditorActionData();
PolycodeSceneEditorActionData *data = new PolycodeSceneEditorActionData();
data->reverse = false;
oldData->deleteEntitiesInDestructor = true;
for(int i=0; i < selectedEntities.size(); i++) {
PolycodeSceneEditorActionDataEntry entry(selectedEntities[i]);
entry.parentEntity = selectedEntities[i]->getParentEntity();
oldData->entries.push_back(entry);
}
editor->didAction("delete", oldData, data);
}
for(int i=0; i < selectedEntities.size(); i++) {
selectedEntities[i]->getParentEntity()->removeChild(selectedEntities[i]);
SceneLight *sceneLight = dynamic_cast<SceneLight*>(selectedEntities[i]);
}
for(int i=0; i < selectedEntities.size(); i++) {
selectedEntities[i]->setOwnsChildrenRecursive(true);
for(int j=0; j < icons.size(); j++) {
if(icons[j]->getUserData() == selectedEntities[i]) {
icons[j]->getParentEntity()->removeChild(icons[j]);
delete icons[j];
icons.erase(icons.begin()+j);
break;
}
}
selectedEntities[i]->removeAllHandlers();
}
selectedEntities.clear();
transformGizmo->setTransformSelection(selectedEntities);
setBBox();
dispatchEvent(new Event(), Event::CHANGE_EVENT);
}
void EntityEditorMainView::onGainFocus() {
transformGizmo->enableGizmo = true;
}
void EntityEditorMainView::onLoseFocus() {
transformGizmo->enableGizmo = false;
}
void EntityEditorMainView::handleEvent(Event *event) {
if(event->getDispatcher() == transformGizmo) {
if(event->getEventCode() == Event::CHANGE_EVENT) {
TrasnformGizmoEvent *trasnformEvent = (TrasnformGizmoEvent*) event;
switch(trasnformEvent->mode) {
case TransformGizmo::TRANSFORM_MOVE:
case TransformGizmo::TRANSFORM_MOVE_VIEW:
{
PolycodeSceneEditorActionData *data = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
data->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]->getPosition()));
}
editor->didAction("move", beforeData, data);
beforeData = NULL;
}
break;
case TransformGizmo::TRANSFORM_SCALE:
case TransformGizmo::TRANSFORM_SCALE_VIEW:
{
PolycodeSceneEditorActionData *data = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
data->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]->getScale(), selectedEntities[i]->getPosition()));
}
editor->didAction("scale", beforeData, data);
beforeData = NULL;
}
break;
case TransformGizmo::TRANSFORM_ROTATE:
case TransformGizmo::TRANSFORM_ROTATE_VIEW:
{
PolycodeSceneEditorActionData *data = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
data->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]->getRotationQuat(), selectedEntities[i]->getPosition()));
}
editor->didAction("rotate", beforeData, data);
beforeData = NULL;
}
break;
}
} else if(event->getEventCode() == Event::SELECT_EVENT) {
TrasnformGizmoEvent *trasnformEvent = (TrasnformGizmoEvent*) event;
switch(trasnformEvent->mode) {
case TransformGizmo::TRANSFORM_MOVE:
case TransformGizmo::TRANSFORM_MOVE_VIEW:
{
beforeData = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
beforeData->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]->getPosition()));
}
}
break;
case TransformGizmo::TRANSFORM_SCALE:
case TransformGizmo::TRANSFORM_SCALE_VIEW:
{
beforeData = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
beforeData->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]->getScale(), selectedEntities[i]->getPosition()));
}
}
break;
case TransformGizmo::TRANSFORM_ROTATE:
case TransformGizmo::TRANSFORM_ROTATE_VIEW:
{
beforeData = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
beforeData->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]->getRotationQuat(), selectedEntities[i]->getPosition()));
}
}
break;
}
}
} else if(event->getEventCode() == Event::RESOURCE_RELOAD_EVENT) {
SceneEntityInstanceResourceEntry *entry = dynamic_cast<SceneEntityInstanceResourceEntry*>(event->getDispatcher());
if(entry) {
setEditorProps(entry->getInstance());
}
} else if(event->getDispatcher() == renderTextureShape) {
focusSelf();
} else if(event->getDispatcher() == trackballCamera) {
Update(0.0);
transformGizmo->Update(0.0);
} else if(event->getDispatcher() == viewModeSelector) {
setEditorMode(viewModeSelector->getSelectedIndex());
} else if(event->getDispatcher() == globalFrame->assetBrowser) {
if(event->getEventCode() == UIEvent::OK_EVENT) {
if(assetSelectType == "mesh") {
SceneMesh *newMesh = new SceneMesh(resourcePool, globalFrame->assetBrowser->getSelectedAssetPath());
sceneObjectRoot->addChild(newMesh);
setEditorProps(newMesh);
newMesh->setMaterial(resourcePool->getMaterial("Default"));
newMesh->setPosition(cursorPosition);
didPlaceEntity(newMesh);
selectEntity(newMesh, false, false);
} else if(assetSelectType == "sprite") {
std::shared_ptr<Resource> selectedResource = globalFrame->assetBrowser->getSelectedResource();
if(selectedResource) {
std::shared_ptr<Sprite> sprite = std::static_pointer_cast<Sprite>(selectedResource);
SceneSprite *newSprite = new SceneSprite(sprite->getParentSpriteSet());
newSprite->setSprite(sprite);
if(sprite->getNumStates() > 0) {
newSprite->setSpriteState(sprite->getState(0), 0, false);
}
sceneObjectRoot->addChild(newSprite);
setEditorProps(newSprite);
newSprite->setPosition(cursorPosition);
didPlaceEntity(newSprite);
selectEntity(newSprite, false, false);
}
} else if(assetSelectType == "entity") {
SceneEntityInstance *newEntity = new SceneEntityInstance(core, globalFrame->assetBrowser->getSelectedAssetPath());
sceneObjectRoot->addChild(newEntity);
setEditorProps(newEntity);
newEntity->setPosition(cursorPosition);
didPlaceEntity(newEntity);
selectEntity(newEntity, false, false);
}
globalFrame->assetBrowser->removeAllHandlersForListener(this);
globalFrame->hideModal();
}
} else if(event->getDispatcher() == addEntityMenu) {
addEntityMenu->removeAllHandlersForListener(this);
String command = addEntityMenu->getSelectedItem()->getMenuItemID();
addEntityMenu = NULL;
addEntityFromMenu(command);
} else if(event->getDispatcher() == addEntityButton) {
addEntityMenu = globalMenu->showMenuAtMouse(150);
addEntityMenu->addOption("Add Primitive", "add_primitive");
addEntityMenu->addOption("Add Mesh", "add_mesh");
addEntityMenu->addOption("Add Entity", "add_entity");
addEntityMenu->addDivider();
addEntityMenu->addOption("Add Sprite", "add_sprite");
addEntityMenu->addOption("Add Label", "add_label");
addEntityMenu->addDivider();
addEntityMenu->addOption("Add Light", "add_light");
addEntityMenu->addOption("Add Particle System", "add_particles");
addEntityMenu->addOption("Add Sound", "add_sound");
addEntityMenu->addOption("Add Camera", "add_camera");
addEntityMenu->addDivider();
addEntityMenu->addOption("Add Empty", "add_empty");
addEntityMenu->addOption("Add Curve", "add_curve");
addEntityMenu->fitToScreenVertical();
addEntityMenu->addEventListener(this, UIEvent::OK_EVENT);
} else if(event->getDispatcher() == input) {
InputEvent *inputEvent = (InputEvent*) event;
if(event->getEventCode() == InputEvent::EVENT_KEYDOWN) {
switch(inputEvent->key) {
case KEY_BACKSPACE:
case KEY_DELETE:
if(hasFocus) {
deleteSelected(true);
}
break;
case KEY_ESCAPE:
{
selectNone(true);
}
break;
}
}
} else if(event->getDispatcher() == lightingModeSelector) {
switch(lightingModeSelector->getSelectedIndex()) {
case 0:
disableLighting(false);
break;
case 1:
disableLighting(true);
break;
}
} else if(event->getDispatcher() == shadeModeSelector) {
switch(shadeModeSelector->getSelectedIndex()) {
case 0:
mainScene->setOverrideMaterial(NULL);
break;
case 1:
{
ResourcePool *pool = core->getResourceManager()->getGlobalPool();
mainScene->setOverrideMaterial(std::static_pointer_cast<Material>(pool->getResource(Resource::RESOURCE_MATERIAL, "Default")));
}
break;
case 2:
{
ResourcePool *pool = core->getResourceManager()->getGlobalPool();
std::shared_ptr<Material> wireframeMaterial = std::static_pointer_cast<Material>(pool->getResource(Resource::RESOURCE_MATERIAL, "UnlitWireframe"));
if(!wireframeMaterial->getShaderPass(0).shaderBinding->getLocalParamByName("wireframeColor")) {
wireframeMaterial->getShaderPass(0).shaderBinding->addParam(ProgramParam::PARAM_COLOR, "wireframeColor")->setColor(Color(1.0, 1.0, 1.0, 1.0));
}
mainScene->setOverrideMaterial(wireframeMaterial);
}
break;
}
} else if(event->getDispatcher() == moveUpButton) {
moveSelectedUp();
} else if(event->getDispatcher() == moveTopButton) {
moveSelectedTop();
} else if(event->getDispatcher() == moveDownButton) {
moveSelectedDown();
} else if(event->getDispatcher() == moveBottomButton) {
moveSelectedBottom();
} else if(event->getDispatcher() == gridSettingsButton) {
gridSettings->visible = !gridSettings->visible;
gridSettings->enabled = !gridSettings->enabled;
} else if(event->getDispatcher() == snapSelector) {
switch(snapSelector->getSelectedIndex()) {
case 0:
transformGizmo->enableSnap(false);
break;
case 1:
transformGizmo->enableSnap(true);
transformGizmo->setSnapSize(grid->getGridSize());
break;
}
} else if(event->getDispatcher() == grid) {
transformGizmo->setSnapSize(grid->getGridSize());
} else if(event->getDispatcher() == iconVisibilitySelector) {
switch(iconVisibilitySelector->getSelectedIndex()) {
case 0:
iconBase->visible = true;
break;
case 1:
iconBase->visible = false;
break;
}
} else {
if(event->getEventCode() == InputEvent::EVENT_MOUSEDOWN && hasFocus && event->getDispatcher() != renderTextureShape) {
InputEvent *inputEvent = (InputEvent*) event;
Entity* targetEntity = (Entity*) event->getDispatcher();
if(inputEvent->mouseButton == CoreInput::MOUSE_BUTTON2 && targetEntity->visible && targetEntity != getObjectRoot()) {
// if it's an icon, select the entity linked to the icon
for(int i=0; i < icons.size(); i++) {
if(icons[i] == targetEntity) {
targetEntity = (Entity*)targetEntity->getUserData();
}
}
// check if dispatcher is a dummy target
DummyTargetEntity *dummyTarget = dynamic_cast<DummyTargetEntity*>(event->getDispatcher());
if(dummyTarget) {
targetEntity = dummyEntity;
if(dummyTargetEntity) {
dummyTargetEntity->handleDeselect();
}
dummyTargetEntity = dummyTarget;
dummyEntity->setPosition(dummyTarget->getSelectedPoint());
}
MultiselectorEntry entry;
entry.entity = targetEntity;
entry.distance = inputEvent->hitDistance;
entitiesToSelect.push_back(entry);
}
}
}
}
void EntityEditorMainView::moveSelectedUp() {
for(int i=0; i < selectedEntities.size(); i++) {
Entity *parent = selectedEntities[i]->getParentEntity();
if(parent) {
parent->moveChildUp(selectedEntities[i]);
}
}
}
void EntityEditorMainView::moveSelectedDown() {
for(int i=0; i < selectedEntities.size(); i++) {
Entity *parent = selectedEntities[i]->getParentEntity();
if(parent) {
parent->moveChildDown(selectedEntities[i]);
}
}
}
void EntityEditorMainView::moveSelectedTop() {
for(int i=0; i < selectedEntities.size(); i++) {
Entity *parent = selectedEntities[i]->getParentEntity();
if(parent) {
parent->moveChildTop(selectedEntities[i]);
}
}
}
void EntityEditorMainView::moveSelectedBottom() {
for(int i=0; i < selectedEntities.size(); i++) {
Entity *parent = selectedEntities[i]->getParentEntity();
if(parent) {
parent->moveChildBottom(selectedEntities[i]);
}
}
}
void EntityEditorMainView::selectAll(bool doAction) {
if(doAction) {
beforeData = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
beforeData->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]));
}
editor->didAction("select", beforeData, NULL, false);
beforeData = NULL;
}
selectedEntities.clear();
for(int i=0; i < objectRootInstance->getNumChildren(); i++) {
Entity *child = objectRootInstance->getChildAtIndex(i);
if(!child->editorOnly) {
selectEntity(child, true, false);
}
}
transformGizmo->setTransformSelection(selectedEntities);
setBBox();
dispatchEvent(new Event(), Event::CHANGE_EVENT);
}
void EntityEditorMainView::selectNone(bool doAction) {
if(doAction) {
beforeData = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
beforeData->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]));
}
editor->didAction("select", beforeData, NULL, false);
beforeData = NULL;
}
for(int i=0; i < selectedEntities.size(); i++) {
doEntityDeselect(selectedEntities[i]);
}
cameraPreview->setCamera(mainScene, NULL);
selectedEntities.clear();
transformGizmo->setTransformSelection(selectedEntities);
setBBox();
dispatchEvent(new Event(), Event::CHANGE_EVENT);
}
void EntityEditorMainView::disableLighting(bool disable) {
lightsDisabled = disable;
if(disable) {
customLight1->enabled = true;
customLight2->enabled = true;
} else {
customLight1->enabled = false;
customLight2->enabled = false;
}
}
Scene *EntityEditorMainView::getMainScene() {
return mainScene;
}
void EntityEditorMainView::doEntityDeselect(Entity *targetEntity) {
SceneMesh *sceneMesh = dynamic_cast<SceneMesh*>(targetEntity);
if(sceneMesh) {
setOverlayWireframeRecursive(sceneMesh, false);
}
if(targetEntity == dummyEntity) {
if(dummyTargetEntity) {
dummyTargetEntity->handleDeselect();
}
}
std::vector<Entity*> dummySelectChildren = targetEntity->getEntitiesByTag("dummy_target", true);
for(int i=0; i < dummySelectChildren.size(); i++) {
DummyTargetEntity *dummy = dynamic_cast<DummyTargetEntity*>(dummySelectChildren[i]);
if(dummy) {
dummy->handleDeselect();
}
}
SceneEntityInstance *instance = dynamic_cast<SceneEntityInstance*>(targetEntity);
if(instance) {
setOverlayWireframeRecursive(targetEntity, false);
}
}
void EntityEditorMainView::setOverlayWireframeRecursive(Entity *targetEntity, bool val) {
SceneMesh *sceneMesh = dynamic_cast<SceneMesh*>(targetEntity);
if(sceneMesh) {
std::shared_ptr<Material> material = sceneMesh->getMaterial();
if(material) {
if(val) {
ShaderPass wireframePass;
ResourcePool *pool = core->getResourceManager()->getGlobalPool();
wireframePass.shader = std::static_pointer_cast<Shader>(pool->getResource(Resource::RESOURCE_SHADER, "UnlitWireframe"));
wireframePass.wireframe = true;
wireframePass.shaderBinding = std::make_shared<ShaderBinding>();
wireframePass.shaderBinding->targetShader = wireframePass.shader;
wireframePass.blendingMode = Renderer::BLEND_MODE_NORMAL;
wireframePass.shaderBinding->addParam(ProgramParam::PARAM_COLOR, "wireframeColor")->setColor(Color(0.5, 0.6, 1.0, 0.75));
sceneMesh->addShaderPass(wireframePass);
} else {
if(sceneMesh->getNumShaderPasses() > 1) {
sceneMesh->removeShaderPass(sceneMesh->getNumShaderPasses()-1);
}
}
}
}
for(int i=0; i < targetEntity->getNumChildren(); i++) {
setOverlayWireframeRecursive(targetEntity->getChildAtIndex(i), val);
}
}
void EntityEditorMainView::doEntitySelect(Entity *targetEntity) {
SceneMesh *sceneMesh = dynamic_cast<SceneMesh*>(targetEntity);
SceneParticleEmitter *emitter = dynamic_cast<SceneParticleEmitter*>(targetEntity);
if(sceneMesh && ! emitter) {
setOverlayWireframeRecursive(sceneMesh, true);
}
if(targetEntity == dummyEntity) {
if(dummyTargetEntity) {
dummyTargetEntity->handleSelect();
}
} else {
// clear the dummy target if dummy is not selected
dummyTargetEntity = NULL;
}
std::vector<Entity*> dummySelectChildren = targetEntity->getEntitiesByTag("dummy_target", true);
for(int i=0; i < dummySelectChildren.size(); i++) {
DummyTargetEntity *dummy = dynamic_cast<DummyTargetEntity*>(dummySelectChildren[i]);
if(dummy) {
dummy->handleSelect();
}
}
SceneEntityInstance *instance = dynamic_cast<SceneEntityInstance*>(targetEntity);
if(instance) {
setOverlayWireframeRecursive(targetEntity, true);
}
Camera *camera = dynamic_cast<Camera*>(targetEntity);
cameraPreview->setCamera(mainScene, camera);
}
void EntityEditorMainView::selectEntity(Entity *targetEntity, bool addToSelection, bool doAction) {
if(doAction) {
beforeData = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
beforeData->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]));
}
}
if(targetEntity->getUserData()) {
SceneEntityInstance *instance = (SceneEntityInstance*)targetEntity->getUserData();
targetEntity = instance;
}
bool doNotReselect = false;
if(!addToSelection) {
for(int i=0; i < selectedEntities.size(); i++) {
doEntityDeselect(selectedEntities[i]);
}
selectedEntities.clear();
} else {
for(int i=0; i < selectedEntities.size(); i++) {
if(targetEntity == selectedEntities[i]) {
doEntityDeselect(targetEntity);
selectedEntities.erase(selectedEntities.begin() + i);
doNotReselect = true;
break;
}
}
}
if(!doNotReselect) {
selectedEntities.push_back(targetEntity);
doEntitySelect(targetEntity);
}
if(doAction) {
PolycodeSceneEditorActionData *data = new PolycodeSceneEditorActionData();
for(int i=0; i < selectedEntities.size(); i++) {
data->entries.push_back(PolycodeSceneEditorActionDataEntry(selectedEntities[i]));
}
editor->didAction("select", beforeData, data, false);
beforeData = NULL;
}
transformGizmo->setTransformSelection(selectedEntities);
setBBox();
dispatchEvent(new Event(), Event::CHANGE_EVENT);
}
void EntityEditorMainView::setBBox(Entity *targetEntity) {
if(!targetEntity) {
if(selectedEntities.size() > 0) {
targetEntity = selectedEntities[0];
}
}
if(!targetEntity) {
bBoxVis->visible = false;
return;
} else {
bBoxVis->visible = true;
bBoxVis->setPrimitiveOptions(ScenePrimitive::TYPE_BOX, targetEntity->getLocalBoundingBox().x, targetEntity->getLocalBoundingBox().y, targetEntity->getLocalBoundingBox().z);
Matrix4 mat = targetEntity->getConcatenatedMatrix();
bBoxVis->setTransformByMatrixPure(mat);
bBoxVis->dirtyMatrix(false);
}
}
Entity *EntityEditorMainView::getObjectRoot() {
return sceneObjectRoot;
}
void EntityEditorMainView::setObjectRoot(SceneEntityInstance *entity) {
objectRootInstance = entity;
if(sceneObjectRoot) {
sceneObjectRoot->getParentEntity()->removeChild(sceneObjectRoot);
delete sceneObjectRoot;
}
sceneObjectRoot = entity;
sceneObjectRoot->processInputEvents = true;
objectRootBase->addChild(sceneObjectRoot);
sceneObjectRoot->getParentEntity()->moveChildBottom(sceneObjectRoot);
}
EntityEditorMainView::~EntityEditorMainView() {
mainScene->rootEntity.setOwnsChildrenRecursive(true);
delete mainScene;
delete renderTexture;
// delete transformGizmo;
// delete transformGizmoMenu;
// delete trackballCamera;
// delete grid;
// delete cameraPreview;
input->removeAllHandlersForListener(this);
}
void EntityEditorMainView::Resize(Number width, Number height) {
headerBg->Resize(width, 30);
footerBg->Resize(width, 30);
footerBg->setPosition(0.0, height-30);
bottomBar->setPosition(0.0, height-30);
viewModeSelector->setPosition(width-viewModeSelector->getWidth()-10.0, 3);
Vector2 screenPos = renderTextureShape->getScreenPositionForMainCamera();
renderTexture->resizeRenderTexture(width, height-60);
renderTextureShape->setTexture(renderTexture->getTargetTexture());
renderTextureShape->Resize(width, height-60);
mainScene->sceneMouseRect.x = screenPos.x;
mainScene->sceneMouseRect.y = screenPos.y;
mainScene->sceneMouseRect.w = renderTextureShape->getWidth();
mainScene->sceneMouseRect.h = renderTextureShape->getHeight();
mainScene->remapMouse = true;
Update(0.0);
}
EntityEditorPropertyContainer::EntityEditorPropertyContainer(Core *core, ResourcePool *pool, PolycodeEditor *editor) : UIElement(core) {
this->editor = editor;
propIconSelector = new UIIconSelector(core, pool);
addChild(propIconSelector);
propIconSelector->addIcon("entityEditor/properties_icon.png");
propIconSelector->addIcon("entityEditor/icon_tree.png");
propIconSelector->addIcon("entityEditor/settings_icon.png");
propIconSelector->setPosition(10.0, 3.0);
propIconSelector->addEventListener(this, UIEvent::SELECT_EVENT);
propertyView = new EntityEditorPropertyView(core, pool);
propertyView->addEventListener(this, PropEvent::EVENT_PROP_CHANGE);
addChild(propertyView);
propertyView->setPosition(0.0, 30.0);
currentView = propertyView;
treeView = new EntityEditorTreeView(core, pool);
addChild(treeView);
treeView->setPosition(0.0, 30.0);
treeView->visible = false;
treeView->enabled = false;
settingsView = new EntityEditorSettingsView(core, pool);
addChild(settingsView);
settingsView->setPosition(0.0, 30.0);
settingsView->visible = false;
settingsView->enabled = false;
}
void EntityEditorPropertyContainer::handleEvent(Event *event) {
if(event->getDispatcher() == propIconSelector) {
currentView->visible = false;
currentView->enabled = false;
switch(propIconSelector->getSelectedIndex()) {
case 0:
currentView = propertyView;
break;
case 1:
currentView = treeView;
treeView->getTreeSheet()->refreshTree();
break;
case 2:
currentView = settingsView;
break;
}
currentView->visible = true;
currentView->enabled = true;
} else if(event->getDispatcher() == propertyView) {
if(event->getEventCode() == PropEvent::EVENT_PROP_CHANGE) {
PropEvent *propEvent = (PropEvent*) event;
editor->didAction("prop_change", propEvent->beforeData, propEvent->afterData);
}
}
}
EntityEditorPropertyContainer::~EntityEditorPropertyContainer() {
}
void EntityEditorPropertyContainer::Resize(Number width, Number height) {
propertyView->Resize(width, height-30);
treeView->Resize(width, height-30);
settingsView->Resize(width, height-30);
}
PolycodeEntityEditor::PolycodeEntityEditor(Core *core, ResourcePool *pool) : PolycodeEditor(core, pool, true){
mainSizer = new UIHSizer(core, pool, 300, 300, 300, false);
addChild(mainSizer);
mainView = new EntityEditorMainView(core, pool, this);
mainView->addEventListener(this, Event::CHANGE_EVENT);
mainSizer->addLeftChild(mainView);
mainSizer->setMinimumSize(200);
propertyContainer = new EntityEditorPropertyContainer(core, pool, this);
propertyView = propertyContainer->propertyView;
treeView = propertyContainer->treeView;
settingsView = propertyContainer->settingsView;
treeView->getTreeSheet()->addEventListener(this, Event::CHANGE_EVENT);
mainSizer->addRightChild(propertyContainer);
}
void PolycodeEntityEditor::handleEvent(Event *event) {
if(event->getDispatcher() == treeView->getTreeSheet()) {
if(treeView->getTreeSheet()->getSelectedEntity() == mainView->getObjectRoot()) {
mainView->selectNone(true);
} else {
mainView->selectEntity(treeView->getTreeSheet()->getSelectedEntity());
}
}
if(event->getDispatcher() == mainView) {
switch(event->getEventCode()) {
case Event::CHANGE_EVENT:
if(mainView->getSelectedEntity()) {
propertyView->setEntity(mainView->getSelectedEntity());
treeView->getTreeSheet()->setSelectedEntity(mainView->getSelectedEntity());
propertyView->getEntityProps()->setCaption("PROPERTIES");
} else {
propertyView->setEntity(mainView->getObjectRoot(), true);
treeView->getTreeSheet()->setSelectedEntity(mainView->getObjectRoot());
propertyView->getEntityProps()->setCaption("ROOT ENTITY");
mainView->setBBox(mainView->getObjectRoot());
}
break;
}
}
PolycodeEditor::handleEvent(event);
}
void PolycodeEntityEditor::doAction(String actionName, PolycodeEditorActionData *data) {
if(actionName == "prop_change") {
PolycodeEditorPropActionData *propData = (PolycodeEditorPropActionData*) data;
propData->sheet->applyPropActionData(propData);
} else {
mainView->doAction(actionName, data);
}
}
PolycodeEntityEditor::~PolycodeEntityEditor() {
mainView->getMainScene()->rootEntity.setOwnsChildrenRecursive(true);
delete mainView;
delete propertyView;
delete treeView;
delete settingsView;
delete propertyContainer;
delete mainSizer;
}
bool PolycodeEntityEditor::openFile(OSFileEntry filePath) {
PolycodeEditor::openFile(filePath);
// return true;
loadedInstance = new SceneEntityInstance(core, filePath.fullPath);
// disable sounds :)
for(int i=0; i < loadedInstance->getNumChildren(); i++) {
SceneSound *sound = dynamic_cast<SceneSound*>(loadedInstance->getChildAtIndex(i));
if(sound) {
sound->getSound()->Stop();
}
}
mainView->setObjectRoot(loadedInstance);
mainView->setEditorPropsRecursive(loadedInstance);
treeView->setEntityInstance(loadedInstance);
propertyView->setEntityInstance(loadedInstance);
settingsView->setEntityInstance(loadedInstance);
mainView->dispatchEvent(new Event(), Event::CHANGE_EVENT);
return true;
}
void PolycodeEntityEditor::Activate() {
Resize(getWidth(), getHeight());
mainView->getMainScene()->enabled = true;
mainView->getRenderTexture()->enabled = true;
}
void PolycodeEntityEditor::Deactivate() {
mainView->getMainScene()->enabled = false;
mainView->getRenderTexture()->enabled = false;
}
void PolycodeEntityEditor::saveCurveToObject(ObjectEntry *entry, BezierCurve *curve) {
ObjectEntry *controlPoints = entry->addChild("controlPoints");
for(int i=0; i < curve->getNumControlPoints(); i++) {
ObjectEntry *controlPointEntry = controlPoints->addChild("controlPoint");
ObjectEntry *pt1 = controlPointEntry->addChild("pt1");
pt1->addChild("x", curve->getControlPoint(i)->p1.x);
pt1->addChild("y", curve->getControlPoint(i)->p1.y);
pt1->addChild("z", curve->getControlPoint(i)->p1.z);
ObjectEntry *pt2 = controlPointEntry->addChild("pt2");
pt2->addChild("x", curve->getControlPoint(i)->p2.x);
pt2->addChild("y", curve->getControlPoint(i)->p2.y);
pt2->addChild("z", curve->getControlPoint(i)->p2.z);
ObjectEntry *pt3 = controlPointEntry->addChild("pt3");
pt3->addChild("x", curve->getControlPoint(i)->p3.x);
pt3->addChild("y", curve->getControlPoint(i)->p3.y);
pt3->addChild("z", curve->getControlPoint(i)->p3.z);
}
}
void PolycodeEntityEditor::saveEntityToObjectEntry(Entity *entity, ObjectEntry *entry) {
if(entity->editorOnly)
return;
entry->addChild("id", entity->id);
entry->addChild("layerID", (int)entity->layerID);
String tagString = "";
for(int i=0; i < entity->getNumTags(); i++) {
if(i != 0) {
tagString += ",";
}
tagString += entity->getTagAtIndex(i);
}
entry->addChild("tags", tagString);
if(entity->entityProps.size() > 0) {
ObjectEntry *props = entry->addChild("props");
for(int i=0; i < entity->entityProps.size(); i++) {
ObjectEntry *prop = props->addChild("prop");
prop->addChild("name", entity->entityProps[i].propName);
prop->addChild("value", entity->entityProps[i].propValue);
}
}
if(dynamic_cast<SceneEntityInstance*>(entity) && entity != mainView->getObjectRoot()) {
if(!(*(entry))["type"]) {
entry->addChild("type", "SceneEntityInstance");
}
SceneEntityInstance *instance = (SceneEntityInstance*) entity;
ObjectEntry *instanceEntry = entry->addChild("SceneEntityInstance");
instanceEntry->addChild("filePath", instance->getFileName());
}
if(dynamic_cast<SceneParticleEmitter*>(entity)) {
if(!(*(entry))["type"])
entry->addChild("type", "SceneParticleEmitter");
SceneParticleEmitter *emitter = (SceneParticleEmitter*) entity;
ObjectEntry *emitterEntry = entry->addChild("SceneParticleEmitter");
emitterEntry->addChild("type", (int)emitter->getParticleType());
emitterEntry->addChild("count", (int)emitter->getParticleCount());
emitterEntry->addChild("speed", emitter->getParticleSpeed());
emitterEntry->addChild("lifetime", emitter->getParticleLifetime());
emitterEntry->addChild("size", emitter->getParticleSize());
emitterEntry->addChild("world", emitter->getParticlesInWorldSpace());
emitterEntry->addChild("loop", emitter->getLoopParticles());
emitterEntry->addChild("rX", emitter->getParticleRotationSpeed().x);
emitterEntry->addChild("rY", emitter->getParticleRotationSpeed().y);
emitterEntry->addChild("rZ", emitter->getParticleRotationSpeed().z);
emitterEntry->addChild("gX", emitter->getGravity().x);
emitterEntry->addChild("gY", emitter->getGravity().y);
emitterEntry->addChild("gZ", emitter->getGravity().z);
emitterEntry->addChild("dirX", emitter->getParticleDirection().x);
emitterEntry->addChild("dirY", emitter->getParticleDirection().y);
emitterEntry->addChild("dirZ", emitter->getParticleDirection().z);
emitterEntry->addChild("eX", emitter->getEmitterSize().x);
emitterEntry->addChild("eY", emitter->getEmitterSize().y);
emitterEntry->addChild("eZ", emitter->getEmitterSize().z);
emitterEntry->addChild("devX", emitter->getDirectionDeviation().x);
emitterEntry->addChild("devY", emitter->getDirectionDeviation().y);
emitterEntry->addChild("devZ", emitter->getDirectionDeviation().z);
emitterEntry->addChild("perlin", emitter->getPerlinEnabled());
emitterEntry->addChild("pX", emitter->getPerlinValue().x);
emitterEntry->addChild("pY", emitter->getPerlinValue().y);
emitterEntry->addChild("pZ", emitter->getPerlinValue().z);
emitterEntry->addChild("useColorCurves", emitter->useColorCurves);
emitterEntry->addChild("useScaleCurve", emitter->useScaleCurve);
saveCurveToObject(emitterEntry->addChild("scaleCurve"), &emitter->scaleCurve);
saveCurveToObject(emitterEntry->addChild("colorCurveR"), &emitter->colorCurveR);
saveCurveToObject(emitterEntry->addChild("colorCurveG"), &emitter->colorCurveG);
saveCurveToObject(emitterEntry->addChild("colorCurveB"), &emitter->colorCurveB);
saveCurveToObject(emitterEntry->addChild("colorCurveA"), &emitter->colorCurveA);
}
if(dynamic_cast<SceneSprite*>(entity)) {
if(!(*(entry))["type"])
entry->addChild("type", "SceneSprite");
SceneSprite *sprite = (SceneSprite*) entity;
ObjectEntry *spriteEntry = entry->addChild("SceneSprite");
spriteEntry->addChild("sprite_set", sprite->getSpriteSet()->getName());
spriteEntry->addChild("sprite", sprite->getCurrentSprite()->getName());
spriteEntry->addChild("random_frame", sprite->getStartOnRandomFrame());
String animName = "";
if(sprite->getCurrentSpriteState()) {
animName = sprite->getCurrentSpriteState()->getName();
}
spriteEntry->addChild("state", animName);
}
if(dynamic_cast<SceneCurve*>(entity)) {
SceneCurve *curve = (SceneCurve*) entity;
if(!(*(entry))["type"])
entry->addChild("type", "SceneCurve");
ObjectEntry *curveEntry = entry->addChild("SceneCurve");
curveEntry->addChild("render", curve->renderCurve);
curveEntry->addChild("resolution", curve->curveResolution);
saveCurveToObject(curveEntry->addChild("curve"), curve->getCurve());
}
if(dynamic_cast<SceneLabel*>(entity)) {
SceneLabel *label = (SceneLabel*) entity;
if(!(*(entry))["type"])
entry->addChild("type", "SceneLabel");
ObjectEntry *labelEntry = entry->addChild("SceneLabel");
labelEntry->addChild("text", label->getText());
labelEntry->addChild("font", label->getLabel()->getFont()->getFontName());
labelEntry->addChild("size", (Number)label->getLabel()->getSize());
labelEntry->addChild("actualHeight", label->getLabelActualHeight());
labelEntry->addChild("aaMode", (int)label->getLabel()->getAntialiasMode());
}
if(dynamic_cast<SceneLight*>(entity)) {
SceneLight *light = (SceneLight*) entity;
if(!(*(entry))["type"]) {
entry->addChild("type", "SceneLight");
}
ObjectEntry *lightEntry = entry->addChild("SceneLight");
lightEntry->addChild("type", light->getType());
LightInfo lightInfo = light->getLightInfo();
lightEntry->addChild("cR", lightInfo.diffuseColor.r);
lightEntry->addChild("cG", lightInfo.diffuseColor.g);
lightEntry->addChild("cB", lightInfo.diffuseColor.b);
lightEntry->addChild("cA", lightInfo.diffuseColor.a);
lightEntry->addChild("scR", lightInfo.specularColor.r);
lightEntry->addChild("scG", lightInfo.specularColor.g);
lightEntry->addChild("scB", lightInfo.specularColor.b);
lightEntry->addChild("scA", lightInfo.specularColor.a);
lightEntry->addChild("intensity", light->getIntensity());
lightEntry->addChild("importance", light->getLightImportance());
lightEntry->addChild("cAtt", light->getConstantAttenuation());
lightEntry->addChild("lAtt", light->getLinearAttenuation());
lightEntry->addChild("qAtt", light->getQuadraticAttenuation());
if(light->getType() == SceneLight::SPOT_LIGHT) {
lightEntry->addChild("spotCutoff", light->getSpotlightCutoff());
lightEntry->addChild("spotExponent", light->getSpotlightExponent());
lightEntry->addChild("shadows", light->areShadowsEnabled());
if(light->areShadowsEnabled()) {
lightEntry->addChild("shadowmapFOV", light->getShadowMapFOV());
lightEntry->addChild("shadowmapRes", (int)light->getShadowMapResolution());
}
}
}
if(dynamic_cast<SceneSound*>(entity)) {
SceneSound *sound = (SceneSound*) entity;
if(!(*(entry))["type"]) {
entry->addChild("type", "SceneSound");
}
ObjectEntry *soundEntry = entry->addChild("SceneSound");
soundEntry->addChild("filePath", sound->getSound()->getFileName());
soundEntry->addChild("refDistance", sound->getSound()->getReferenceDistance());
soundEntry->addChild("maxDistance", sound->getSound()->getMaxDistance());
soundEntry->addChild("volume", sound->getSound()->getVolume());
soundEntry->addChild("pitch", sound->getSound()->getPitch());
soundEntry->addChild("loopOnLoad", sound->getLoopOnLoad());
}
if(dynamic_cast<Camera*>(entity)) {
Camera *camera = (Camera*) entity;
if(!(*(entry))["type"]) {
entry->addChild("type", "Camera");
}
ObjectEntry *cameraEntry = entry->addChild("Camera");
//cameraEntry->addChild("exposure", camera->getExposureLevel());
cameraEntry->addChild("nearClip", camera->getNearClippingPlane());
cameraEntry->addChild("farClip", camera->getFarClippingPlane());
cameraEntry->addChild("ortho", camera->getOrthoMode());
if(camera->getOrthoMode()) {
cameraEntry->addChild("sizeMode", camera->getOrthoSizeMode());
cameraEntry->addChild("orthoWidth", camera->getOrthoSizeX());
cameraEntry->addChild("orthoHeight", camera->getOrthoSizeY());
} else {
cameraEntry->addChild("fov", camera->getFOV());
}
}
if(dynamic_cast<ScenePrimitive*>(entity) && !dynamic_cast<SceneSprite*>(entity) && !dynamic_cast<SceneLabel*>(entity)) {
if(!(*(entry))["type"]) {
entry->addChild("type", "ScenePrimitive");
}
ScenePrimitive *primitive = (ScenePrimitive*) entity;
ObjectEntry *primitiveEntry = entry->addChild("ScenePrimitive");
primitiveEntry->addChild("type", primitive->getPrimitiveType());
primitiveEntry->addChild("p1", primitive->getPrimitiveParameter1());
primitiveEntry->addChild("p2", primitive->getPrimitiveParameter2());
primitiveEntry->addChild("p3", primitive->getPrimitiveParameter3());
primitiveEntry->addChild("p4", primitive->getPrimitiveParameter4());
primitiveEntry->addChild("p5", primitive->getPrimitiveParameter5());
}
if(dynamic_cast<SceneMesh*>(entity)) {
if(!(*(entry))["type"]) {
entry->addChild("type", "SceneMesh");
}
SceneMesh *sceneMesh = (SceneMesh*) entity;
ObjectEntry *meshEntry = entry->addChild("SceneMesh");
if(sceneMesh->getFilename() != "") {
meshEntry->addChild("file", sceneMesh->getFilename().replace(parentProject->getRootFolder()+"/", ""));
}
meshEntry->addChild("backfaceCulled", sceneMesh->backfaceCulled);
meshEntry->addChild("sendBoneMatricesToMaterial", sceneMesh->sendBoneMatricesToMaterial);
if(sceneMesh->getMaterial()) {
meshEntry->addChild("material", sceneMesh->getMaterial()->getResourceName());
ObjectEntry *shaderOptions = meshEntry->addChild("shader_options");
// RENDERER_TODO
saveShaderOptionsToEntry(shaderOptions, &*sceneMesh->getMaterial(), &*sceneMesh->getShaderPass(0).shaderBinding);
}
}
if(!(*(entry))["type"])
entry->addChild("type", "Entity");
entry->addChild("cR", entity->color.r);
entry->addChild("cG", entity->color.g);
entry->addChild("cB", entity->color.b);
entry->addChild("cA", entity->color.a);
entry->addChild("blendMode", (int)entity->getBlendingMode());
entry->addChild("sX", entity->getScale().x);
entry->addChild("sY", entity->getScale().y);
entry->addChild("sZ", entity->getScale().z);
entry->addChild("rX", entity->getRotationQuat().x);
entry->addChild("rY", entity->getRotationQuat().y);
entry->addChild("rZ", entity->getRotationQuat().z);
entry->addChild("rW", entity->getRotationQuat().w);
entry->addChild("pX", entity->getPosition().x);
entry->addChild("pY", entity->getPosition().y);
entry->addChild("pZ", entity->getPosition().z);
entry->addChild("bbX", entity->getLocalBoundingBox().x);
entry->addChild("bbY", entity->getLocalBoundingBox().y);
entry->addChild("bbZ", entity->getLocalBoundingBox().z);
ObjectEntry *children = NULL;
for(int i=0; i < entity->getNumChildren(); i++) {
if(!entity->getChildAtIndex(i)->editorOnly) {
if(!children)
children = entry->addChild("children");
ObjectEntry *child = children->addChild("child");
saveEntityToObjectEntry((ScreenEntity*)entity->getChildAtIndex(i), child);
}
}
}
void PolycodeEntityEditor::saveShaderOptionsToEntry(ObjectEntry *entry, Material *material, ShaderBinding *binding) {
if(material->getNumShaderPasses() > 0) {
for(int s=0; s < material->getNumShaderPasses(); s++) {
Shader *shader = &*material->getShader(s);
ObjectEntry *shaderEntry = entry->addChild("shader");
if(shader->expectedParams.size() > 0 || shader->expectedParams.size() > 0) {
ObjectEntry *paramsEntry = shaderEntry->addChild("params");
for(int j=0; j < shader->expectedParams.size(); j++) {
if(binding->getLocalParamByName(shader->expectedParams[j].name)) {
ObjectEntry *paramEntry = paramsEntry->addChild("param");
paramEntry->addChild("name", shader->expectedParams[j].name);
paramEntry->addChild("value", PolycodeMaterialEditor::createStringValue(binding->getLocalParamByName(shader->expectedParams[j].name)));
}
}
}
}
}
}
String PolycodeEntityEditor::Copy(void **data) {
std::vector<Entity*> selectedEntities = mainView->getSelectedEntities();
if(selectedEntities.size() > 0) {
EntityEditorClipboardData *newData = new EntityEditorClipboardData();
for(int i=0; i < selectedEntities.size(); i++) {
ScreenEntity *clone = (ScreenEntity*)selectedEntities[i]->Clone(true, true);
newData->entities.push_back(clone);
}
*data = (void*) newData;
}
return "Entity";
}
void PolycodeEntityEditor::destroyClipboardData(void *data, String type) {
if(type == "Entity") {
EntityEditorClipboardData *oldData = (EntityEditorClipboardData*) data;
for(int i=0; i < oldData->entities.size(); i++) {
delete oldData->entities[i];
}
delete oldData;
}
}
void PolycodeEntityEditor::selectAll() {
if(mainView->hasFocus) {
mainView->selectAll(true);
}
}
void PolycodeEntityEditor::Paste(void *data, String clipboardType) {
if(!data) {
return;
}
if(clipboardType == "Entity") {
mainView->Paste((EntityEditorClipboardData*)data);
}
}
void PolycodeEntityEditor::Render(GPUDrawBuffer *buffer) {
mainView->getRenderTexture()->Render(buffer->renderFrame, mainView->getMainScene(), mainView->getMainScene()->getDefaultCamera());
}
void PolycodeEntityEditor::saveFile() {
Object saveObject;
ObjectEntry *settings = saveObject.root.addChild("settings");
ObjectEntry *linkedMaterialFiles = settings->addChild("linkedResourcePools");
for(int i=0; i < loadedInstance->getNumLinkedResourePools(); i++) {
ResourcePool *pool = loadedInstance->getLinkedResourcePoolAtIndex(i);
linkedMaterialFiles->addChild("resourcePool")->addChild("path", pool->getName());
}
ObjectEntry *layersEntry = settings->addChild("layers");
for(int i=0; i < loadedInstance->getNumLayers(); i++) {
SceneEntityInstanceLayer *layer = loadedInstance->getLayerAtIndex(i);
if(layer->layerID != 0) {
ObjectEntry *layerEntry = layersEntry->addChild("layer");
layerEntry->addChild("name", layer->name);
layerEntry->addChild("id", layer->layerID);
layerEntry->addChild("visible", layer->visible);
}
}
saveObject.root.name = "entity";
saveObject.root.addChild("version", 2);
ObjectEntry *children = saveObject.root.addChild("root");
saveEntityToObjectEntry(mainView->getObjectRoot(), children);
saveObject.saveToXML(core, filePath);
setHasChanges(false);
}
void PolycodeEntityEditor::Resize(int x, int y) {
mainSizer->Resize(x, y);
PolycodeEditor::Resize(x,y);
}
| 33.365362 | 221 | 0.726009 | [
"mesh",
"geometry",
"render",
"object",
"vector",
"transform"
] |
82d05c05842e596d681514b73d8bf93803cb0d8d | 1,831 | cpp | C++ | cpp/test/jsoncpp_test.cpp | walterfan/snippets | 62f87720c411093fcff888f25b338afd1d99a6f9 | [
"Apache-2.0"
] | 1 | 2021-06-18T09:31:59.000Z | 2021-06-18T09:31:59.000Z | cpp/test/jsoncpp_test.cpp | walterfan/snippets | 62f87720c411093fcff888f25b338afd1d99a6f9 | [
"Apache-2.0"
] | 10 | 2020-12-12T08:12:06.000Z | 2022-03-02T06:54:10.000Z | cpp/test/jsoncpp_test.cpp | walterfan/snippets | 62f87720c411093fcff888f25b338afd1d99a6f9 | [
"Apache-2.0"
] | null | null | null | #include <fstream>
#include <iostream>
#include <vector>
#include "gtest/gtest.h"
#include "json/json.h"
#include "TestCase.h"
using namespace std;
using namespace testing;
struct User {
User(string strName, string strEmail, int nAge): name(strName), email(strEmail), age(nAge)
{}
string name;
string email;
int age;
Json::Value toJson() {
Json::Value root;
root["name"] = name;
root["email"] = email;
root["age"] = age;
return root;
}
};
TEST(JsonCppTest, VectorToJson)
{
cout<<"--- JsonCppTest.VectorToJson --"<<endl;
vector<User> users;
users.push_back(User("ff", "ff@sina.com" ,3 ));
users.push_back(User("xx", "xx@sina.com" ,10 ));
Json::Value root;
Json::Value arr;
arr.append(users[0].toJson());
arr.append(users[1].toJson());
root["users"] = arr;
cout<< root <<endl;
}
TEST(JsonCppTest, JsonFileRead)
{
cout<<"--- JsonCppTest.JsonFileRead --"<<endl;
Json::Value root;
std::ifstream json_file("./dat/login_test_cases.json", std::ifstream::binary);
json_file >> root;
Json::Value jsonSuites = root["testsuites"];
//cout<< jsonSuites <<endl;
int nSuiteCount = jsonSuites.size();
ASSERT_TRUE(nSuiteCount > 0);
Json::Value jsonSuite = jsonSuites[0];
EXPECT_EQ(jsonSuite.get("name", "").asString(), "login_module_test") << "test suite name is not login_module_test ";
const Json::Value jsonCases = jsonSuite["testcases"];
int nCaseCount = jsonCases.size();
ASSERT_TRUE(nCaseCount > 0);
for ( int i = 0; i < nCaseCount; ++i ) {
Json::Value jsonCase = jsonCases[i];
cout<< jsonCase <<endl;
EXPECT_EQ(jsonCase["feature"].asString(), "login") << "feature is not login ";
}
}
| 23.779221 | 120 | 0.601311 | [
"vector"
] |
82dc8ebbad9776d89ed9965743f9678226bb6762 | 4,661 | cpp | C++ | src/onnx/mnist.cpp | turneram/AMDMIGraphX | 48fa934d180cda7b6764b21465e203e39ca1cab3 | [
"MIT"
] | null | null | null | src/onnx/mnist.cpp | turneram/AMDMIGraphX | 48fa934d180cda7b6764b21465e203e39ca1cab3 | [
"MIT"
] | null | null | null | src/onnx/mnist.cpp | turneram/AMDMIGraphX | 48fa934d180cda7b6764b21465e203e39ca1cab3 | [
"MIT"
] | null | null | null | #include <cstdio>
#include <string>
#include <fstream>
#include <numeric>
#include <stdexcept>
#include <migraphx/onnx.hpp>
#include <migraphx/gpu/target.hpp>
#include <migraphx/gpu/hip.hpp>
#include <migraphx/generate.hpp>
#include "softmax.hpp"
auto reverse_int(unsigned int i)
{
unsigned char c1;
unsigned char c2;
unsigned char c3;
unsigned char c4;
c1 = i & 255u;
c2 = (i >> 8u) & 255u;
c3 = (i >> 16u) & 255u;
c4 = (i >> 24u) & 255u;
return (static_cast<unsigned int>(c1) << 24u) + (static_cast<unsigned int>(c2) << 16u) +
(static_cast<unsigned int>(c3) << 8u) + c4;
};
std::vector<float>
read_mnist_images(const std::string& full_path, int& number_of_images, int& image_size)
{
using uchar = unsigned char;
std::ifstream file(full_path, std::ios::binary);
if(file.is_open())
{
int magic_number = 0;
int n_rows = 0;
int n_cols = 0;
file.read(reinterpret_cast<char*>(&magic_number), sizeof(magic_number));
magic_number = reverse_int(magic_number);
if(magic_number != 2051)
throw std::runtime_error("Invalid MNIST image file!");
file.read(reinterpret_cast<char*>(&number_of_images), sizeof(number_of_images));
number_of_images = reverse_int(number_of_images);
file.read(reinterpret_cast<char*>(&n_rows), sizeof(n_rows));
n_rows = reverse_int(n_rows);
file.read(reinterpret_cast<char*>(&n_cols), sizeof(n_cols));
n_cols = reverse_int(n_cols);
image_size = n_rows * n_cols;
std::vector<float> result(number_of_images * image_size);
for(int i = 0; i < number_of_images; i++)
{
for(int j = 0; j < image_size; j++)
{
uchar tmp;
file.read(reinterpret_cast<char*>(&tmp), 1);
result[i * image_size + j] = tmp / 255.0;
}
}
return result;
}
else
{
throw std::runtime_error("Cannot open file `" + full_path + "`!");
}
}
std::vector<int32_t> read_mnist_labels(const std::string& full_path, int& number_of_labels)
{
using uchar = unsigned char;
std::ifstream file(full_path, std::ios::binary);
if(file.is_open())
{
int magic_number = 0;
file.read(reinterpret_cast<char*>(&magic_number), sizeof(magic_number));
magic_number = reverse_int(magic_number);
if(magic_number != 2049)
throw std::runtime_error("Invalid MNIST label file!");
file.read(reinterpret_cast<char*>(&number_of_labels), sizeof(number_of_labels));
number_of_labels = reverse_int(number_of_labels);
std::vector<int32_t> result(number_of_labels);
for(int i = 0; i < number_of_labels; i++)
{
uchar tmp;
file.read(reinterpret_cast<char*>(&tmp), 1);
result[i] = tmp;
}
return result;
}
else
{
throw std::runtime_error("Unable to open file `" + full_path + "`!");
}
}
int main(int argc, char const* argv[])
{
if(argc > 3)
{
std::string datafile = argv[2];
std::string labelfile = argv[3];
int nimages = -1;
int image_size = -1;
int nlabels = -1;
std::vector<float> input = read_mnist_images(datafile, nimages, image_size);
std::vector<int32_t> labels = read_mnist_labels(labelfile, nlabels);
std::string file = argv[1];
auto prog = migraphx::parse_onnx(file);
std::cout << prog << std::endl << std::endl;
prog.compile(migraphx::gpu::target{});
auto s = migraphx::shape{migraphx::shape::float_type, {1, 1, 28, 28}};
std::cout << s << std::endl;
auto ptr = input.data();
migraphx::program::parameter_map m;
m["output"] =
migraphx::gpu::to_gpu(migraphx::generate_argument(prog.get_parameter_shape("output")));
for(int i = 0; i < 20; i++)
{
std::cout << "label: " << labels[i] << " ----> ";
m["0"] = migraphx::gpu::to_gpu(migraphx::argument{s, &ptr[784 * i]});
auto results = prog.eval(m).back();
auto result = migraphx::gpu::from_gpu(results);
std::vector<float> logits;
result.visit([&](auto output) { logits.assign(output.begin(), output.end()); });
std::vector<float> probs = softmax(logits);
for(auto x : probs)
std::cout << x << " ";
std::cout << std::endl;
}
std::cout << std::endl;
}
}
| 31.924658 | 99 | 0.564257 | [
"shape",
"vector"
] |
82defc74f69bcd2f6822bdb5416b8de591658a84 | 6,503 | cpp | C++ | src/libraries/turbulenceModels/compressible/RAS/RASModel/compressibleRASModel.cpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | src/libraries/turbulenceModels/compressible/RAS/RASModel/compressibleRASModel.cpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | src/libraries/turbulenceModels/compressible/RAS/RASModel/compressibleRASModel.cpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | /*---------------------------------------------------------------------------*\
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2014 Applied CCM
-------------------------------------------------------------------------------
License
This file is part of CAELUS.
CAELUS 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.
CAELUS 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 CAELUS. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "compressibleRASModel.hpp"
#include "wallFvPatch.hpp"
#include "addToRunTimeSelectionTable.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef windows
// Symbol to force loading at runtime
extern "C"
void compressibleRASModelsLoad()
{}
#endif
namespace CML
{
namespace compressible
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(RASModel, 0);
defineRunTimeSelectionTable(RASModel, dictionary);
addToRunTimeSelectionTable(turbulenceModel, RASModel, turbulenceModel);
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void RASModel::printCoeffs()
{
if (printCoeffs_)
{
Info<< type() << "Coeffs" << coeffDict_ << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
RASModel::RASModel
(
const word& type,
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& phi,
const fluidThermo& thermophysicalModel,
const word& turbulenceModelName
)
:
turbulenceModel(rho, U, phi, thermophysicalModel, turbulenceModelName),
IOdictionary
(
IOobject
(
"RASProperties",
U.time().constant(),
U.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
turbulence_(lookup("turbulence")),
printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
coeffDict_(subOrEmptyDict(type + "Coeffs")),
kMin_("kMin", sqr(dimVelocity), SMALL),
epsilonMin_("epsilonMin", kMin_.dimensions()/dimTime, SMALL),
omegaMin_("omegaMin", dimless/dimTime, SMALL),
y_(mesh_)
{
kMin_.readIfPresent(*this);
epsilonMin_.readIfPresent(*this);
omegaMin_.readIfPresent(*this);
// Force the construction of the mesh deltaCoeffs which may be needed
// for the construction of the derived models and BCs
mesh_.deltaCoeffs();
}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
autoPtr<RASModel> RASModel::New
(
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& phi,
const fluidThermo& thermophysicalModel,
const word& turbulenceModelName
)
{
// get model name, but do not register the dictionary
// otherwise it is registered in the database twice
const word modelType
(
IOdictionary
(
IOobject
(
"RASProperties",
U.time().constant(),
U.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
).lookup("RASModel")
);
Info<< "Selecting RAS turbulence model " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown RASModel type "
<< modelType << nl << nl
<< "Valid RASModel types:" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<RASModel>
(
cstrIter()(rho, U, phi, thermophysicalModel, turbulenceModelName)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
{
scalar ypl = 11.0;
for (int i=0; i<10; i++)
{
ypl = log(max(E*ypl, 1))/kappa;
}
return ypl;
}
tmp<scalarField> RASModel::yPlus(const label patchNo, const scalar Cmu) const
{
const fvPatch& curPatch = mesh_.boundary()[patchNo];
tmp<scalarField> tYp(new scalarField(curPatch.size()));
scalarField& Yp = tYp();
if (isA<wallFvPatch>(curPatch))
{
Yp = pow025(Cmu)
*y_[patchNo]
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
/(
mu().boundaryField()[patchNo].patchInternalField()
/rho_.boundaryField()[patchNo]
);
}
else
{
WarningInFunction
<< "Patch " << patchNo << " is not a wall. Returning null field"
<< nl << endl;
Yp.setSize(0);
}
return tYp;
}
void RASModel::correct()
{
if (mesh_.changing())
{
y_.correct();
}
}
bool RASModel::read()
{
//if (regIOobject::read())
// Bit of trickery : we are both IOdictionary ('RASProperties') and
// an regIOobject from the turbulenceModel level. Problem is to distinguish
// between the two - we only want to reread the IOdictionary.
bool ok = IOdictionary::readData
(
IOdictionary::readStream
(
IOdictionary::type()
)
);
IOdictionary::close();
if (ok)
{
lookup("turbulence") >> turbulence_;
if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
{
coeffDict_ <<= *dictPtr;
}
kMin_.readIfPresent(*this);
epsilonMin_.readIfPresent(*this);
omegaMin_.readIfPresent(*this);
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace compressible
} // End namespace CML
// ************************************************************************* //
| 25.602362 | 79 | 0.549439 | [
"mesh",
"model"
] |
82dfea23fc59fb81b6e225382ab7c00f6a656851 | 77,671 | cxx | C++ | main/unotools/source/config/moduleoptions.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 679 | 2015-01-06T06:34:58.000Z | 2022-03-30T01:06:03.000Z | main/unotools/source/config/moduleoptions.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 102 | 2017-11-07T08:51:31.000Z | 2022-03-17T12:13:49.000Z | main/unotools/source/config/moduleoptions.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 331 | 2015-01-06T11:40:55.000Z | 2022-03-14T04:07:51.000Z | /**************************************************************
*
* 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.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_unotools.hxx"
#ifndef GCC
#endif
//_________________________________________________________________________________________________________________
// includes
//_________________________________________________________________________________________________________________
#include <unotools/moduleoptions.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/configitem.hxx>
#include <unotools/processfactory.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <rtl/logfile.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/document/XTypeDetection.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include "itemholder1.hxx"
//_________________________________________________________________________________________________________________
// namespaces
//_________________________________________________________________________________________________________________
#ifndef css
namespace css = ::com::sun::star;
#endif
//_________________________________________________________________________________________________________________
// const
//_________________________________________________________________________________________________________________
/*-************************************************************************************************************//**
@descr These values are used to define necessary keys from our configuration management to support
all functionality of these implementation.
It's a fast way to make changes if some keys change his name or location!
Property handle are necessary to specify right position in return list of configuration
for asked values. We ask it with a list of properties to get his values. The returned list
has the same order like our given name list!
e.g.:
NAMELIST[ PROPERTYHANDLE_xxx ] => VALUELIST[ PROPERTYHANDLE_xxx ]
*//*-*************************************************************************************************************/
#define ROOTNODE_FACTORIES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/Office/Factories" ))
#define PATHSEPERATOR ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
// Attention: The property "ooSetupFactoryEmptyDocumentURL" is read from configuration but not used! There is
// special code that uses hard coded strings to return them.
#define PROPERTYNAME_SHORTNAME ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryShortName" ))
#define PROPERTYNAME_TEMPLATEFILE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryTemplateFile" ))
#define PROPERTYNAME_WINDOWATTRIBUTES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryWindowAttributes"))
#define PROPERTYNAME_EMPTYDOCUMENTURL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryEmptyDocumentURL"))
#define PROPERTYNAME_DEFAULTFILTER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryDefaultFilter" ))
#define PROPERTYNAME_ICON ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryIcon" ))
#define PROPERTYHANDLE_SHORTNAME 0
#define PROPERTYHANDLE_TEMPLATEFILE 1
#define PROPERTYHANDLE_WINDOWATTRIBUTES 2
#define PROPERTYHANDLE_EMPTYDOCUMENTURL 3
#define PROPERTYHANDLE_DEFAULTFILTER 4
#define PROPERTYHANDLE_ICON 5
#define PROPERTYCOUNT 6
#define FACTORYNAME_WRITER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ))
#define FACTORYNAME_WRITERWEB ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.WebDocument" ))
#define FACTORYNAME_WRITERGLOBAL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GlobalDocument" ))
#define FACTORYNAME_CALC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ))
#define FACTORYNAME_DRAW ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument" ))
#define FACTORYNAME_IMPRESS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"))
#define FACTORYNAME_MATH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.formula.FormulaProperties" ))
#define FACTORYNAME_CHART ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.ChartDocument" ))
#define FACTORYNAME_DATABASE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument" ))
#define FACTORYNAME_STARTMODULE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule" ))
#define FACTORYCOUNT 10
/*-************************************************************************************************************//**
@descr This struct hold information about one factory. We declare a complete array which can hold infos
for all well known factories. Values of enum "EFactory" (see header!) are directly used as index!
So we can support a fast access on these informations.
*//*-*************************************************************************************************************/
struct FactoryInfo
{
public:
//---------------------------------------------------------------------------------------------------------
// initialize empty struct
FactoryInfo()
{
free();
// @@@ should be supplied from outside!
xSMgr = ::utl::getProcessServiceFactory();
}
//---------------------------------------------------------------------------------------------------------
// easy way to reset struct member!
void free()
{
bInstalled = sal_False ;
sFactory = ::rtl::OUString() ;
sShortName = ::rtl::OUString() ;
sTemplateFile = ::rtl::OUString() ;
sWindowAttributes = ::rtl::OUString() ;
sEmptyDocumentURL = ::rtl::OUString() ;
sDefaultFilter = ::rtl::OUString() ;
nIcon = 0 ;
bChangedTemplateFile = sal_False ;
bChangedWindowAttributes = sal_False ;
bChangedEmptyDocumentURL = sal_False ;
bChangedDefaultFilter = sal_False ;
bChangedIcon = sal_False ;
bDefaultFilterReadonly = sal_False ;
}
//---------------------------------------------------------------------------------------------------------
// returns list of properties, which has changed only!
// We use given value of sNodeBase to build full qualified pathes ...
// Last sign of it must be "/". Because we use it directly, without any additional things!
css::uno::Sequence< css::beans::PropertyValue > getChangedProperties( const ::rtl::OUString& sNodeBase )
{
// a) reserve memory for max. count of changed properties
// b) add names and values of changed ones only and count it
// c) resize return list by using count
css::uno::Sequence< css::beans::PropertyValue > lProperties ( 4 );
sal_Int8 nRealyChanged = 0 ;
if( bChangedTemplateFile == sal_True )
{
lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_TEMPLATEFILE;
if ( sTemplateFile.getLength() > 0 )
{
lProperties[nRealyChanged].Value
<<= getStringSubstitution()
->reSubstituteVariables( sTemplateFile );
}
else
{
lProperties[nRealyChanged].Value <<= sTemplateFile;
}
++nRealyChanged;
}
if( bChangedWindowAttributes == sal_True )
{
lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_WINDOWATTRIBUTES;
lProperties[nRealyChanged].Value <<= sWindowAttributes;
++nRealyChanged;
}
if( bChangedEmptyDocumentURL == sal_True )
{
lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_EMPTYDOCUMENTURL;
lProperties[nRealyChanged].Value <<= sEmptyDocumentURL;
++nRealyChanged;
}
if( bChangedDefaultFilter == sal_True )
{
lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_DEFAULTFILTER;
lProperties[nRealyChanged].Value <<= sDefaultFilter;
++nRealyChanged;
}
if( bChangedIcon == sal_True )
{
lProperties[nRealyChanged].Name = sNodeBase + PROPERTYNAME_ICON;
lProperties[nRealyChanged].Value <<= nIcon;
++nRealyChanged;
}
// Don't forget to reset changed flags! Otherwise we save it again and again and ...
bChangedTemplateFile = sal_False ;
bChangedWindowAttributes = sal_False ;
bChangedEmptyDocumentURL = sal_False ;
bChangedDefaultFilter = sal_False ;
bChangedIcon = sal_False ;
lProperties.realloc( nRealyChanged );
return lProperties;
}
//---------------------------------------------------------------------------------------------------------
// We must support setting AND marking of changed values.
// That's why we can't make our member public. We must use get/set/init methods
// to control access on it!
sal_Bool getInstalled () const { return bInstalled; };
::rtl::OUString getFactory () const { return sFactory; };
::rtl::OUString getShortName () const { return sShortName; };
::rtl::OUString getTemplateFile () const { return sTemplateFile; };
::rtl::OUString getWindowAttributes () const { return sWindowAttributes; };
::rtl::OUString getEmptyDocumentURL () const { return sEmptyDocumentURL; };
::rtl::OUString getDefaultFilter () const { return sDefaultFilter; };
sal_Bool isDefaultFilterReadonly() const { return bDefaultFilterReadonly; }
sal_Int32 getIcon () const { return nIcon; };
//---------------------------------------------------------------------------------------------------------
// If you call set-methods - we check for changes of valkues and mark it.
// But if you whish to set it without that ... you must initialize it!
void initInstalled ( sal_Bool bNewInstalled ) { bInstalled = bNewInstalled ; }
void initFactory ( const ::rtl::OUString& sNewFactory ) { sFactory = sNewFactory ; }
void initShortName ( const ::rtl::OUString& sNewShortName ) { sShortName = sNewShortName ; }
void initWindowAttributes ( const ::rtl::OUString& sNewWindowAttributes ) { sWindowAttributes = sNewWindowAttributes ; }
void initEmptyDocumentURL ( const ::rtl::OUString& sNewEmptyDocumentURL ) { sEmptyDocumentURL = sNewEmptyDocumentURL ; }
void initDefaultFilter ( const ::rtl::OUString& sNewDefaultFilter ) { sDefaultFilter = sNewDefaultFilter ; }
void setDefaultFilterReadonly( const sal_Bool bVal){bDefaultFilterReadonly = bVal;}
void initIcon ( sal_Int32 nNewIcon ) { nIcon = nNewIcon ; }
//---------------------------------------------------------------------------------------------------------
void initTemplateFile( const ::rtl::OUString& sNewTemplateFile )
{
if ( sNewTemplateFile.getLength() > 0 )
{
sTemplateFile
= getStringSubstitution()
->substituteVariables( sNewTemplateFile, sal_False );
}
else
{
sTemplateFile = sNewTemplateFile;
}
}
//---------------------------------------------------------------------------------------------------------
void setInstalled( sal_Bool bNewInstalled )
{
bInstalled = bNewInstalled;
};
//---------------------------------------------------------------------------------------------------------
void setFactory( const ::rtl::OUString& sNewFactory )
{
sFactory = sNewFactory;
};
//---------------------------------------------------------------------------------------------------------
void setShortName( const ::rtl::OUString& sNewShortName )
{
sShortName = sNewShortName;
};
//---------------------------------------------------------------------------------------------------------
void setTemplateFile( const ::rtl::OUString& sNewTemplateFile )
{
if( sTemplateFile != sNewTemplateFile )
{
sTemplateFile = sNewTemplateFile;
bChangedTemplateFile = sal_True ;
}
};
//---------------------------------------------------------------------------------------------------------
void setWindowAttributes( const ::rtl::OUString& sNewWindowAttributes )
{
if( sWindowAttributes != sNewWindowAttributes )
{
sWindowAttributes = sNewWindowAttributes;
bChangedWindowAttributes = sal_True ;
}
};
//---------------------------------------------------------------------------------------------------------
void setEmptyDocumentURL( const ::rtl::OUString& sNewEmptyDocumentURL )
{
if( sEmptyDocumentURL != sNewEmptyDocumentURL )
{
sEmptyDocumentURL = sNewEmptyDocumentURL;
bChangedEmptyDocumentURL = sal_True ;
}
};
//---------------------------------------------------------------------------------------------------------
void setDefaultFilter( const ::rtl::OUString& sNewDefaultFilter )
{
if( sDefaultFilter != sNewDefaultFilter )
{
sDefaultFilter = sNewDefaultFilter;
bChangedDefaultFilter = sal_True ;
}
};
//---------------------------------------------------------------------------------------------------------
void setIcon( sal_Int32 nNewIcon )
{
if( nIcon != nNewIcon )
{
nIcon = nNewIcon;
bChangedIcon = sal_True;
}
};
private:
css::uno::Reference< css::util::XStringSubstitution > getStringSubstitution()
{
if ( !xSubstVars.is() )
{
xSubstVars
= css::uno::Reference< css::util::XStringSubstitution >(
xSMgr->createInstance(
::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.util.PathSubstitution" ) ) ),
css::uno::UNO_QUERY );
if ( !xSubstVars.is() )
throw css::uno::RuntimeException(
::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"Cannot instanciate service "
"com.sun.star.util.PathSubstitution" ) ),
css::uno::Reference< css::uno::XInterface >() );
}
return xSubstVars;
}
sal_Bool bInstalled ;
::rtl::OUString sFactory ;
::rtl::OUString sShortName ;
::rtl::OUString sTemplateFile ;
::rtl::OUString sWindowAttributes ;
::rtl::OUString sEmptyDocumentURL ;
::rtl::OUString sDefaultFilter ;
sal_Int32 nIcon ;
sal_Bool bChangedTemplateFile :1 ;
sal_Bool bChangedWindowAttributes :1 ;
sal_Bool bChangedEmptyDocumentURL :1 ;
sal_Bool bChangedDefaultFilter :1 ;
sal_Bool bChangedIcon :1 ;
sal_Bool bDefaultFilterReadonly :1 ;
css::uno::Reference< css::lang::XMultiServiceFactory > xSMgr;
css::uno::Reference< css::util::XStringSubstitution > xSubstVars;
};
typedef FactoryInfo FactoryInfoList[FACTORYCOUNT];
/*-************************************************************************************************************//**
@short IMPL data container for wrapper class SvtModulOptions!
@descr These class is used as a static data container of class SvtModuleOptions. The hold it by using
a refcount and make it threadsafe by using an osl mutex. So we don't must do anything for that.
We can implement pure functionality to read/write configuration data only.
@implements -
@base ConfigItem
@devstatus ready to use
@threadsafe no
*//*-*************************************************************************************************************/
class SvtModuleOptions_Impl : public ::utl::ConfigItem
{
//-------------------------------------------------------------------------------------------------------------
// public methods
//-------------------------------------------------------------------------------------------------------------
public:
//---------------------------------------------------------------------------------------------------------
// constructor / destructor
//---------------------------------------------------------------------------------------------------------
SvtModuleOptions_Impl(SvtModuleOptions* pOutsideClass);
~SvtModuleOptions_Impl();
//---------------------------------------------------------------------------------------------------------
// overloaded methods of baseclass
//---------------------------------------------------------------------------------------------------------
virtual void Notify( const css::uno::Sequence< ::rtl::OUString >& lPropertyNames );
virtual void Commit( );
//---------------------------------------------------------------------------------------------------------
// public interface
//---------------------------------------------------------------------------------------------------------
sal_Bool IsModuleInstalled ( SvtModuleOptions::EModule eModule ) const;
::com::sun::star::uno::Sequence < ::rtl::OUString > GetAllServiceNames();
::rtl::OUString GetFactoryName ( SvtModuleOptions::EFactory eFactory ) const;
::rtl::OUString GetFactoryShortName ( SvtModuleOptions::EFactory eFactory ) const;
::rtl::OUString GetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ) const;
::rtl::OUString GetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ) const;
::rtl::OUString GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory eFactory ) const;
::rtl::OUString GetFactoryDefaultFilter ( SvtModuleOptions::EFactory eFactory ) const;
sal_Bool IsDefaultFilterReadonly( SvtModuleOptions::EFactory eFactory ) const;
sal_Int32 GetFactoryIcon ( SvtModuleOptions::EFactory eFactory ) const;
static sal_Bool ClassifyFactoryByName ( const ::rtl::OUString& sName ,
SvtModuleOptions::EFactory& eFactory );
void SetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ,
const ::rtl::OUString& sTemplate );
void SetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ,
const ::rtl::OUString& sAttributes);
void SetFactoryDefaultFilter ( SvtModuleOptions::EFactory eFactory ,
const ::rtl::OUString& sFilter );
void MakeReadonlyStatesAvailable();
//-------------------------------------------------------------------------------------------------------------
// private methods
//-------------------------------------------------------------------------------------------------------------
private:
static css::uno::Sequence< ::rtl::OUString > impl_ExpandSetNames ( const css::uno::Sequence< ::rtl::OUString >& lSetNames );
void impl_Read ( const css::uno::Sequence< ::rtl::OUString >& lSetNames );
//-------------------------------------------------------------------------------------------------------------
// private types
//-------------------------------------------------------------------------------------------------------------
private:
//-------------------------------------------------------------------------------------------------------------
// private member
//-------------------------------------------------------------------------------------------------------------
private:
FactoryInfoList m_lFactories;
sal_Bool m_bReadOnlyStatesWellKnown;
SvtModuleOptions* m_pOutsideClass;
};
//_________________________________________________________________________________________________________________
// definitions
//_________________________________________________________________________________________________________________
/*-************************************************************************************************************//**
@short default ctor
@descr We open our configuration here and read all necessary values from it.
These values are cached till everyone call Commit(). Then we write changed ones back to cfg.
@seealso baseclass ConfigItem
@seealso method impl_Read()
@param -
@return -
@onerror -
@threadsafe no
*//*-*************************************************************************************************************/
SvtModuleOptions_Impl::SvtModuleOptions_Impl(SvtModuleOptions* pOutsideClass)
: ::utl::ConfigItem( ROOTNODE_FACTORIES )
, m_bReadOnlyStatesWellKnown( sal_False )
, m_pOutsideClass( pOutsideClass )
{
// First initialize list of factory infos! Otherwise we couldn't guarantee right working of these class.
for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
m_lFactories[nFactory].free();
// Get name list of all existing set node names in configuration to read her properties in impl_Read().
// These list is a list of long names of our factories.
const css::uno::Sequence< ::rtl::OUString > lFactories = GetNodeNames( ::rtl::OUString() );
impl_Read( lFactories );
// Enable notification for changes by using configuration directly.
// So we can update our internal values immediately.
EnableNotification( lFactories );
}
/*-************************************************************************************************************//**
@short default dtor
@descr If any values of our cache was modified we should write it back to configuration.
@attention Don't forget to call "SetModified()" method of base class ConfigItem if any interface method
of this class modify internal member list m_lFactories! Otherwise Commit() will never be called!!!
@seealso baseclass ConfigItem
@param -
@return -
@onerror -
@threadsafe no
*//*-*************************************************************************************************************/
SvtModuleOptions_Impl::~SvtModuleOptions_Impl()
{
if( IsModified() == sal_True )
{
Commit();
}
}
/*-************************************************************************************************************//**
@short called for notify of configmanager
@descr These method is called from the ConfigManager before application ends or from the
PropertyChangeListener if the sub tree broadcasts changes. You must update our
internal values.
@attention We are registered for pure set node names only. So we can use our internal method "impl_Read()" to
update our info list. Because - these method expand given name list to full qualified property list
and use it to read the values. These values are filled into our internal member list m_lFactories
at right position.
@seealso method impl_Read()
@param "lNames" is the list of set node entries which should be updated.
@return -
@onerror -
@threadsafe no
*//*-*************************************************************************************************************/
void SvtModuleOptions_Impl::Notify( const css::uno::Sequence< ::rtl::OUString >& )
{
OSL_ENSURE( sal_False, "SvtModuleOptions_Impl::Notify()\nNot implemented yet!\n" );
}
/*-****************************************************************************************************//**
@short write changes to configuration
@descr These method writes the changed values into the sub tree
and should always called in our destructor to guarantee consistency of config data.
@attention We clear complete set in configuration first and write it completly new! So we don't must
distinguish between existing, added or removed elements. Our internal cached values
are the only and right ones.
@seealso baseclass ConfigItem
@param -
@return -
@onerror -
@threadsafe no
*//*-*****************************************************************************************************/
void SvtModuleOptions_Impl::Commit()
{
// Reserve memory for ALL possible factory properties!
// Step over all factories and get her really changed values only.
// Build list of these ones and use it for commit.
css::uno::Sequence< css::beans::PropertyValue > lCommitProperties( FACTORYCOUNT*PROPERTYCOUNT );
FactoryInfo* pInfo = NULL ;
sal_Int32 nRealCount = 0 ;
::rtl::OUString sBasePath ;
for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
{
pInfo = &(m_lFactories[nFactory]);
// These path is used to build full qualified property names ....
// See pInfo->getChangedProperties() for further informations
sBasePath = PATHSEPERATOR + pInfo->getFactory() + PATHSEPERATOR;
const css::uno::Sequence< css::beans::PropertyValue > lChangedProperties = pInfo->getChangedProperties ( sBasePath );
const css::beans::PropertyValue* pChangedProperties = lChangedProperties.getConstArray();
sal_Int32 nPropertyCount = lChangedProperties.getLength();
for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
{
lCommitProperties[nRealCount] = pChangedProperties[nProperty];
++nRealCount;
}
}
// Resize commit list to real size.
// If nothing to do - suppress calling of configuration ...
// It could be to expensive :-)
if( nRealCount > 0 )
{
lCommitProperties.realloc( nRealCount );
SetSetProperties( ::rtl::OUString(), lCommitProperties );
}
}
/*-****************************************************************************************************//**
@short access method to get internal values
@descr These methods implement easy access to our internal values.
You give us right enum value to specify which module interest you ... we return right information.
@attention Some poeple use any value as enum ... but we support in header specified values only!
We use it directly as index in our internal list. If enum value isn't right - we crash with an
"index out of range"!!! Please use me right - otherwise there is no guarantee.
@seealso -
@param "eModule" , index in list - specify module
@param "eFactory" , index in list - specify factory
@param "sTemplate", set new standard template for these factory
@return Queried information.
@onerror We return default values. (mostly "not installed"!)
@threadsafe no
*//*-*****************************************************************************************************/
sal_Bool SvtModuleOptions_Impl::IsModuleInstalled( SvtModuleOptions::EModule eModule ) const
{
sal_Bool bInstalled = sal_False;
switch( eModule )
{
case SvtModuleOptions::E_SWRITER : bInstalled = m_lFactories[SvtModuleOptions::E_WRITER].getInstalled();
break;
case SvtModuleOptions::E_SWEB : bInstalled = m_lFactories[SvtModuleOptions::E_WRITERWEB].getInstalled();
break;
case SvtModuleOptions::E_SGLOBAL : bInstalled = m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getInstalled();
break;
case SvtModuleOptions::E_SCALC : bInstalled = m_lFactories[SvtModuleOptions::E_CALC].getInstalled();
break;
case SvtModuleOptions::E_SDRAW : bInstalled = m_lFactories[SvtModuleOptions::E_DRAW].getInstalled();
break;
case SvtModuleOptions::E_SIMPRESS : bInstalled = m_lFactories[SvtModuleOptions::E_IMPRESS].getInstalled();
break;
case SvtModuleOptions::E_SMATH : bInstalled = m_lFactories[SvtModuleOptions::E_MATH].getInstalled();
break;
case SvtModuleOptions::E_SCHART : bInstalled = m_lFactories[SvtModuleOptions::E_CHART].getInstalled();
break;
case SvtModuleOptions::E_SSTARTMODULE : bInstalled = m_lFactories[SvtModuleOptions::E_STARTMODULE].getInstalled();
break;
case SvtModuleOptions::E_SBASIC : bInstalled = sal_True; // Couldn't be deselected by setup yet!
break;
case SvtModuleOptions::E_SDATABASE : bInstalled = m_lFactories[SvtModuleOptions::E_DATABASE].getInstalled();
break;
}
return bInstalled;
}
::com::sun::star::uno::Sequence < ::rtl::OUString > SvtModuleOptions_Impl::GetAllServiceNames()
{
sal_uInt32 nCount=0;
if( m_lFactories[SvtModuleOptions::E_WRITER].getInstalled() )
nCount++;
if ( m_lFactories[SvtModuleOptions::E_WRITERWEB].getInstalled() )
nCount++;
if ( m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getInstalled() )
nCount++;
if( m_lFactories[SvtModuleOptions::E_SCALC].getInstalled() )
nCount++;
if( m_lFactories[SvtModuleOptions::E_SDRAW].getInstalled() )
nCount++;
if( m_lFactories[SvtModuleOptions::E_SIMPRESS].getInstalled() )
nCount++;
if( m_lFactories[SvtModuleOptions::E_SCHART].getInstalled() )
nCount++;
if( m_lFactories[SvtModuleOptions::E_SMATH].getInstalled() )
nCount++;
if( m_lFactories[SvtModuleOptions::E_SBASIC].getInstalled() )
nCount++;
if( m_lFactories[SvtModuleOptions::E_SDATABASE].getInstalled() )
nCount++;
css::uno::Sequence < ::rtl::OUString > aRet( nCount );
sal_Int32 n=0;
if( m_lFactories[SvtModuleOptions::E_WRITER].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_WRITER].getFactory();
if ( m_lFactories[SvtModuleOptions::E_WRITERWEB].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_WRITERWEB].getFactory();
if ( m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].getFactory();
if( m_lFactories[SvtModuleOptions::E_SCALC].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_SCALC].getFactory();
if( m_lFactories[SvtModuleOptions::E_SDRAW].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_SDRAW].getFactory();
if( m_lFactories[SvtModuleOptions::E_SIMPRESS].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_SIMPRESS].getFactory();
if( m_lFactories[SvtModuleOptions::E_SCHART].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_SCHART].getFactory();
if( m_lFactories[SvtModuleOptions::E_SMATH].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_SMATH].getFactory();
if( m_lFactories[SvtModuleOptions::E_SBASIC].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_SBASIC].getFactory();
if( m_lFactories[SvtModuleOptions::E_SDATABASE].getInstalled() )
aRet[n++] = m_lFactories[SvtModuleOptions::E_SDATABASE].getFactory();
return aRet;
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions_Impl::GetFactoryName( SvtModuleOptions::EFactory eFactory ) const
{
::rtl::OUString sName;
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
sName = m_lFactories[eFactory].getFactory();
}
return sName;
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions_Impl::GetFactoryShortName( SvtModuleOptions::EFactory eFactory ) const
{
// Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
// But it's good to plan further possibilities!
//return m_lFactories[eFactory].sShortName;
::rtl::OUString sShortName;
switch( eFactory )
{
case SvtModuleOptions::E_WRITER : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("swriter"));
break;
case SvtModuleOptions::E_WRITERWEB : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("swriter/web"));
break;
case SvtModuleOptions::E_WRITERGLOBAL : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("swriter/GlobalDocument"));
break;
case SvtModuleOptions::E_CALC : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("scalc"));
break;
case SvtModuleOptions::E_DRAW : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdraw"));
break;
case SvtModuleOptions::E_IMPRESS : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("simpress"));
break;
case SvtModuleOptions::E_MATH : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("smath"));
break;
case SvtModuleOptions::E_CHART : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("schart"));
break;
case SvtModuleOptions::E_BASIC : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sbasic"));
break;
case SvtModuleOptions::E_DATABASE : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdatabase"));
break;
default:
OSL_ASSERT( "unknown factory" );
break;
}
return sShortName;
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions_Impl::GetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ) const
{
::rtl::OUString sFile;
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
sFile = m_lFactories[eFactory].getTemplateFile();
}
return sFile;
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions_Impl::GetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ) const
{
::rtl::OUString sAttributes;
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
sAttributes = m_lFactories[eFactory].getWindowAttributes();
}
return sAttributes;
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions_Impl::GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory eFactory ) const
{
// Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
// But it's good to plan further possibilities!
//return m_lFactories[eFactory].getEmptyDocumentURL();
::rtl::OUString sURL;
switch( eFactory )
{
case SvtModuleOptions::E_WRITER : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter"));
break;
case SvtModuleOptions::E_WRITERWEB : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter/web"));
break;
case SvtModuleOptions::E_WRITERGLOBAL : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter/GlobalDocument"));
break;
case SvtModuleOptions::E_CALC : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc"));
break;
case SvtModuleOptions::E_DRAW : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/sdraw"));
break;
case SvtModuleOptions::E_IMPRESS : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/simpress?slot=6686"));
break;
case SvtModuleOptions::E_MATH : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/smath"));
break;
case SvtModuleOptions::E_CHART : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/schart"));
break;
case SvtModuleOptions::E_BASIC : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/sbasic"));
break;
case SvtModuleOptions::E_DATABASE : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/sdatabase?Interactive"));
break;
default:
OSL_ASSERT( "unknown factory" );
break;
}
return sURL;
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions_Impl::GetFactoryDefaultFilter( SvtModuleOptions::EFactory eFactory ) const
{
::rtl::OUString sDefaultFilter;
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
sDefaultFilter = m_lFactories[eFactory].getDefaultFilter();
}
return sDefaultFilter;
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions_Impl::IsDefaultFilterReadonly( SvtModuleOptions::EFactory eFactory ) const
{
sal_Bool bRet = sal_False;
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
bRet = m_lFactories[eFactory].isDefaultFilterReadonly();
}
return bRet;
}
//*****************************************************************************************************************
sal_Int32 SvtModuleOptions_Impl::GetFactoryIcon( SvtModuleOptions::EFactory eFactory ) const
{
sal_Int32 nIcon = 0;
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
nIcon = m_lFactories[eFactory].getIcon();
}
return nIcon;
}
//*****************************************************************************************************************
void SvtModuleOptions_Impl::SetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ,
const ::rtl::OUString& sTemplate )
{
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
m_lFactories[eFactory].setTemplateFile( sTemplate );
SetModified();
}
}
//*****************************************************************************************************************
void SvtModuleOptions_Impl::SetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ,
const ::rtl::OUString& sAttributes)
{
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
m_lFactories[eFactory].setWindowAttributes( sAttributes );
SetModified();
}
}
//*****************************************************************************************************************
void SvtModuleOptions_Impl::SetFactoryDefaultFilter( SvtModuleOptions::EFactory eFactory,
const ::rtl::OUString& sFilter )
{
if( eFactory>=0 && eFactory<FACTORYCOUNT )
{
m_lFactories[eFactory].setDefaultFilter( sFilter );
SetModified();
}
}
/*-************************************************************************************************************//**
@short return list of key names of our configuration management which represent our module tree
@descr You give use a list of current existing set node names .. and we expand it for all
well known properties which are necessary for this implementation.
These full expanded list should be used to get values of this properties.
@seealso ctor
@param -
@return List of all relative addressed properties of given set entry names.
@onerror List will be empty.
@threadsafe no
*//*-*************************************************************************************************************/
css::uno::Sequence< ::rtl::OUString > SvtModuleOptions_Impl::impl_ExpandSetNames( const css::uno::Sequence< ::rtl::OUString >& lSetNames )
{
sal_Int32 nCount = lSetNames.getLength() ;
css::uno::Sequence< ::rtl::OUString > lPropNames ( nCount*PROPERTYCOUNT );
::rtl::OUString* pPropNames = lPropNames.getArray() ;
sal_Int32 nPropStart = 0 ;
for( sal_Int32 nName=0; nName<nCount; ++nName )
{
pPropNames[nPropStart+PROPERTYHANDLE_SHORTNAME ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_SHORTNAME ;
pPropNames[nPropStart+PROPERTYHANDLE_TEMPLATEFILE ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_TEMPLATEFILE ;
pPropNames[nPropStart+PROPERTYHANDLE_WINDOWATTRIBUTES] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_WINDOWATTRIBUTES;
pPropNames[nPropStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_EMPTYDOCUMENTURL;
pPropNames[nPropStart+PROPERTYHANDLE_DEFAULTFILTER ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_DEFAULTFILTER ;
pPropNames[nPropStart+PROPERTYHANDLE_ICON ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_ICON ;
nPropStart += PROPERTYCOUNT;
}
return lPropNames;
}
/*-************************************************************************************************************//**
@short helper to classify given factory by name
@descr Every factory has his own long and short name. So we can match right enum value for internal using.
@attention We change in/out parameter "eFactory" in every case! But you should use it only, if return value is sal_True!
Algorithm: Set out-parameter to propably value ... and check the longname.
If it match with these factory - break operation and return true AND right set parameter.
Otherwise try next one and so on. If no factory was found return false. Out parameter eFactory
is set to last tried value but shouldn't be used! Because our return value is false!
@seealso -
@param "sLongName" , long name of factory, which should be classified
@return "eFactory" , right enum value, which match given long name
and true for successfully classification, false otherwise
@onerror We return false.
@threadsafe no
*//*-*************************************************************************************************************/
sal_Bool SvtModuleOptions_Impl::ClassifyFactoryByName( const ::rtl::OUString& sName, SvtModuleOptions::EFactory& eFactory )
{
sal_Bool bState;
eFactory = SvtModuleOptions::E_WRITER ;
bState = ( sName == FACTORYNAME_WRITER );
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_WRITERWEB ;
bState = ( sName == FACTORYNAME_WRITERWEB );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_WRITERGLOBAL ;
bState = ( sName == FACTORYNAME_WRITERGLOBAL );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_CALC ;
bState = ( sName == FACTORYNAME_CALC );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_DRAW ;
bState = ( sName == FACTORYNAME_DRAW );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_IMPRESS ;
bState = ( sName == FACTORYNAME_IMPRESS );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_MATH ;
bState = ( sName == FACTORYNAME_MATH );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_CHART ;
bState = ( sName == FACTORYNAME_CHART );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_DATABASE ;
bState = ( sName == FACTORYNAME_DATABASE );
}
// no else!
if( bState == sal_False )
{
eFactory = SvtModuleOptions::E_STARTMODULE ;
bState = ( sName == FACTORYNAME_STARTMODULE);
}
return bState;
}
/*-************************************************************************************************************//**
@short read factory configuration
@descr Give us a list of pure factory names (long names!) which can be used as
direct set node names ... and we read her property values and fill internal list.
These method can be used by initial reading at ctor and later updating by "Notify()".
@seealso ctor
@seealso method Notify()
@param "lFactories" is the list of set node entries which should be readed.
@return -
@onerror We do nothing.
@threadsafe no
*//*-*************************************************************************************************************/
void SvtModuleOptions_Impl::impl_Read( const css::uno::Sequence< ::rtl::OUString >& lFactories )
{
// Expand every set node name in lFactories to full qualified pathes to his properties
// and get right values from configuration.
const css::uno::Sequence< ::rtl::OUString > lProperties = impl_ExpandSetNames( lFactories );
const css::uno::Sequence< css::uno::Any > lValues = GetProperties( lProperties );
// Safe impossible cases.
// We need values from ALL configuration keys.
// Follow assignment use order of values in relation to our list of key names!
OSL_ENSURE( !(lProperties.getLength()!=lValues.getLength()), "SvtModuleOptions_Impl::impl_Read()\nI miss some values of configuration keys!\n" );
// Algorithm: We step over all given factory names and classify it. These enum value can be used as direct index
// in our member list m_lFactories! VAriable nPropertyStart marks start position of every factory
// and her properties in expanded property/value list. The defines PROPERTHANDLE_xxx are used as offset values
// added to nPropertyStart. So we can address every property relative in these lists.
// If we found any valid values ... we reset all existing informations for corresponding m_lFactories-entry and
// use a pointer to these struct in memory directly to set new values.
// But we set it only, if bInstalled is true. Otherwise all other values of a factory can be undeclared .. They
// shouldn't be used then.
// Attention: If a propertyset of a factory will be ignored we must step to next start position of next factory infos!
// see "nPropertyStart += PROPERTYCOUNT" ...
sal_Int32 nPropertyStart = 0 ;
sal_Int32 nNodeCount = lFactories.getLength();
FactoryInfo* pInfo = NULL ;
SvtModuleOptions::EFactory eFactory ;
for( sal_Int32 nSetNode=0; nSetNode<nNodeCount; ++nSetNode )
{
const ::rtl::OUString& sFactoryName = lFactories[nSetNode];
if( ClassifyFactoryByName( sFactoryName, eFactory ) == sal_True )
{
::rtl::OUString sTemp;
sal_Int32 nTemp = 0;
pInfo = &(m_lFactories[eFactory]);
pInfo->free();
pInfo->initInstalled( sal_True );
pInfo->initFactory ( sFactoryName );
if (lValues[nPropertyStart+PROPERTYHANDLE_SHORTNAME] >>= sTemp)
pInfo->initShortName( sTemp );
if (lValues[nPropertyStart+PROPERTYHANDLE_TEMPLATEFILE] >>= sTemp)
pInfo->initTemplateFile( sTemp );
if (lValues[nPropertyStart+PROPERTYHANDLE_WINDOWATTRIBUTES] >>= sTemp)
pInfo->initWindowAttributes( sTemp );
if (lValues[nPropertyStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] >>= sTemp)
pInfo->initEmptyDocumentURL( sTemp );
if (lValues[nPropertyStart+PROPERTYHANDLE_DEFAULTFILTER ] >>= sTemp)
pInfo->initDefaultFilter( sTemp );
if (lValues[nPropertyStart+PROPERTYHANDLE_ICON] >>= nTemp)
pInfo->initIcon( nTemp );
}
nPropertyStart += PROPERTYCOUNT;
}
}
//*****************************************************************************************************************
void SvtModuleOptions_Impl::MakeReadonlyStatesAvailable()
{
if (m_bReadOnlyStatesWellKnown)
return;
css::uno::Sequence< ::rtl::OUString > lFactories = GetNodeNames(::rtl::OUString());
sal_Int32 c = lFactories.getLength();
sal_Int32 i = 0;
for (i=0; i<c; ++i)
{
::rtl::OUStringBuffer sPath(256);
sPath.append(lFactories[i] );
sPath.append(PATHSEPERATOR );
sPath.append(PROPERTYNAME_DEFAULTFILTER);
lFactories[i] = sPath.makeStringAndClear();
}
css::uno::Sequence< sal_Bool > lReadonlyStates = GetReadOnlyStates(lFactories);
for (i=0; i<c; ++i)
{
::rtl::OUString& rFactoryName = lFactories[i];
SvtModuleOptions::EFactory eFactory ;
if (!ClassifyFactoryByName(rFactoryName, eFactory))
continue;
FactoryInfo& rInfo = m_lFactories[eFactory];
rInfo.setDefaultFilterReadonly(lReadonlyStates[i]);
}
m_bReadOnlyStatesWellKnown = sal_True;
}
//*****************************************************************************************************************
// initialize static member
// DON'T DO IT IN YOUR HEADER!
// see definition for further informations
//*****************************************************************************************************************
SvtModuleOptions_Impl* SvtModuleOptions::m_pDataContainer = NULL ;
sal_Int32 SvtModuleOptions::m_nRefCount = 0 ;
/*-************************************************************************************************************//**
@short standard constructor and destructor
@descr This will initialize an instance with default values. We initialize/deinitialize our static data
container and create a static mutex, which is used for threadsafe code in further time of this object.
@seealso method impl_GetOwnStaticMutex()
@param -
@return -
@onerror -
@threadsafe yes
*//*-*************************************************************************************************************/
SvtModuleOptions::SvtModuleOptions()
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
++m_nRefCount;
if( m_nRefCount == 1 )
{
RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtModuleOptions_Impl::ctor()");
m_pDataContainer = new SvtModuleOptions_Impl(this);
ItemHolder1::holdConfigItem(E_MODULEOPTIONS);
}
}
//*****************************************************************************************************************
SvtModuleOptions::~SvtModuleOptions()
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
--m_nRefCount;
if( m_nRefCount == 0 )
{
delete m_pDataContainer;
m_pDataContainer = NULL;
}
}
/*-************************************************************************************************************//**
@short access to configuration data
@descr This methods allow read/write access to configuration values.
They are threadsafe. All calls are forwarded to impl-data-container. See there for further informations!
@seealso method impl_GetOwnStaticMutex()
@param -
@return -
@onerror -
@threadsafe yes
*//*-*************************************************************************************************************/
sal_Bool SvtModuleOptions::IsModuleInstalled( EModule eModule ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( eModule );
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions::GetFactoryName( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetFactoryName( eFactory );
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions::GetFactoryShortName( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetFactoryShortName( eFactory );
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions::GetFactoryStandardTemplate( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetFactoryStandardTemplate( eFactory );
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions::GetFactoryWindowAttributes( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetFactoryWindowAttributes( eFactory );
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions::GetFactoryEmptyDocumentURL( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetFactoryEmptyDocumentURL( eFactory );
}
//*****************************************************************************************************************
::rtl::OUString SvtModuleOptions::GetFactoryDefaultFilter( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetFactoryDefaultFilter( eFactory );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsDefaultFilterReadonly( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
m_pDataContainer->MakeReadonlyStatesAvailable();
return m_pDataContainer->IsDefaultFilterReadonly( eFactory );
}
//*****************************************************************************************************************
sal_Int32 SvtModuleOptions::GetFactoryIcon( EFactory eFactory ) const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetFactoryIcon( eFactory );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::ClassifyFactoryByName( const ::rtl::OUString& sName ,
EFactory& eFactory )
{
// We don't need any mutex here ... because we don't use any member here!
return SvtModuleOptions_Impl::ClassifyFactoryByName( sName, eFactory );
}
//*****************************************************************************************************************
void SvtModuleOptions::SetFactoryStandardTemplate( EFactory eFactory ,
const ::rtl::OUString& sTemplate )
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
m_pDataContainer->SetFactoryStandardTemplate( eFactory, sTemplate );
}
//*****************************************************************************************************************
void SvtModuleOptions::SetFactoryWindowAttributes( EFactory eFactory ,
const ::rtl::OUString& sAttributes)
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
m_pDataContainer->SetFactoryWindowAttributes( eFactory, sAttributes );
}
//*****************************************************************************************************************
void SvtModuleOptions::SetFactoryDefaultFilter( EFactory eFactory,
const ::rtl::OUString& sFilter )
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
m_pDataContainer->SetFactoryDefaultFilter( eFactory, sFilter );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsMath() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( E_SMATH );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsChart() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( E_SCHART );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsCalc() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( E_SCALC );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsDraw() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( E_SDRAW );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsWriter() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( E_SWRITER );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsImpress() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( E_SIMPRESS );
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsBasicIDE() const
{
return sal_True;
}
//*****************************************************************************************************************
sal_Bool SvtModuleOptions::IsDataBase() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->IsModuleInstalled( E_SDATABASE );
}
//*****************************************************************************************************************
sal_uInt32 SvtModuleOptions::GetFeatures() const
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
sal_uInt32 nFeature = 0;
if( m_pDataContainer->IsModuleInstalled( E_SWRITER ) == sal_True )
nFeature |= FEATUREFLAG_WRITER;
if( m_pDataContainer->IsModuleInstalled( E_SCALC ) == sal_True )
nFeature |= FEATUREFLAG_CALC;
if( m_pDataContainer->IsModuleInstalled( E_SDRAW ) == sal_True )
nFeature |= FEATUREFLAG_DRAW;
if( m_pDataContainer->IsModuleInstalled( E_SIMPRESS ) == sal_True )
nFeature |= FEATUREFLAG_IMPRESS;
if( m_pDataContainer->IsModuleInstalled( E_SCHART ) == sal_True )
nFeature |= FEATUREFLAG_CHART;
if( m_pDataContainer->IsModuleInstalled( E_SMATH ) == sal_True )
nFeature |= FEATUREFLAG_MATH;
if( m_pDataContainer->IsModuleInstalled( E_SBASIC ) == sal_True )
nFeature |= FEATUREFLAG_BASICIDE;
if( m_pDataContainer->IsModuleInstalled( E_SDATABASE ) == sal_True )
nFeature |= FEATUREFLAG_INSIGHT;
return nFeature;
}
/*-****************************************************************************************************//**
@short return a reference to a static mutex
@descr These class is threadsafe.
We create a static mutex only for one time and use it to protect our refcount and container
member!
@seealso -
@param -
@return A reference to a static mutex member.
@onerror -
@threadsafe yes
*//*-*****************************************************************************************************/
::osl::Mutex& SvtModuleOptions::impl_GetOwnStaticMutex()
{
// Initialize static mutex only for one time!
static ::osl::Mutex* pMutex = NULL;
// If these method first called (Mutex not already exist!) ...
if( pMutex == NULL )
{
// ... we must create a new one. Protect follow code with the global mutex -
// It must be - we create a static variable!
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
// We must check our pointer again - because it can be that another instance of our class will be faster than these!
if( pMutex == NULL )
{
// Create the new mutex and set it for return on static variable.
static ::osl::Mutex aMutex;
pMutex = &aMutex;
}
}
// Return new created or already existing mutex object.
return *pMutex;
}
::rtl::OUString SvtModuleOptions::GetModuleName( EModule eModule ) const
{
switch( eModule )
{
case SvtModuleOptions::E_SWRITER : { return ::rtl::OUString::createFromAscii("Writer"); }
case SvtModuleOptions::E_SWEB : { return ::rtl::OUString::createFromAscii("Web"); }
case SvtModuleOptions::E_SGLOBAL : { return ::rtl::OUString::createFromAscii("Global"); }
case SvtModuleOptions::E_SCALC : { return ::rtl::OUString::createFromAscii("Calc"); }
case SvtModuleOptions::E_SDRAW : { return ::rtl::OUString::createFromAscii("Draw"); }
case SvtModuleOptions::E_SIMPRESS : { return ::rtl::OUString::createFromAscii("Impress"); }
case SvtModuleOptions::E_SMATH : { return ::rtl::OUString::createFromAscii("Math"); }
case SvtModuleOptions::E_SCHART : { return ::rtl::OUString::createFromAscii("Chart"); }
case SvtModuleOptions::E_SBASIC : { return ::rtl::OUString::createFromAscii("Basic"); }
case SvtModuleOptions::E_SDATABASE : { return ::rtl::OUString::createFromAscii("Database"); }
default:
OSL_ASSERT( "unknown module" );
break;
}
return ::rtl::OUString();
}
::rtl::OUString SvtModuleOptions::GetModuleName( EFactory eFactory ) const
{
switch( eFactory )
{
case SvtModuleOptions::E_WRITER : { return ::rtl::OUString::createFromAscii("Writer"); }
case SvtModuleOptions::E_WRITERWEB : { return ::rtl::OUString::createFromAscii("Writer"); }
case SvtModuleOptions::E_WRITERGLOBAL : { return ::rtl::OUString::createFromAscii("Writer"); }
case SvtModuleOptions::E_CALC : { return ::rtl::OUString::createFromAscii("Calc"); }
case SvtModuleOptions::E_DRAW : { return ::rtl::OUString::createFromAscii("Draw"); }
case SvtModuleOptions::E_IMPRESS : { return ::rtl::OUString::createFromAscii("Impress"); }
case SvtModuleOptions::E_MATH : { return ::rtl::OUString::createFromAscii("Math"); }
case SvtModuleOptions::E_CHART : { return ::rtl::OUString::createFromAscii("Chart"); }
case SvtModuleOptions::E_BASIC : { return ::rtl::OUString::createFromAscii("Basic"); }
case SvtModuleOptions::E_DATABASE : { return ::rtl::OUString::createFromAscii("Database"); }
default:
OSL_ASSERT( "unknown factory" );
break;
}
return ::rtl::OUString();
}
/*-----------------------------------------------
07.03.2004 15:03
-----------------------------------------------*/
SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByShortName(const ::rtl::OUString& sName)
{
if (sName.equalsAscii("swriter"))
return E_WRITER;
if (sName.equalsIgnoreAsciiCaseAscii("swriter/Web")) // sometimes they are registerd for swriter/web :-(
return E_WRITERWEB;
if (sName.equalsIgnoreAsciiCaseAscii("swriter/GlobalDocument")) // sometimes they are registerd for swriter/globaldocument :-(
return E_WRITERGLOBAL;
if (sName.equalsAscii("scalc"))
return E_CALC;
if (sName.equalsAscii("sdraw"))
return E_DRAW;
if (sName.equalsAscii("simpress"))
return E_IMPRESS;
if (sName.equalsAscii("schart"))
return E_CHART;
if (sName.equalsAscii("smath"))
return E_MATH;
if (sName.equalsAscii("sbasic"))
return E_BASIC;
if (sName.equalsAscii("sdatabase"))
return E_DATABASE;
return E_UNKNOWN_FACTORY;
}
/*-----------------------------------------------
31.07.2003 10:41
-----------------------------------------------*/
SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByServiceName(const ::rtl::OUString& sName)
{
if (sName.equals(FACTORYNAME_WRITERGLOBAL))
return E_WRITERGLOBAL;
if (sName.equals(FACTORYNAME_WRITERWEB))
return E_WRITERWEB;
if (sName.equals(FACTORYNAME_WRITER))
return E_WRITER;
if (sName.equals(FACTORYNAME_CALC))
return E_CALC;
if (sName.equals(FACTORYNAME_DRAW))
return E_DRAW;
if (sName.equals(FACTORYNAME_IMPRESS))
return E_IMPRESS;
if (sName.equals(FACTORYNAME_MATH))
return E_MATH;
if (sName.equals(FACTORYNAME_CHART))
return E_CHART;
if (sName.equals(FACTORYNAME_DATABASE))
return E_DATABASE;
return E_UNKNOWN_FACTORY;
}
/*-----------------------------------------------
31.07.2003 14:39
-----------------------------------------------*/
SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByURL(const ::rtl::OUString& sURL ,
const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor)
{
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::utl::getProcessServiceFactory();
if (!xSMGR.is())
return E_UNKNOWN_FACTORY;
css::uno::Reference< css::container::XNameAccess > xFilterCfg;
css::uno::Reference< css::container::XNameAccess > xTypeCfg ;
try
{
xFilterCfg = css::uno::Reference< css::container::XNameAccess >(
xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.document.FilterFactory")), css::uno::UNO_QUERY);
xTypeCfg = css::uno::Reference< css::container::XNameAccess >(
xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection")), css::uno::UNO_QUERY);
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::uno::Exception&)
{ return E_UNKNOWN_FACTORY; }
::comphelper::SequenceAsHashMap stlDesc(lMediaDescriptor);
// is there already a filter inside the descriptor?
::rtl::OUString sFilterName = stlDesc.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("FilterName"), ::rtl::OUString());
if (sFilterName.getLength())
{
try
{
::comphelper::SequenceAsHashMap stlFilterProps (xFilterCfg->getByName(sFilterName));
::rtl::OUString sDocumentService = stlFilterProps.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("DocumentService"), ::rtl::OUString());
SvtModuleOptions::EFactory eApp = SvtModuleOptions::ClassifyFactoryByServiceName(sDocumentService);
if (eApp != E_UNKNOWN_FACTORY)
return eApp;
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::uno::Exception&)
{ /* do nothing here ... may the following code can help!*/ }
}
// is there already a type inside the descriptor?
::rtl::OUString sTypeName = stlDesc.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("TypeName"), ::rtl::OUString());
if (!sTypeName.getLength())
{
// no :-(
// start flat detection of URL
css::uno::Reference< css::document::XTypeDetection > xDetect(xTypeCfg, css::uno::UNO_QUERY);
sTypeName = xDetect->queryTypeByURL(sURL);
}
if (!sTypeName.getLength())
return E_UNKNOWN_FACTORY;
// yes - there is a type info
// Try to find the preferred filter.
try
{
::comphelper::SequenceAsHashMap stlTypeProps (xTypeCfg->getByName(sTypeName));
::rtl::OUString sPreferredFilter = stlTypeProps.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("PreferredFilter"), ::rtl::OUString());
::comphelper::SequenceAsHashMap stlFilterProps (xFilterCfg->getByName(sPreferredFilter));
::rtl::OUString sDocumentService = stlFilterProps.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("DocumentService"), ::rtl::OUString());
SvtModuleOptions::EFactory eApp = SvtModuleOptions::ClassifyFactoryByServiceName(sDocumentService);
if (eApp != E_UNKNOWN_FACTORY)
return eApp;
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::uno::Exception&)
{ /* do nothing here ... may the following code can help!*/ }
// no filter/no type/no detection result => no fun :-)
return E_UNKNOWN_FACTORY;
}
/*-----------------------------------------------
31.07.2003 10:41
-----------------------------------------------*/
SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByModel(const css::uno::Reference< css::frame::XModel >& xModel)
{
css::uno::Reference< css::lang::XServiceInfo > xInfo(xModel, css::uno::UNO_QUERY);
if (!xInfo.is())
return E_UNKNOWN_FACTORY;
const css::uno::Sequence< ::rtl::OUString > lServices = xInfo->getSupportedServiceNames();
const ::rtl::OUString* pServices = lServices.getConstArray();
for (sal_Int32 i=0; i<lServices.getLength() ; ++i)
{
SvtModuleOptions::EFactory eApp = SvtModuleOptions::ClassifyFactoryByServiceName(pServices[i]);
if (eApp != E_UNKNOWN_FACTORY)
return eApp;
}
return E_UNKNOWN_FACTORY;
}
::com::sun::star::uno::Sequence < ::rtl::OUString > SvtModuleOptions::GetAllServiceNames()
{
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
return m_pDataContainer->GetAllServiceNames();
}
::rtl::OUString SvtModuleOptions::GetDefaultModuleName()
{
::rtl::OUString aModule;
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SWRITER))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_WRITER);
else
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SCALC))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_CALC);
else
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SIMPRESS))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_IMPRESS);
else
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_DATABASE);
else
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SDRAW))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_DRAW);
else
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SWEB))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_WRITERWEB);
else
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SGLOBAL))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_WRITERGLOBAL);
else
if (m_pDataContainer->IsModuleInstalled(SvtModuleOptions::E_SMATH))
aModule = m_pDataContainer->GetFactoryShortName(SvtModuleOptions::E_MATH);
return aModule;
}
| 48.727102 | 176 | 0.537897 | [
"object"
] |
82ea40d995f29805bb010b23ab50e5ae0e6be5a9 | 1,635 | cpp | C++ | test/cpp/tensorexpr/test_cpp_codegen.cpp | FloCF/pytorch | 383a33a0eb28ae454c0c8965650aea8ce1608943 | [
"Intel"
] | 1 | 2021-08-18T08:59:49.000Z | 2021-08-18T08:59:49.000Z | test/cpp/tensorexpr/test_cpp_codegen.cpp | FloCF/pytorch | 383a33a0eb28ae454c0c8965650aea8ce1608943 | [
"Intel"
] | 1 | 2021-09-03T09:35:27.000Z | 2021-09-03T09:35:27.000Z | test/cpp/tensorexpr/test_cpp_codegen.cpp | FloCF/pytorch | 383a33a0eb28ae454c0c8965650aea8ce1608943 | [
"Intel"
] | null | null | null | #include <gtest/gtest.h>
#include <test/cpp/tensorexpr/test_base.h>
#include <torch/csrc/jit/tensorexpr/cpp_codegen.h>
#include <torch/csrc/jit/tensorexpr/mem_arena.h>
#include <torch/csrc/jit/tensorexpr/stmt.h>
#include <torch/csrc/jit/testing/file_check.h>
namespace torch {
namespace jit {
using namespace torch::jit::tensorexpr;
TEST(CppPrinter, AllocateOnStackThenFree) {
KernelScope kernel_scope;
std::vector<ExprPtr> dims = {alloc<IntImm>(2), alloc<IntImm>(3)};
BufPtr buf = alloc<Buf>("x", dims, kInt);
AllocatePtr alloc_ = alloc<Allocate>(buf);
FreePtr free_ = alloc<Free>(buf);
BlockPtr block = Block::make({alloc_, free_});
std::stringstream ss;
CppPrinter printer(&ss);
printer.visit(block);
const std::string expected = R"(
# CHECK: {
# CHECK: int x[6];
# CHECK: }
)";
torch::jit::testing::FileCheck().run(expected, ss.str());
}
TEST(CppPrinter, AllocateOnHeapThenFree) {
KernelScope kernel_scope;
std::vector<ExprPtr> dims = {
alloc<IntImm>(20), alloc<IntImm>(50), alloc<IntImm>(3)};
BufPtr buf = alloc<Buf>("y", dims, kLong);
AllocatePtr alloc_ = alloc<Allocate>(buf);
FreePtr free_ = alloc<Free>(buf);
BlockPtr block = Block::make({alloc_, free_});
std::stringstream ss;
CppPrinter printer(&ss);
printer.visit(block);
// size(long) = 8;
// dim0 * dim1 * dim2 * size(long) = 24000.
const std::string expected = R"(
# CHECK: {
# CHECK: int64_t* y = static_cast<int64_t*>(malloc(24000));
# CHECK: free(y);
# CHECK: }
)";
torch::jit::testing::FileCheck().run(expected, ss.str());
}
} // namespace jit
} // namespace torch
| 27.711864 | 67 | 0.666055 | [
"vector"
] |
82eaf0fbda4d16275564732839f9168cb450854f | 4,796 | cpp | C++ | src/generated/lsd_saveinventory.cpp | TestGabu/liblcf | c4b58844ef10179910b92a7cfbf23ab593cc2ade | [
"MIT"
] | null | null | null | src/generated/lsd_saveinventory.cpp | TestGabu/liblcf | c4b58844ef10179910b92a7cfbf23ab593cc2ade | [
"MIT"
] | null | null | null | src/generated/lsd_saveinventory.cpp | TestGabu/liblcf | c4b58844ef10179910b92a7cfbf23ab593cc2ade | [
"MIT"
] | null | null | null | /* !!!! GENERATED FILE - DO NOT EDIT !!!!
* --------------------------------------
*
* This file is part of liblcf. Copyright (c) 2020 liblcf authors.
* https://github.com/EasyRPG/liblcf - https://easyrpg.org
*
* liblcf is Free/Libre Open Source Software, released under the MIT License.
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code.
*/
// Headers
#include "lcf/lsd/reader.h"
#include "lcf/lsd/chunks.h"
#include "reader_struct_impl.h"
namespace lcf {
// Read SaveInventory.
template <>
char const* const Struct<rpg::SaveInventory>::name = "SaveInventory";
static CountField<rpg::SaveInventory, int16_t> static_size_party(
&rpg::SaveInventory::party,
LSD_Reader::ChunkSaveInventory::party_size,
1,
0
);
static TypedField<rpg::SaveInventory, std::vector<int16_t>> static_party(
&rpg::SaveInventory::party,
LSD_Reader::ChunkSaveInventory::party,
"party",
1,
0
);
static CountField<rpg::SaveInventory, int16_t> static_size_item_ids(
&rpg::SaveInventory::item_ids,
LSD_Reader::ChunkSaveInventory::item_ids_size,
1,
0
);
static TypedField<rpg::SaveInventory, std::vector<int16_t>> static_item_ids(
&rpg::SaveInventory::item_ids,
LSD_Reader::ChunkSaveInventory::item_ids,
"item_ids",
1,
0
);
static TypedField<rpg::SaveInventory, std::vector<uint8_t>> static_item_counts(
&rpg::SaveInventory::item_counts,
LSD_Reader::ChunkSaveInventory::item_counts,
"item_counts",
1,
0
);
static TypedField<rpg::SaveInventory, std::vector<uint8_t>> static_item_usage(
&rpg::SaveInventory::item_usage,
LSD_Reader::ChunkSaveInventory::item_usage,
"item_usage",
1,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_gold(
&rpg::SaveInventory::gold,
LSD_Reader::ChunkSaveInventory::gold,
"gold",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_timer1_frames(
&rpg::SaveInventory::timer1_frames,
LSD_Reader::ChunkSaveInventory::timer1_frames,
"timer1_frames",
0,
0
);
static TypedField<rpg::SaveInventory, bool> static_timer1_active(
&rpg::SaveInventory::timer1_active,
LSD_Reader::ChunkSaveInventory::timer1_active,
"timer1_active",
0,
0
);
static TypedField<rpg::SaveInventory, bool> static_timer1_visible(
&rpg::SaveInventory::timer1_visible,
LSD_Reader::ChunkSaveInventory::timer1_visible,
"timer1_visible",
0,
0
);
static TypedField<rpg::SaveInventory, bool> static_timer1_battle(
&rpg::SaveInventory::timer1_battle,
LSD_Reader::ChunkSaveInventory::timer1_battle,
"timer1_battle",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_timer2_frames(
&rpg::SaveInventory::timer2_frames,
LSD_Reader::ChunkSaveInventory::timer2_frames,
"timer2_frames",
0,
0
);
static TypedField<rpg::SaveInventory, bool> static_timer2_active(
&rpg::SaveInventory::timer2_active,
LSD_Reader::ChunkSaveInventory::timer2_active,
"timer2_active",
0,
0
);
static TypedField<rpg::SaveInventory, bool> static_timer2_visible(
&rpg::SaveInventory::timer2_visible,
LSD_Reader::ChunkSaveInventory::timer2_visible,
"timer2_visible",
0,
0
);
static TypedField<rpg::SaveInventory, bool> static_timer2_battle(
&rpg::SaveInventory::timer2_battle,
LSD_Reader::ChunkSaveInventory::timer2_battle,
"timer2_battle",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_battles(
&rpg::SaveInventory::battles,
LSD_Reader::ChunkSaveInventory::battles,
"battles",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_defeats(
&rpg::SaveInventory::defeats,
LSD_Reader::ChunkSaveInventory::defeats,
"defeats",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_escapes(
&rpg::SaveInventory::escapes,
LSD_Reader::ChunkSaveInventory::escapes,
"escapes",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_victories(
&rpg::SaveInventory::victories,
LSD_Reader::ChunkSaveInventory::victories,
"victories",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_turns(
&rpg::SaveInventory::turns,
LSD_Reader::ChunkSaveInventory::turns,
"turns",
0,
0
);
static TypedField<rpg::SaveInventory, int32_t> static_steps(
&rpg::SaveInventory::steps,
LSD_Reader::ChunkSaveInventory::steps,
"steps",
0,
0
);
template <>
Field<rpg::SaveInventory> const* Struct<rpg::SaveInventory>::fields[] = {
&static_size_party,
&static_party,
&static_size_item_ids,
&static_item_ids,
&static_item_counts,
&static_item_usage,
&static_gold,
&static_timer1_frames,
&static_timer1_active,
&static_timer1_visible,
&static_timer1_battle,
&static_timer2_frames,
&static_timer2_active,
&static_timer2_visible,
&static_timer2_battle,
&static_battles,
&static_defeats,
&static_escapes,
&static_victories,
&static_turns,
&static_steps,
NULL
};
template class Struct<rpg::SaveInventory>;
} //namespace lcf
| 24.100503 | 79 | 0.760842 | [
"vector"
] |
82eb23e10a277e1b8f7774756403b4ed13127f5a | 6,315 | cpp | C++ | main.cpp | padeler/rmpe_dataset_server | b7c815c6f29eb7872424e354e5ee7710ba0da2f6 | [
"BSD-3-Clause"
] | 17 | 2017-11-10T06:50:02.000Z | 2020-10-30T20:50:57.000Z | main.cpp | padeler/rmpe_dataset_server | b7c815c6f29eb7872424e354e5ee7710ba0da2f6 | [
"BSD-3-Clause"
] | 5 | 2017-11-09T06:34:43.000Z | 2020-05-28T09:50:22.000Z | main.cpp | padeler/rmpe_dataset_server | b7c815c6f29eb7872424e354e5ee7710ba0da2f6 | [
"BSD-3-Clause"
] | 6 | 2017-11-02T04:52:42.000Z | 2019-02-10T18:26:17.000Z | #include <iostream>
#include <vector>
#include "DataTransformer.h"
#include "H5Cpp.h"
#include "Eigen/Dense"
#include <zmq.hpp>
using Eigen::MatrixXd;
using Eigen::VectorXd;
using Eigen::Map;
struct DatumMetadata {
uchar* datum;
hsize_t shape[3];
};
int getKeys(std::vector<string> *keys, const H5::Group *group) {
hsize_t num_obj;
H5Gget_num_objs(group->getId(), &num_obj);
char buff[10];
for (int i=0; i < num_obj; i++) {
snprintf(buff, sizeof(buff), "%07d", i);
keys->push_back(string(buff));
}
return 0;
}
int getDatum(const string key, const H5::Group *group, DatumMetadata &meta) {
H5::DataSet *dataset = new H5::DataSet( group->openDataSet( key.data()));
H5::DataSpace dataspace = dataset->getSpace();
int rank = dataspace.getSimpleExtentNdims();
dataspace.getSimpleExtentDims( meta.shape, NULL);
H5::DataSpace mspace1(rank, meta.shape);
meta.datum = new uchar[meta.shape[0] * meta.shape[1] * meta.shape[2]];
dataset->read(meta.datum, H5::PredType::NATIVE_UCHAR, mspace1, dataspace);
dataset->close();
delete dataset;
return 0;
}
int sendTransformed(
uchar *transformed_data, double *transformed_label,
const int rows_data, const int cols_data,
const int rows_label,
const int cols_label,
const int np,
const int start_label_data,
zmq::socket_t *s, int stop) {
if (stop==1) {
string headers = "{\"stop\":true}";
zmq::message_t request (headers.size());
memcpy (request.data (), (headers.c_str()), (headers.size()));
s->send (request);
} else {
// prepare data
Eigen::MatrixXd weights = Eigen::Map<Eigen::MatrixXd>(
transformed_label, rows_label * np, cols_label);
Eigen::MatrixXd vec = Eigen::Map<Eigen::MatrixXd>(
transformed_label + start_label_data, rows_label * np, cols_label);
Eigen::MatrixXd label = vec.cwiseProduct(weights);
Eigen::MatrixXd mask = Eigen::Map<Eigen::MatrixXd>(
transformed_label, rows_label, cols_label);
const int lbl_rows(rows_label);
const int lbl_cols(cols_label);
const int dta_rows(rows_data);
const int dta_cols(cols_data);
const int mask_rows(rows_label);
const int mask_cols(cols_label);
// send headers
string header_data = "{\"descr\":\"uint8\",\"shape\":\"(3, 368,368)\",\"fortran_order\":false}";
string header_mask = "{\"descr\":\"<f8\",\"shape\":\"(46,46)\",\"fortran_order\":false}";
string header_label = "{\"descr\":\"<f8\",\"shape\":\"(57,46,46)\",\"fortran_order\":false}";
string headers = "[" + header_data + "," + header_mask + "," + header_label + "]";
zmq::message_t request (headers.size());
memcpy (request.data (), (headers.c_str()), (headers.size()));
s->send (request, ZMQ_SNDMORE);
// send data
size_t data_size(dta_rows * dta_cols * 3);
zmq::message_t data_buff (transformed_data, data_size);
s->send(data_buff, ZMQ_SNDMORE);
//send mask
size_t mask_size(mask_rows * mask_cols * sizeof(double));
zmq::message_t mask_buff (mask.data(), mask_size);
s->send(mask_buff, ZMQ_SNDMORE);
// send label
size_t label_size(lbl_rows * lbl_cols * sizeof(double) * np);
zmq::message_t lbl_buff (label.data(), label_size);
s->send(lbl_buff);
}
return 0;
}
int main(int argc, char* argv[]) {
// Check the number of parameters
if (argc < 3) {
std::cerr << "Usage: " << argv[0] << " <INPUT DATASET>" << " <PORT>" << std::endl;
return 1;
}
const string in_dataset = argv[1];
const string port = argv[2];
// Initialize zmq socket
zmq::context_t ctx (1);
zmq::socket_t s (ctx, ZMQ_PUSH);
s.setsockopt(ZMQ_SNDHWM, 160);
string bind_addr = "tcp://*:";
bind_addr.append(port);
int rc = zmq_bind (s, bind_addr.c_str());
assert (rc == 0);
int stop = 0;
// Initialize params
TransformationParameter params;
params.stride=8;
params.crop_size_x=368;
params.crop_size_y=368;
params.target_dist=0.6;
params.scale_prob=1;
params.scale_min=0.5;
params.scale_max=1.1;
params.max_rotate_degree=40;
params.center_perterb_max=40;
params.do_clahe=false;
params.num_parts_in_annot=17;
params.num_parts=56;
params.mirror = true;
DataTransformer* cpmDataTransformer = new DataTransformer(params);
cpmDataTransformer->InitRand();
const int np = 2*(params.num_parts+1);
const int stride = params.stride;
const int grid_x = params.crop_size_x / stride;
const int grid_y = params.crop_size_y / stride;
const int channelOffset = grid_y * grid_x;
const int vec_channels = 38;
const int heat_channels = 19;
const int ch = vec_channels + heat_channels;
const int start_label_data = (params.num_parts+1) * channelOffset;
uchar* transformed_data = new uchar[params.crop_size_x * params.crop_size_y * 3];
double* transformed_label = new double[grid_x * grid_y * np];
// read all samples ids
std::vector<string> keys;
H5::H5File *f_in = new H5::H5File( in_dataset.c_str(), H5F_ACC_RDONLY );
H5::Group* datum = new H5::Group( f_in->openGroup( "datum" ));
getKeys(&keys, datum);
cout << "Total samples: " << keys.size() << endl;
int epoch_cnt = 0;
int samples = keys.size();
// process all samples for multiple epochs until stopped Ctrl+C
// samples are shuffled for each epoch
while (true) {
cout << "Epoch " << ++epoch_cnt << endl;
std::random_shuffle(std::begin(keys), std::end(keys));
// transform samples in current epoch
for (int i = 0; i < keys.size(); i++) {
string key = keys[i];
if (i % 500 == 0) {
cout << "curr_sample/total_samples/curr_epoch = " << i+1 << "/" << samples << "/" << epoch_cnt << endl;
}
// read sample
DatumMetadata meta;
getDatum(key, datum, meta);
// transform sample
int channels = meta.shape[0];
int height = meta.shape[1];
int width = meta.shape[2];
cpmDataTransformer->Transform(meta.datum, channels, height, width,
transformed_data, transformed_label);
// send transformed data and label to the socket
sendTransformed(
transformed_data, transformed_label,
params.crop_size_y, params.crop_size_x,
grid_y, grid_x, ch, start_label_data, &s, stop);
delete[] meta.datum;
}
}
}
| 28.191964 | 111 | 0.651306 | [
"shape",
"vector",
"transform"
] |
82eb377fefc86a82f83ce1da6b89c189ea8b0a00 | 1,340 | cc | C++ | src/geometry/Mesh2D.cc | RLReed/libdetran | 77637c788823e0a14aae7e40e476a291f6f3184b | [
"MIT"
] | 4 | 2015-03-07T16:20:23.000Z | 2020-02-10T13:40:16.000Z | src/geometry/Mesh2D.cc | RLReed/libdetran | 77637c788823e0a14aae7e40e476a291f6f3184b | [
"MIT"
] | 3 | 2018-02-27T21:24:22.000Z | 2020-12-16T00:56:44.000Z | src/geometry/Mesh2D.cc | RLReed/libdetran | 77637c788823e0a14aae7e40e476a291f6f3184b | [
"MIT"
] | 9 | 2015-03-07T16:20:26.000Z | 2022-01-29T00:14:23.000Z | //----------------------------------*-C++-*----------------------------------//
/**
* @file Mesh2D.hh
* @author Jeremy Roberts
* @brief Mesh2D member definitions.
*/
//---------------------------------------------------------------------------//
#include "Mesh2D.hh"
namespace detran_geometry
{
//---------------------------------------------------------------------------//
Mesh2D::Mesh2D(vec_int xfm, vec_int yfm,
vec_dbl xcme, vec_dbl ycme,
vec_int mat_map)
: Mesh(2,
xfm,
yfm,
vec_int(1, 1),
xcme,
ycme,
vec_dbl(2, 0.0),
mat_map)
{
// Set the second z mesh edge to unity.
d_zcme[1] = 1.0;
d_dz[0] = 1.0;
}
//---------------------------------------------------------------------------//
Mesh2D::Mesh2D(vec_dbl xfme, vec_dbl yfme, vec_int mat_map)
: Mesh(2,
xfme,
yfme,
vec_dbl(2, 0.0),
mat_map)
{
// Set the second z mesh edge to unity.
d_zcme[1] = 1.0;
d_dz[0] = 1.0;
}
} // end namespace detran_geometry
#ifdef DETRAN_ENABLE_BOOST
BOOST_CLASS_EXPORT_IMPLEMENT(detran_geometry::Mesh2D)
#endif
//---------------------------------------------------------------------------//
// end of Mesh2D.cc
//---------------------------------------------------------------------------//
| 24.814815 | 79 | 0.370149 | [
"mesh"
] |
82f09efba0516ebd4a217134fbf16cf9d6b46c88 | 4,036 | hh | C++ | RecoDataProducts/inc/TrkToCaloExtrapol.hh | bonventre/Offline | 77db9d6368f27ab9401c690c2c2a4257ade6c231 | [
"Apache-2.0"
] | null | null | null | RecoDataProducts/inc/TrkToCaloExtrapol.hh | bonventre/Offline | 77db9d6368f27ab9401c690c2c2a4257ade6c231 | [
"Apache-2.0"
] | 1 | 2019-11-22T14:45:51.000Z | 2019-11-22T14:50:03.000Z | RecoDataProducts/inc/TrkToCaloExtrapol.hh | bonventre/Offline | 77db9d6368f27ab9401c690c2c2a4257ade6c231 | [
"Apache-2.0"
] | 2 | 2019-10-14T17:46:58.000Z | 2020-03-30T21:05:15.000Z | //
// container for the info of the extrapolated trajectory on the calorimeter
//
// $Id: TrkToCaloExtrapol.hh,v 1.9 2014/08/20 14:23:09 murat Exp $
// $Author: murat $
// $Date: 2014/08/20 14:23:09 $
//
// Original author G. Pezzullo
//
#ifndef TrackCaloMatching_TrkToCaloExtrapol_hh
#define TrackCaloMatching_TrkToCaloExtrapol_hh
// Mu2e includes:
#include "canvas/Persistency/Common/Ptr.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Matrix/Vector.h"
#include "CLHEP/Vector/TwoVector.h"
#include "CLHEP/Matrix/Matrix.h"
#include "BTrk/BbrGeom/HepPoint.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include "CLHEP/Matrix/SymMatrix.h"
#include "BTrk/BbrGeom/BbrVectorErr.hh"
#include "BTrk/BbrGeom/BbrPointErr.hh"
#include "BTrk/BbrGeom/BbrLorentzVectorErr.hh"
//tracker includes
#include "BTrk/KalmanTrack/KalRep.hh"
#include "BTrk/KalmanTrack/KalHit.hh"
#include "BTrk/BaBar/BaBar.hh"
#include "BTrk/TrkBase/HelixParams.hh"
#include "BTrk/TrkBase/HelixTraj.hh"
#include "BTrkData/inc/TrkStrawHit.hh"
#include "RecoDataProducts/inc/KalRepPtrCollection.hh"
// C++ includes
#include <vector>
namespace mu2e {
// typedef art::Ptr<const KalRep * const> EKalRepPtr;
// typedef art::Ptr<KalRep> EKalRepPtr;
struct TrkToCaloExtrapol{
private:
int _diskId;
int _trackNumber; // track numeber
KalRepPtr _trk;
double _pathLengthEntrance;
double _pathLengthExit;
public:
TrkToCaloExtrapol():_diskId(-1),
_pathLengthEntrance(0.0),
_pathLengthExit(0.0){}
TrkToCaloExtrapol(int disk, int trkNumber,
KalRepPtr& trk, double entrance, double exit):
_diskId(disk),
_trackNumber(trkNumber),
_trk(trk),
_pathLengthEntrance(entrance),
_pathLengthExit(exit){
}
~TrkToCaloExtrapol(){}
//Accessors
int diskId() const;
int trackNumber() const {return _trackNumber;}
double time() const;
double timeErr() const;
double pathLengthEntrance() const;
double pathLenghtEntranceErr() const;
double pathLengthExit() const;
double fitConsistency() const;
double t0() const;
double t0Err() const;
double tOrigin() const;
double tOriginErr() const;
CLHEP::Hep3Vector t0Momentum() const;
BbrVectorErr t0MomentumErr() const;
HepPoint entrancePosition() const;
BbrPointErr entrancePositionErr() const;
HepPoint exitPosition() const;
BbrPointErr exitPositionErr() const;
CLHEP::Hep3Vector momentum() const;
BbrVectorErr momentumErr() const;
KalRepPtr const& trk() const{ return _trk; }
void print( std::ostream& ost = std::cout, bool doEndl = true ) const;
bool operator == (const TrkToCaloExtrapol & other) const ;
bool operator<( const TrkToCaloExtrapol& other) const{
return ( _pathLengthEntrance< other._pathLengthEntrance);
}
};
inline std::ostream& operator<<( std::ostream& ost,TrkToCaloExtrapol const& t){
t.print(ost,false);
return ost;
}
typedef std::vector<mu2e::TrkToCaloExtrapol> TrkToCaloExtrapolCollection;
} // namespace mu2e
#endif /* TrackCaloMatching_TrkToCaloExtrapol_hh */
| 34.20339 | 89 | 0.552527 | [
"vector"
] |
82f5381c709b514abc14dabbae7ab84a5e805b55 | 4,377 | hpp | C++ | ThirdParty-mod/java2cpp/org/apache/http/client/protocol/RequestTargetAuthentication.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | 1 | 2019-04-03T01:53:28.000Z | 2019-04-03T01:53:28.000Z | ThirdParty-mod/java2cpp/org/apache/http/client/protocol/RequestTargetAuthentication.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | null | null | null | ThirdParty-mod/java2cpp/org/apache/http/client/protocol/RequestTargetAuthentication.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | null | null | null | /*================================================================================
code generated by: java2cpp
author: Zoran Angelov, mailto://baldzar@gmail.com
class: org.apache.http.client.protocol.RequestTargetAuthentication
================================================================================*/
#ifndef J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ORG_APACHE_HTTP_CLIENT_PROTOCOL_REQUESTTARGETAUTHENTICATION_HPP_DECL
#define J2CPP_ORG_APACHE_HTTP_CLIENT_PROTOCOL_REQUESTTARGETAUTHENTICATION_HPP_DECL
namespace j2cpp { namespace java { namespace lang { class Object; } } }
namespace j2cpp { namespace org { namespace apache { namespace http { class HttpRequest; } } } }
namespace j2cpp { namespace org { namespace apache { namespace http { class HttpRequestInterceptor; } } } }
namespace j2cpp { namespace org { namespace apache { namespace http { namespace protocol { class HttpContext; } } } } }
#include <java/lang/Object.hpp>
#include <org/apache/http/HttpRequest.hpp>
#include <org/apache/http/HttpRequestInterceptor.hpp>
#include <org/apache/http/protocol/HttpContext.hpp>
namespace j2cpp {
namespace org { namespace apache { namespace http { namespace client { namespace protocol {
class RequestTargetAuthentication;
class RequestTargetAuthentication
: public object<RequestTargetAuthentication>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
J2CPP_DECLARE_METHOD(1)
explicit RequestTargetAuthentication(jobject jobj)
: object<RequestTargetAuthentication>(jobj)
{
}
operator local_ref<java::lang::Object>() const;
operator local_ref<org::apache::http::HttpRequestInterceptor>() const;
RequestTargetAuthentication();
void process(local_ref< org::apache::http::HttpRequest > const&, local_ref< org::apache::http::protocol::HttpContext > const&);
}; //class RequestTargetAuthentication
} //namespace protocol
} //namespace client
} //namespace http
} //namespace apache
} //namespace org
} //namespace j2cpp
#endif //J2CPP_ORG_APACHE_HTTP_CLIENT_PROTOCOL_REQUESTTARGETAUTHENTICATION_HPP_DECL
#else //J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ORG_APACHE_HTTP_CLIENT_PROTOCOL_REQUESTTARGETAUTHENTICATION_HPP_IMPL
#define J2CPP_ORG_APACHE_HTTP_CLIENT_PROTOCOL_REQUESTTARGETAUTHENTICATION_HPP_IMPL
namespace j2cpp {
org::apache::http::client::protocol::RequestTargetAuthentication::operator local_ref<java::lang::Object>() const
{
return local_ref<java::lang::Object>(get_jobject());
}
org::apache::http::client::protocol::RequestTargetAuthentication::operator local_ref<org::apache::http::HttpRequestInterceptor>() const
{
return local_ref<org::apache::http::HttpRequestInterceptor>(get_jobject());
}
org::apache::http::client::protocol::RequestTargetAuthentication::RequestTargetAuthentication()
: object<org::apache::http::client::protocol::RequestTargetAuthentication>(
call_new_object<
org::apache::http::client::protocol::RequestTargetAuthentication::J2CPP_CLASS_NAME,
org::apache::http::client::protocol::RequestTargetAuthentication::J2CPP_METHOD_NAME(0),
org::apache::http::client::protocol::RequestTargetAuthentication::J2CPP_METHOD_SIGNATURE(0)
>()
)
{
}
void org::apache::http::client::protocol::RequestTargetAuthentication::process(local_ref< org::apache::http::HttpRequest > const &a0, local_ref< org::apache::http::protocol::HttpContext > const &a1)
{
return call_method<
org::apache::http::client::protocol::RequestTargetAuthentication::J2CPP_CLASS_NAME,
org::apache::http::client::protocol::RequestTargetAuthentication::J2CPP_METHOD_NAME(1),
org::apache::http::client::protocol::RequestTargetAuthentication::J2CPP_METHOD_SIGNATURE(1),
void
>(get_jobject(), a0, a1);
}
J2CPP_DEFINE_CLASS(org::apache::http::client::protocol::RequestTargetAuthentication,"org/apache/http/client/protocol/RequestTargetAuthentication")
J2CPP_DEFINE_METHOD(org::apache::http::client::protocol::RequestTargetAuthentication,0,"<init>","()V")
J2CPP_DEFINE_METHOD(org::apache::http::client::protocol::RequestTargetAuthentication,1,"process","(Lorg/apache/http/HttpRequest;Lorg/apache/http/protocol/HttpContext;)V")
} //namespace j2cpp
#endif //J2CPP_ORG_APACHE_HTTP_CLIENT_PROTOCOL_REQUESTTARGETAUTHENTICATION_HPP_IMPL
#endif //J2CPP_INCLUDE_IMPLEMENTATION
| 37.732759 | 199 | 0.745259 | [
"object"
] |
82fbc70d9893cf25f78db027a50c90b5682147f4 | 4,317 | cpp | C++ | samples/Ch14_common_parallel_patterns/fig_14_24_local_unpack.cpp | kgeorgen/data-parallel-CPP | c1fc8f5f9e3029be0c97f680649f07ab3f86d295 | [
"MIT"
] | null | null | null | samples/Ch14_common_parallel_patterns/fig_14_24_local_unpack.cpp | kgeorgen/data-parallel-CPP | c1fc8f5f9e3029be0c97f680649f07ab3f86d295 | [
"MIT"
] | null | null | null | samples/Ch14_common_parallel_patterns/fig_14_24_local_unpack.cpp | kgeorgen/data-parallel-CPP | c1fc8f5f9e3029be0c97f680649f07ab3f86d295 | [
"MIT"
] | null | null | null | // Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: MIT
#include <CL/sycl.hpp>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <numeric>
#include <random>
using namespace sycl;
using namespace sycl::intel;
const uint32_t max_iterations = 1024;
const uint32_t Nx = 1024, Ny = 768;
struct Parameters {
float xc;
float yc;
float zoom;
float zoom_px;
float x_span;
float y_span;
float x0;
float y0;
float dx;
float dy;
};
void reset(
Parameters params,
uint32_t i,
uint32_t j,
uint32_t& count,
float& cr,
float& ci,
float& zr,
float& zi) {
count = 0;
cr = params.x0 + i * params.dx;
ci = params.y0 + j * params.dy;
zr = zi = 0.0f;
}
bool next_iteration(
Parameters params,
uint32_t i,
uint32_t j,
uint32_t& count,
float& cr,
float& ci,
float& zr,
float& zi,
uint32_t* mandelbrot) {
bool converged = false;
if (i < Nx) {
float next_zr = zr * zr - zi * zi;
float next_zi = 2 * zr * zi;
zr = next_zr + cr;
zi = next_zi + ci;
count++;
// Mark that this value of i has converged
// Output the i result for this value of i
if (count >= max_iterations or zr * zr + zi * zi >= 4.0f) {
converged = true;
uint32_t px = j * Nx + i;
mandelbrot[px] = count;
}
}
return converged;
}
int main() {
queue Q;
// Set up parameters to control divergence, image size, etc
Parameters params;
params.xc = 0.0f;
params.yc = 0.0f;
params.zoom = 1.0f;
params.zoom_px = pow(2.0f, 3.0f - params.zoom) * 1e-3f;
params.x_span = Nx * params.zoom_px;
params.y_span = Ny * params.zoom_px;
params.x0 = params.xc - params.x_span * 0.5f;
params.y0 = params.yc - params.y_span * 0.5f;
params.dx = params.zoom_px;
params.dy = params.zoom_px;
// Initialize output on the host
uint32_t* mandelbrot = malloc_shared<uint32_t>(Ny * Nx, Q);
std::fill(mandelbrot, mandelbrot + Ny * Nx, 0);
range<2> global(Ny, 8);
range<2> local(1, 8);
Q.parallel_for(
nd_range<2>(global, local),
[=](nd_item<2> it) [[intel::reqd_sub_group_size(8)]] {
const uint32_t j = it.get_global_id(0);
sub_group sg = it.get_sub_group();
// Treat each row as a queue of i values to compute
// Initially the head of the queue is at 0
uint32_t iq = 0;
// Initially each work-item in the sub-group works on contiguous values
uint32_t i = iq + sg.get_local_id()[0];
iq += sg.get_max_local_range()[0];
// Initialize the iterator variables
uint32_t count;
float cr, ci, zr, zi;
if (i < Nx) {
reset(params, i, j, count, cr, ci, zr, zi);
}
// Keep iterating as long as one work-item has work to do
while (any_of(sg, i < Nx)) {
uint32_t converged =
next_iteration(params, i, j, count, cr, ci, zr, zi, mandelbrot);
if (any_of(sg, converged)) {
// Replace pixels that have converged using an unpack
// Pixels that haven't converged are not replaced
uint32_t index = exclusive_scan(sg, converged, plus<>());
i = (converged) ? iq + index : i;
iq += reduce(sg, converged, plus<>());
// Reset the iterator variables for the new i
if (converged) {
reset(params, i, j, count, cr, ci, zr, zi);
}
}
}
}).wait();
// Produce an image as a PPM file
constexpr uint32_t max_color = 65535;
std::ofstream ppm;
ppm.open("mandelbrot.ppm");
ppm << std::string("P6").c_str() << "\n";
ppm << Nx << "\n";
ppm << Ny << "\n";
ppm << max_color << "\n";
size_t eof = ppm.tellp();
ppm.close();
ppm.open("mandelbrot.ppm", std::ofstream::binary | std::ofstream::app);
ppm.seekp(eof);
std::vector<uint16_t> colors(Nx * Ny * 3);
for (uint32_t px = 0; px < Nx * Ny; ++px) {
const uint16_t color = (max_iterations - mandelbrot[px]) *
(max_color / (double)max_iterations);
colors[3 * px + 0] = color;
colors[3 * px + 1] = color;
colors[3 * px + 2] = color;
}
ppm.write((char*)colors.data(), 2 * colors.size());
ppm.close();
free(mandelbrot, Q);
return 0;
}
| 25.850299 | 79 | 0.58675 | [
"vector"
] |
82ff791db203344bcf577eab184039ed697d24f7 | 3,469 | cpp | C++ | test/alucell_import.cpp | thomasfoetisch/tfel | c67acabaf4acf4a93edb55a9f415c87fe6b56e89 | [
"BSD-3-Clause"
] | 1 | 2019-07-09T09:31:09.000Z | 2019-07-09T09:31:09.000Z | test/alucell_import.cpp | thomashilke/tfel | c67acabaf4acf4a93edb55a9f415c87fe6b56e89 | [
"BSD-3-Clause"
] | null | null | null | test/alucell_import.cpp | thomashilke/tfel | c67acabaf4acf4a93edb55a9f415c87fe6b56e89 | [
"BSD-3-Clause"
] | null | null | null |
#include "../src/core/projector.hpp"
#include "../src/utility/importer.hpp"
#include "../src/core/export.hpp"
#include "../src/core/composite_fe.hpp"
#include "../src/core/composite_fes.hpp"
#include "../src/core/fes.hpp"
double f(const double* x) {
return std::sin(x[0] * M_PI);
}
void test_restriction_extension() {
using cell_type = cell::edge;
using mesh_type = fe_mesh<cell_type>;
using fe_type = cell::edge::fe::lagrange_p1_bubble;
using fes_type = finite_element_space<fe_type>;
fe_mesh<cell_type> m(gen_segment_mesh(0.0, 1.0, 40));
submesh<cell_type, cell_type> center_sm(m.query_cells([] (const double* x) -> bool {
return x[0] > 0.25 and x[0] < 0.75;
}));
fe_mesh<cell_type> center(center_sm);
fes_type
m_fes(m),
center_fes(center);
const fes_type::element f_h(projector::l2<fe_type, quad::edge::gauss3>(f, m_fes));
exporter::ascii<mesh_type>("f_h.dat", to_mesh_vertex_data<fe_type>(f_h));
const fes_type::element f_h_center(f_h.restrict(center_fes, center_sm));
exporter::ascii<mesh_type>("f_h_center.dat", to_mesh_vertex_data<fe_type>(f_h_center));
const fes_type::element f_h_extended(f_h_center.extend(m_fes, center_sm));
exporter::ascii<mesh_type>("f_h_extended.dat", to_mesh_vertex_data<fe_type>(f_h_extended));
}
void test_alucell_import() {
try {
using cell_type = cell::tetrahedron;
using mesh_type = fe_mesh<cell_type>;
fe_mesh<cell_type> cuve(importer::alucell::mesh<cell_type>("/home/thomas/git/alu-data/AP32/stat/dbfile_stat", "cuveb"));
submesh<cell_type, cell_type> electrolyte(cuve.get_submesh_with_reference(2));
fe_mesh<cell_type> electrolyte_m(electrolyte);
using fe_type = cell::tetrahedron::fe::lagrange_p1;
using cfe_type = composite_finite_element<fe_type, fe_type, fe_type>;
using cfes_type = composite_finite_element_space<cfe_type>;
cfes_type velocity_fes(cuve);
cfes_type electrolyte_velocity_fes(electrolyte_m);
cfes_type::element
velocity(to_composite_p1_finite_element_function<3, cell_type>(
importer::alucell::variable<cell_type>(
"/home/thomas/git/alu-data/AP32/stat/dbfile_stat",
"cuveb", "vitesse", cuve),
velocity_fes));
cfes_type::element electrolyte_velocity(velocity.restrict(electrolyte_velocity_fes, electrolyte));
exporter::ensight6(
"cuveb",
to_mesh_vertex_data<fe_type>(velocity.get_component<0>()), "v0",
to_mesh_vertex_data<fe_type>(velocity.get_component<1>()), "v1",
to_mesh_vertex_data<fe_type>(velocity.get_component<2>()), "v2");
exporter::ensight6("electrolyte",
to_mesh_vertex_data<fe_type>(electrolyte_velocity.get_component<0>()), "v0",
to_mesh_vertex_data<fe_type>(electrolyte_velocity.get_component<1>()), "v1",
to_mesh_vertex_data<fe_type>(electrolyte_velocity.get_component<2>()), "v2");
/*exporter::ensight6("electrolyte",
velocity.get_component<0>().restrict(electrolyte_velocity_fes.get_finite_element_space<0>(), electrolyte), "v0",
velocity.get_component<1>().restrict(electrolyte_velocity_fes.get_finite_element_space<1>(), electrolyte), "v1",
velocity.get_component<2>().restrict(electrolyte_velocity_fes.get_finite_element_space<2>(), electrolyte), "v2");*/
}
catch (const std::string& e) {
std::cout << e << std::endl;
}
}
int main(int argc, char *argv[]) {
test_restriction_extension();
test_alucell_import();
return 0;
}
| 35.762887 | 124 | 0.71548 | [
"mesh"
] |
d201d5a71e74b6198173d98b7069a24a1677c38c | 2,686 | cpp | C++ | src/graphics/d3d12/d3d12_mesh.cpp | irisengine/iris | 0deb12f5d00c67bf0dde1a702344a2cf73925db6 | [
"BSL-1.0"
] | 85 | 2021-10-16T14:58:23.000Z | 2022-03-26T11:05:37.000Z | src/graphics/d3d12/d3d12_mesh.cpp | MaximumProgrammer/iris | cbc2f571bd8d485cdd04f903dcb867e699314682 | [
"BSL-1.0"
] | null | null | null | src/graphics/d3d12/d3d12_mesh.cpp | MaximumProgrammer/iris | cbc2f571bd8d485cdd04f903dcb867e699314682 | [
"BSL-1.0"
] | 2 | 2021-10-17T16:57:13.000Z | 2021-11-14T19:11:30.000Z | ////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#include "graphics/d3d12/d3d12_mesh.h"
#include <memory>
#include <tuple>
#include <vector>
#include "directx/d3d12.h"
#include "directx/d3dx12.h"
#include "core/exception.h"
#include "graphics/vertex_attributes.h"
namespace
{
/**
* Helper function to map engine attribute types to D3D12 types.
*
* @param type
* Engine type
*
* @returns
* D3D12 type.
*/
DXGI_FORMAT to_directx_format(iris::VertexAttributeType type)
{
auto format = DXGI_FORMAT_UNKNOWN;
switch (type)
{
case iris::VertexAttributeType::FLOAT_3: format = DXGI_FORMAT_R32G32B32_FLOAT; break;
case iris::VertexAttributeType::FLOAT_4: format = DXGI_FORMAT_R32G32B32A32_FLOAT; break;
case iris::VertexAttributeType::UINT32_1: format = DXGI_FORMAT_R32_UINT; break;
case iris::VertexAttributeType::UINT32_4: format = DXGI_FORMAT_R32G32B32A32_UINT; break;
default: throw iris::Exception("unknown vertex attribute type");
}
return format;
}
}
namespace iris
{
D3D12Mesh::D3D12Mesh(
const std::vector<VertexData> &vertices,
const std::vector<std::uint32_t> &indices,
const VertexAttributes &attributes)
: vertex_buffer_(vertices)
, index_buffer_(indices)
, input_descriptors_()
{
// build a D3D12 descriptors from supplied attributes
auto index = 0u;
for (const auto &[type, _1, _2, offset] : attributes)
{
// the engine doesn't care too much about vertex semantics, so we just
// call everything a TEXCOORD
input_descriptors_.push_back(
{"TEXCOORD",
index,
to_directx_format(type),
0u,
static_cast<UINT>(offset),
D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA,
0u});
++index;
}
}
void D3D12Mesh::update_vertex_data(const std::vector<VertexData> &data)
{
vertex_buffer_.write(data);
}
void D3D12Mesh::update_index_data(const std::vector<std::uint32_t> &data)
{
index_buffer_.write(data);
}
const D3D12Buffer &D3D12Mesh::vertex_buffer() const
{
return vertex_buffer_;
}
const D3D12Buffer &D3D12Mesh::index_buffer() const
{
return index_buffer_;
}
std::vector<D3D12_INPUT_ELEMENT_DESC> D3D12Mesh::input_descriptors() const
{
return input_descriptors_;
}
}
| 25.826923 | 96 | 0.624721 | [
"vector"
] |
d201f38de9ceb32f46576c9f9d657fc347f1eea6 | 11,649 | cpp | C++ | src/RemotePhotoTool/CameraInfoDlg.cpp | vividos/RemotePhotoTool | d17ae2abbda531acbd0ec8e90ddc4856c4fdfa00 | [
"BSD-2-Clause"
] | 16 | 2015-03-26T02:32:43.000Z | 2021-10-18T16:34:31.000Z | src/RemotePhotoTool/CameraInfoDlg.cpp | vividos/RemotePhotoTool | d17ae2abbda531acbd0ec8e90ddc4856c4fdfa00 | [
"BSD-2-Clause"
] | 7 | 2019-02-21T06:07:09.000Z | 2022-01-01T10:00:50.000Z | src/RemotePhotoTool/CameraInfoDlg.cpp | vividos/RemotePhotoTool | d17ae2abbda531acbd0ec8e90ddc4856c4fdfa00 | [
"BSD-2-Clause"
] | 6 | 2019-05-07T09:21:15.000Z | 2021-09-01T06:36:24.000Z | //
// RemotePhotoTool - remote camera control software
// Copyright (C) 2008-2014 Michael Fink
//
/// \file CameraInfoDlg.cpp Camera info dialog
//
// includes
#include "StdAfx.h"
#include "resource.h"
#include "CameraInfoDlg.hpp"
#include "Instance.hpp"
#include "CameraException.hpp"
#include "SourceDevice.hpp"
#include "RemoteReleaseControl.hpp"
LRESULT CameraInfoDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
DoDataExchange(DDX_LOAD);
CenterWindow(GetParent());
DlgResize_Init(false, false);
CString cszText;
try
{
cszText = CollectCameraInfo();
}
catch (const CameraException& ex)
{
cszText.AppendFormat(_T("\nError while collecting camera info: %s\n"), ex.Message().GetString());
}
cszText.Replace(_T("\n"), _T("\r\n"));
m_ecCameraInfo.SetWindowText(cszText);
return TRUE;
}
CString CameraInfoDlg::CollectCameraInfo()
{
CString cszText;
cszText = _T("Camera model: ") + m_sourceDevice.ModelName() + _T("\n");
cszText += _T("Serial number: ") + m_sourceDevice.SerialNumber() + _T("\n\n");
// get available device properties
CollectDeviceProperties(cszText);
// check if device supports remote release control
if (!m_sourceDevice.GetDeviceCapability(SourceDevice::capRemoteReleaseControl))
{
cszText += _T("Camera doesn't support remote release control");
return cszText;
}
std::shared_ptr<RemoteReleaseControl> spRemoteReleaseControl = m_sourceDevice.EnterReleaseControl();
CollectCapabilities(spRemoteReleaseControl, cszText);
CollectImageProperties(spRemoteReleaseControl, cszText);
CollectShootingModeInfos(spRemoteReleaseControl, cszText);
return cszText;
}
void CameraInfoDlg::CollectDeviceProperties(CString& cszText)
{
cszText += _T("Supported device properties:\n");
std::vector<unsigned int> vecProperties;
try
{
vecProperties = m_sourceDevice.EnumDeviceProperties();
}
catch (CameraException& ex)
{
cszText.AppendFormat(_T("Error while enumerating device properties: %s\n"),
ex.Message().GetString());
}
if (vecProperties.empty())
{
cszText += _T("no device properties found.\n");
}
else
for (size_t iProp=0, iMaxProp = vecProperties.size(); iProp<iMaxProp; iProp++)
{
try
{
unsigned int uiPropertyId = vecProperties[iProp];
const DeviceProperty p = m_sourceDevice.GetDeviceProperty(uiPropertyId);
cszText.AppendFormat(_T("Property \"%s\" (%08x): [%s]\n"),
p.Name().GetString(), uiPropertyId, p.AsString().GetString());
try
{
const std::vector<Variant>& vecValues = p.ValidValues();
for (size_t iValue = 0, iMaxValue = vecValues.size(); iValue < iMaxValue; iValue++)
{
cszText.AppendFormat(_T(" Valid value: %s (%s)\n"),
p.ValueAsString(vecValues[iValue]).GetString(),
vecValues[iValue].ToString().GetString());
}
}
catch (const CameraException& ex)
{
cszText.AppendFormat(_T("Error while enumerating device property values for %08x: %s\n"),
uiPropertyId, ex.Message().GetString());
}
}
catch (const CameraException& ex)
{
cszText.AppendFormat(_T("Error while evaluating device property %08x: %s\n"),
vecProperties[iProp], ex.Message().GetString());
}
}
cszText += _T("\n");
}
void CameraInfoDlg::CollectCapabilities(std::shared_ptr<RemoteReleaseControl> spRemoteReleaseControl, CString& cszText)
{
cszText += _T("Remote release control capabilities:\n");
cszText += _T("- can change shooting parameter: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capChangeShootingParameter) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("- can change shooting mode: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capChangeShootingMode) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("- can control zoom: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capZoomControl) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("- supports viewfinder: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capViewfinder) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("- can release while viewfinder is on: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capReleaseWhileViewfinder) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("- can lock/unlock AF: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capAFLock) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("- can use Bulb mode: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capBulbMode) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("- can lock/unlock user interface: ");
cszText += spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capUILock) ? _T("Yes") : _T("NO");
cszText += _T("\n");
cszText += _T("\n");
}
void CameraInfoDlg::CollectImageProperties(std::shared_ptr<RemoteReleaseControl> spRemoteReleaseControl, CString& cszText)
{
cszText += _T("Supported image properties:\n");
std::vector<unsigned int> vecImageProperties = spRemoteReleaseControl->EnumImageProperties();
if (vecImageProperties.empty())
{
cszText += _T("no image properties found.\n");
}
else
for (size_t i=0,iMax=vecImageProperties.size(); i<iMax; i++)
{
unsigned int uiPropertyId = vecImageProperties[i];
try
{
ImageProperty ip = spRemoteReleaseControl->GetImageProperty(uiPropertyId);
cszText.AppendFormat(_T("Image property \"%s\" (%04x)%s: %s (%s)\n"),
ip.Name().GetString(),
uiPropertyId,
ip.IsReadOnly() ? _T(" [read-only]") : _T(""),
ip.Value().ToString().GetString(),
ip.AsString().GetString());
try
{
std::vector<ImageProperty> vecValues;
spRemoteReleaseControl->EnumImagePropertyValues(vecImageProperties[i], vecValues);
for (size_t j=0, jMax=vecValues.size(); j<jMax; j++)
{
const ImageProperty& ip2 = vecValues[j];
cszText.AppendFormat(_T(" Valid value: %s (%s)\n"),
ip2.Value().ToString().GetString(),
ip.ValueAsString(ip2.Value()).GetString());
}
}
catch (CameraException& ex)
{
cszText.AppendFormat(_T("Error while enumerating image property values for %08x: %s\n"),
uiPropertyId, ex.Message().GetString());
}
}
catch (CameraException& ex)
{
cszText.AppendFormat(_T("Error while evaluating image property %08x: %s\n"),
uiPropertyId, ex.Message().GetString());
}
}
cszText += _T("\n");
}
void CameraInfoDlg::CollectShootingModeInfos(std::shared_ptr<RemoteReleaseControl> spRemoteReleaseControl, CString& cszText)
{
cszText += _T("Supported shooting modes:\n");
try
{
if (!spRemoteReleaseControl->GetCapability(RemoteReleaseControl::capChangeShootingMode))
{
cszText += _T("(Switching shooting modes not supported, can only dump current mode)\n");
unsigned int uiShootingModePropertyId =
spRemoteReleaseControl->MapImagePropertyTypeToId(T_enImagePropertyType::propShootingMode);
// no, just dump current shooting mode
ImageProperty currentShootingMode = spRemoteReleaseControl->GetImageProperty(uiShootingModePropertyId);
CollectShootingModeDetails(spRemoteReleaseControl, currentShootingMode, cszText);
}
else
{
// switch through all shooting modes and dump
std::vector<ImageProperty> vecShootingModes;
unsigned int uiPropertyId = spRemoteReleaseControl->MapImagePropertyTypeToId(T_enImagePropertyType::propShootingMode);
spRemoteReleaseControl->EnumImagePropertyValues(uiPropertyId, vecShootingModes);
if (vecShootingModes.empty())
cszText += _T("(No shooting modes found)\n");
for (const ImageProperty& ip : vecShootingModes)
{
spRemoteReleaseControl->SetImageProperty(ip);
CollectShootingModeDetails(spRemoteReleaseControl, ip, cszText);
}
}
}
catch (CameraException& ex)
{
cszText.AppendFormat(_T("Error while enumerating shooting modes: %s\n"),
ex.Message().GetString());
}
}
void CameraInfoDlg::CollectShootingModeDetails(std::shared_ptr<RemoteReleaseControl> spRemoteReleaseControl,
const ImageProperty& shootingMode, CString& cszText)
{
cszText.AppendFormat(_T("Shooting mode: %s\n"), shootingMode.AsString().GetString());
// get Av values
{
std::vector<ImageProperty> vecAvValues;
unsigned int uiAvPropertyId = spRemoteReleaseControl->MapImagePropertyTypeToId(T_enImagePropertyType::propAv);
try
{
spRemoteReleaseControl->EnumImagePropertyValues(uiAvPropertyId, vecAvValues);
}
catch (const CameraException& ex)
{
cszText.AppendFormat(_T("Error while enumerating Av values: %s\n"), ex.Message().GetString());
}
if (!vecAvValues.empty())
{
cszText += _T(" Available aperture values: ");
for (size_t i=0, iMax=vecAvValues.size(); i<iMax; i++)
{
const ImageProperty& val = vecAvValues[i];
cszText.AppendFormat(_T("%s%s"), i==0 ? _T("") : _T(", "), val.AsString().GetString());
}
cszText += _T("\n");
}
}
// get Tv values
{
std::vector<ImageProperty> vecTvValues;
unsigned int uiTvPropertyId = spRemoteReleaseControl->MapImagePropertyTypeToId(T_enImagePropertyType::propTv);
try
{
spRemoteReleaseControl->EnumImagePropertyValues(uiTvPropertyId, vecTvValues);
}
catch (const CameraException& ex)
{
cszText.AppendFormat(_T("Exception while enumerating Tv values: %s\n"), ex.Message().GetString());
}
if (!vecTvValues.empty())
{
cszText += _T(" Available shutter speed values: ");
for (size_t i=0, iMax=vecTvValues.size(); i<iMax; i++)
{
const ImageProperty& val = vecTvValues[i];
cszText.AppendFormat(_T("%s%s"), i==0 ? _T("") : _T(", "), val.AsString().GetString());
}
cszText += _T("\n");
}
}
// get exposure compensation values
{
std::vector<ImageProperty> vecEcValues;
unsigned int uiEcPropertyId = spRemoteReleaseControl->MapImagePropertyTypeToId(T_enImagePropertyType::propExposureCompensation);
try
{
spRemoteReleaseControl->EnumImagePropertyValues(uiEcPropertyId, vecEcValues);
}
catch (const CameraException& ex)
{
cszText.AppendFormat(_T("Error while enumerating exposure compensation values: %s\n"), ex.Message().GetString());
}
if (!vecEcValues.empty())
{
cszText += _T(" Available exposure compensation values: ");
for (size_t i=0, iMax=vecEcValues.size(); i<iMax; i++)
{
const ImageProperty& val = vecEcValues[i];
cszText.AppendFormat(_T("%s%s"), i==0 ? _T("") : _T(", "), val.AsString().GetString());
}
cszText += _T("\n");
}
}
cszText += _T("\n");
}
| 33.378223 | 134 | 0.638166 | [
"vector",
"model"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.