blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cef5e90bb9cb53b0b02ed1f4070275a0f6fcadb4 | 5b4bdacd0df4a79a4ad70bb4ba7e4a92677f6237 | /src/ast/IfStatement.h | dd3ad6596b816074de8b311d2e9f5df68e1fcbd8 | [] | no_license | lukaa12/TKOM-simple_language_interpreter | e4b7675456312c466310944bae8d00007ad78f8b | 98ec6c574c804b69db6d26100136ccd6b053ef1f | refs/heads/master | 2022-09-17T14:33:49.354595 | 2020-06-03T11:14:40 | 2020-06-03T11:14:40 | 269,164,618 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,092 | h | #ifndef IF_STATEMENT_H
#define IF_STATEMENT_H
#include "AstNode.h"
#include "../stdlib/DataTypes.h"
namespace tkom {
namespace ast {
class IfStatement : public Instruction
{
public:
Condition* getCondition()
{
return condition.get();
}
Body* getIfBody()
{
return ifBody.get();
}
Body* getElseBody()
{
return elseBody.get();
}
void setCondition(std::unique_ptr<Condition> ptr)
{
ptr->parent = this;
this->condition = std::move(ptr);
}
void setIfBody(std::unique_ptr<Body> ptr)
{
ptr->parent = this;
this->ifBody = std::move(ptr);
}
void setElseBody(std::unique_ptr<Body> ptr)
{
ptr->parent = this;
this->elseBody = std::move(ptr);
}
Type getType()
{
return Type::If;
}
void exec();
bool wasReturned;
bool wasBreaked;
DataType dtype;
std::variant<int, std::string, lib::Color, lib::Graphic> returned;
private:
std::unique_ptr<Condition> condition;
std::unique_ptr<Body> ifBody;
std::unique_ptr<Body> elseBody;
};
}
}
#endif // !IF_STATEMENT_H | [
"l.wolanin@stud.elka.pw.edu.pl"
] | l.wolanin@stud.elka.pw.edu.pl |
8e5d6282a34b320245fb292dc2ff8de49e898b55 | 08c01a0ebe125f5ee2f1db73a9e942a8e0786d82 | /main.cpp | 8f614b8fda584fce79a9d1a9fef31c1bd55fff2e | [] | no_license | SealBelek/physicEngine | ac5e68df49e325e52dc16451d2f71dbf16d292d6 | d7ca569ab73c13f156d2aae6d50011506e121d7a | refs/heads/master | 2022-08-02T22:40:17.608962 | 2020-05-26T20:54:32 | 2020-05-26T20:54:32 | 240,591,519 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,133 | cpp |
#include <GL/glut.h>
#include "include/app.h"
#include "include/timing.h"
extern Application* getApplication();
// Store the global application object.
Application* app;
/**
* Creates a window in which to display the scene.
*/
void createWindow(const char* title)
{
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(640,320);
glutInitWindowPosition(0,0);
glutCreateWindow(title);
}
/**
* Called each frame to update the 3D scene. Delegates to
* the application.
*/
void update()
{
// Update the timing.
TimingData::get().update();
// Delegate to the application.
app->update();
}
/**
* Called each frame to display the 3D scene. Delegates to
* the application.
*/
void display()
{
app->display();
// Update the displayed content.
glFlush();
glutSwapBuffers();
}
/**
* Called when a mouse button is pressed. Delegates to the
* application.
*/
void mouse(int button, int state, int x, int y)
{
app->mouse(button, state, x, y);
}
/**
* Called when the display window changes size.
*/
void reshape(int width, int height)
{
app->resize(width, height);
}
/**
* Called when a key is pressed.
*/
void keyboard(unsigned char key, int x, int y)
{
// Note we omit passing on the x and y: they are rarely needed.
app->key(key);
}
/**
* Called when the mouse is dragged.
*/
void motion(int x, int y)
{
app->mouseDrag(x, y);
}
/**
* The main entry point. We pass arguments onto GLUT.
*/
int main(int argc, char** argv) {
// Set up GLUT and the timers
glutInit(&argc, argv);
TimingData::init();
// Create the application and its window
app = getApplication();
createWindow(app->getTitle());
// Set up the appropriate handler functions
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutIdleFunc(update);
glutMouseFunc(mouse);
glutMotionFunc(motion);
// Run the application
app->initGraphics();
glutMainLoop();
// Clean up the application
app->deinit();
delete app;
TimingData::deinit();
return 0;
} | [
"berdyschev@yandex.ru"
] | berdyschev@yandex.ru |
6de355d3c60b766184924a64a6751168dd6b37db | e8bf28ea44ccaf90fa9802a7b84de11f39539bc7 | /src/debugger/bridge/delayload.cpp | 5636c0128c7e0984bc245cb30b26187ede166915 | [
"MIT"
] | permissive | pengdebin/vscode-lua-debug | 7e1aeeb0064f4dd0ea088a6bc6d245dd24521363 | e4535ad6ef6a45bf7236a7c0599a013954dd20e3 | refs/heads/master | 2020-04-06T09:28:28.418753 | 2018-11-26T02:45:01 | 2018-11-26T02:45:01 | 157,343,933 | 3 | 0 | MIT | 2018-11-13T08:12:54 | 2018-11-13T08:12:54 | null | UTF-8 | C++ | false | false | 2,688 | cpp | #if defined(DEBUGGER_BRIDGE)
#include <debugger/bridge/delayload.h>
#include <windows.h>
#define DELAYIMP_INSECURE_WRITABLE_HOOKS
#include <DelayImp.h>
#include <debugger/bridge/lua.h>
namespace delayload
{
static std::wstring luadll_path;
static HMODULE luadll_handle = 0;
static GetLuaApi get_lua_api = ::GetProcAddress;
bool has_luadll()
{
return !luadll_path.empty() || luadll_handle != 0;
}
void set_luadll(const std::wstring& path)
{
if (has_luadll()) return;
luadll_path = path;
get_lua_api = ::GetProcAddress;
}
void set_luadll(HMODULE handle, GetLuaApi fn)
{
if (has_luadll()) return;
luadll_handle = handle;
get_lua_api = fn ? fn : ::GetProcAddress;
}
static FARPROC WINAPI hook(unsigned dliNotify, PDelayLoadInfo pdli)
{
switch (dliNotify) {
case dliStartProcessing:
break;
case dliNotePreLoadLibrary:
if (strcmp("lua53.dll", pdli->szDll) == 0) {
if (!luadll_path.empty()) {
HMODULE m = LoadLibraryW(luadll_path.c_str());
lua::check_version(m);
return (FARPROC)m;
}
else if (luadll_handle) {
lua::check_version(luadll_handle);
return (FARPROC)luadll_handle;
}
}
break;
case dliNotePreGetProcAddress: {
FARPROC ret = get_lua_api(pdli->hmodCur, pdli->dlp.szProcName);
if (ret) {
return ret;
}
if (strcmp(pdli->dlp.szProcName, "lua_getuservalue") == 0) {
lua::lua54::lua_getiuservalue = (int(__cdecl*)(lua_State*, int, int))get_lua_api(pdli->hmodCur, "lua_getiuservalue");
if (lua::lua54::lua_getiuservalue) {
return (FARPROC)lua::lua54::lua_getuservalue;
}
}
else if (strcmp(pdli->dlp.szProcName, "lua_setuservalue") == 0) {
lua::lua54::lua_setiuservalue = (int(__cdecl*)(lua_State*, int, int))get_lua_api(pdli->hmodCur, "lua_setiuservalue");
if (lua::lua54::lua_setiuservalue) {
return (FARPROC)lua::lua54::lua_setuservalue;
}
}
else if (strcmp(pdli->dlp.szProcName, "lua_newuserdata") == 0) {
lua::lua54::lua_newuserdatauv = (void*(__cdecl*)(lua_State*, size_t, int))get_lua_api(pdli->hmodCur, "lua_newuserdatauv");
if (lua::lua54::lua_newuserdatauv) {
return (FARPROC)lua::lua54::lua_newuserdata;
}
}
else if (strcmp(pdli->dlp.szProcName, "lua_getprotohash") == 0) {
return (FARPROC)lua::lua_getprotohash;
}
char str[256];
sprintf(str, "Can't find lua c function: `%s`.", pdli->dlp.szProcName);
MessageBoxA(0, str, "Fatal Error.", 0);
return NULL;
}
break;
case dliFailLoadLib:
break;
case dliFailGetProc:
break;
case dliNoteEndProcessing:
break;
default:
return NULL;
}
return NULL;
}
}
PfnDliHook __pfnDliNotifyHook2 = delayload::hook;
#endif
| [
"actboy168@gmail.com"
] | actboy168@gmail.com |
85580d65c5010bc1daa3790cc0dcfbe4c6f7e4fb | a57cc4f074203e8ceefa3285a1a72b564e831eae | /src/wallet/api/subaddress.cpp | e8b910c71e3361d862bfbd70af3dfdabd3ee49bb | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | trublud/kickasscoin | 286b2c9637bf92416d8e2017c6c0c15a25f8ebc8 | 8153ff2f1fe8f3a761b71eab9afb1b02876809d5 | refs/heads/master | 2020-06-19T15:58:58.218099 | 2019-07-13T23:04:47 | 2019-07-13T23:04:47 | 194,447,129 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,005 | cpp | // Copyright (c) 2017-2019, The KickAssCoin Project
//
// 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 the copyright holder 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.
#include "subaddress.h"
#include "wallet.h"
#include "crypto/hash.h"
#include "wallet/wallet2.h"
#include "common_defines.h"
#include <vector>
namespace KickAssCoin {
Subaddress::~Subaddress() {}
SubaddressImpl::SubaddressImpl(WalletImpl *wallet)
: m_wallet(wallet) {}
void SubaddressImpl::addRow(uint32_t accountIndex, const std::string &label)
{
m_wallet->m_wallet->add_subaddress(accountIndex, label);
refresh(accountIndex);
}
void SubaddressImpl::setLabel(uint32_t accountIndex, uint32_t addressIndex, const std::string &label)
{
try
{
m_wallet->m_wallet->set_subaddress_label({accountIndex, addressIndex}, label);
refresh(accountIndex);
}
catch (const std::exception& e)
{
LOG_ERROR("setLabel: " << e.what());
}
}
void SubaddressImpl::refresh(uint32_t accountIndex)
{
LOG_PRINT_L2("Refreshing subaddress");
clearRows();
for (size_t i = 0; i < m_wallet->m_wallet->get_num_subaddresses(accountIndex); ++i)
{
m_rows.push_back(new SubaddressRow(i, m_wallet->m_wallet->get_subaddress_as_str({accountIndex, (uint32_t)i}), m_wallet->m_wallet->get_subaddress_label({accountIndex, (uint32_t)i})));
}
}
void SubaddressImpl::clearRows() {
for (auto r : m_rows) {
delete r;
}
m_rows.clear();
}
std::vector<SubaddressRow*> SubaddressImpl::getAll() const
{
return m_rows;
}
SubaddressImpl::~SubaddressImpl()
{
clearRows();
}
} // namespace
| [
"xmindpingx@gmail.com"
] | xmindpingx@gmail.com |
9a52d5a5016c4b710e847be505cedeac7ba36eb5 | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir35435/dir35536/dir35859/dir38124/file38203.cpp | b23ad5ba27e860b0106dae9163b243166f2c3bd0 | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115 | cpp | #ifndef file38203
#error "macro file38203 must be defined"
#endif
static const char* file38203String = "file38203"; | [
"tgeng@google.com"
] | tgeng@google.com |
664cb5fdfc37d865ba5ac0b46e3af1f97493fe3f | 14bb0b5d7478d3a8740cbc15cc7870fcd1fa8207 | /tensorflow/lite/micro/examples/magic_wand/magic_wand_test.cc | fb75afee309f5c296ac83da82baa3a80072971d4 | [
"Apache-2.0"
] | permissive | terigrossheim/tensorflow | 2be34891c99e0fcf88cf8418632f24676f1620a7 | ed9d45f096097c77664815c361c75e73af4f32d4 | refs/heads/master | 2022-11-06T12:08:10.099807 | 2020-06-29T12:10:56 | 2020-06-29T12:35:24 | 275,867,898 | 1 | 0 | Apache-2.0 | 2020-06-29T16:21:41 | 2020-06-29T16:21:39 | null | UTF-8 | C++ | false | false | 6,560 | cc | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/lite/micro/examples/magic_wand/magic_wand_model_data.h"
#include "tensorflow/lite/micro/examples/magic_wand/ring_micro_features_data.h"
#include "tensorflow/lite/micro/examples/magic_wand/slope_micro_features_data.h"
#include "tensorflow/lite/micro/kernels/micro_ops.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/micro/testing/micro_test.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/version.h"
TF_LITE_MICRO_TESTS_BEGIN
TF_LITE_MICRO_TEST(LoadModelAndPerformInference) {
// Set up logging
tflite::MicroErrorReporter micro_error_reporter;
tflite::ErrorReporter* error_reporter = µ_error_reporter;
// Map the model into a usable data structure. This doesn't involve any
// copying or parsing, it's a very lightweight operation.
const tflite::Model* model = ::tflite::GetModel(g_magic_wand_model_data);
if (model->version() != TFLITE_SCHEMA_VERSION) {
TF_LITE_REPORT_ERROR(error_reporter,
"Model provided is schema version %d not equal "
"to supported version %d.\n",
model->version(), TFLITE_SCHEMA_VERSION);
}
// Pull in only the operation implementations we need.
// This relies on a complete list of all the ops needed by this graph.
// An easier approach is to just use the AllOpsResolver, but this will
// incur some penalty in code space for op implementations that are not
// needed by this graph.
static tflite::MicroMutableOpResolver<5> micro_op_resolver; // NOLINT
micro_op_resolver.AddConv2D();
micro_op_resolver.AddDepthwiseConv2D();
micro_op_resolver.AddFullyConnected();
micro_op_resolver.AddMaxPool2D();
micro_op_resolver.AddSoftmax();
// Create an area of memory to use for input, output, and intermediate arrays.
// Finding the minimum value for your model may require some trial and error.
const int tensor_arena_size = 60 * 1024;
uint8_t tensor_arena[tensor_arena_size];
// Build an interpreter to run the model with
tflite::MicroInterpreter interpreter(model, micro_op_resolver, tensor_arena,
tensor_arena_size, error_reporter);
// Allocate memory from the tensor_arena for the model's tensors
interpreter.AllocateTensors();
// Obtain a pointer to the model's input tensor
TfLiteTensor* input = interpreter.input(0);
// Make sure the input has the properties we expect
TF_LITE_MICRO_EXPECT_NE(nullptr, input);
TF_LITE_MICRO_EXPECT_EQ(4, input->dims->size);
// The value of each element gives the length of the corresponding tensor.
TF_LITE_MICRO_EXPECT_EQ(1, input->dims->data[0]);
TF_LITE_MICRO_EXPECT_EQ(128, input->dims->data[1]);
TF_LITE_MICRO_EXPECT_EQ(3, input->dims->data[2]);
TF_LITE_MICRO_EXPECT_EQ(1, input->dims->data[3]);
// The input is a 32 bit floating point value
TF_LITE_MICRO_EXPECT_EQ(kTfLiteFloat32, input->type);
// Provide an input value
const float* ring_features_data = g_ring_micro_f9643d42_nohash_4_data;
TF_LITE_REPORT_ERROR(error_reporter, "%d", input->bytes);
for (int i = 0; i < (input->bytes / sizeof(float)); ++i) {
input->data.f[i] = ring_features_data[i];
}
// Run the model on this input and check that it succeeds
TfLiteStatus invoke_status = interpreter.Invoke();
if (invoke_status != kTfLiteOk) {
TF_LITE_REPORT_ERROR(error_reporter, "Invoke failed\n");
}
TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, invoke_status);
// Obtain a pointer to the output tensor and make sure it has the
// properties we expect.
TfLiteTensor* output = interpreter.output(0);
TF_LITE_MICRO_EXPECT_EQ(2, output->dims->size);
TF_LITE_MICRO_EXPECT_EQ(1, output->dims->data[0]);
TF_LITE_MICRO_EXPECT_EQ(4, output->dims->data[1]);
TF_LITE_MICRO_EXPECT_EQ(kTfLiteFloat32, output->type);
// There are four possible classes in the output, each with a score.
const int kWingIndex = 0;
const int kRingIndex = 1;
const int kSlopeIndex = 2;
const int kNegativeIndex = 3;
// Make sure that the expected "Ring" score is higher than the other
// classes.
float wing_score = output->data.f[kWingIndex];
float ring_score = output->data.f[kRingIndex];
float slope_score = output->data.f[kSlopeIndex];
float negative_score = output->data.f[kNegativeIndex];
TF_LITE_MICRO_EXPECT_GT(ring_score, wing_score);
TF_LITE_MICRO_EXPECT_GT(ring_score, slope_score);
TF_LITE_MICRO_EXPECT_GT(ring_score, negative_score);
// Now test with a different input, from a recording of "Slope".
const float* slope_features_data = g_slope_micro_f2e59fea_nohash_1_data;
for (int i = 0; i < (input->bytes / sizeof(float)); ++i) {
input->data.f[i] = slope_features_data[i];
}
// Run the model on this "Slope" input.
invoke_status = interpreter.Invoke();
if (invoke_status != kTfLiteOk) {
TF_LITE_REPORT_ERROR(error_reporter, "Invoke failed\n");
}
TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, invoke_status);
// Get the output from the model, and make sure it's the expected size and
// type.
output = interpreter.output(0);
TF_LITE_MICRO_EXPECT_EQ(2, output->dims->size);
TF_LITE_MICRO_EXPECT_EQ(1, output->dims->data[0]);
TF_LITE_MICRO_EXPECT_EQ(4, output->dims->data[1]);
TF_LITE_MICRO_EXPECT_EQ(kTfLiteFloat32, output->type);
// Make sure that the expected "Slope" score is higher than the other classes.
wing_score = output->data.f[kWingIndex];
ring_score = output->data.f[kRingIndex];
slope_score = output->data.f[kSlopeIndex];
negative_score = output->data.f[kNegativeIndex];
TF_LITE_MICRO_EXPECT_GT(slope_score, wing_score);
TF_LITE_MICRO_EXPECT_GT(slope_score, ring_score);
TF_LITE_MICRO_EXPECT_GT(slope_score, negative_score);
}
TF_LITE_MICRO_TESTS_END
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
30ba70a803570564a4b6c3b6a6322770c0ee95fd | da8d8d5c91b88494036b5fd17665324891759db4 | /IRCBot/Thread.cpp | 3538fdd1c83af1176efa52cc87edf53f411c0eeb | [] | no_license | ftbmynameis/IRCBot | 62d18da9dce87818cc07190d6316f4e3ff36b322 | eb1ceca571d8225ff77eed53cb8b63ab1c569b08 | refs/heads/master | 2021-01-23T08:56:32.273413 | 2014-11-16T20:05:29 | 2014-11-16T20:05:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 447 | cpp | #include "Thread.h"
#include <process.h>
#include <memory>
Thread::Thread(ThreadEntryPoint *entry)
{
m_ThreadHandle = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &Thread::EntryPoint, entry, 0, NULL));
}
Thread::~Thread()
{
if(m_ThreadHandle)
CloseHandle(m_ThreadHandle);
}
unsigned int __stdcall Thread::EntryPoint(void* userdata)
{
ThreadEntryPoint* entry = reinterpret_cast<ThreadEntryPoint*>(userdata);
entry->Run();
return 0;
} | [
"ftbmynameis@gmail.com"
] | ftbmynameis@gmail.com |
507a3a481ed05882c6b4a546f6ac32acb2c86c05 | 73bd1c793872902f7c35bd44b9fb10aaa68d172e | /v0.1/EventLoopThread.h | 3d191e1e31869360b35ea2cb847d1b4c2bcd5bdc | [] | no_license | lin-tony/HttpServer | 26dd11b3c8ee2cb443d2e3b08f293be796304f8c | 41c5f50082271066e38be240cb1c81dbd4f92a1e | refs/heads/master | 2020-04-26T16:26:01.823888 | 2019-05-04T07:13:39 | 2019-05-04T07:13:39 | 173,678,104 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 327 | h | #ifndef EVENTLOOPTHREAD_H
#define EVENTLOOPTHREAD_H
#include <functional>
#include "Thread.h"
#include "EventLoop.h"
class EventLoopThread{
public:
EventLoopThread();
~EventLoopThread();
EventLoop* getLoop(){
return _loop;
}
private:
static void* threadFunc(void* arg);
EventLoop* _loop;
Thread _thread;
};
#endif
| [
"lin-tony@users.noreply.github.com"
] | lin-tony@users.noreply.github.com |
6057a39ced6bfaf8781a97ac09cc4d80bb9a965c | 05225a3102bd0f6acac531b65f0e5a47262aff7c | /catromcurveevaluator.h | fde9a95b778f7eae3f7bd131f1128b92f5a31114 | [] | no_license | kaivanwadia/animator | e8c518e2656b08e2b85e0c2662c3113d90465347 | ecf03b9d65fd8b1e22bcd5b376b163b5f8674b4a | refs/heads/master | 2020-06-02T10:53:41.360236 | 2015-09-18T21:50:38 | 2015-09-18T21:50:38 | 42,748,340 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 389 | h | #ifndef INCLUDED_CATMULLROM_CURVE_EVALUATOR_H
#define INCLUDED_CATMULLROM_CURVE_EVALUATOR_H
#pragma warning(disable : 4786)
#include "curveevaluator.h"
class CatRomCurveEvaluator : public CurveEvaluator
{
public:
void evaluateCurve(const std::vector<Point>& ptvCtrlPts,
std::vector<Point>& ptvEvaluatedCurvePts,
const float& fAniLength,
const bool& bWrap) const;
};
#endif
| [
"kaivanwadia@gmail.com"
] | kaivanwadia@gmail.com |
c4e10d6941d18db21bfefb93c6c38c4633296f39 | 980a4702cf5396ab54cb0e9282055e1e2d3edd1d | /libnd4j/include/ops/declarable/helpers/cpu/convolutions_conv2dBP.cpp | 6a01a4a4dda5515f66f1bc2013f310dc2c5233c4 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | pxiuqin/deeplearning4j | 5d7abea2102ad3c8d6455803f7afc5e7641062a1 | e11ddf3c24d355b43d36431687b807c8561aaae4 | refs/heads/master | 2022-12-02T00:09:48.450622 | 2020-08-13T10:32:14 | 2020-08-13T10:32:14 | 277,511,646 | 1 | 0 | Apache-2.0 | 2020-08-13T10:32:16 | 2020-07-06T10:28:22 | null | UTF-8 | C++ | false | false | 6,479 | cpp | /*******************************************************************************
* Copyright (c) 2015-2018 Skymind, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available 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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/
//
// @author Yurii Shyrma (iuriish@yahoo.com), created on 18.09.2018
//
#include <ops/declarable/helpers/convolutions.h>
#include <ops/declarable/helpers/im2col.h>
#include <ops/declarable/helpers/col2im.h>
#include <array/NDArrayFactory.h>
#include <helpers/MmulHelper.h>
#include <execution/Threads.h>
namespace sd {
namespace ops {
//////////////////////////////////////////////////////////////////////////
template <typename X, typename Y>
static void conv2dBP_(sd::graph::Context& block, const NDArray* input, const NDArray* weights, const NDArray* bias, const NDArray* gradO, NDArray* gradI, NDArray* gradW, NDArray* gradB, const int kH, const int kW, const int sH, const int sW, int pH, int pW, const int dH, const int dW, const int paddingMode, const int isNCHW, const int wFormat) {
// input [bS, iH, iW, iC] (NHWC) or [bS, iC, iH, iW] (NCHW)
// weights [kH, kW, iC, oC], [oC, iC, kH, kW], [oC, kH, kW, iC]
// bias [oC]
// gradO [bS, oH, oW, oC] (NHWC) or [bS, oC, oH, oW] (NCHW), epsilon_next
// gradI [bS, iH, iW, iC] (NHWC) or [bS, iC, iH, iW] (NCHW), epsilon
// gradW [kH, kW, iC, oC], [oC, iC, kH, kW], [oC, kH, kW, iC]
// gradB [oC]
// kH filter(kernel) height
// kW filter(kernel) width
// sH strides height
// sW strides width
// pH paddings height
// pW paddings width
// dH dilations height
// dW dilations width
// paddingMode 0-VALID, 1-SAME
// isNCHW 0-NHWC, 1-NCHW
int bS, iC, iH, iW, oC, oH, oW; // batch size, input channels, input height/width, output channels, output height/width;
int indIOioC, indIiH, indWoC, indWiC, indWkH, indOoH; // corresponding indexes
ConvolutionUtils::getSizesAndIndexesConv2d(isNCHW, wFormat, *input, *gradO, bS, iC, iH, iW, oC, oH, oW, indIOioC, indIiH, indWiC, indWoC, indWkH, indOoH);
ConvolutionUtils::calcPadding2D(pH, pW, oH, oW, iH, iW, kH, kW, sH, sW, dH, dW, paddingMode);
nd4j_debug("MKL-DNN is not used for conv2d_bp!\n", 0);
std::vector<int> gradOaxesForDot;
if(!isNCHW) {
gradOaxesForDot = {0, 1, 2}; // bS, oH, oW
input = new NDArray(input->permute({0, 3, 1, 2})); // [bS, iH, iW, iC] -> [bS, iC, iH, iW]
gradI = new NDArray(gradI->permute({0, 3, 1, 2})); // [bS, iH, iW, iC] -> [bS, iC, iH, iW]
} else {
gradOaxesForDot = {0, 2, 3}; // bS, oH, oW
}
std::vector<int> wPermut, colPermut;
if(0 == wFormat) {
wPermut = {2, 0, 1, 3};
colPermut = {2, 3, 1, 0, 4, 5};
}
else if(1 == wFormat) {
wPermut = {1, 2, 3, 0};
colPermut = {1, 2, 3, 0, 4, 5};
}
else {
wPermut = {3, 1, 2, 0};
colPermut = {2, 3, 1, 0, 4, 5};
}
NDArray columns(input->ordering(), {bS, iC, kH, kW, oH, oW}, input->dataType(), input->getContext());
// ----- calculation of gradW ----- //
if(gradW) {
auto ctx = block.launchContext();
helpers::im2col(*ctx, *input, columns, kH, kW, sH, sW, pH, pW, dH, dW, NDArrayFactory::create(0.f, input->getContext())); // [bS, iC, iH, iW] is convoluted to [bS, iC, kH, kW, oH, oW]
sd::MmulHelper::tensorDot(&columns, gradO, gradW, {0,4,5}, gradOaxesForDot, wPermut); // [bS, iC, kH, kW, oH, oW] x [bS, oH, oW, oC]/[bS, oC, oH, oW] = [iC, kH, kW, oC]
}
// ----- calculation of gradB ----- //
if(gradB) {
NDArray* gradBR = gradB;
if(gradB->rankOf() == 2)
gradBR = new NDArray(gradB->reshape(gradB->ordering(), {(int)gradB->lengthOf()}));
gradO->reduceAlongDimension(reduce::Sum, *gradBR, gradOaxesForDot); // sum over bS, oH, oW
if(gradBR != gradB)
delete gradBR;
}
//----- calculation of gradI -----//
// [kH, kW, iC, oC] x [bS, oH, oW, oC]/[bS, oC, oH, oW] = [kH, kW, iC, bS, oH, oW]
// [oC, iC, kH, kW] x [bS, oH, oW, oC]/[bS, oC, oH, oW] = [iC, kH, kW, bS, oH, oW]
// [oC, kH, kW, iC] x [bS, oH, oW, oC]/[bS, oC, oH, oW] = [kH, kW, iC, bS, oH, oW]
sd::MmulHelper::tensorDot(weights, gradO, &columns, {indWoC}, {indIOioC}, colPermut);
helpers::col2im(*block.launchContext(), columns, *gradI, sH, sW, pH, pW, iH, iW, dH, dW); // [bS, iC, kH, kW, oH, oW] is de-convoluted to [bS, iC, iH, iW]
if(!isNCHW) {
delete input;
delete gradI;
}
}
void ConvolutionUtils::conv2dBP(sd::graph::Context& block, const NDArray* input, const NDArray* weights, const NDArray* bias, const NDArray* gradO, NDArray* gradI, NDArray* gradW, NDArray* gradB, const int kH, const int kW, const int sH, const int sW, int pH, int pW, const int dH, const int dW, const int paddingMode, const int isNCHW, const int wFormat) {
BUILD_SINGLE_SELECTOR_TWICE(input->dataType(), conv2dBP_, (block, input, weights, bias, gradO, gradI, gradW, gradB, kH, kW, sH, sW, pH, pW, dH, dW, paddingMode, isNCHW, wFormat), FLOAT_TYPES);
}
}
} | [
"noreply@github.com"
] | noreply@github.com |
1655cd26050f3cfa8b8db98c91a2a964e1b57391 | c831d5b1de47a062e1e25f3eb3087404b7680588 | /webkit/Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h | 7ae8d2a6f54a4d958bea76ac704304fb16e25a91 | [] | no_license | naver/sling | 705b09c6bba6a5322e6478c8dc58bfdb0bfb560e | 5671cd445a2caae0b4dd0332299e4cfede05062c | refs/heads/master | 2023-08-24T15:50:41.690027 | 2016-12-20T17:19:13 | 2016-12-20T17:27:47 | 75,152,972 | 126 | 6 | null | 2022-10-31T00:25:34 | 2016-11-30T04:59:07 | C++ | UTF-8 | C++ | false | false | 2,232 | h | /*
* Copyright (C) 2014 Apple Inc. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 BlobDataFileReferenceWithSandboxExtension_h
#define BlobDataFileReferenceWithSandboxExtension_h
#include <WebCore/BlobDataFileReference.h>
namespace WebKit {
class SandboxExtension;
class BlobDataFileReferenceWithSandboxExtension final : public WebCore::BlobDataFileReference {
public:
static Ref<BlobDataFileReference> create(const String& path, PassRefPtr<SandboxExtension> sandboxExtension)
{
return adoptRef(*new BlobDataFileReferenceWithSandboxExtension(path, sandboxExtension));
}
private:
BlobDataFileReferenceWithSandboxExtension(const String& path, PassRefPtr<SandboxExtension>);
virtual ~BlobDataFileReferenceWithSandboxExtension();
void prepareForFileAccess() override;
void revokeFileAccess() override;
RefPtr<SandboxExtension> m_sandboxExtension;
};
}
#endif // BlobDataFileReferenceWithSandboxExtension_h
| [
"daewoong.jang@navercorp.com"
] | daewoong.jang@navercorp.com |
f0b9ac49575ff0363443a289b0f10063bd515f44 | 32b62d900a1396f56042082bfe3243e90b40456c | /URI/1221.cpp | 3345936d4ceff1e96b3b680ce214a3eab407b691 | [] | no_license | gabialverga/competitiveProgramming | a6fc72cf372fc7653ea8cb2b127f87a6b01cb54d | ce13d0fb772f8c1a017a552c47706e72381a0ebc | refs/heads/master | 2023-05-12T01:02:41.583143 | 2023-04-29T04:13:32 | 2023-04-29T04:13:32 | 166,239,700 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 380 | cpp | #include <iostream>
#include <math.h>
using namespace std;
bool is_prime(int n){
if(n%2==0 && n!=2) return false;
for(int i =3;i<sqrt(n)+1;i+=2){
if(n%i==0) return false;
}
return true;
}
int main(){
int n,x;
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
if(is_prime(x)) cout<<"Prime"<<endl;
else cout<<"Not Prime"<<endl;
}
return 0;
} | [
"gabrielaalverga@gmail.com"
] | gabrielaalverga@gmail.com |
73410e9f4ef73bf5703e43cbbceded39d62dae33 | 252f107a4fa932ba7adce8cab5d8ed22587e1b03 | /Test/Test.cpp | 6081e00824c56d6468a6fd8d0bcfd8c7d816ffa1 | [] | no_license | wMolloMw/MyFirstRepository | 6834b061ae549afdc5bc9d2e7da40d76886ae34e | 429f77cc2971a2abd661db8a9719c2ee573d4937 | refs/heads/master | 2023-06-17T22:32:13.031541 | 2021-07-22T08:06:57 | 2021-07-22T08:06:57 | 388,647,634 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,940 | cpp | // Test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
using namespace std;
class Solution {
public:
string longestPalindrome(string s) {
if (s.length() <= 1) {
return s;
}
int length = 0, pos = 0;
for (int i = 0; i < s.length() - 1 - (length >> 2); ++i) {//如果最后剩下的字符小于已知回文子串最大长度的一半,则没有必要继续遍历
int j = i + 1;
int k = i;
int l_length = 0;
while (j < s.length() && k >= 0) {//判断当前回文子串长度
if (s[j] == s[k]) {
l_length += 2;
if (l_length > length) {
length = l_length;
pos = k;
}
++j;
--k;
// cout << length << endl;
}
else {
break;
}
}
}
//cout << pos << " " << length << endl;
if (s.length() <= 2) {
return s.substr(pos,length);
}
for (int i = 1; i < s.length() - 1 - ((length - 1) >> 2); ++i) {
int j = i + 1;
int k = i - 1;
int l_length = 1;
while (j <= s.length() && k >= 0) {//判断当前最大回文子串长度
if (s[j] == s[k]) {
l_length += 2;
if (l_length > length) {
length = l_length;
pos = k;
}
++j;
--k;
}
else {
break;
}
}
}
return s.substr(pos,length);
}
};
int main()
{
Solution s;
string a = "cbbbbd";
std::cout << s.longestPalindrome(a);
} | [
"318480983@qq.com"
] | 318480983@qq.com |
2af8040c67acfba44d12b8e6c0350605f7fa522d | c7d081431d10921930311b2f5fdf0f8b7c2bf5f2 | /Hmwk/Assignment 3/Gaddis_8thEd_Ch4_Prob10_Daysinamonth/main.cpp | 76c9c4c74c6e5355ac672b8b05365c5637302343 | [] | no_license | Hassan-Farhat/FarhatHassan_48102 | 25def8dec04f9bbee0e428a2c5192752fdf68654 | 19e9c6a67b7dfb0f041cd7d7cea89ad565ce34fb | refs/heads/master | 2020-04-15T11:47:08.190350 | 2016-12-13T04:40:59 | 2016-12-13T04:40:59 | 68,135,565 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,701 | cpp | /*
* File: main.cpp
* Author: Hassan Farhat
* Created on October 1, 2016, 2:22 PM
* Purpose : Determine the number of day in each month
*/
//System Libraries
#include <iostream> //Input/Output objects
using namespace std; //Name-space used in the System Library
//User Libraries
//Global Constants
//Function prototypes
//Execution Begins Here!
int main(int argc, char** argv) {
//Declaration of Variables
unsigned short month, // month (1-12)
year; // year
//Input values
cout << "Enter a month in number form (1-12): ";
cin >> month;
cout << "Enter a year (1500 - 3000): ";
cin >> year;
//Process values -> Map inputs to Outputs
if ((1500 > year || year > 3000) || (1 < month || month > 12)){
cout << "Bad year please input a year between 1500 to 3000 or you entered a Bad month" << endl;
}
if (((year % 100 == 0) && (year % 400 == 0)) && (month == 2)){
cout << "29 days" << endl;
}
else if (((year % 100 != 0) && (year % 4 == 0)) && (month == 2)){
cout << "29 days" << endl;
}
else if (month == 2){
cout << "28 days" << endl;
}
else if ( 1 <= month && month <= 7){
if (month % 2 == 0){
cout << "30 days" << endl;
}
else {
cout << "31 days" << endl;
}
}
else if (month > 7 && month <= 12){
if (month % 2 == 0){
cout << "31 days" << endl;
}
else {
cout << "30 days" << endl;
}
}
else {
cout << "You entered a number greater or less than 12" << endl;
}
//Display Output
//Exit Program
return 0;
}
| [
"hfarhat@student.rcc.edu"
] | hfarhat@student.rcc.edu |
78bc12258205e7bbd8bc07303ce7791932d2cf42 | 1e2aa10f0244c9893ceb4e0c14b8d999ed4f320a | /Shaders/shader.hpp | 8334efe704a1577a8038cae2415b5b23afa498e8 | [] | no_license | fieryheart/LearningRenderer | 27addc6036ebd75bf6b3c040a63b11b898ee3b01 | 8c9caeaba67b298012bab6a6bfc70b25e61e1976 | refs/heads/master | 2023-08-13T11:06:24.702823 | 2021-09-05T04:48:51 | 2021-09-05T04:48:51 | 358,198,084 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 844 | hpp | #ifndef __SHADERS_H__
#define __SHADERS_H__
#include <vector>
#include "../Objects/object.hpp"
namespace QGL {
// Shader中用到的
struct InVert {
Vec3f vertex;
int nthface;
int nthvert;
Object* model;
InVert(){}
};
struct OutVert {
Vec4f vertex; // 屏幕坐标
float depth;
OutVert(){}
};
struct InFrag {
Vec3f bar;
float depth;
Object* model;
std::vector<Light*> lights;
InFrag(){}
};
struct OutFrag {
Vec4f color;
OutFrag(){}
};
class Shader {
public:
std::shared_ptr<Sample2D> TEXTURE0, TEXTURE1, TEXTURE2, TEXTURE3;
Shader() {}
void texture0(std::string path);
void texture0(Vec4f color);
virtual ~Shader() {};
virtual void vertex(const InVert &in, OutVert &out) {};
virtual bool fragment(const InFrag &in, OutFrag &out) {};
};
}
#endif | [
"fiery_heart@163.com"
] | fiery_heart@163.com |
ce45b94d0253b372c51c63e84a3c4beca011a4e2 | 68b6aa96e955e39688838e1c069fe2e1ab2e89d0 | /Src/Representations/Infrastructure/JointRequest.h | 25946aa67233144a0f5737e983974dabc8118c89 | [
"BSD-2-Clause"
] | permissive | taokehao/RobCup2021 | 96963093e8ec16ceb2864054973680f8caada3ac | 0e02edcf43e3d8d4ba6a80af38d79b314e7cc7ab | refs/heads/main | 2023-06-06T01:49:16.908718 | 2021-07-04T16:59:26 | 2021-07-04T16:59:26 | 382,896,248 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,707 | h | #pragma once
#include "JointAngles.h"
#include "StiffnessData.h"
#include "Tools/Streams/AutoStreamable.h"
#include "Tools/Debugging/Debugging.h"
#include <cmath>
STREAMABLE_WITH_BASE(JointRequest, JointAngles,
{
JointRequest();
/** Initializes this instance with the mirrored data of other. */
void mirror(const JointRequest& other);
/** Returns the mirrored angle of joint. */
Angle mirror(const Joints::Joint joint) const;
/** Checkes if the JointRequest is valide. */
bool isValid() const,
(StiffnessData) stiffnessData, /**< the stiffness for all joints */
});
STREAMABLE_WITH_BASE(HeadJointRequest, JointRequest,
{,
});
STREAMABLE_WITH_BASE(ArmJointRequest, JointRequest,
{,
});
STREAMABLE_WITH_BASE(LegJointRequest, JointRequest,
{
LegJointRequest()
{
angles[0] = JointAngles::ignore;
angles[1] = JointAngles::ignore;
},
});
STREAMABLE_WITH_BASE(StandArmRequest, ArmJointRequest,
{,
});
STREAMABLE_WITH_BASE(StandLegRequest, LegJointRequest,
{,
});
STREAMABLE_WITH_BASE(NonArmeMotionEngineOutput, JointRequest,
{,
});
inline JointRequest::JointRequest()
{
angles.fill(off);
}
inline void JointRequest::mirror(const JointRequest& other)
{
JointAngles::mirror(other);
stiffnessData.mirror(other.stiffnessData);
}
inline Angle JointRequest::mirror(const Joints::Joint joint) const
{
return JointAngles::mirror(joint);
}
inline bool JointRequest::isValid() const
{
bool isValid = true;
for(unsigned i = 0; i < Joints::numOfJoints; i++)
if(!std::isfinite(angles[i]))
{
OUTPUT_ERROR("Joint " << TypeRegistry::getEnumName(Joints::Joint(i)) << " is invalid");
isValid = false;
}
return stiffnessData.isValid() && isValid;
}
| [
"2352661843@qq.com"
] | 2352661843@qq.com |
63c3e9a794f146aaee596bf9838d7a613daa8b32 | 4c57208812ed9e56b7346916733196a5bb40ff03 | /Devices/Generic HTTP Device/ArduinoNano.ino | 3604cc135aa93d74a3a5e9a7bd20c584bef3b3c0 | [
"Apache-2.0"
] | permissive | JZ-SmartThings/SmartThings | 37c03eb5ba5f44f456bb978420de9eca9ca01ef5 | 4bec0ff1d7803f245abd64c75df409ba378baf35 | refs/heads/master | 2021-01-17T13:50:15.550572 | 2019-08-31T21:29:13 | 2019-08-31T21:29:13 | 54,531,322 | 43 | 34 | null | 2017-07-11T23:27:11 | 2016-03-23T04:40:57 | HTML | UTF-8 | C++ | false | false | 15,693 | ino | /**
* Arduino Nano & Ethernet Shield Sample v1.0.20170327
* Source code can be found here: https://github.com/JZ-SmartThings/SmartThings/blob/master/Devices/Generic%20HTTP%20Device
* Copyright 2017 JZ
*
* 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 <UIPEthernet.h>
#include <EEPROM.h>
// DESIGNATE WHICH PINS ARE USED FOR TRIGGERS
// IF USING 3.3V RELAY, TRANSISTOR OR MOSFET THEN TOGGLE Use5Vrelay TO FALSE VIA UI
int relayPin1 = 2; // GPIO5 = D2
int relayPin2 = 3; // GPIO6 = D3
bool Use5Vrelay; // Value defaults by reading eeprom in the setup method
// DESIGNATE CONTACT SENSOR PINS.
#define SENSORPIN 5 // what pin is the Contact Sensor on?
#define SENSORPIN2 6 // what pin is the 2nd Contact Sensor on?
// OTHER VARIALBES
String currentIP;
void(* resetFunction) (void) = 0;
EthernetServer server = EthernetServer(80);
void setup()
{
Serial.begin(115200);
// DEFAULT CONFIG FOR CONTACT SENSOR
//EEPROM.begin(1);
int ContactSensor=EEPROM.read(1);
if (ContactSensor != 0 && ContactSensor != 1) {
EEPROM.write(1,0);
//EEPROM.commit();
}
if (ContactSensor==1) {
pinMode(SENSORPIN, INPUT_PULLUP);
} else {
pinMode(SENSORPIN, OUTPUT);
digitalWrite(SENSORPIN2, HIGH);
}
// DEFAULT CONFIG FOR CONTACT SENSOR 2
int ContactSensor2=EEPROM.read(2);
if (ContactSensor2 != 0 && ContactSensor2 != 1) {
EEPROM.write(2,0);
}
if (ContactSensor2==1) {
pinMode(SENSORPIN2, INPUT_PULLUP);
} else {
pinMode(SENSORPIN2, OUTPUT);
digitalWrite(SENSORPIN2, HIGH);
}
// DEFAULT CONFIG FOR USE5VRELAY
//EEPROM.begin(5);
int eepromUse5Vrelay=EEPROM.read(5);
if (eepromUse5Vrelay != 0 && eepromUse5Vrelay != 1) {
EEPROM.write(5,1);
//EEPROM.commit();
}
if (eepromUse5Vrelay ? Use5Vrelay=1 : Use5Vrelay=0);
pinMode(relayPin1, OUTPUT);
pinMode(relayPin2, OUTPUT);
digitalWrite(relayPin1, Use5Vrelay==true ? HIGH : LOW);
digitalWrite(relayPin2, Use5Vrelay==true ? HIGH : LOW);
uint8_t mac[6] = {0x0A,0x0B,0x0C,0x0D,0x0E,0x0F};
IPAddress myIP(192,168,0,225);
Ethernet.begin(mac,myIP);
/* // DHCP
if (Ethernet.begin(mac) == 0) {
while (1) {
Serial.println(F("Failed to configure Ethernet using DHCP"));
delay(10000);
}
}
*/
server.begin();
Serial.print(F("localIP: ")); Serial.println(Ethernet.localIP());
Serial.print(F("subnetMask: ")); Serial.println(Ethernet.subnetMask());
Serial.print(F("gatewayIP: ")); Serial.println(Ethernet.gatewayIP());
Serial.print(F("dnsServerIP: ")); Serial.println(Ethernet.dnsServerIP());
currentIP=Ethernet.localIP()[0]; currentIP+="."; currentIP+= Ethernet.localIP()[1]; currentIP+= ".";
currentIP+=Ethernet.localIP()[2]; currentIP+= "."; currentIP+=Ethernet.localIP()[3] ;
}
void loop()
{
// SERIAL MESSAGE
if (millis()%900000==0) { // every 15 minutes
Serial.print("UpTime: "); Serial.println(uptime());
}
// REBOOT
//EEPROM.begin(1);
int days=EEPROM.read(0);
int RebootFrequencyDays=0;
RebootFrequencyDays=days;
if (RebootFrequencyDays > 0 && millis() >= (86400000*RebootFrequencyDays)) { //86400000 per day
while(true);
}
EthernetClient client = server.available(); // try to get client
String HTTP_req; // stores the HTTP request
String request;
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
HTTP_req += c; // save the HTTP request 1 char at a time
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == '\n') { //&& currentLineIsBlank --- first line only on low memory like UNO/Nano otherwise get it all for AUTH
request = HTTP_req.substring(0,HTTP_req.indexOf('\r'));
//auth = HTTP_req.substring(HTTP_req.indexOf('Authorization: Basic '),HTTP_req.indexOf('\r'));
HTTP_req = ""; // finished with request, empty string
request.replace("GET ", "");
request.replace(" HTTP/1.1", "");
// Match the request
if (request.indexOf("/favicon.ico") > -1) {
return;
}
if (request.indexOf("/RebootNow") != -1) {
resetFunction();
}
if (request.indexOf("RebootFrequencyDays=") != -1) {
//EEPROM.begin(1);
String RebootFrequencyDays=request;
RebootFrequencyDays.replace("RebootFrequencyDays=",""); RebootFrequencyDays.replace("/",""); RebootFrequencyDays.replace("?","");
//for (int i = 0 ; i < 512 ; i++) { EEPROM.write(i, 0); } // fully clear EEPROM before overwrite
EEPROM.write(0,atoi(RebootFrequencyDays.c_str()));
//EEPROM.commit();
}
if (request.indexOf("/ToggleSensor") != -1) {
//EEPROM.begin(1);
if (EEPROM.read(1) == 0) {
EEPROM.write(1,1);
//EEPROM.commit();
pinMode(SENSORPIN, INPUT_PULLUP);
} else if (EEPROM.read(1) == 1) {
EEPROM.write(1,0);
//EEPROM.commit();
pinMode(SENSORPIN, OUTPUT);
digitalWrite(SENSORPIN, HIGH);
}
}
if (request.indexOf("/Toggle2ndSensor") != -1) {
if (EEPROM.read(2) == 0) {
EEPROM.write(2,1);
pinMode(SENSORPIN2, INPUT_PULLUP);
} else if (EEPROM.read(2) == 1) {
EEPROM.write(2,0);
}
}
if (request.indexOf("/ToggleUse5Vrelay") != -1) {
//EEPROM.begin(5);
if (EEPROM.read(5) == 0) {
Use5Vrelay=true;
EEPROM.write(5,1);
//EEPROM.commit();
pinMode(SENSORPIN2, OUTPUT);
digitalWrite(SENSORPIN2, HIGH);
} else {
Use5Vrelay=false;
EEPROM.write(5,0);
//EEPROM.commit();
}
resetFunction();
}
//Serial.print("Use5Vrelay == "); Serial.println(Use5Vrelay);
if (request.indexOf("RELAY1=ON") != -1 || request.indexOf("MainTriggerOn=") != -1) {
digitalWrite(relayPin1, Use5Vrelay==true ? LOW : HIGH);
}
if (request.indexOf("RELAY1=OFF") != -1 || request.indexOf("MainTriggerOff=") != -1) {
digitalWrite(relayPin1, Use5Vrelay==true ? HIGH : LOW);
}
if (request.indexOf("RELAY1=MOMENTARY") != -1 || request.indexOf("MainTrigger=") != -1) {
digitalWrite(relayPin1, Use5Vrelay==true ? LOW : HIGH);
delay(300);
digitalWrite(relayPin1, Use5Vrelay==true ? HIGH : LOW);
}
if (request.indexOf("RELAY2=ON") != -1 || request.indexOf("CustomTriggerOn=") != -1) {
digitalWrite(relayPin2, Use5Vrelay==true ? LOW : HIGH);
}
if (request.indexOf("RELAY2=OFF") != -1 || request.indexOf("CustomTriggerOff=") != -1) {
digitalWrite(relayPin2, Use5Vrelay==true ? HIGH : LOW);
}
if (request.indexOf("RELAY2=MOMENTARY") != -1 || request.indexOf("CustomTrigger=") != -1) {
digitalWrite(relayPin2, Use5Vrelay==true ? LOW : HIGH);
delay(300);
digitalWrite(relayPin2, Use5Vrelay==true ? HIGH : LOW);
}
// Return the response
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: text/html"));
client.println(F("\n")); // do not forget this one
client.println(F("<!DOCTYPE HTML>"));
client.println(F("<html><head><title>Arduino & ENC28J60 Dual Switch</title></head><meta name=viewport content='width=500'>\n<style type='text/css'>\nbutton {line-height: 1.8em; margin: 5px; padding: 3px 7px;}"));
client.println(F("\nbody {text-align:center;}\ndiv {border:solid 1px; margin: 3px; width:150px;}\n.center { margin: auto; width: 400px; border: 3px solid #73AD21; padding: 3px;}"));
client.println(F("\nhr {width:400px;}\n</style></head>\n<h3 style=\"height: 15px; margin-top: 0px;\"><a href='/'>ARDUINO & ENC28J60 DUAL SWITCH</h3><h3 style=\"height: 15px;\">"));
client.println(currentIP);
client.println(F("</a>\n</h3>\n"));
client.println(F("<i>Current Request:</i><br><b>"));
client.println(request);
client.println(F("</b><hr>"));
client.println(F("<pre>"));
// SHOW Use5Vrelay
client.print(F("Use5Vrelay=")); client.print(Use5Vrelay ? F("true") : F("false") ); client.print(F("\n"));
// SHOW CONTACT SENSOR
if (EEPROM.read(1)==1) {
client.print(F("<b><i>Contact Sensor Enabled:</i></b>\n"));
client.print(F("Contact Sensor=")); client.print(digitalRead(SENSORPIN) ? F("Open") : F("Closed") ); client.print(F("\n"));
} else {
client.print(F("<b><i>Contact Sensor Disabled:</i></b>\n"));
client.print(F("Contact Sensor=Closed\n"));
}
// SHOW CONTACT SENSOR
if (EEPROM.read(2)==1) {
client.print(F("<b><i>Contact Sensor 2 Enabled:</i></b>\n"));
client.print(F("Contact Sensor 2=")); client.print(digitalRead(SENSORPIN2) ? F("Open") : F("Closed") ); client.print(F("\n"));
} else {
client.print(F("<b><i>Contact Sensor 2 Disabled:</i></b>\n"));
client.print(F("Contact Sensor 2=Closed\n"));
}
client.print(F("UpTime=")); client.println(uptime());
client.println(freeRam());
client.println(F("</pre>")); client.println(F("<hr>\n"));
client.println(F("<div class='center'>\n"));
client.print(F("RELAY1 pin is now: "));
if(Use5Vrelay==true) {
if(digitalRead(relayPin1) == LOW) { client.print(F("On")); } else { client.print(F("Off")); }
} else {
if(digitalRead(relayPin1) == HIGH) { client.print(F("On")); } else { client.print(F("Off")); }
}
client.println(F("\n<br><a href=\"/RELAY1=ON\"><button onClick=\"parent.location='/RELAY1=ON'\">Turn On</button></a>\n"));
client.println(F("<a href=\"/RELAY1=OFF\"><button onClick=\"parent.location='/RELAY1=OFF'\">Turn Off</button></a>\n"));
client.println(F("<a href=\"/RELAY1=MOMENTARY\"><button onClick=\"parent.location='/RELAY1=MOMENTARY'\">MOMENTARY</button></a><br/></div><hr>\n"));
client.println(F("<div class='center'>\n"));
client.print(F("RELAY2 pin is now: "));
if(Use5Vrelay==true) {
if(digitalRead(relayPin2) == LOW) { client.print(F("On")); } else { client.print(F("Off")); }
} else {
if(digitalRead(relayPin2) == HIGH) { client.print(F("On")); } else { client.print(F("Off")); }
}
client.println(F("\n<br><a href=\"/RELAY2=ON\"><button onClick=\"parent.location='/RELAY2=ON'\">Turn On</button></a>\n"));
client.println(F("<a href=\"/RELAY2=OFF\"><button onClick=\"parent.location='/RELAY2=OFF'\">Turn Off</button></a>\n"));
client.println(F("<a href=\"/RELAY2=MOMENTARY\"><button onClick=\"parent.location='/RELAY2=MOMENTARY'\">MOMENTARY</button></a><br/></div><hr>\n"));
client.println(F("<div class='center'>"));
// SHOW TOGGLE Use5Vrelay
client.println(F("<button onClick=\"javascript: if (confirm(\'Are you sure you want to toggle the Use5Vrelay flag?\\nTrue/1 sends a GND signal. False/0 sends a VCC with 3.3 volts.\\nThis will also reboot the device!!!\\nIf the device does not come back up, reset it manually.\')) parent.location='/ToggleUse5Vrelay';\">Toggle Use 5V Relay</button><br><hr>\n"));
// SHOW TOGGLE CONTACT SENSORS
client.println(F("<button onClick=\"javascript: if (confirm(\'Are you sure you want to toggle the Contact Sensor?\')) parent.location='/ToggleSensor';\">Toggle Contact Sensor</button> \n"));
client.println(F("<button onClick=\"javascript: if (confirm(\'Are you sure you want to toggle the 2nd Contact Sensor?\')) parent.location='/Toggle2ndSensor';\">Toggle Contact Sensor 2</button><br><hr>\n"));
client.println(F("<input id=\"RebootFrequencyDays\" type=\"text\" name=\"RebootFrequencyDays\" value=\""));
//EEPROM.begin(1);
int days=EEPROM.read(0);
client.println(days);
client.println(F("\" maxlength=\"3\" size=\"2\" min=\"0\" max=\"255\"> <button style=\"line-height: 1em; margin: 3px; padding: 3px 3px;\" onClick=\"parent.location='/RebootFrequencyDays='+document.getElementById('RebootFrequencyDays').value;\">SAVE</button><br>Days between reboots.<br>0 to disable & 255 days is max."));
client.println(F("<br><button onClick=\"javascript: if (confirm(\'Are you sure you want to reboot?\')) parent.location='/RebootNow';\">Reboot Now</button><br></div><hr>\n"));
client.println(F("<div class='center'><a target='_blank' href='https://community.smartthings.com/t/raspberry-pi-to-php-to-gpio-to-relay-to-gate-garage-trigger/43335'>Project on SmartThings Community</a></br>\n"));
client.println(F("<a target='_blank' href='https://github.com/JZ-SmartThings/SmartThings/tree/master/Devices/Generic%20HTTP%20Device'>Project on GitHub</a></br></div></html>\n"));
break;
}
// every line of text received from the client ends with \r\n
if (c == '\n') {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
} else if (c != '\r') {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}
String freeRam () {
#if defined(ARDUINO_ARCH_AVR)
extern int __heap_start, *__brkval;
int v;
return "Free Mem="+String((int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval))+"B of 2048B";
#elif defined(ESP8266)
return "Free Mem="+String(ESP.getFreeHeap()/1024)+"KB of 80KB";
#endif
}
String uptime() {
float d,hr,m,s;
String dstr,hrstr, mstr, sstr;
unsigned long over;
d=int(millis()/(3600000*24));
dstr=String(d,0);
dstr.replace(" ", "");
over=millis()%(3600000*24);
hr=int(over/3600000);
hrstr=String(hr,0);
if (hr<10) {hrstr=hrstr="0"+hrstr;}
hrstr.replace(" ", "");
over=over%3600000;
m=int(over/60000);
mstr=String(m,0);
if (m<10) {mstr=mstr="0"+mstr;}
mstr.replace(" ", "");
over=over%60000;
s=int(over/1000);
sstr=String(s,0);
if (s<10) {sstr="0"+sstr;}
sstr.replace(" ", "");
if (dstr=="0") {
return hrstr + ":" + mstr + ":" + sstr;
} else if (dstr=="1") {
return dstr + " Day " + hrstr + ":" + mstr + ":" + sstr;
} else {
return dstr + " Days " + hrstr + ":" + mstr + ":" + sstr;
}
}
| [
"jzelyeny@gmail.com"
] | jzelyeny@gmail.com |
be9bfb724742b639535762b937663d59cf720d14 | e053db1d1502bd3ebfe5268de86547ab2bd27308 | /ext/tiny_gltf/rb_tiny_gltf_node.cpp | 5017ae2abd14f7bb7edf2a990fd56c144106f3cd | [
"MIT"
] | permissive | sinisterchipmunk/tiny_gltf-ruby | 649f065d85aa66c22869bd4cb223d836676fdf35 | eae673ee4de383fdd474c570d46fc813aa3b3b4a | refs/heads/master | 2022-04-26T15:45:18.068172 | 2022-03-17T18:08:32 | 2022-03-17T18:08:32 | 159,384,090 | 2 | 3 | MIT | 2022-03-16T20:51:06 | 2018-11-27T18:54:41 | C++ | UTF-8 | C++ | false | false | 2,767 | cpp | #include "rb_tiny_gltf.h"
VALUE rNode_new(const Node *node, VALUE rmodel) {
VALUE rnode = rb_funcall(rb_cNode, rb_intern("new"), 0);
// *Node_unwrap(rnode) = *node;
VALUE rweights = rb_ary_new();
for (size_t i = 0; i < node->weights.size(); i++)
rb_ary_push(rweights, DBL2NUM(node->weights[i]));
VALUE rchildren = rb_ary_new();
for (size_t i = 0; i < node->children.size(); i++)
rb_ary_push(rchildren, RINDEX_OR_NIL(node->children[i]));
VALUE rmatrix = Qnil, rrotation = Qnil, rtranslation = Qnil, rscale = Qnil;
if (node->matrix.size() == 0) {
rtranslation = rb_ary_new();
if (node->translation.size() == 0) {
rb_ary_push(rtranslation, DBL2NUM(0.0));
rb_ary_push(rtranslation, DBL2NUM(0.0));
rb_ary_push(rtranslation, DBL2NUM(0.0));
} else {
for (size_t i = 0; i < node->translation.size(); i++)
rb_ary_push(rtranslation, DBL2NUM(node->translation[i]));
}
rrotation = rb_ary_new();
if (node->rotation.size() == 0) {
rb_ary_push(rrotation, DBL2NUM(0.0));
rb_ary_push(rrotation, DBL2NUM(0.0));
rb_ary_push(rrotation, DBL2NUM(0.0));
rb_ary_push(rrotation, DBL2NUM(1.0));
} else {
for (size_t i = 0; i < node->rotation.size(); i++)
rb_ary_push(rrotation, DBL2NUM(node->rotation[i]));
}
rscale = rb_ary_new();
if (node->scale.size() == 0) {
rb_ary_push(rscale, DBL2NUM(1.0));
rb_ary_push(rscale, DBL2NUM(1.0));
rb_ary_push(rscale, DBL2NUM(1.0));
} else {
for (size_t i = 0; i < node->scale.size(); i++)
rb_ary_push(rscale, DBL2NUM(node->scale[i]));
}
} else {
rmatrix = rb_ary_new();
for (size_t i = 0; i < node->matrix.size(); i++)
rb_ary_push(rmatrix, DBL2NUM(node->matrix[i]));
}
rb_ivar_set(rnode, rb_intern("@model"), rmodel);
rb_ivar_set(rnode, rb_intern("@name"), rb_str_new2(node->name.c_str()));
rb_ivar_set(rnode, rb_intern("@camera_index"), RINDEX_OR_NIL(node->camera));
rb_ivar_set(rnode, rb_intern("@skin_index"), RINDEX_OR_NIL(node->skin));
rb_ivar_set(rnode, rb_intern("@mesh_index"), RINDEX_OR_NIL(node->mesh));
rb_ivar_set(rnode, rb_intern("@children_indices"), rchildren);
rb_ivar_set(rnode, rb_intern("@rotation"), rrotation);
rb_ivar_set(rnode, rb_intern("@translation"), rtranslation);
rb_ivar_set(rnode, rb_intern("@scale"), rscale);
rb_ivar_set(rnode, rb_intern("@matrix"), rmatrix);
rb_ivar_set(rnode, rb_intern("@weights"), rweights);
rb_ivar_set(rnode, rb_intern("@extensions"), rExtensionMap_new(&node->extensions, rmodel));
rb_ivar_set(rnode, rb_intern("@extras"), rValue_new(&node->extras, rmodel));
return rnode;
}
| [
"sinisterchipmunk@gmail.com"
] | sinisterchipmunk@gmail.com |
568f77dc936e29999df02f2e919de366ba21635b | 344ff74c268c2d327468c376d03f906bfe64d92d | /ex 1.cpp | f5fd45e09139e5bbf06ae3ea147177b357c3ed99 | [] | no_license | Dimash1905/pr-1 | 9f7927856f5a619ff8bc6bea3a1bd00f316b6c29 | a7b0cff6e1612e39d58dcd27af54d4a3330c28f5 | refs/heads/master | 2020-09-13T02:12:14.387078 | 2019-11-20T17:17:12 | 2019-11-20T17:17:12 | 222,630,454 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 273 | cpp | #include <iostream>
#include <cmath>
using namespace std;
int main()
{
string a = "Silence is golden";
cout << a << endl;
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
string a = "Silence is golden";
cout << a << endl;
return 0;
} | [
"57893153+Dimash1905@users.noreply.github.com"
] | 57893153+Dimash1905@users.noreply.github.com |
3983babdfa47689ebc0e1aaf31847d9db4a45edd | 650720c3d1d38bef00c871937376127bb7a53313 | /7_3_model_loading_fbx/main.cpp | 393f12b87d25e6ef2cff4d48c344a595db673807 | [] | no_license | shin1/Qt3D_TechBookFest7 | 865458a19ba7a61554ca8c205e893abba5ca0663 | 47aaf3edecf7a8b9551a874943ea1f965c8b6335 | refs/heads/master | 2020-07-11T08:46:40.944034 | 2019-09-26T14:10:02 | 2019-09-26T14:10:02 | 204,494,697 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 659 | cpp | #include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QSurfaceFormat>
#include <QOpenGLContext>
int main(int argc, char *argv[])
{
QSurfaceFormat format;
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(format);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
| [
"shinichi.okada@qt.io"
] | shinichi.okada@qt.io |
51ef445c4761267e8445e5d62789e8f2d2affb1d | 17f8f6b83553b23cfa01df698a51657cd551dab8 | /Camera.cpp | 16f03a8a82f76c2a38bafc17c54afee9110dd6b4 | [] | no_license | bbardi/OpenGL-Desert | 7a49001474927033d9d59dead5096041275b9d30 | 990a79474145b3b2ff57f17ddc8ff1c7cd008f7e | refs/heads/master | 2023-06-02T12:47:42.495325 | 2021-06-21T13:12:43 | 2021-06-21T13:12:43 | 378,929,918 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,525 | cpp | #include "Camera.hpp"
namespace gps
{
//Camera constructor
Camera::Camera(glm::vec3 cameraPosition, glm::vec3 cameraTarget, glm::vec3 cameraUp)
{
this->cameraPosition = cameraPosition;
this->cameraTarget = cameraTarget;
this->cameraUpDirection = cameraUp;
this->cameraFrontDirection = glm::normalize(cameraTarget - cameraPosition);
this->cameraRightDirection = glm::cross(cameraFrontDirection, cameraUpDirection);
//TODO - Update the rest of camera parameters
}
//return the view matrix, using the glm::lookAt() function
glm::mat4 Camera::getViewMatrix()
{
return glm::lookAt(cameraPosition, cameraPosition + cameraFrontDirection, cameraUpDirection);
}
//update the camera internal parameters following a camera move event
void Camera::move(MOVE_DIRECTION direction, float speed)
{
switch (direction)
{
case MOVE_LEFT:
this->cameraPosition -= cameraRightDirection * speed;
break;
case MOVE_RIGHT:
this->cameraPosition += cameraRightDirection * speed;
break;
case MOVE_FORWARD:
this->cameraPosition += cameraFrontDirection * speed;
break;
case MOVE_BACKWARD:
this->cameraPosition -= cameraFrontDirection * speed;
break;
case MOVE_DOWN:
this->cameraPosition.y -= speed;
break;
}
}
//update the camera internal parameters following a camera rotate event
//yaw - camera rotation around the y axis
//pitch - camera rotation around the x axis
void Camera::rotate(float pitch, float yaw)
{
// calculate the new Front vector
glm::vec3 front;
cameraFrontDirection.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
cameraFrontDirection.y = sin(glm::radians(pitch));
cameraFrontDirection.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
//cameraFrontDirection = glm::normalize(front);
// also re-calculate the Right and Up vector
cameraTarget = cameraPosition + cameraFrontDirection;
cameraRightDirection = glm::normalize(glm::cross(cameraFrontDirection, glm::vec3(0.0, 1.0, 0.0))); // normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
cameraUpDirection = glm::normalize(glm::cross(cameraRightDirection, cameraFrontDirection));
}
} // namespace gps | [
"bardibogdan@gmail.com"
] | bardibogdan@gmail.com |
1f0e15437e01d1fe062af7f7b894124a5e80f9ea | 5adec71b5927f3da801f8ec6a97e347141fde1a0 | /LaiOffer/Find Node with Max Diff Subtree.cpp | f16a9a27c13722c8ccec899bfb9f36396d7454ff | [] | no_license | FangLiu68/OldCode2016 | bbb0d2b5dfbf660013cbe3384fedbb7189eee139 | 37cef0c01c217cc145317298477cfc57598565f5 | refs/heads/master | 2021-01-12T07:06:29.455232 | 2016-12-20T21:21:16 | 2016-12-20T21:21:16 | 76,911,834 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,259 | cpp | //
// Find Node with Max Diff subtree.cpp
// LaiOffer
//
// Created by Fang Liu on 1/7/15.
// Copyright (c) 2015 Fang Liu. All rights reserved.
//
// Find the node with the max difference in the total number descendents in its left subtree and right subtree
/*
从下往上返回值
题意是:找到这样一个node,他的左子树的节点个数和右子树的节点个数的差值 最大
定义function signature:
return value: 你想返回给上一层什么值,就把function的return value设为什么类型的值
arguments: 哪些值是你需要在整个过程中跟踪的,就放在arguments里,作为外部变量
*/
#include "BinaryTree.h"
#include <iostream>
using namespace std;
/*
1. what do you want from your left and right child?
left_cost: left subtree一共有多少个node
right_cost: right subtree一共有多少个node
2. what do you want to do in this current layer?
如果abs(left_cost-right_cost)>max_val,更新max_val, 同时更新pNode
pNode一直跟踪的是最大max_val的node
3. what do you want to report to your parent?
left_cost+right_cost+1 (1代表当前节点,有一个)
这题类似于,找二叉树有几个节点。因为找节点是从底往上加的,所以我们只用在每次找完左右子树节点之后,比较下当前root下的max_diff是否需要改变就好。
*/
// O(N) runtime
int helper_maxDiffSubtree(BinaryTreeNode* root, BinaryTreeNode* &pNode, int &max_diff);
BinaryTreeNode* find_node_with_max_diffSubtree(BinaryTreeNode* root){
if(root == NULL){
return NULL;
}
BinaryTreeNode* pNode = NULL;
int max_diff = 0;
helper_maxDiffSubtree(root, pNode, max_diff);
return pNode;
}
int helper_maxDiffSubtree(BinaryTreeNode* root, BinaryTreeNode* &pNode, int &max_diff){
// base case
if(root == NULL) return 0;
int left_cost = helper_maxDiffSubtree(root->left, pNode, max_diff);
int right_cost = helper_maxDiffSubtree(root->right, pNode, max_diff);
if(abs(left_cost - right_cost) > max_diff){
max_diff = abs(left_cost - right_cost);
pNode = root;
}
// 往上一层汇报的是 包括当前节点在内的,他的subtree的所有节点
return left_cost + right_cost + 1;
}
| [
"lfang68@gmail.com"
] | lfang68@gmail.com |
a5dae18c99a689cf156404c399b9a1147d84770d | 8cb4d5aaa4a767b53195e3a1d5fa5b3ba072a7e4 | /module/src/main/cpp/main.cpp | 71a07a770d824fb94bb084a40b5dada6c153f279 | [] | no_license | imkingcn/Thanox-Magisk | 9f0c5de4cea5b81bdf5d83cb393a7340342b678a | 4283b13545c5a2356e2b4b138cef9d52506d3d3e | refs/heads/master | 2022-12-07T02:36:15.940964 | 2020-09-01T13:56:01 | 2020-09-01T13:56:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,594 | cpp | #include <jni.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
// You can remove functions you don't need
extern "C" {
#define EXPORT __attribute__((visibility("default"))) __attribute__((used))
EXPORT void nativeForkAndSpecializePre(
JNIEnv *env, jclass clazz, jint *_uid, jint *gid, jintArray *gids, jint *runtimeFlags,
jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
jintArray *fdsToClose, jintArray *fdsToIgnore, jboolean *is_child_zygote,
jstring *instructionSet, jstring *appDataDir, jboolean *isTopApp,
jobjectArray *pkgDataInfoList,
jobjectArray *whitelistedDataInfoList, jboolean *bindMountAppDataDirs,
jboolean *bindMountAppStorageDirs) {
}
EXPORT int nativeForkAndSpecializePost(JNIEnv *env, jclass clazz, jint res) {
if (res == 0) {
// in app process
} else {
// in zygote process, res is child pid
// don't print log here, see https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66
}
return 0;
}
EXPORT __attribute__((visibility("default"))) void specializeAppProcessPre(
JNIEnv *env, jclass clazz, jint *_uid, jint *gid, jintArray *gids, jint *runtimeFlags,
jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
jboolean *startChildZygote, jstring *instructionSet, jstring *appDataDir,
jboolean *isTopApp, jobjectArray *pkgDataInfoList, jobjectArray *whitelistedDataInfoList,
jboolean *bindMountAppDataDirs, jboolean *bindMountAppStorageDirs) {
// added from Android 10, but disabled at least in Google Pixel devices
}
EXPORT __attribute__((visibility("default"))) int specializeAppProcessPost(
JNIEnv *env, jclass clazz) {
// added from Android 10, but disabled at least in Google Pixel devices
return 0;
}
EXPORT void nativeForkSystemServerPre(
JNIEnv *env, jclass clazz, uid_t *uid, gid_t *gid, jintArray *gids, jint *runtimeFlags,
jobjectArray *rlimits, jlong *permittedCapabilities, jlong *effectiveCapabilities) {
}
EXPORT int nativeForkSystemServerPost(JNIEnv *env, jclass clazz, jint res) {
if (res == 0) {
// in system server process
char buffer[4096];
char *p = NULL;
strcpy(buffer, (p = getenv("SYSTEMSERVERCLASSPATH")) ? p : "");
// /system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar:/system/framework/com.android.location.provider.jar
// Test.
setenv("SYSTEMSERVERCLASSPATH",
"/system/framework/services-thanox.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar:/system/framework/com.android.location.provider.jar",
1);
LOGI("nativeForkSystemServerPost, SYSTEMSERVERCLASSPATH= %s", getenv("SYSTEMSERVERCLASSPATH"));
LOGI("nativeForkSystemServerPost, BOOTCLASSPATH= %s", getenv("BOOTCLASSPATH"));
} else {
// in zygote process, res is child pid
// don't print log here, see https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66
}
return 0;
}
EXPORT int shouldSkipUid(int uid) {
// by default, Riru only call module functions in "normal app processes" (10000 <= uid % 100000 <= 19999)
// false = don't skip
return false;
}
EXPORT void onModuleLoaded() {
// called when the shared library of Riru core is loaded
}
} | [
"tornaco@163.com"
] | tornaco@163.com |
5edd87e1d3a3891a1f461da79d99369159fc9248 | 03692371cad0fdd3c8db9fca9282230811228336 | /LearnCG/Math/Math.cpp | cb4eff2c057221ffd2d945369dbec16d0f38c5c2 | [] | no_license | leezyli/LearnGL | da877dbd5e05e167c629bc5a7970a981c66f3469 | 1347d5efb3177ed7da1fcbc5f73ef911db81b680 | refs/heads/master | 2021-01-17T13:25:59.499150 | 2016-10-01T03:29:28 | 2016-10-01T03:29:28 | 60,972,458 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,458 | cpp | //
// Math.cpp
// LearnCG
//
// Created by leezy on 16/7/25.
// Copyright (c) 2016年 leezy. All rights reserved.
//
#include "Math.h"
#include <iostream>
void Util::Math::CalcAxisVector(const std::vector<glm::vec3> & v, Eigen::Vector3f &R, Eigen::Vector3f &S, Eigen::Vector3f &T)
{
Eigen::Vector3f aveVector(0, 0, 0);
// 1. 计算向量平均值
for (size_t i = 0; i < v.size(); ++i)
{
aveVector += Util::Internal::ToEigenVector3f(v[i]);
}
aveVector /= v.size();
// 2. 构造协方差矩阵
float xx = 0, yy = 0, zz = 0;
float xy = 0, xz = 0, yz = 0;
size_t n = v.size();
for (size_t i = 0; i < n; ++i) {
xx += (v[i].x - aveVector.x())*(v[i].x - aveVector.x());
}
for (size_t i = 0; i < n; ++i) {
yy += (v[i].y - aveVector.y())*(v[i].y - aveVector.y());
}
for (size_t i = 0; i < n; ++i) {
zz += (v[i].z - aveVector.z())*(v[i].z - aveVector.z());
}
for (size_t i = 0; i < n; ++i) {
xy += (v[i].x - aveVector.x())*(v[i].y - aveVector.y());
}
for (size_t i = 0; i < n; ++i) {
xz += (v[i].x - aveVector.x())*(v[i].z - aveVector.z());
}
for (size_t i = 0; i < n; ++i) {
yz += (v[i].y - aveVector.y())*(v[i].z - aveVector.z());
}
xx /= n; yy /= n; zz /= n;
xy /= n; yz /= n; xz /= n;
Eigen::Matrix3f cotMat;
cotMat << xx, xy, xz, xy, yy, yz, xz, yz, zz;
// 3. 求协方差矩阵的特征向量
Eigen::EigenSolver<Eigen::Matrix3f> solver(cotMat);
Eigen::Vector3f a = solver.eigenvectors().col(0).real();
Eigen::Vector3f b = solver.eigenvectors().col(1).real();
Eigen::Vector3f c = solver.eigenvectors().col(2).real();
float an = a.squaredNorm();
float bn = b.squaredNorm();
float cn = c.squaredNorm();
if ( an >= bn ) {
if ( an >= cn ) {
if ( bn >= cn ) {
R = a; S = b; T = c;
} else {
R = a; S = c; T = b;
}
} else { // cn > an > bn
R = c; S = a; T = b;
}
} else {
if ( bn >= cn ) {
if ( an >= cn ) { // bn > an > cn
R = b; S = a; T = c;
} else {
R = b; S = c; T = a;
}
} else { // cn > bn > an
R = c; S = b; T = a;
}
}
//std::cout << "eigenvectors:\n" << R << "\n" << S << "\n" << T << std::endl;
}
| [
"leezyli@leezydeMacBook-Pro.local"
] | leezyli@leezydeMacBook-Pro.local |
0534e94156826b70c8d7125d64cf7e939e475a49 | 89514fc56df1db2074b1dc79ab35d775e9605f5e | /Test/WellRenderComponent.h | 6fce128874dfb9d8018b2b80a96db489a8f77a94 | [] | no_license | EthanShimooka/BAA | aa4117be9944b61553fd45b14b709670d7ab1716 | 49e5cd4ef608d9f630b03edaa8912632087986f0 | refs/heads/master | 2021-01-18T22:48:39.371732 | 2016-06-04T07:20:36 | 2016-06-04T07:20:36 | 49,625,246 | 6 | 2 | null | 2016-06-04T07:20:36 | 2016-01-14T05:36:26 | C++ | UTF-8 | C++ | false | false | 421 | h | /**
* MidBaseRenderComponet.h
* Authors: Ethan Shimooka
* Date 5/1/2016
* Description :
Render Component class for the Well
*/
#pragma once
#ifndef WELLRENDERCOMPONENT_H_INCLUDED
#define WELLRENDERCOMPONENT_H_INCLUDED
#include "RenderComponent.h"
class WellRenderComponent :
public RenderComponent
{
public:
WellRenderComponent(GameObject * well, int team);
~WellRenderComponent();
void Update();
};
#endif | [
"sshimook@ucsc.edu"
] | sshimook@ucsc.edu |
9d69065fa20a6f6a9974c676f40009478e94424d | 2821d5308a3855fbdbee1a2af1d2531373a1c80f | /src/tetris/FontTomThumb.cpp | bef8c13d50d23db16943e55f2ff3670bc8ee90b6 | [] | no_license | tolbier/LedMatrixTetris | a374d61fcad75af269a6b2b92959f4aa73758c36 | 7e9166a29abc85d59c0a24dd8bb4b6d408962d79 | refs/heads/master | 2020-04-10T22:46:10.919498 | 2017-02-18T09:38:16 | 2017-02-18T09:38:16 | 68,046,880 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,975 | cpp | /*
* FontTomThumb.cpp
*
* Created on: 24 sept. 2016
* Author: toyos
*/
#include "FontTomThumb.h"
FontTomThumb::FontTomThumb() {
}
FontTomThumb::~FontTomThumb() {
}
const uint8_t FontTomThumb::TomThumbBitmaps[] PROGMEM = {
0x00, /* 0x20 space */
0x80, 0x80, 0x80, 0x00, 0x80, /* 0x21 exclam */
0xA0, 0xA0, /* 0x22 quotedbl */
0xA0, 0xE0, 0xA0, 0xE0, 0xA0, /* 0x23 numbersign */
0x60, 0xC0, 0x60, 0xC0, 0x40, /* 0x24 dollar */
0x80, 0x20, 0x40, 0x80, 0x20, /* 0x25 percent */
0xC0, 0xC0, 0xE0, 0xA0, 0x60, /* 0x26 ampersand */
0x80, 0x80, /* 0x27 quotesingle */
0x40, 0x80, 0x80, 0x80, 0x40, /* 0x28 parenleft */
0x80, 0x40, 0x40, 0x40, 0x80, /* 0x29 parenright */
0xA0, 0x40, 0xA0, /* 0x2A asterisk */
0x40, 0xE0, 0x40, /* 0x2B plus */
0x40, 0x80, /* 0x2C comma */
0xE0, /* 0x2D hyphen */
0x80, /* 0x2E period */
0x20, 0x20, 0x40, 0x80, 0x80, /* 0x2F slash */
0x60, 0xA0, 0xA0, 0xA0, 0xC0, /* 0x30 zero */
0x40, 0xC0, 0x40, 0x40, 0x40, /* 0x31 one */
0xC0, 0x20, 0x40, 0x80, 0xE0, /* 0x32 two */
0xC0, 0x20, 0x40, 0x20, 0xC0, /* 0x33 three */
0xA0, 0xA0, 0xE0, 0x20, 0x20, /* 0x34 four */
0xE0, 0x80, 0xC0, 0x20, 0xC0, /* 0x35 five */
0x60, 0x80, 0xE0, 0xA0, 0xE0, /* 0x36 six */
0xE0, 0x20, 0x40, 0x80, 0x80, /* 0x37 seven */
0xE0, 0xA0, 0xE0, 0xA0, 0xE0, /* 0x38 eight */
0xE0, 0xA0, 0xE0, 0x20, 0xC0, /* 0x39 nine */
0x80, 0x00, 0x80, /* 0x3A colon */
0x40, 0x00, 0x40, 0x80, /* 0x3B semicolon */
0x20, 0x40, 0x80, 0x40, 0x20, /* 0x3C less */
0xE0, 0x00, 0xE0, /* 0x3D equal */
0x80, 0x40, 0x20, 0x40, 0x80, /* 0x3E greater */
0xE0, 0x20, 0x40, 0x00, 0x40, /* 0x3F question */
0x40, 0xA0, 0xE0, 0x80, 0x60, /* 0x40 at */
0x40, 0xA0, 0xE0, 0xA0, 0xA0, /* 0x41 A */
0xC0, 0xA0, 0xC0, 0xA0, 0xC0, /* 0x42 B */
0x60, 0x80, 0x80, 0x80, 0x60, /* 0x43 C */
0xC0, 0xA0, 0xA0, 0xA0, 0xC0, /* 0x44 D */
0xE0, 0x80, 0xE0, 0x80, 0xE0, /* 0x45 E */
0xE0, 0x80, 0xE0, 0x80, 0x80, /* 0x46 F */
0x60, 0x80, 0xE0, 0xA0, 0x60, /* 0x47 G */
0xA0, 0xA0, 0xE0, 0xA0, 0xA0, /* 0x48 H */
0xE0, 0x40, 0x40, 0x40, 0xE0, /* 0x49 I */
0x20, 0x20, 0x20, 0xA0, 0x40, /* 0x4A J */
0xA0, 0xA0, 0xC0, 0xA0, 0xA0, /* 0x4B K */
0x80, 0x80, 0x80, 0x80, 0xE0, /* 0x4C L */
0xA0, 0xE0, 0xE0, 0xA0, 0xA0, /* 0x4D M */
0xA0, 0xE0, 0xE0, 0xE0, 0xA0, /* 0x4E N */
0x40, 0xA0, 0xA0, 0xA0, 0x40, /* 0x4F O */
0xC0, 0xA0, 0xC0, 0x80, 0x80, /* 0x50 P */
0x40, 0xA0, 0xA0, 0xE0, 0x60, /* 0x51 Q */
0xC0, 0xA0, 0xE0, 0xC0, 0xA0, /* 0x52 R */
0x60, 0x80, 0x40, 0x20, 0xC0, /* 0x53 S */
0xE0, 0x40, 0x40, 0x40, 0x40, /* 0x54 T */
0xA0, 0xA0, 0xA0, 0xA0, 0x60, /* 0x55 U */
0xA0, 0xA0, 0xA0, 0x40, 0x40, /* 0x56 V */
0xA0, 0xA0, 0xE0, 0xE0, 0xA0, /* 0x57 W */
0xA0, 0xA0, 0x40, 0xA0, 0xA0, /* 0x58 X */
0xA0, 0xA0, 0x40, 0x40, 0x40, /* 0x59 Y */
0xE0, 0x20, 0x40, 0x80, 0xE0, /* 0x5A Z */
0xE0, 0x80, 0x80, 0x80, 0xE0, /* 0x5B bracketleft */
0x80, 0x40, 0x20, /* 0x5C backslash */
0xE0, 0x20, 0x20, 0x20, 0xE0, /* 0x5D bracketright */
0x40, 0xA0, /* 0x5E asciicircum */
0xE0, /* 0x5F underscore */
0x80, 0x40, /* 0x60 grave */
0xC0, 0x60, 0xA0, 0xE0, /* 0x61 a */
0x80, 0xC0, 0xA0, 0xA0, 0xC0, /* 0x62 b */
0x60, 0x80, 0x80, 0x60, /* 0x63 c */
0x20, 0x60, 0xA0, 0xA0, 0x60, /* 0x64 d */
0x60, 0xA0, 0xC0, 0x60, /* 0x65 e */
0x20, 0x40, 0xE0, 0x40, 0x40, /* 0x66 f */
0x60, 0xA0, 0xE0, 0x20, 0x40, /* 0x67 g */
0x80, 0xC0, 0xA0, 0xA0, 0xA0, /* 0x68 h */
0x80, 0x00, 0x80, 0x80, 0x80, /* 0x69 i */
0x20, 0x00, 0x20, 0x20, 0xA0, 0x40, /* 0x6A j */
0x80, 0xA0, 0xC0, 0xC0, 0xA0, /* 0x6B k */
0xC0, 0x40, 0x40, 0x40, 0xE0, /* 0x6C l */
0xE0, 0xE0, 0xE0, 0xA0, /* 0x6D m */
0xC0, 0xA0, 0xA0, 0xA0, /* 0x6E n */
0x40, 0xA0, 0xA0, 0x40, /* 0x6F o */
0xC0, 0xA0, 0xA0, 0xC0, 0x80, /* 0x70 p */
0x60, 0xA0, 0xA0, 0x60, 0x20, /* 0x71 q */
0x60, 0x80, 0x80, 0x80, /* 0x72 r */
0x60, 0xC0, 0x60, 0xC0, /* 0x73 s */
0x40, 0xE0, 0x40, 0x40, 0x60, /* 0x74 t */
0xA0, 0xA0, 0xA0, 0x60, /* 0x75 u */
0xA0, 0xA0, 0xE0, 0x40, /* 0x76 v */
0xA0, 0xE0, 0xE0, 0xE0, /* 0x77 w */
0xA0, 0x40, 0x40, 0xA0, /* 0x78 x */
0xA0, 0xA0, 0x60, 0x20, 0x40, /* 0x79 y */
0xE0, 0x60, 0xC0, 0xE0, /* 0x7A z */
0x60, 0x40, 0x80, 0x40, 0x60, /* 0x7B braceleft */
0x80, 0x80, 0x00, 0x80, 0x80, /* 0x7C bar */
0xC0, 0x40, 0x20, 0x40, 0xC0, /* 0x7D braceright */
0x60, 0xC0, /* 0x7E asciitilde */
#if (TOMTHUMB_USE_EXTENDED)
0x80, 0x00, 0x80, 0x80, 0x80, /* 0xA1 exclamdown */
0x40, 0xE0, 0x80, 0xE0, 0x40, /* 0xA2 cent */
0x60, 0x40, 0xE0, 0x40, 0xE0, /* 0xA3 sterling */
0xA0, 0x40, 0xE0, 0x40, 0xA0, /* 0xA4 currency */
0xA0, 0xA0, 0x40, 0xE0, 0x40, /* 0xA5 yen */
0x80, 0x80, 0x00, 0x80, 0x80, /* 0xA6 brokenbar */
0x60, 0x40, 0xA0, 0x40, 0xC0, /* 0xA7 section */
0xA0, /* 0xA8 dieresis */
0x60, 0x80, 0x60, /* 0xA9 copyright */
0x60, 0xA0, 0xE0, 0x00, 0xE0, /* 0xAA ordfeminine */
0x40, 0x80, 0x40, /* 0xAB guillemotleft */
0xE0, 0x20, /* 0xAC logicalnot */
0xC0, /* 0xAD softhyphen */
0xC0, 0xC0, 0xA0, /* 0xAE registered */
0xE0, /* 0xAF macron */
0x40, 0xA0, 0x40, /* 0xB0 degree */
0x40, 0xE0, 0x40, 0x00, 0xE0, /* 0xB1 plusminus */
0xC0, 0x40, 0x60, /* 0xB2 twosuperior */
0xE0, 0x60, 0xE0, /* 0xB3 threesuperior */
0x40, 0x80, /* 0xB4 acute */
0xA0, 0xA0, 0xA0, 0xC0, 0x80, /* 0xB5 mu */
0x60, 0xA0, 0x60, 0x60, 0x60, /* 0xB6 paragraph */
0xE0, 0xE0, 0xE0, /* 0xB7 periodcentered */
0x40, 0x20, 0xC0, /* 0xB8 cedilla */
0x80, 0x80, 0x80, /* 0xB9 onesuperior */
0x40, 0xA0, 0x40, 0x00, 0xE0, /* 0xBA ordmasculine */
0x80, 0x40, 0x80, /* 0xBB guillemotright */
0x80, 0x80, 0x00, 0x60, 0x20, /* 0xBC onequarter */
0x80, 0x80, 0x00, 0xC0, 0x60, /* 0xBD onehalf */
0xC0, 0xC0, 0x00, 0x60, 0x20, /* 0xBE threequarters */
0x40, 0x00, 0x40, 0x80, 0xE0, /* 0xBF questiondown */
0x40, 0x20, 0x40, 0xE0, 0xA0, /* 0xC0 Agrave */
0x40, 0x80, 0x40, 0xE0, 0xA0, /* 0xC1 Aacute */
0xE0, 0x00, 0x40, 0xE0, 0xA0, /* 0xC2 Acircumflex */
0x60, 0xC0, 0x40, 0xE0, 0xA0, /* 0xC3 Atilde */
0xA0, 0x40, 0xA0, 0xE0, 0xA0, /* 0xC4 Adieresis */
0xC0, 0xC0, 0xA0, 0xE0, 0xA0, /* 0xC5 Aring */
0x60, 0xC0, 0xE0, 0xC0, 0xE0, /* 0xC6 AE */
0x60, 0x80, 0x80, 0x60, 0x20, 0x40, /* 0xC7 Ccedilla */
0x40, 0x20, 0xE0, 0xC0, 0xE0, /* 0xC8 Egrave */
0x40, 0x80, 0xE0, 0xC0, 0xE0, /* 0xC9 Eacute */
0xE0, 0x00, 0xE0, 0xC0, 0xE0, /* 0xCA Ecircumflex */
0xA0, 0x00, 0xE0, 0xC0, 0xE0, /* 0xCB Edieresis */
0x40, 0x20, 0xE0, 0x40, 0xE0, /* 0xCC Igrave */
0x40, 0x80, 0xE0, 0x40, 0xE0, /* 0xCD Iacute */
0xE0, 0x00, 0xE0, 0x40, 0xE0, /* 0xCE Icircumflex */
0xA0, 0x00, 0xE0, 0x40, 0xE0, /* 0xCF Idieresis */
0xC0, 0xA0, 0xE0, 0xA0, 0xC0, /* 0xD0 Eth */
0xC0, 0x60, 0xA0, 0xE0, 0xA0, /* 0xD1 Ntilde */
0x40, 0x20, 0xE0, 0xA0, 0xE0, /* 0xD2 Ograve */
0x40, 0x80, 0xE0, 0xA0, 0xE0, /* 0xD3 Oacute */
0xE0, 0x00, 0xE0, 0xA0, 0xE0, /* 0xD4 Ocircumflex */
0xC0, 0x60, 0xE0, 0xA0, 0xE0, /* 0xD5 Otilde */
0xA0, 0x00, 0xE0, 0xA0, 0xE0, /* 0xD6 Odieresis */
0xA0, 0x40, 0xA0, /* 0xD7 multiply */
0x60, 0xA0, 0xE0, 0xA0, 0xC0, /* 0xD8 Oslash */
0x80, 0x40, 0xA0, 0xA0, 0xE0, /* 0xD9 Ugrave */
0x20, 0x40, 0xA0, 0xA0, 0xE0, /* 0xDA Uacute */
0xE0, 0x00, 0xA0, 0xA0, 0xE0, /* 0xDB Ucircumflex */
0xA0, 0x00, 0xA0, 0xA0, 0xE0, /* 0xDC Udieresis */
0x20, 0x40, 0xA0, 0xE0, 0x40, /* 0xDD Yacute */
0x80, 0xE0, 0xA0, 0xE0, 0x80, /* 0xDE Thorn */
0x60, 0xA0, 0xC0, 0xA0, 0xC0, 0x80, /* 0xDF germandbls */
0x40, 0x20, 0x60, 0xA0, 0xE0, /* 0xE0 agrave */
0x40, 0x80, 0x60, 0xA0, 0xE0, /* 0xE1 aacute */
0xE0, 0x00, 0x60, 0xA0, 0xE0, /* 0xE2 acircumflex */
0x60, 0xC0, 0x60, 0xA0, 0xE0, /* 0xE3 atilde */
0xA0, 0x00, 0x60, 0xA0, 0xE0, /* 0xE4 adieresis */
0x60, 0x60, 0x60, 0xA0, 0xE0, /* 0xE5 aring */
0x60, 0xE0, 0xE0, 0xC0, /* 0xE6 ae */
0x60, 0x80, 0x60, 0x20, 0x40, /* 0xE7 ccedilla */
0x40, 0x20, 0x60, 0xE0, 0x60, /* 0xE8 egrave */
0x40, 0x80, 0x60, 0xE0, 0x60, /* 0xE9 eacute */
0xE0, 0x00, 0x60, 0xE0, 0x60, /* 0xEA ecircumflex */
0xA0, 0x00, 0x60, 0xE0, 0x60, /* 0xEB edieresis */
0x80, 0x40, 0x80, 0x80, 0x80, /* 0xEC igrave */
0x40, 0x80, 0x40, 0x40, 0x40, /* 0xED iacute */
0xE0, 0x00, 0x40, 0x40, 0x40, /* 0xEE icircumflex */
0xA0, 0x00, 0x40, 0x40, 0x40, /* 0xEF idieresis */
0x60, 0xC0, 0x60, 0xA0, 0x60, /* 0xF0 eth */
0xC0, 0x60, 0xC0, 0xA0, 0xA0, /* 0xF1 ntilde */
0x40, 0x20, 0x40, 0xA0, 0x40, /* 0xF2 ograve */
0x40, 0x80, 0x40, 0xA0, 0x40, /* 0xF3 oacute */
0xE0, 0x00, 0x40, 0xA0, 0x40, /* 0xF4 ocircumflex */
0xC0, 0x60, 0x40, 0xA0, 0x40, /* 0xF5 otilde */
0xA0, 0x00, 0x40, 0xA0, 0x40, /* 0xF6 odieresis */
0x40, 0x00, 0xE0, 0x00, 0x40, /* 0xF7 divide */
0x60, 0xE0, 0xA0, 0xC0, /* 0xF8 oslash */
0x80, 0x40, 0xA0, 0xA0, 0x60, /* 0xF9 ugrave */
0x20, 0x40, 0xA0, 0xA0, 0x60, /* 0xFA uacute */
0xE0, 0x00, 0xA0, 0xA0, 0x60, /* 0xFB ucircumflex */
0xA0, 0x00, 0xA0, 0xA0, 0x60, /* 0xFC udieresis */
0x20, 0x40, 0xA0, 0x60, 0x20, 0x40, /* 0xFD yacute */
0x80, 0xC0, 0xA0, 0xC0, 0x80, /* 0xFE thorn */
0xA0, 0x00, 0xA0, 0x60, 0x20, 0x40, /* 0xFF ydieresis */
0x00, /* 0x11D gcircumflex */
0x60, 0xC0, 0xE0, 0xC0, 0x60, /* 0x152 OE */
0x60, 0xE0, 0xC0, 0xE0, /* 0x153 oe */
0xA0, 0x60, 0xC0, 0x60, 0xC0, /* 0x160 Scaron */
0xA0, 0x60, 0xC0, 0x60, 0xC0, /* 0x161 scaron */
0xA0, 0x00, 0xA0, 0x40, 0x40, /* 0x178 Ydieresis */
0xA0, 0xE0, 0x60, 0xC0, 0xE0, /* 0x17D Zcaron */
0xA0, 0xE0, 0x60, 0xC0, 0xE0, /* 0x17E zcaron */
0x00, /* 0xEA4 uni0EA4 */
0x00, /* 0x13A0 uni13A0 */
0x80, /* 0x2022 bullet */
0xA0, /* 0x2026 ellipsis */
0x60, 0xE0, 0xE0, 0xC0, 0x60, /* 0x20AC Euro */
0xE0, 0xA0, 0xA0, 0xA0, 0xE0, /* 0xFFFD uniFFFD */
#endif /* (TOMTHUMB_USE_EXTENDED) */
};
/* {offset, width, height, advance cursor, x offset, y offset} */
const GFXglyph FontTomThumb::TomThumbGlyphs[] PROGMEM = {
{ 0, 8, 1, 2, 0, -5 }, /* 0x20 space */
{ 1, 8, 5, 2, 0, -5 }, /* 0x21 exclam */
{ 6, 8, 2, 4, 0, -5 }, /* 0x22 quotedbl */
{ 8, 8, 5, 4, 0, -5 }, /* 0x23 numbersign */
{ 13, 8, 5, 4, 0, -5 }, /* 0x24 dollar */
{ 18, 8, 5, 4, 0, -5 }, /* 0x25 percent */
{ 23, 8, 5, 4, 0, -5 }, /* 0x26 ampersand */
{ 28, 8, 2, 2, 0, -5 }, /* 0x27 quotesingle */
{ 30, 8, 5, 3, 0, -5 }, /* 0x28 parenleft */
{ 35, 8, 5, 3, 0, -5 }, /* 0x29 parenright */
{ 40, 8, 3, 4, 0, -5 }, /* 0x2A asterisk */
{ 43, 8, 3, 4, 0, -4 }, /* 0x2B plus */
{ 46, 8, 2, 3, 0, -2 }, /* 0x2C comma */
{ 48, 8, 1, 4, 0, -3 }, /* 0x2D hyphen */
{ 49, 8, 1, 2, 0, -1 }, /* 0x2E period */
{ 50, 8, 5, 4, 0, -5 }, /* 0x2F slash */
{ 55, 8, 5, 4, 0, -5 }, /* 0x30 zero */
{ 60, 8, 5, 3, 0, -5 }, /* 0x31 one */
{ 65, 8, 5, 4, 0, -5 }, /* 0x32 two */
{ 70, 8, 5, 4, 0, -5 }, /* 0x33 three */
{ 75, 8, 5, 4, 0, -5 }, /* 0x34 four */
{ 80, 8, 5, 4, 0, -5 }, /* 0x35 five */
{ 85, 8, 5, 4, 0, -5 }, /* 0x36 six */
{ 90, 8, 5, 4, 0, -5 }, /* 0x37 seven */
{ 95, 8, 5, 4, 0, -5 }, /* 0x38 eight */
{ 100, 8, 5, 4, 0, -5 }, /* 0x39 nine */
{ 105, 8, 3, 2, 0, -4 }, /* 0x3A colon */
{ 108, 8, 4, 3, 0, -4 }, /* 0x3B semicolon */
{ 112, 8, 5, 4, 0, -5 }, /* 0x3C less */
{ 117, 8, 3, 4, 0, -4 }, /* 0x3D equal */
{ 120, 8, 5, 4, 0, -5 }, /* 0x3E greater */
{ 125, 8, 5, 4, 0, -5 }, /* 0x3F question */
{ 130, 8, 5, 4, 0, -5 }, /* 0x40 at */
{ 135, 8, 5, 4, 0, -5 }, /* 0x41 A */
{ 140, 8, 5, 4, 0, -5 }, /* 0x42 B */
{ 145, 8, 5, 4, 0, -5 }, /* 0x43 C */
{ 150, 8, 5, 4, 0, -5 }, /* 0x44 D */
{ 155, 8, 5, 4, 0, -5 }, /* 0x45 E */
{ 160, 8, 5, 4, 0, -5 }, /* 0x46 F */
{ 165, 8, 5, 4, 0, -5 }, /* 0x47 G */
{ 170, 8, 5, 4, 0, -5 }, /* 0x48 H */
{ 175, 8, 5, 4, 0, -5 }, /* 0x49 I */
{ 180, 8, 5, 4, 0, -5 }, /* 0x4A J */
{ 185, 8, 5, 4, 0, -5 }, /* 0x4B K */
{ 190, 8, 5, 4, 0, -5 }, /* 0x4C L */
{ 195, 8, 5, 4, 0, -5 }, /* 0x4D M */
{ 200, 8, 5, 4, 0, -5 }, /* 0x4E N */
{ 205, 8, 5, 4, 0, -5 }, /* 0x4F O */
{ 210, 8, 5, 4, 0, -5 }, /* 0x50 P */
{ 215, 8, 5, 4, 0, -5 }, /* 0x51 Q */
{ 220, 8, 5, 4, 0, -5 }, /* 0x52 R */
{ 225, 8, 5, 4, 0, -5 }, /* 0x53 S */
{ 230, 8, 5, 4, 0, -5 }, /* 0x54 T */
{ 235, 8, 5, 4, 0, -5 }, /* 0x55 U */
{ 240, 8, 5, 4, 0, -5 }, /* 0x56 V */
{ 245, 8, 5, 4, 0, -5 }, /* 0x57 W */
{ 250, 8, 5, 4, 0, -5 }, /* 0x58 X */
{ 255, 8, 5, 4, 0, -5 }, /* 0x59 Y */
{ 260, 8, 5, 4, 0, -5 }, /* 0x5A Z */
{ 265, 8, 5, 4, 0, -5 }, /* 0x5B bracketleft */
{ 270, 8, 3, 4, 0, -4 }, /* 0x5C backslash */
{ 273, 8, 5, 4, 0, -5 }, /* 0x5D bracketright */
{ 278, 8, 2, 4, 0, -5 }, /* 0x5E asciicircum */
{ 280, 8, 1, 4, 0, -1 }, /* 0x5F underscore */
{ 281, 8, 2, 3, 0, -5 }, /* 0x60 grave */
{ 283, 8, 4, 4, 0, -4 }, /* 0x61 a */
{ 287, 8, 5, 4, 0, -5 }, /* 0x62 b */
{ 292, 8, 4, 4, 0, -4 }, /* 0x63 c */
{ 296, 8, 5, 4, 0, -5 }, /* 0x64 d */
{ 301, 8, 4, 4, 0, -4 }, /* 0x65 e */
{ 305, 8, 5, 4, 0, -5 }, /* 0x66 f */
{ 310, 8, 5, 4, 0, -4 }, /* 0x67 g */
{ 315, 8, 5, 4, 0, -5 }, /* 0x68 h */
{ 320, 8, 5, 2, 0, -5 }, /* 0x69 i */
{ 325, 8, 6, 4, 0, -5 }, /* 0x6A j */
{ 331, 8, 5, 4, 0, -5 }, /* 0x6B k */
{ 336, 8, 5, 4, 0, -5 }, /* 0x6C l */
{ 341, 8, 4, 4, 0, -4 }, /* 0x6D m */
{ 345, 8, 4, 4, 0, -4 }, /* 0x6E n */
{ 349, 8, 4, 4, 0, -4 }, /* 0x6F o */
{ 353, 8, 5, 4, 0, -4 }, /* 0x70 p */
{ 358, 8, 5, 4, 0, -4 }, /* 0x71 q */
{ 363, 8, 4, 4, 0, -4 }, /* 0x72 r */
{ 367, 8, 4, 4, 0, -4 }, /* 0x73 s */
{ 371, 8, 5, 4, 0, -5 }, /* 0x74 t */
{ 376, 8, 4, 4, 0, -4 }, /* 0x75 u */
{ 380, 8, 4, 4, 0, -4 }, /* 0x76 v */
{ 384, 8, 4, 4, 0, -4 }, /* 0x77 w */
{ 388, 8, 4, 4, 0, -4 }, /* 0x78 x */
{ 392, 8, 5, 4, 0, -4 }, /* 0x79 y */
{ 397, 8, 4, 4, 0, -4 }, /* 0x7A z */
{ 401, 8, 5, 4, 0, -5 }, /* 0x7B braceleft */
{ 406, 8, 5, 2, 0, -5 }, /* 0x7C bar */
{ 411, 8, 5, 4, 0, -5 }, /* 0x7D braceright */
{ 416, 8, 2, 4, 0, -5 }, /* 0x7E asciitilde */
#if (TOMTHUMB_USE_EXTENDED)
{ 418, 8, 5, 2, 0, -5 }, /* 0xA1 exclamdown */
{ 423, 8, 5, 4, 0, -5 }, /* 0xA2 cent */
{ 428, 8, 5, 4, 0, -5 }, /* 0xA3 sterling */
{ 433, 8, 5, 4, 0, -5 }, /* 0xA4 currency */
{ 438, 8, 5, 4, 0, -5 }, /* 0xA5 yen */
{ 443, 8, 5, 2, 0, -5 }, /* 0xA6 brokenbar */
{ 448, 8, 5, 4, 0, -5 }, /* 0xA7 section */
{ 453, 8, 1, 4, 0, -5 }, /* 0xA8 dieresis */
{ 454, 8, 3, 4, 0, -5 }, /* 0xA9 copyright */
{ 457, 8, 5, 4, 0, -5 }, /* 0xAA ordfeminine */
{ 462, 8, 3, 3, 0, -5 }, /* 0xAB guillemotleft */
{ 465, 8, 2, 4, 0, -4 }, /* 0xAC logicalnot */
{ 467, 8, 1, 3, 0, -3 }, /* 0xAD softhyphen */
{ 468, 8, 3, 4, 0, -5 }, /* 0xAE registered */
{ 471, 8, 1, 4, 0, -5 }, /* 0xAF macron */
{ 472, 8, 3, 4, 0, -5 }, /* 0xB0 degree */
{ 475, 8, 5, 4, 0, -5 }, /* 0xB1 plusminus */
{ 480, 8, 3, 4, 0, -5 }, /* 0xB2 twosuperior */
{ 483, 8, 3, 4, 0, -5 }, /* 0xB3 threesuperior */
{ 486, 8, 2, 3, 0, -5 }, /* 0xB4 acute */
{ 488, 8, 5, 4, 0, -5 }, /* 0xB5 mu */
{ 493, 8, 5, 4, 0, -5 }, /* 0xB6 paragraph */
{ 498, 8, 3, 4, 0, -4 }, /* 0xB7 periodcentered */
{ 501, 8, 3, 4, 0, -3 }, /* 0xB8 cedilla */
{ 504, 8, 3, 2, 0, -5 }, /* 0xB9 onesuperior */
{ 507, 8, 5, 4, 0, -5 }, /* 0xBA ordmasculine */
{ 512, 8, 3, 3, 0, -5 }, /* 0xBB guillemotright */
{ 515, 8, 5, 4, 0, -5 }, /* 0xBC onequarter */
{ 520, 8, 5, 4, 0, -5 }, /* 0xBD onehalf */
{ 525, 8, 5, 4, 0, -5 }, /* 0xBE threequarters */
{ 530, 8, 5, 4, 0, -5 }, /* 0xBF questiondown */
{ 535, 8, 5, 4, 0, -5 }, /* 0xC0 Agrave */
{ 540, 8, 5, 4, 0, -5 }, /* 0xC1 Aacute */
{ 545, 8, 5, 4, 0, -5 }, /* 0xC2 Acircumflex */
{ 550, 8, 5, 4, 0, -5 }, /* 0xC3 Atilde */
{ 555, 8, 5, 4, 0, -5 }, /* 0xC4 Adieresis */
{ 560, 8, 5, 4, 0, -5 }, /* 0xC5 Aring */
{ 565, 8, 5, 4, 0, -5 }, /* 0xC6 AE */
{ 570, 8, 6, 4, 0, -5 }, /* 0xC7 Ccedilla */
{ 576, 8, 5, 4, 0, -5 }, /* 0xC8 Egrave */
{ 581, 8, 5, 4, 0, -5 }, /* 0xC9 Eacute */
{ 586, 8, 5, 4, 0, -5 }, /* 0xCA Ecircumflex */
{ 591, 8, 5, 4, 0, -5 }, /* 0xCB Edieresis */
{ 596, 8, 5, 4, 0, -5 }, /* 0xCC Igrave */
{ 601, 8, 5, 4, 0, -5 }, /* 0xCD Iacute */
{ 606, 8, 5, 4, 0, -5 }, /* 0xCE Icircumflex */
{ 611, 8, 5, 4, 0, -5 }, /* 0xCF Idieresis */
{ 616, 8, 5, 4, 0, -5 }, /* 0xD0 Eth */
{ 621, 8, 5, 4, 0, -5 }, /* 0xD1 Ntilde */
{ 626, 8, 5, 4, 0, -5 }, /* 0xD2 Ograve */
{ 631, 8, 5, 4, 0, -5 }, /* 0xD3 Oacute */
{ 636, 8, 5, 4, 0, -5 }, /* 0xD4 Ocircumflex */
{ 641, 8, 5, 4, 0, -5 }, /* 0xD5 Otilde */
{ 646, 8, 5, 4, 0, -5 }, /* 0xD6 Odieresis */
{ 651, 8, 3, 4, 0, -4 }, /* 0xD7 multiply */
{ 654, 8, 5, 4, 0, -5 }, /* 0xD8 Oslash */
{ 659, 8, 5, 4, 0, -5 }, /* 0xD9 Ugrave */
{ 664, 8, 5, 4, 0, -5 }, /* 0xDA Uacute */
{ 669, 8, 5, 4, 0, -5 }, /* 0xDB Ucircumflex */
{ 674, 8, 5, 4, 0, -5 }, /* 0xDC Udieresis */
{ 679, 8, 5, 4, 0, -5 }, /* 0xDD Yacute */
{ 684, 8, 5, 4, 0, -5 }, /* 0xDE Thorn */
{ 689, 8, 6, 4, 0, -5 }, /* 0xDF germandbls */
{ 695, 8, 5, 4, 0, -5 }, /* 0xE0 agrave */
{ 700, 8, 5, 4, 0, -5 }, /* 0xE1 aacute */
{ 705, 8, 5, 4, 0, -5 }, /* 0xE2 acircumflex */
{ 710, 8, 5, 4, 0, -5 }, /* 0xE3 atilde */
{ 715, 8, 5, 4, 0, -5 }, /* 0xE4 adieresis */
{ 720, 8, 5, 4, 0, -5 }, /* 0xE5 aring */
{ 725, 8, 4, 4, 0, -4 }, /* 0xE6 ae */
{ 729, 8, 5, 4, 0, -4 }, /* 0xE7 ccedilla */
{ 734, 8, 5, 4, 0, -5 }, /* 0xE8 egrave */
{ 739, 8, 5, 4, 0, -5 }, /* 0xE9 eacute */
{ 744, 8, 5, 4, 0, -5 }, /* 0xEA ecircumflex */
{ 749, 8, 5, 4, 0, -5 }, /* 0xEB edieresis */
{ 754, 8, 5, 3, 0, -5 }, /* 0xEC igrave */
{ 759, 8, 5, 3, 0, -5 }, /* 0xED iacute */
{ 764, 8, 5, 4, 0, -5 }, /* 0xEE icircumflex */
{ 769, 8, 5, 4, 0, -5 }, /* 0xEF idieresis */
{ 774, 8, 5, 4, 0, -5 }, /* 0xF0 eth */
{ 779, 8, 5, 4, 0, -5 }, /* 0xF1 ntilde */
{ 784, 8, 5, 4, 0, -5 }, /* 0xF2 ograve */
{ 789, 8, 5, 4, 0, -5 }, /* 0xF3 oacute */
{ 794, 8, 5, 4, 0, -5 }, /* 0xF4 ocircumflex */
{ 799, 8, 5, 4, 0, -5 }, /* 0xF5 otilde */
{ 804, 8, 5, 4, 0, -5 }, /* 0xF6 odieresis */
{ 809, 8, 5, 4, 0, -5 }, /* 0xF7 divide */
{ 814, 8, 4, 4, 0, -4 }, /* 0xF8 oslash */
{ 818, 8, 5, 4, 0, -5 }, /* 0xF9 ugrave */
{ 823, 8, 5, 4, 0, -5 }, /* 0xFA uacute */
{ 828, 8, 5, 4, 0, -5 }, /* 0xFB ucircumflex */
{ 833, 8, 5, 4, 0, -5 }, /* 0xFC udieresis */
{ 838, 8, 6, 4, 0, -5 }, /* 0xFD yacute */
{ 844, 8, 5, 4, 0, -4 }, /* 0xFE thorn */
{ 849, 8, 6, 4, 0, -5 }, /* 0xFF ydieresis */
{ 855, 8, 1, 2, 0, -1 }, /* 0x11D gcircumflex */
{ 856, 8, 5, 4, 0, -5 }, /* 0x152 OE */
{ 861, 8, 4, 4, 0, -4 }, /* 0x153 oe */
{ 865, 8, 5, 4, 0, -5 }, /* 0x160 Scaron */
{ 870, 8, 5, 4, 0, -5 }, /* 0x161 scaron */
{ 875, 8, 5, 4, 0, -5 }, /* 0x178 Ydieresis */
{ 880, 8, 5, 4, 0, -5 }, /* 0x17D Zcaron */
{ 885, 8, 5, 4, 0, -5 }, /* 0x17E zcaron */
{ 890, 8, 1, 2, 0, -1 }, /* 0xEA4 uni0EA4 */
{ 891, 8, 1, 2, 0, -1 }, /* 0x13A0 uni13A0 */
{ 892, 8, 1, 2, 0, -3 }, /* 0x2022 bullet */
{ 893, 8, 1, 4, 0, -1 }, /* 0x2026 ellipsis */
{ 894, 8, 5, 4, 0, -5 }, /* 0x20AC Euro */
{ 899, 8, 5, 4, 0, -5 }, /* 0xFFFD uniFFFD */
#endif /* (TOMTHUMB_USE_EXTENDED) */
};
const GFXfont FontTomThumb::TomThumb PROGMEM = {
(uint8_t *)TomThumbBitmaps,
(GFXglyph *)TomThumbGlyphs,
0x20, 0x7E, 6 };
| [
"toyos@parda"
] | toyos@parda |
403fd1db7759accfbbbc783404f5177c5fc195c5 | f76b01b11302c57ad5932bcb6599e06ad6efc9f6 | /teste1.cpp | 166c12b49f56ca717a6903c085f2fb3863564765 | [] | no_license | Gimenesomenes/Carolina- | 377a25d2fb16ea2d85481d43ea15256afd3d9bf6 | 77e79409f30995cdc0e329af257113cf2bd159b9 | refs/heads/master | 2020-08-04T15:15:20.949604 | 2019-10-01T21:31:17 | 2019-10-01T21:31:17 | 212,180,705 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 291 | cpp | #include<stdio.h>
#include<stdlib.h>
main(){
int Valor, Soma=0;
do{
printf("Digite um valor ou -1 para sair:\n");
scanf("%d", &Valor);
if(Valor != -1)
Soma = Soma + Valor;
}while(Valor != -1);
printf("\nA soma eh: %d", Soma);
}
| [
"carolina.gimenes.oliveira@usp.br"
] | carolina.gimenes.oliveira@usp.br |
c5594bd91c7d7447f0cef180b7e99a2c609d53a9 | a6006291400ce051ba5237f5c372c1650bca7da7 | /Cards/Factory/GameCard.cpp | 742b2c97a676543d3b13385e87feca05c651af7a | [] | no_license | legendoftamar/eight-minute-empire | dfcc604ea72f174b516df7ae86e7a6670758e527 | e73043d05d01e043588921baaad866024ddc34f8 | refs/heads/master | 2020-07-29T14:39:20.466022 | 2019-11-25T21:06:50 | 2019-11-25T21:06:50 | 209,845,874 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,905 | cpp | //
// Created by MJ on 2019-11-22.
//
#include <iostream>
#include "../Cards.h"
using namespace std;
class GameCard {
protected:
Card* card;
public:
GameCard() = default;
virtual ~GameCard() {
delete card;
}
virtual void printCard() = 0;
};
class RubyCard : public GameCard {
public:
RubyCard(Action action) {
this->card = new Card(Good(Good::GoodType::GOOD_RUBY, 1), action);
}
void printCard() {
cout << "This is a Ruby Card!" << endl;
this->card->printCard();
}
};
class WoodCard : public GameCard {
public:
WoodCard(Action action) {
this->card = new Card(Good(Good::GoodType::GOOD_WOOD, 1), action);
}
void printCard() {
cout << "This is a Wood Card!" << endl;
this->card->printCard();
}
};
class CarrotCard : public GameCard {
public:
CarrotCard(Action action) {
this->card = new Card(Good(Good::GoodType::GOOD_CARROT, 1), action);
}
void printCard() {
cout << "This is a Carrot Card!" << endl;
this->card->printCard();
}
};
class AnvilCard : public GameCard {
public:
AnvilCard(Action action) {
this->card = new Card(Good(Good::GoodType::GOOD_ANVIL, 1), action);
}
void printCard() {
cout << "This is an Anvil Card!" << endl;
this->card->printCard();
}
};
class OreCard : public GameCard {
public:
OreCard(Action action) {
this->card = new Card(Good(Good::GoodType::GOOD_ORE, 1), action);
}
void printCard() {
cout << "This is an Ore Card!" << endl;
this->card->printCard();
}
};
class WildCard : public GameCard {
public:
WildCard(Action action) {
this->card = new Card(Good(Good::GoodType::GOOD_WILD, 1), action);
}
void printCard() {
cout << "This is a Wild Card!" << endl;
this->card->printCard();
}
};
| [
"mjackson74u@gmail.com"
] | mjackson74u@gmail.com |
e313f8f20443cd0560b8b4d3156bac4bbe485e20 | 9a9bb2fff1fcf771a70c84d43d1c4cb216b7cf23 | /DecoderPicture.cpp | 36297677527b750533d772e442a07e2357fc3f0f | [] | no_license | wupeilin0220/ffmpeg_study | 3a05eaf1dc5666da1ba8202ae20fe48c9fcf78c8 | c6675b6505d3195c037289495e19d4b9c6e2ad65 | refs/heads/master | 2023-03-09T10:57:09.784297 | 2021-02-23T05:57:31 | 2021-02-23T05:57:31 | 341,440,743 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,027 | cpp | // This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include "DecoderPicture.h"
DecoderPicture::DecoderPicture()
{
// sws_getContext()
type = StreamType::PicStream;
}
DecoderPicture::~DecoderPicture()
{
}
int DecoderPicture::decoderStream()
{
AVPacket packet;
AVFrame* frame = av_frame_alloc();
int ret = av_read_frame(formatContext, &packet);
if (ret < 0 && ret != AVERROR_EOF) {
goto end;
}
// 如果是图片数据则会直接输出数据
ret = avcodec_send_packet(video_codecCtx, &packet);
if (ret < 0) {
goto end;
}
ret = avcodec_receive_frame(video_codecCtx, frame);
if (ret < 0) {
goto end;
}
DateSet data;
data.srcData = frame;
data.type = MEDIATYPE::VIDEO;
mutex_link.lock();
if(link)
link->fillBuffer(data);
mutex_link.unlock();
end:
if (ret < 0) {
av_frame_free(&frame);
}
return ret;
}
| [
"peilin0220@163.com"
] | peilin0220@163.com |
f13a42dc4bdf181803fef280d9c7db93466ae73b | 581ba527a357af01f96f65b1827ca619329196dd | /pslindrome_check_made_stl_type/main.cpp | 29bec2d27bf7ae141b83e1667dab3f197e990df1 | [] | no_license | gourav13/c-_code | 3202e14a03838b5435797482caca6f328b82bbf6 | 6ee3ffaa457cea4268d9a31eee1677e965a7a9fb | refs/heads/master | 2020-03-09T10:13:02.128096 | 2018-07-25T05:29:27 | 2018-07-25T05:29:27 | 128,731,860 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 282 | cpp | #include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
string s="eabae";
int n=s.size();
if(string(s.begin(),s.begin()+n)==string(s.rbegin(),s.rbegin()+n))
cout<<"its palindrome";
else
cout<<"no";
return 0;
}
| [
"gourav13041997@gmail.com"
] | gourav13041997@gmail.com |
9439c3ad00ebadbb6857a40d083d6afe8ca1a9ec | 92eead7872140b0ba00e54629ef19d4432f3be4e | /Chapter-3/3.8/3.8_while.cpp | 399ef52f0141cffbd6607f0c534ea1de58f2d8bf | [] | no_license | shengchiliu/Cpp-Primer-Answer | acd8a3b3f0ce80fd759055d7d79788c2b5456b13 | 9a932c349b5cd272c47a7c793c3cee8c84f9edbc | refs/heads/master | 2023-03-22T10:35:00.824761 | 2019-08-30T04:57:29 | 2019-08-30T04:57:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 194 | cpp | #include<iostream>
#include<string>
int main()
{
std::string s;
std::cin >> s;
std::string::size_type i = 0;
while(i < s.size())
{
s[i] = 'X';
i++;
}
std::cout << s;
return 0;
}
| [
"jzplp@qq.com"
] | jzplp@qq.com |
cc5378226ca8006905d4185b985ca464675ddb9f | 5e1f5f2090013041b13d1e280f747aa9f914caa4 | /src/devices/bin/driver_manager/device_watcher.h | 69a1fe810999531b1f18ce1a49f69c8291556dd7 | [
"BSD-2-Clause"
] | permissive | mvanotti/fuchsia-mirror | 477b7d51ae6818e456d5803eea68df35d0d0af88 | 7fb60ae374573299dcb1cc73f950b4f5f981f95c | refs/heads/main | 2022-11-29T08:52:01.817638 | 2021-10-06T05:37:42 | 2021-10-06T05:37:42 | 224,297,435 | 0 | 1 | BSD-2-Clause | 2022-11-21T01:19:37 | 2019-11-26T22:28:11 | C++ | UTF-8 | C++ | false | false | 2,640 | h | // Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_DEVICES_BIN_DRIVER_MANAGER_DEVICE_WATCHER_H_
#define SRC_DEVICES_BIN_DRIVER_MANAGER_DEVICE_WATCHER_H_
#include <fidl/fuchsia.device.manager/cpp/wire.h>
#include <fidl/fuchsia.io/cpp/wire.h>
#include <lib/fdio/directory.h>
#include <lib/fdio/fdio.h>
#include <zircon/errors.h>
#include <list>
#include "lib/fidl/llcpp/transaction.h"
#include "src/lib/fsl/io/device_watcher.h"
class DeviceWatcher : public fidl::WireServer<fuchsia_device_manager::DeviceWatcher> {
public:
DeviceWatcher(std::string dir_path, async_dispatcher_t* dispatcher) {
dir_path_ = std::move(dir_path);
dispatcher_ = dispatcher;
}
void NextDevice(NextDeviceRequestView request, NextDeviceCompleter::Sync& completer) override {
if (watcher_ == nullptr) {
fbl::unique_fd fd;
zx_status_t status =
fdio_open_fd(dir_path_.c_str(),
fuchsia_io::wire::kOpenRightWritable | fuchsia_io::wire::kOpenRightReadable,
fd.reset_and_get_address());
if (status != ZX_OK) {
completer.ReplyError(status);
return;
}
watcher_ = fsl::DeviceWatcher::CreateWithIdleCallback(
std::move(fd), fit::bind_member(this, &DeviceWatcher::FdCallback), [] {}, dispatcher_);
}
if (request_) {
completer.ReplyError(ZX_ERR_ALREADY_BOUND);
return;
}
if (channels_list_.empty()) {
request_ = completer.ToAsync();
return;
}
completer.ReplySuccess(std::move(channels_list_.front()));
channels_list_.pop_front();
}
private:
void FdCallback(int dir_fd, const std::string& filename) {
int fd = 0;
zx_status_t status = fdio_open_fd_at(dir_fd, filename.c_str(), O_RDONLY, &fd);
if (status != ZX_OK) {
FX_LOGS(ERROR) << "Failed to open device " << filename;
return;
}
zx::channel channel;
status = fdio_get_service_handle(fd, channel.reset_and_get_address());
if (status != ZX_OK) {
FX_LOGS(ERROR) << "Failed to get service handle " << filename;
return;
}
if (request_) {
request_->ReplySuccess(std::move(channel));
request_.reset();
return;
}
channels_list_.push_back(std::move(channel));
}
std::optional<NextDeviceCompleter::Async> request_;
std::unique_ptr<fsl::DeviceWatcher> watcher_;
std::list<zx::channel> channels_list_;
std::string dir_path_;
async_dispatcher_t* dispatcher_;
};
#endif // SRC_DEVICES_BIN_DRIVER_MANAGER_DEVICE_WATCHER_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
9c935c80164246c13d7e29f97cc3fe791567db07 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5646553574277120_0/C++/Retrograd/main.cpp | ac1276636f08c94a5f8d0113dde33b0800196e4b | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,428 | cpp | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<unordered_map>
using namespace std;
typedef int var;
#define MAX 100
bool Can[MAX];
bool In[MAX];
var c, d, v;
bool check() {
memset(Can, 0, sizeof(Can));
for(var i=1; i<=v; i++) {
if(In[i]) {
for(var j=v-i; j; j--) {
if(Can[j])
Can[i+j] = 1;
}
Can[i] = 1;
}
}
for(var i=1; i<=v; i++) {
if(!Can[i])
return false;
}
return true;
}
bool good(var num, var from, var chosen) {
if(chosen == num)
return check();
if(from > v)
return false;
if(good(num, from+1, chosen))
return true;
if(In[from])
return false;
In[from] = 1;
bool r = good(num, from+1, chosen+1);
In[from] = 0;
return r;
}
int main() {
freopen("D.in", "r", stdin);
freopen("D.out", "w", stdout);
var t;
var val;
cin>>t;
for(var tt=1; tt<=t; tt++) {
cin>>c>>d>>v;
memset(In, 0, sizeof(In));
for(var i=1; i<=d; i++) {
cin>>val;
In[val] = 1;
}
var sol;
for(sol=0; !good(sol, 1, 0); sol++);
printf("Case #%d: %d\n", tt, sol);
fflush(stdout);
}
return 0;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
7e34ea40ee94a3cab807bab632bda96f8617cc77 | 84b066b24d4ce9910b5eb2f77a7c6bc712475227 | /EL_CIRCUITO_2.ino | dd98e62ddf63bc1838855c367d996cd1f12914e9 | [
"CC0-1.0"
] | permissive | Wesley3455/Arduino- | 8599161ff13c4997cee2bc7270a5a39ec00fb4ec | fb91e35e422ef994069f5e0241bed99a10533a48 | refs/heads/main | 2023-03-16T22:15:12.935473 | 2021-03-22T12:40:50 | 2021-03-22T12:40:50 | 334,881,532 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 563 | ino | int notes[] = {262,294,330,349};
//relaciona cada valor de la lista anterior con uno de esta
void setup(){
Serial.begin(9600);
}
void loop(){
int keyVal = analogRead(A0);
//lee un valor entre 0 y 1024 dependiendo de qué botón está pulsado
Serial.println(keyVal);
if(keyVal == 1023){
tone(8, notes[0]);
}
else if(keyVal >= 990 && keyVal <=1010){
tone(8, notes[1]);
}
else if(keyVal >= 505 && keyVal <= 515){
tone(8, notes[2]);
}
else if(keyVal >= 5 && keyVal <=10){
tone(8, notes[3]);
}
else{
noTone(8);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
9ebafca572daa881dc8df79fe466e6425178b813 | 9fc4de2ab87d73df6a048838baeee0deddd97903 | /src/VjObject.cpp | 37ac91ba929d9a61f47e6c44b22cc7875dc03180 | [] | no_license | revilo196/ofVisualGenerator | 3ecea14a1367d394265172cfd206d4ff84492ff1 | b7acde7e9e60299a7efa881493c28501ec259572 | refs/heads/master | 2023-04-16T21:20:04.835173 | 2023-04-06T10:39:33 | 2023-04-06T10:39:33 | 128,386,407 | 5 | 0 | null | 2018-11-05T01:07:26 | 2018-04-06T11:30:42 | C++ | UTF-8 | C++ | false | false | 1,438 | cpp | #include "VjObject.h"
const float * VjObject::rms = nullptr;
const SoundAnalyzer * VjObject::sound_connect = nullptr;
int VjObject::width = 0;
int VjObject::height = 0;
VjObject::VjObject(std::string name)
{
this->nameParameter = name;
this->parameters.add(this->nameParameter);
}
VjObject::~VjObject()
{
}
void VjObject::addParameter(ofAbstractParameter & param, bool rms)
{
auto ptype = param.type();
if (ptype == typeid(ofParameter<float>).name() && rms) { // !!! typeid name is diffrent on other os
parameters.add(param);
ofParameter<float> p = param.cast<float>();
mod.emplace_back(p.getName(), p.get(), p.getMin(), p.getMax());
act.emplace_back("rms-" + p.getName(), false);
modg1.add(mod.back());
modg1.add(act.back());
}
else {
modg1.add(param);
}
}
ofParameterGroup VjObject::getParameterGroup()
{
return modg1;
}
void VjObject::setName(string name)
{
nameParameter = name;
}
string VjObject::getName()
{
return nameParameter.get();
}
void VjObject::updateParms()
{
for (int i = 0; i < parameters.size(); i++) {
if (parameters.getType(i) == typeid(ofParameter<float>).name()) {
ofParameter<float> p = parameters.getFloat(i);
if (modg1.contains(p.getName()) && modg1.getBool("rms-" + p.getName()) && rms != nullptr)
{
p = modg1.getFloat(p.getName()) + ((p.getMax() - p.getMin())/ 4) * (*rms) ;
}
else {
p = modg1.getFloat(p.getName());
}
}
}
}
| [
"oli1111@web.de"
] | oli1111@web.de |
fe72be29ebe70aebab4ec58fa8e7dcff2c2c3355 | 8723e226fadbbf754f07ff762954b751d6232085 | /template/IOS/include/Urho3D/Graphics/DecalSet.h | a1bf6439ab9c3d08d160fc60922da3cd5469a0d2 | [
"MIT"
] | permissive | elix22/Urho.Net | 35d286d26c123c69f28014e223dbf6ad658f0ff3 | 10c44992729643693f63d5be3d7d84b76436110e | refs/heads/main | 2023-04-07T23:20:07.783221 | 2021-04-19T12:24:18 | 2021-04-19T12:24:18 | 330,765,788 | 7 | 1 | MIT | 2021-04-18T06:42:11 | 2021-01-18T19:24:31 | C++ | UTF-8 | C++ | false | false | 10,197 | h | //
// Copyright (c) 2008-2020 the Urho3D project.
//
// 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.
//
#pragma once
#include "../Container/List.h"
#include "../Graphics/Drawable.h"
#include "../Graphics/Skeleton.h"
#include "../Math/Frustum.h"
namespace Urho3D
{
class IndexBuffer;
class VertexBuffer;
/// %Decal vertex.
struct DecalVertex
{
/// Construct with defaults.
DecalVertex() = default;
/// Construct with position and normal.
DecalVertex(const Vector3& position, const Vector3& normal) :
position_(position),
normal_(normal)
{
}
/// Construct with position, normal and skinning information.
DecalVertex(const Vector3& position, const Vector3& normal, const float* blendWeights, const unsigned char* blendIndices) :
position_(position),
normal_(normal)
{
for (unsigned i = 0; i < 4; ++i)
{
blendWeights_[i] = blendWeights[i];
blendIndices_[i] = blendIndices[i];
}
}
/// Position.
Vector3 position_;
/// Normal.
Vector3 normal_;
/// Texture coordinates.
Vector2 texCoord_;
/// Tangent.
Vector4 tangent_;
/// Blend weights.
float blendWeights_[4]{};
/// Blend indices.
unsigned char blendIndices_[4]{};
};
/// One decal in a decal set.
struct Decal
{
/// Construct with defaults.
Decal() :
timer_(0.0f),
timeToLive_(0.0f)
{
}
/// Add a vertex.
void AddVertex(const DecalVertex& vertex);
/// Calculate local-space bounding box.
void CalculateBoundingBox();
/// Decal age timer.
float timer_;
/// Maximum time to live in seconds (0 = infinite).
float timeToLive_;
/// Local-space bounding box.
BoundingBox boundingBox_;
/// Decal vertices.
PODVector<DecalVertex> vertices_;
/// Decal indices.
PODVector<unsigned short> indices_;
};
/// %Decal renderer component.
class URHO3D_API DecalSet : public Drawable
{
URHO3D_OBJECT(DecalSet, Drawable);
public:
/// Construct.
explicit DecalSet(Context* context);
/// Destruct.
~DecalSet() override;
/// Register object factory.
static void RegisterObject(Context* context);
/// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
void ApplyAttributes() override;
/// Handle enabled/disabled state change.
void OnSetEnabled() override;
/// Process octree raycast. May be called from a worker thread.
void ProcessRayQuery(const RayOctreeQuery& query, PODVector<RayQueryResult>& results) override;
/// Calculate distance and prepare batches for rendering. May be called from worker thread(s), possibly re-entrantly.
void UpdateBatches(const FrameInfo& frame) override;
/// Prepare geometry for rendering. Called from a worker thread if possible (no GPU update).
void UpdateGeometry(const FrameInfo& frame) override;
/// Return whether a geometry update is necessary, and if it can happen in a worker thread.
UpdateGeometryType GetUpdateGeometryType() override;
/// Set material. The material should use a small negative depth bias to avoid Z-fighting.
void SetMaterial(Material* material);
/// Set maximum number of decal vertices.
void SetMaxVertices(unsigned num);
/// Set maximum number of decal vertex indices.
void SetMaxIndices(unsigned num);
/// Set whether to optimize GPU buffer sizes according to current amount of decals. Default false, which will size the buffers according to the maximum vertices/indices. When true, buffers will be reallocated whenever decals are added/removed, which can be worse for performance.
void SetOptimizeBufferSize(bool enable);
/// Add a decal at world coordinates, using a target drawable's geometry for reference. If the decal needs to move with the target, the decal component should be created to the target's node. Return true if successful.
bool AddDecal(Drawable* target, const Vector3& worldPosition, const Quaternion& worldRotation, float size, float aspectRatio,
float depth, const Vector2& topLeftUV, const Vector2& bottomRightUV, float timeToLive = 0.0f, float normalCutoff = 0.1f,
unsigned subGeometry = M_MAX_UNSIGNED);
/// Remove n oldest decals.
void RemoveDecals(unsigned num);
/// Remove all decals.
void RemoveAllDecals();
/// Return material.
Material* GetMaterial() const;
/// Return number of decals.
unsigned GetNumDecals() const { return decals_.Size(); }
/// Retur number of vertices in the decals.
unsigned GetNumVertices() const { return numVertices_; }
/// Retur number of vertex indices in the decals.
unsigned GetNumIndices() const { return numIndices_; }
/// Return maximum number of decal vertices.
unsigned GetMaxVertices() const { return maxVertices_; }
/// Return maximum number of decal vertex indices.
unsigned GetMaxIndices() const { return maxIndices_; }
/// Return whether is optimizing GPU buffer sizes according to current amount of decals.
bool GetOptimizeBufferSize() const { return optimizeBufferSize_; }
/// Set material attribute.
void SetMaterialAttr(const ResourceRef& value);
/// Set decals attribute.
void SetDecalsAttr(const PODVector<unsigned char>& value);
/// Return material attribute.
ResourceRef GetMaterialAttr() const;
/// Return decals attribute.
PODVector<unsigned char> GetDecalsAttr() const;
protected:
/// Recalculate the world-space bounding box.
void OnWorldBoundingBoxUpdate() override;
/// Handle node transform being dirtied.
void OnMarkedDirty(Node* node) override;
private:
/// Get triangle faces from the target geometry.
void GetFaces(Vector<PODVector<DecalVertex> >& faces, Drawable* target, unsigned batchIndex, const Frustum& frustum,
const Vector3& decalNormal, float normalCutoff);
/// Get triangle face from the target geometry.
void GetFace
(Vector<PODVector<DecalVertex> >& faces, Drawable* target, unsigned batchIndex, unsigned i0, unsigned i1, unsigned i2,
const unsigned char* positionData, const unsigned char* normalData, const unsigned char* skinningData,
unsigned positionStride, unsigned normalStride, unsigned skinningStride, const Frustum& frustum,
const Vector3& decalNormal, float normalCutoff);
/// Get bones referenced by skinning data and remap the skinning indices. Return true if successful.
bool GetBones(Drawable* target, unsigned batchIndex, const float* blendWeights, const unsigned char* blendIndices,
unsigned char* newBlendIndices);
/// Calculate UV coordinates for the decal.
void CalculateUVs
(Decal& decal, const Matrix3x4& view, const Matrix4& projection, const Vector2& topLeftUV, const Vector2& bottomRightUV);
/// Transform decal's vertices from the target geometry to the decal set local space.
void TransformVertices(Decal& decal, const Matrix3x4& transform);
/// Remove a decal by iterator and return iterator to the next decal.
List<Decal>::Iterator RemoveDecal(List<Decal>::Iterator i);
/// Mark decals and the bounding box dirty.
void MarkDecalsDirty();
/// Recalculate the local-space bounding box.
void CalculateBoundingBox();
/// Rewrite decal vertex and index buffers.
void UpdateBuffers();
/// Recalculate skinning.
void UpdateSkinning();
/// Update the batch (geometry type, shader data).
void UpdateBatch();
/// Find bones after loading.
void AssignBoneNodes();
/// Subscribe/unsubscribe from scene post-update as necessary.
void UpdateEventSubscription(bool checkAllDecals);
/// Handle scene post-update event.
void HandleScenePostUpdate(StringHash eventType, VariantMap& eventData);
/// Geometry.
SharedPtr<Geometry> geometry_;
/// Vertex buffer.
SharedPtr<VertexBuffer> vertexBuffer_;
/// Index buffer.
SharedPtr<IndexBuffer> indexBuffer_;
/// Decals.
List<Decal> decals_;
/// Bones used for skinned decals.
Vector<Bone> bones_;
/// Skinning matrices.
PODVector<Matrix3x4> skinMatrices_;
/// Vertices in the current decals.
unsigned numVertices_;
/// Indices in the current decals.
unsigned numIndices_;
/// Maximum vertices.
unsigned maxVertices_;
/// Maximum indices.
unsigned maxIndices_;
/// Optimize buffer sizes flag.
bool optimizeBufferSize_;
/// Skinned mode flag.
bool skinned_;
/// Vertex buffer needs rewrite / resizing flag.
bool bufferDirty_;
/// Bounding box needs update flag.
bool boundingBoxDirty_;
/// Skinning dirty flag.
bool skinningDirty_;
/// Bone nodes assignment pending flag.
bool assignBonesPending_;
/// Subscribed to scene post update event flag.
bool subscribed_;
};
}
| [
"elix22@gmail.com"
] | elix22@gmail.com |
3c912a34c03e86944479afc82d13786a0177d37b | ebf1bb0e33c3a3748ae8e2e4ad5ad0faf2abde21 | /ch12/Fig12_12_16/BasePlusCommissionEmployee.cpp | c5abcaa4a9ea84404d12c43d0f2eb584270c0cfa | [] | no_license | salehi/deitel-and-deitel-c-persian | d6cdb963f9e6f64f37ca0d346f198dda0e1153c5 | a25c2e530ea9fefffd6740247c70e9ec465cc188 | refs/heads/master | 2022-11-23T14:29:08.811553 | 2020-07-27T09:15:30 | 2020-07-27T09:15:30 | 282,849,119 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,715 | cpp | // Fig. 12.15: BasePlusCommissionEmployee.cpp
// Class BasePlusCommissionEmployee member-function definitions.
#include <iostream>
using std::cout;
// BasePlusCommissionEmployee class definition
#include "BasePlusCommissionEmployee.h"
// constructor
BasePlusCommissionEmployee::BasePlusCommissionEmployee(
const string &first, const string &last, const string &ssn,
double sales, double rate, double salary )
// explicitly call base-class constructor
: CommissionEmployee( first, last, ssn, sales, rate )
{
setBaseSalary( salary ); // validate and store base salary
} // end BasePlusCommissionEmployee constructor
// set base salary
void BasePlusCommissionEmployee::setBaseSalary( double salary )
{
baseSalary = ( salary < 0.0 ) ? 0.0 : salary;
} // end function setBaseSalary
// return base salary
double BasePlusCommissionEmployee::getBaseSalary() const
{
return baseSalary;
} // end function getBaseSalary
// calculate earnings
double BasePlusCommissionEmployee::earnings() const
{
// can access protected data of base class
return baseSalary + ( commissionRate * grossSales );
} // end function earnings
// print BasePlusCommissionEmployee object
void BasePlusCommissionEmployee::print() const
{
// can access protected data of base class
cout << "base-salaried commission employee: " << firstName << ' '
<< lastName << "\nsocial security number: " << socialSecurityNumber
<< "\ngross sales: " << grossSales
<< "\ncommission rate: " << commissionRate
<< "\nbase salary: " << baseSalary;
} // end function print
/**************************************************************************
* (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/
| [
"salehi1994@gmail.com"
] | salehi1994@gmail.com |
291245202fc534eb79650db5de33470d4d4d7af7 | 8132b4ad00ddc7d7a17c15d098c7d1ac9bdfeb8b | /core/engine/scene/nodes/node.hpp | fc59490499e6ca7f9f881d7f12251589c4776712 | [
"MIT"
] | permissive | ImanolFotia/Epsilon-Engine | c404a45d4307e52295a196356110c0b6bcc44546 | 7c38327691128b380235c853888bad0aa07fbdc5 | refs/heads/master | 2023-08-31T11:59:58.345416 | 2023-08-30T19:59:02 | 2023-08-30T19:59:02 | 179,153,425 | 31 | 3 | MIT | 2023-03-08T02:24:16 | 2019-04-02T20:27:29 | C++ | UTF-8 | C++ | false | false | 690 | hpp | #pragma once
#include <memory>
#include <vector>
#include <functional>
namespace engine
{
struct NodeBase
{
using type = void;
int Index() { return index; }
std::shared_ptr<NodeBase> Parent() {
return parent;
}
private:
int index = 0;
std::shared_ptr<NodeBase> parent;
std::vector<std::function<void()>> destroy_children;
friend class SceneManager;
};
template <typename T>
struct Node : NodeBase
{
template <class... Args>
Node(Args &&...args) : data(std::forward<Args>(args)...) {}
using type = T;
T data;
};
struct Root
{
};
} | [
"imanolfotia@gmail.com"
] | imanolfotia@gmail.com |
61904794510920d78bbe7f590f5120dafeae5c3b | 65a932ec316a0f46de92016ede3b761413201f25 | /UnitTest/GameObject/Player.cpp | c25da0e709c356ae2c52a50ab8c82a47c183659b | [] | no_license | lyunDev/directx11-2D-topdown-shooter | ddd3de0fb9b7ca4b4f166b71af44b9964946ae33 | 20bd8b186414c766a84b90470cc4761910c72692 | refs/heads/main | 2023-02-07T18:10:02.630121 | 2020-12-30T04:28:20 | 2020-12-30T04:28:20 | 320,711,874 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,244 | cpp | #include "Framework.h"
#include "Player.h"
#include "Geometries/TextureRect.h"
#include "Game/Transform.h"
#include "GameObject/MuzzleFlash.h"
#include "GameEffects/AfterImage.h"
#include "GameEffects/BoostEffect.h"
#include "Utilities/Layers.h"
#include "GameObject/HPBar.h"
#include "ShaderBuffers/ColorBuffer.h"
#include "GameObject/BulletRemoveEffect.h"
#include "Game/GameObjectManager.h"
#include "Event/EventDispatcher.h"
#include "Event/EventTypes.h"
#include "GameObject/LevelUpEffect.h"
#include "GameUI/BossCautionPannel.h"
#include "GameObject/Skills/Shield.h"
#include "GameObject/Skills/WideExplosion.h"
#include "UI/Pannel.h"
#include "Effects/Dissolve.h"
Player::Player(Vector3 position, Vector3 size)
: Actor(ActorInfo(100, 100),position, size, 0, false)
{
Texture2D * tex = new Texture2D(TexturePath + L"GameObject/Player.png");
SetSRV(tex->GetSRV());
machineGunModeSRV = tex->GetSRV();
Texture2D * canonTex = new Texture2D(TexturePath + L"GameObject/HeavyGunner_Canon.png");
canonGunModeSRV = canonTex->GetSRV();
SAFE_DELETE(tex);
firePos = new Transform();
muzzlePos = new Transform();
leftBoostPos = new Transform();
rightBoostPos = new Transform();
//hpBar = new HPBar(this, &actorInfo, true);
Camera::Get()->SetTarget(&this->transform->position);
SetRenderToCollisionBox(true);
SetTag("Player");
machineGunBulletPool = new ObjectPool<NormalBullet>();
canonGunBulletPool = new ObjectPool<PlayerPlazmaBullet>();
SetRenderLayer(RenderLayer::GAMEOBJECT);
//muzzleFlash = new MuzzleFlash();
machineGunMuzzleFlash = make_shared<NormalMuzzleFlash>();
canonGunMuzzleFlash = make_shared<PlayerPlazmaMuzzleFlash>();
//leftBoostEffect = new BoostEffect();
//rightBoostEffect = new BoostEffect();
SetObjectLayer(ObjectLayer::PLAYER);
collisionTr = new Transform();
collisionTr->position = transform->position;
collisionTr->size = Vector3(60, 60, 1);
collisionTr->rotation = transform->rotation;
SetCollisionTr(&transform->position, &collisionTr->size, &transform->rotation);
maxLevel = expTable.size() - 1;
EventDispatcher::AddEventListener(BattleEvent::KillEnemy, [&]()
{
exp += 10;
if (exp >= expTable[level] && level != maxLevel)
{
level++;
LevelUp();
}
});
shield = new Shield(this, Vector3(150, 150, 1), shieldEnergy);
machineGunUI = new Pannel(TexturePath + L"UI/heavygun.png", Vector3(WinMaxWidth - 130, 150, 0), Vector3(150, 200, 1), false);
canonGunUI = new Pannel(TexturePath + L"UI/luncher.png", Vector3(WinMaxWidth - 130, 150, 0), Vector3(150, 200, 1), false);
machineGunUI->SetActive(true);
canonGunUI->SetActive(false);
}
Player::~Player()
{
SAFE_DELETE(leftBoostPos);
SAFE_DELETE(rightBoostPos);
SAFE_DELETE(firePos);
SAFE_DELETE(machineGunBulletPool);
SAFE_DELETE(muzzlePos);
}
void Player::OnUpdate()
{
ChangeAttackMode();
PlayerMove();
PlayerRotate();
FirePosUpdate();
Fire();
SlowUpdate();
BoostUpdate();
ShieldUpdate();
ActiveShield();
WideExplosionSkill();
if (actorInfo.isDie)
{
GetDissolveBuffer()->IncreaseDissolveAmount(Time::Delta());
if (GetDissolveBuffer()->GetDissolveAmount() >= 1)
{
SetActive(false);
EventDispatcher::TriggerEvent(GameEvent::PlayerDie);
}
}
}
void Player::OnPostUpdate()
{
leftMoveStop = false;
rightMoveStop = false;
upMoveStop = false;
downMoveStop = false;
BulletUpdate();
}
void Player::OnCollisionStay(GameObject * other)
{
GameObject::OnCollisionStay(other);
if (other->GetTag() == "Enemy")
{
float xDistance = std::abs(transform->position.x - other->transform->position.x);
float yDistance = std::abs(transform->position.y - other->transform->position.y);
if (xDistance - transform->size.x * 0.5f <= other->transform->size.x * 0.5f && yDistance - transform->size.y * 0.5f <= other->transform->size.y * 0.5f)
{
if (other->transform->position.x > transform->position.x)
rightMoveStop = true;
else if (other->transform->position.x <= transform->position.x)
leftMoveStop = true;
if (other->transform->position.y > transform->position.y)
upMoveStop = true;
else if (other->transform->position.y <= transform->position.y)
downMoveStop = true;
}
}
}
void Player::OnCollisionEnter(GameObject * other)
{
GameObject::OnCollisionEnter(other);
if (other->GetObjectLayer() == ObjectLayer::ENEMY_BULLET)
{
Bullet * bullet = static_cast<Bullet *>(other);
if (bullet == nullptr) return;
Hit(bullet->GetBulletInfo().damage);
}
}
void Player::OnPostRender()
{
if (GetColorBuffer()->GetColor() == Color(1, 1, 1, 0))
GetColorBuffer()->SetColor(Color(0, 0, 0, 0));
}
void Player::Hit(float damage)
{
if (bActiveShield)
{
shield->HitShield(damage);
}
else
{
GetColorBuffer()->SetColor(Color(1, 1, 1, 0));
actorInfo.Hit(damage);
}
}
void Player::Delete()
{
GameObject::Delete();
shield->Delete();
//hpBar->Delete();
}
void Player::PlayerMove()
{
if (Keyboard::Get()->Press('A') && !leftMoveStop)
{
transform->position.x -= playerSpeed * Time::Delta();
}
if (Keyboard::Get()->Press('D') && !rightMoveStop)
{
transform->position.x += playerSpeed * Time::Delta();
}
if (Keyboard::Get()->Press('W') && !upMoveStop)
{
transform->position.y += playerSpeed * Time::Delta();
}
if (Keyboard::Get()->Press('S') && !downMoveStop)
{
transform->position.y -= playerSpeed * Time::Delta();
}
}
void Player::PlayerRotate()
{
Vector3 mPos = Mouse::Get()->GetPosition();
Vector3 outpos;
Camera::Get()->UnProjection(&outpos, mPos, Values::Identity);
outpos.z = 0.0f;
float rot = DxMath::GetAngle(Values::UpVec, outpos - transform->position);
transform->rotation = rot;
}
void Player::FirePosUpdate()
{
if (bMachineGunMode)
{
firePos->position = Vector3(-5, 30, 0);
firePos->size = transform->size;
firePos->Rotate((float)D3DXToRadian(transform->rotation));
firePos->position += transform->position;
firePos->rotation = transform->rotation;
muzzlePos->position = Vector3(-5, 90, 0);
muzzlePos->size = transform->size;
muzzlePos->Rotate((float)D3DXToRadian(transform->rotation));
muzzlePos->position += transform->position;
muzzlePos->rotation = transform->rotation;
}
else // canongun mode
{
firePos->position = Vector3(-5, 50, 0);
firePos->size = transform->size;
firePos->Rotate((float)D3DXToRadian(transform->rotation));
firePos->position += transform->position;
firePos->rotation = transform->rotation;
muzzlePos->position = Vector3(-5, 70, 0);
muzzlePos->size = transform->size;
muzzlePos->Rotate((float)D3DXToRadian(transform->rotation));
muzzlePos->position += transform->position;
muzzlePos->rotation = transform->rotation;
}
}
void Player::ShieldUpdate()
{
if (shield->GetActive() == false)
bActiveShield = false;
}
void Player::Fire()
{
machineGunCurrentShootDelay += Time::Delta();
canonGunCurrentShootDelay += Time::Delta();
if (Mouse::Get()->Press(0))
{
if (machineGunCurrentShootDelay >= machineGunShootDelay)
{
machineGunCurrentShootDelay = 0;
if (machineGunActiveBullets.size() >= machineGunBulletMaximum)
return;
auto bullet = machineGunBulletPool->AccquireObject();
machineGunActiveBullets.push_back(bullet);
bullet->Fire(firePos);
machineGunMuzzleFlash->Flash(muzzlePos);
Camera::Get()->Shake(0.1f, 2.0f);
}
}
if (Mouse::Get()->Press(1))
{
if (canonGunCurrentShootDelay >= canonGunShootDelay)
{
canonGunCurrentShootDelay = 0;
if (canonGunActiveBullets.size() >= canonGunBulletMaximum)
return;
auto bullet = canonGunBulletPool->AccquireObject();
canonGunActiveBullets.push_back(bullet);
bullet->Fire(firePos);
canonGunMuzzleFlash->Flash(muzzlePos);
}
}
}
void Player::BulletUpdate()
{
/*for (int i = 0; i < activeBullets.size(); i++)
{
float length = D3DXVec3Length(&(transform->position - activeBullets[i]->transform->position));
if (length >= bulletRange || activeBullets[i]->isHited)
{
activeBullets[i]->SetActive(false);
activeBullets[i]->isHited = false;
bulletPool->ReleaseObject(activeBullets[i]);
activeBullets.erase(activeBullets.begin() + i);
}
}*/
if (bMachineGunMode)
{
for (int i = 0; i < machineGunActiveBullets.size(); i++)
{
float length = D3DXVec3Length(&(transform->position - machineGunActiveBullets[i]->transform->position));
if (length >= machineGunBulletRange || machineGunActiveBullets[i]->GetActive() == false)
{
machineGunBulletPool->ReleaseObject(machineGunActiveBullets[i]);
machineGunActiveBullets.erase(machineGunActiveBullets.begin() + i);
}
}
}
}
void Player::ActiveShield()
{
if (Keyboard::Get()->Down('R'))
{
if (bActiveShield == false)
{
bActiveShield = true;
shield->ActiveShield();
}
}
}
void Player::SlowUpdate()
{
if (Keyboard::Get()->Press(VK_SPACE))
{
Time::Get()->SetTimeScale(0.3f);
playerSpeed = 200;
currentAfterImageDelay += Time::Delta();
if (currentAfterImageDelay >= afterImageDelay)
{
currentAfterImageDelay = 0;
AfterImage * afterImage = new AfterImage(transform);
afterImage->SetAfterImageSRV(GetSRV());
}
}
else
{
playerSpeed = 100;
Time::Get()->SetTimeScale(1);
currentAfterImageDelay = afterImageDelay;
}
}
void Player::BoostUpdate()
{
/*if (Keyboard::Get()->Press(VK_SHIFT))
{
float xPos = 0;
float yPos = 0;
if (Keyboard::Get()->Press('A') && !leftMoveStop)
{
xPos -= playerSpeed * Time::Delta();
}
if (Keyboard::Get()->Press('D') && !rightMoveStop)
{
xPos += playerSpeed * Time::Delta();
}
if (Keyboard::Get()->Press('W') && !upMoveStop)
{
yPos += playerSpeed * Time::Delta();
}
if (Keyboard::Get()->Press('S') && !downMoveStop)
{
yPos -= playerSpeed * Time::Delta();
}
if (xPos != 0 || yPos != 0)
{
Vector3 lookAt = Vector3(xPos, yPos, 0);
float angle = DxMath::GetAngle(Values::UpVec, lookAt);
transform->rotation = angle;
}
playerSpeed = 300;
}
else
{
playerSpeed = 100;
}
leftBoostPos->position = Vector3(-15, 100, 0);
leftBoostPos->size = transform->size;
leftBoostPos->Rotate((float)D3DXToRadian(transform->rotation + 180));
leftBoostPos->position += transform->position;
leftBoostPos->rotation = transform->rotation + 180;
rightBoostPos->position = Vector3(15, 100, 0);
rightBoostPos->size = transform->size;
rightBoostPos->Rotate((float)D3DXToRadian(transform->rotation + 180));
rightBoostPos->position += transform->position;
rightBoostPos->rotation = transform->rotation + 180;
if (Keyboard::Get()->Down(VK_SHIFT))
{
leftBoostEffect->SetTr(leftBoostPos);
leftBoostEffect->SetActive(true);
rightBoostEffect->SetTr(rightBoostPos);
rightBoostEffect->SetActive(true);
}*/
}
void Player::BulletRemoveSkill()
{
/*if (Keyboard::Get()->Down('R'))
{*/
BulletRemoveEffect * effect = new BulletRemoveEffect();
effect->Explode(transform);
auto bullets = GameObjectManager::Get()->FindObjectsWithDistance(this, WinMaxWidth, ObjectLayer::ENEMY_BULLET);
for (auto bullet : bullets)
{
bullet->SetActive(false);
}
//}
}
void Player::WideExplosionSkill()
{
if (Keyboard::Get()->Down('T'))
{
WideExplosion * effect = new WideExplosion();
effect->Explode(transform);
auto bullets = GameObjectManager::Get()->FindObjectsWithDistance(this, WinMaxWidth, ObjectLayer::ENEMY_BULLET);
for (auto bullet : bullets)
{
bullet->SetActive(false);
}
auto enemies = GameObjectManager::Get()->FindObjectsWithDistance(this, WinMaxWidth, ObjectLayer::ENEMY);
for (auto enemy : enemies)
{
Actor * actor =static_cast<Actor*>( enemy);
assert(actor != nullptr);
actor->Hit(100);
}
}
}
void Player::LevelUp()
{
LevelUpEffect * levelUpEffect = new LevelUpEffect();
levelUpEffect->LevelUp(transform);
BulletRemoveSkill();
}
void Player::ChangeAttackMode()
{
if (Mouse::Get()->Press(0))
{
if (bMachineGunMode == false)
{
bMachineGunMode = true;
SetSRV(machineGunModeSRV);
transform->size = Vector3(100, 100, 1);
machineGunUI->SetActive(true);
canonGunUI->SetActive(false);
}
}
if (Mouse::Get()->Press(1))
{
if (bMachineGunMode == true)
{
bMachineGunMode = false;
SetSRV(canonGunModeSRV);
transform->size = Vector3(100, 120, 1);
machineGunUI->SetActive(false);
canonGunUI->SetActive(true);
}
}
}
| [
"lyun.dev@gmail.com"
] | lyun.dev@gmail.com |
96d5fb766aa7bdc90a014a033d0ccc2de22677d7 | fbdd3a21a727bc25123ca15f3244b645ede3af98 | /adb/file_sync_client.cpp | e7f3a5448a364bf387387e57f184010e52f2effc | [
"BSD-2-Clause"
] | permissive | betalphafai/adb | f51e10e308b865095a2adb6f622ab9dd342fd7b8 | e83b049781719cddbb0110d94c21c93b5384e5a9 | refs/heads/master | 2021-01-13T01:28:39.445293 | 2013-12-08T10:38:26 | 2013-12-08T10:38:26 | 14,104,285 | 0 | 2 | null | null | null | null | GB18030 | C++ | false | false | 26,629 | cpp | /*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <dirent.h>
#include <limits.h>
#include <sys/types.h>
#include <zipfile/zipfile.h>
#include "sysdeps.h"
#include "adb.h"
#include "adb_client.h"
#include "file_sync_service.h"
static unsigned long long total_bytes;
static long long start_time;
//////////////////////////////////////////////////////////////////////////
// 获取当前的时间
// 很奇怪这个只针对win版的,难道GetLocalTime函数,SYSTEMTIME结构跟Linux下是一样的?
int gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm. tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;
return (0);
}
// 把拿到的时间转换成一个long long型,返回
static long long NOW()
{
struct timeval tv;
gettimeofday(&tv, 0);
return ((long long) tv.tv_usec) +
1000000LL * ((long long) tv.tv_sec);
}
// BEGIN与END函数是成对使用,作用是计算时间和传输速度
// 例如计算push与pull的时候所花费的时间
static void BEGIN()
{
total_bytes = 0;
start_time = NOW();
}
static void END()
{
long long t = NOW() - start_time;
if(total_bytes == 0) return;
if (t == 0) /* prevent division by 0 :-) */
t = 1000000;
fprintf(stderr,"%lld KB/s (%lld bytes in %lld.%03llds)\n",
((total_bytes * 1000000LL) / t) / 1024LL,
total_bytes, (t / 1000000LL), (t % 1000000LL) / 1000LL);
}
//////////////////////////////////////////////////////////////////////////
void sync_quit(int fd)
{
syncmsg msg;
msg.req.id = ID_QUIT;
msg.req.namelen = 0;
writex(fd, &msg.req, sizeof(msg.req));
}
typedef void (*sync_ls_cb)(unsigned mode, unsigned size, unsigned time, const char *name, void *cookie);
int sync_ls(int fd, const char *path, sync_ls_cb func, void *cookie)
{
syncmsg msg;
char buf[257];
int len;
len = strlen(path);
if(len > 1024) goto fail;
msg.req.id = ID_LIST;
msg.req.namelen = htoll(len);
if(writex(fd, &msg.req, sizeof(msg.req)) ||
writex(fd, path, len)) {
goto fail;
}
for(;;) {
if(readx(fd, &msg.dent, sizeof(msg.dent))) break;
if(msg.dent.id == ID_DONE) return 0;
if(msg.dent.id != ID_DENT) break;
len = ltohl(msg.dent.namelen);
if(len > 256) break;
if(readx(fd, buf, len)) break;
buf[len] = 0;
func(ltohl(msg.dent.mode),
ltohl(msg.dent.size),
ltohl(msg.dent.time),
buf, cookie);
}
fail:
adb_close(fd);
return -1;
}
typedef struct syncsendbuf syncsendbuf;
struct syncsendbuf {
unsigned id;
unsigned size;
char data[SYNC_DATA_MAX];
};
static syncsendbuf send_buffer;
int sync_readtime(int fd, const char *path, unsigned *timestamp)
{
syncmsg msg;
int len = strlen(path);
msg.req.id = ID_STAT;
msg.req.namelen = htoll(len);
if(writex(fd, &msg.req, sizeof(msg.req)) ||
writex(fd, path, len)) {
return -1;
}
if(readx(fd, &msg.stat, sizeof(msg.stat))) {
return -1;
}
if(msg.stat.id != ID_STAT) {
return -1;
}
*timestamp = ltohl(msg.stat.time);
return 0;
}
static int sync_start_readtime(int fd, const char *path)
{
syncmsg msg;
int len = strlen(path);
msg.req.id = ID_STAT;
msg.req.namelen = htoll(len);
if(writex(fd, &msg.req, sizeof(msg.req)) ||
writex(fd, path, len)) {
return -1;
}
return 0;
}
static int sync_finish_readtime(int fd, unsigned int *timestamp,
unsigned int *mode, unsigned int *size)
{
syncmsg msg;
if(readx(fd, &msg.stat, sizeof(msg.stat)))
return -1;
if(msg.stat.id != ID_STAT)
return -1;
*timestamp = ltohl(msg.stat.time);
*mode = ltohl(msg.stat.mode);
*size = ltohl(msg.stat.size);
return 0;
}
int sync_readmode(int fd, const char *path, unsigned *mode)
{
syncmsg msg;
int len = strlen(path);
msg.req.id = ID_STAT;
msg.req.namelen = htoll(len);
if(writex(fd, &msg.req, sizeof(msg.req)) ||
writex(fd, path, len)) {
return -1;
}
if(readx(fd, &msg.stat, sizeof(msg.stat))) {
return -1;
}
if(msg.stat.id != ID_STAT) {
return -1;
}
*mode = ltohl(msg.stat.mode);
return 0;
}
static int write_data_file(int fd, const char *path, syncsendbuf *sbuf)
{
int lfd, err = 0;
lfd = adb_open(path, O_RDONLY);
if(lfd < 0) {
fprintf(stderr,"cannot open '%s': %s\n", path, strerror(errno));
return -1;
}
sbuf->id = ID_DATA;
for(;;) {
int ret;
ret = adb_read(lfd, sbuf->data, SYNC_DATA_MAX);
if(!ret)
break;
if(ret < 0) {
if(errno == EINTR)
continue;
fprintf(stderr,"cannot read '%s': %s\n", path, strerror(errno));
break;
}
sbuf->size = htoll(ret);
if(writex(fd, sbuf, sizeof(unsigned) * 2 + ret)){
err = -1;
break;
}
total_bytes += ret;
}
adb_close(lfd);
return err;
}
static int write_data_buffer(int fd, char* file_buffer, int size, syncsendbuf *sbuf)
{
int err = 0;
int total = 0;
sbuf->id = ID_DATA;
while (total < size) {
int count = size - total;
if (count > SYNC_DATA_MAX) {
count = SYNC_DATA_MAX;
}
memcpy(sbuf->data, &file_buffer[total], count);
sbuf->size = htoll(count);
if(writex(fd, sbuf, sizeof(unsigned) * 2 + count)){
err = -1;
break;
}
total += count;
total_bytes += count;
}
return err;
}
#ifdef HAVE_SYMLINKS
static int write_data_link(int fd, const char *path, syncsendbuf *sbuf)
{
int len, ret;
len = readlink(path, sbuf->data, SYNC_DATA_MAX-1);
if(len < 0) {
fprintf(stderr, "error reading link '%s': %s\n", path, strerror(errno));
return -1;
}
sbuf->data[len] = '\0';
sbuf->size = htoll(len + 1);
sbuf->id = ID_DATA;
ret = writex(fd, sbuf, sizeof(unsigned) * 2 + len + 1);
if(ret)
return -1;
total_bytes += len + 1;
return 0;
}
#endif
static int sync_send(int fd, const char *lpath, const char *rpath,
unsigned mtime, mode_t mode, int verifyApk)
{
syncmsg msg;
int len, r;
syncsendbuf *sbuf = &send_buffer;
char* file_buffer = NULL;
int size = 0;
char tmp[64];
len = strlen(rpath);
if(len > 1024) goto fail;
snprintf(tmp, sizeof(tmp), ",%d", mode);
r = strlen(tmp);
if (verifyApk) {
int lfd;
zipfile_t zip;
zipentry_t entry;
int amt;
// if we are transferring an APK file, then sanity check to make sure
// we have a real zip file that contains an AndroidManifest.xml
// this requires that we read the entire file into memory.
lfd = adb_open(lpath, O_RDONLY);
if(lfd < 0) {
fprintf(stderr,"cannot open '%s': %s\n", lpath, strerror(errno));
return -1;
}
size = adb_lseek(lfd, 0, SEEK_END);
if (size == -1 || -1 == adb_lseek(lfd, 0, SEEK_SET)) {
fprintf(stderr, "error seeking in file '%s'\n", lpath);
adb_close(lfd);
return 1;
}
file_buffer = (char *)malloc(size);
if (file_buffer == NULL) {
fprintf(stderr, "could not allocate buffer for '%s'\n",
lpath);
adb_close(lfd);
return 1;
}
amt = adb_read(lfd, file_buffer, size);
if (amt != size) {
fprintf(stderr, "error reading from file: '%s'\n", lpath);
adb_close(lfd);
free(file_buffer);
return 1;
}
adb_close(lfd);
zip = init_zipfile(file_buffer, size);
if (zip == NULL) {
fprintf(stderr, "file '%s' is not a valid zip file\n",
lpath);
free(file_buffer);
return 1;
}
entry = lookup_zipentry(zip, "AndroidManifest.xml");
release_zipfile(zip);
if (entry == NULL) {
fprintf(stderr, "file '%s' does not contain AndroidManifest.xml\n",
lpath);
free(file_buffer);
return 1;
}
}
msg.req.id = ID_SEND;
msg.req.namelen = htoll(len + r);
if(writex(fd, &msg.req, sizeof(msg.req)) ||
writex(fd, rpath, len) || writex(fd, tmp, r)) {
free(file_buffer);
goto fail;
}
if (file_buffer) {
write_data_buffer(fd, file_buffer, size, sbuf);
free(file_buffer);
} else if (S_ISREG(mode))
write_data_file(fd, lpath, sbuf);
#ifdef HAVE_SYMLINKS
else if (S_ISLNK(mode))
write_data_link(fd, lpath, sbuf);
#endif
else
goto fail;
msg.data.id = ID_DONE;
msg.data.size = htoll(mtime);
if(writex(fd, &msg.data, sizeof(msg.data)))
goto fail;
if(readx(fd, &msg.status, sizeof(msg.status)))
return -1;
if(msg.status.id != ID_OKAY) {
if(msg.status.id == ID_FAIL) {
len = ltohl(msg.status.msglen);
if(len > 256) len = 256;
if(readx(fd, sbuf->data, len)) {
return -1;
}
sbuf->data[len] = 0;
} else
strcpy(sbuf->data, "unknown reason");
fprintf(stderr,"failed to copy '%s' to '%s': %s\n", lpath, rpath, sbuf->data);
return -1;
}
return 0;
fail:
fprintf(stderr,"protocol failure\n");
adb_close(fd);
return -1;
}
static int mkdirs(char *name)
{
int ret;
char *x = name + 1;
for(;;) {
x = adb_dirstart(x);
if(x == 0) return 0;
*x = 0;
ret = adb_mkdir(name, 0775);
*x = OS_PATH_SEPARATOR;
if((ret < 0) && (errno != EEXIST)) {
return ret;
}
x++;
}
return 0;
}
int sync_recv(int fd, const char *rpath, const char *lpath)
{
syncmsg msg;
int len;
int lfd = -1;
char *buffer = send_buffer.data;
unsigned id;
len = strlen(rpath);
if(len > 1024) return -1;
msg.req.id = ID_RECV;
msg.req.namelen = htoll(len);
if(writex(fd, &msg.req, sizeof(msg.req)) ||
writex(fd, rpath, len)) {
return -1;
}
if(readx(fd, &msg.data, sizeof(msg.data))) {
return -1;
}
id = msg.data.id;
if((id == ID_DATA) || (id == ID_DONE)) {
adb_unlink(lpath);
mkdirs((char *)lpath);
lfd = adb_creat(lpath, 0644);
if(lfd < 0) {
fprintf(stderr,"cannot create '%s': %s\n", lpath, strerror(errno));
return -1;
}
goto handle_data;
} else {
goto remote_error;
}
for(;;) {
if(readx(fd, &msg.data, sizeof(msg.data))) {
return -1;
}
id = msg.data.id;
handle_data:
len = ltohl(msg.data.size);
if(id == ID_DONE) break;
if(id != ID_DATA) goto remote_error;
if(len > SYNC_DATA_MAX) {
fprintf(stderr,"data overrun\n");
adb_close(lfd);
return -1;
}
if(readx(fd, buffer, len)) {
adb_close(lfd);
return -1;
}
if(writex(lfd, buffer, len)) {
fprintf(stderr,"cannot write '%s': %s\n", rpath, strerror(errno));
adb_close(lfd);
return -1;
}
total_bytes += len;
}
adb_close(lfd);
return 0;
remote_error:
adb_close(lfd);
adb_unlink(lpath);
if(id == ID_FAIL) {
len = ltohl(msg.data.size);
if(len > 256) len = 256;
if(readx(fd, buffer, len)) {
return -1;
}
buffer[len] = 0;
} else {
memcpy(buffer, &id, 4);
buffer[4] = 0;
// strcpy(buffer,"unknown reason");
}
fprintf(stderr,"failed to copy '%s' to '%s': %s\n", rpath, lpath, buffer);
return 0;
}
/* --- */
static void do_sync_ls_cb(unsigned mode, unsigned size, unsigned time,
const char *name, void *cookie)
{
printf("%08x %08x %08x %s\n", mode, size, time, name);
}
int do_sync_ls(const char *path)
{
int fd = adb_connect("sync:");
if(fd < 0) {
fprintf(stderr,"error: %s\n", adb_error());
return 1;
}
if(sync_ls(fd, path, do_sync_ls_cb, 0)) {
return 1;
} else {
sync_quit(fd);
return 0;
}
}
typedef struct copyinfo copyinfo;
struct copyinfo
{
copyinfo *next;
const char *src;
const char *dst;
unsigned int time;
unsigned int mode;
unsigned int size;
int flag;
//char data[0];
};
copyinfo *mkcopyinfo(const char *spath, const char *dpath,
const char *name, int isdir)
{
int slen = strlen(spath);
int dlen = strlen(dpath);
int nlen = strlen(name);
int ssize = slen + nlen + 2;
int dsize = dlen + nlen + 2;
copyinfo *ci = (copyinfo *)malloc(sizeof(copyinfo) + ssize + dsize);
if(ci == 0) {
fprintf(stderr,"out of memory\n");
abort();
}
ci->next = 0;
ci->time = 0;
ci->mode = 0;
ci->size = 0;
ci->flag = 0;
ci->src = (const char*)(ci + 1);
ci->dst = ci->src + ssize;
snprintf((char*) ci->src, ssize, isdir ? "%s%s/" : "%s%s", spath, name);
snprintf((char*) ci->dst, dsize, isdir ? "%s%s/" : "%s%s", dpath, name);
// fprintf(stderr,"mkcopyinfo('%s','%s')\n", ci->src, ci->dst);
return ci;
}
static int local_build_list(copyinfo **filelist,
const char *lpath, const char *rpath)
{
DIR *d;
struct dirent *de;
struct stat st;
copyinfo *dirlist = 0;
copyinfo *ci, *next;
// fprintf(stderr,"local_build_list('%s','%s')\n", lpath, rpath);
d = opendir(lpath);
if(d == 0) {
fprintf(stderr,"cannot open '%s': %s\n", lpath, strerror(errno));
return -1;
}
while((de = readdir(d))) {
char stat_path[PATH_MAX];
char *name = de->d_name;
if(name[0] == '.') {
if(name[1] == 0) continue;
if((name[1] == '.') && (name[2] == 0)) continue;
}
/*
* We could use d_type if HAVE_DIRENT_D_TYPE is defined, but reiserfs
* always returns DT_UNKNOWN, so we just use stat() for all cases.
*/
if (strlen(lpath) + strlen(de->d_name) + 1 > sizeof(stat_path))
continue;
strcpy(stat_path, lpath);
strcat(stat_path, de->d_name);
stat(stat_path, &st);
if (S_ISDIR(st.st_mode)) {
ci = mkcopyinfo(lpath, rpath, name, 1);
ci->next = dirlist;
dirlist = ci;
} else {
ci = mkcopyinfo(lpath, rpath, name, 0);
if(lstat(ci->src, &st)) {
fprintf(stderr,"cannot stat '%s': %s\n", ci->src, strerror(errno));
closedir(d);
return -1;
}
if(!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode)) {
fprintf(stderr, "skipping special file '%s'\n", ci->src);
free(ci);
} else {
ci->time = st.st_mtime;
ci->mode = st.st_mode;
ci->size = st.st_size;
ci->next = *filelist;
*filelist = ci;
}
}
}
closedir(d);
for(ci = dirlist; ci != 0; ci = next) {
next = ci->next;
local_build_list(filelist, ci->src, ci->dst);
free(ci);
}
return 0;
}
static int copy_local_dir_remote(int fd, const char *lpath, const char *rpath, int checktimestamps, int listonly)
{
copyinfo *filelist = 0;
copyinfo *ci, *next;
int pushed = 0;
int skipped = 0;
if((lpath[0] == 0) || (rpath[0] == 0)) return -1;
if(lpath[strlen(lpath) - 1] != '/') {
int tmplen = strlen(lpath)+2;
char *tmp = (char *)malloc(tmplen);
if(tmp == 0) return -1;
snprintf(tmp, tmplen, "%s/",lpath);
lpath = tmp;
}
if(rpath[strlen(rpath) - 1] != '/') {
int tmplen = strlen(rpath)+2;
char *tmp = (char *)malloc(tmplen);
if(tmp == 0) return -1;
snprintf(tmp, tmplen, "%s/",rpath);
rpath = tmp;
}
if(local_build_list(&filelist, lpath, rpath)) {
return -1;
}
if(checktimestamps){
for(ci = filelist; ci != 0; ci = ci->next) {
if(sync_start_readtime(fd, ci->dst)) {
return 1;
}
}
for(ci = filelist; ci != 0; ci = ci->next) {
unsigned int timestamp, mode, size;
if(sync_finish_readtime(fd, ×tamp, &mode, &size))
return 1;
if(size == ci->size) {
/* for links, we cannot update the atime/mtime */
if((S_ISREG(ci->mode & mode) && timestamp == ci->time) ||
(S_ISLNK(ci->mode & mode) && timestamp >= ci->time))
ci->flag = 1;
}
}
}
for(ci = filelist; ci != 0; ci = next) {
next = ci->next;
if(ci->flag == 0) {
fprintf(stderr,"%spush: %s -> %s\n", listonly ? "would " : "", ci->src, ci->dst);
if(!listonly &&
sync_send(fd, ci->src, ci->dst, ci->time, ci->mode, 0 /* no verify APK */)){
return 1;
}
pushed++;
} else {
skipped++;
}
free(ci);
}
fprintf(stderr,"%d file%s pushed. %d file%s skipped.\n",
pushed, (pushed == 1) ? "" : "s",
skipped, (skipped == 1) ? "" : "s");
return 0;
}
int do_sync_push(const char *lpath, const char *rpath, int verifyApk)
{
struct stat st;
unsigned mode;
int fd;
fd = adb_connect("sync:");
if(fd < 0) {
fprintf(stderr,"error: %s\n", adb_error());
return 1;
}
if(stat(lpath, &st)) {
fprintf(stderr,"cannot stat '%s': %s\n", lpath, strerror(errno));
sync_quit(fd);
return 1;
}
if(S_ISDIR(st.st_mode)) {
BEGIN();
if(copy_local_dir_remote(fd, lpath, rpath, 0, 0)) {
return 1;
} else {
END();
sync_quit(fd);
}
} else {
if(sync_readmode(fd, rpath, &mode)) {
return 1;
}
if((mode != 0) && S_ISDIR(mode)) {
/* if we're copying a local file to a remote directory,
** we *really* want to copy to remotedir + "/" + localfilename
*/
const char *name = adb_dirstop(lpath);
if(name == 0) {
name = lpath;
} else {
name++;
}
int tmplen = strlen(name) + strlen(rpath) + 2;
char *tmp = (char *)malloc(strlen(name) + strlen(rpath) + 2);
if(tmp == 0) return 1;
snprintf(tmp, tmplen, "%s/%s", rpath, name);
rpath = tmp;
}
BEGIN();
if(sync_send(fd, lpath, rpath, st.st_mtime, st.st_mode, verifyApk)) {
return 1;
} else {
END();
sync_quit(fd);
return 0;
}
}
return 0;
}
typedef struct {
copyinfo **filelist;
copyinfo **dirlist;
const char *rpath;
const char *lpath;
} sync_ls_build_list_cb_args;
void
sync_ls_build_list_cb(unsigned mode, unsigned size, unsigned time,
const char *name, void *cookie)
{
sync_ls_build_list_cb_args *args = (sync_ls_build_list_cb_args *)cookie;
copyinfo *ci;
if (S_ISDIR(mode)) {
copyinfo **dirlist = args->dirlist;
/* Don't try recursing down "." or ".." */
if (name[0] == '.') {
if (name[1] == '\0') return;
if ((name[1] == '.') && (name[2] == '\0')) return;
}
ci = mkcopyinfo(args->rpath, args->lpath, name, 1);
ci->next = *dirlist;
*dirlist = ci;
} else if (S_ISREG(mode) || S_ISLNK(mode)) {
copyinfo **filelist = args->filelist;
ci = mkcopyinfo(args->rpath, args->lpath, name, 0);
ci->time = time;
ci->mode = mode;
ci->size = size;
ci->next = *filelist;
*filelist = ci;
} else {
fprintf(stderr, "skipping special file '%s'\n", name);
}
}
static int remote_build_list(int syncfd, copyinfo **filelist,
const char *rpath, const char *lpath)
{
copyinfo *dirlist = NULL;
sync_ls_build_list_cb_args args;
args.filelist = filelist;
args.dirlist = &dirlist;
args.rpath = rpath;
args.lpath = lpath;
/* Put the files/dirs in rpath on the lists. */
if (sync_ls(syncfd, rpath, sync_ls_build_list_cb, (void *)&args)) {
return 1;
}
/* Recurse into each directory we found. */
while (dirlist != NULL) {
copyinfo *next = dirlist->next;
if (remote_build_list(syncfd, filelist, dirlist->src, dirlist->dst)) {
return 1;
}
free(dirlist);
dirlist = next;
}
return 0;
}
static int copy_remote_dir_local(int fd, const char *rpath, const char *lpath,
int checktimestamps)
{
copyinfo *filelist = 0;
copyinfo *ci, *next;
int pulled = 0;
int skipped = 0;
/* Make sure that both directory paths end in a slash. */
if (rpath[0] == 0 || lpath[0] == 0) return -1;
if (rpath[strlen(rpath) - 1] != '/') {
int tmplen = strlen(rpath) + 2;
char *tmp = (char *)malloc(tmplen);
if (tmp == 0) return -1;
snprintf(tmp, tmplen, "%s/", rpath);
rpath = tmp;
}
if (lpath[strlen(lpath) - 1] != '/') {
int tmplen = strlen(lpath) + 2;
char *tmp = (char *)malloc(tmplen);
if (tmp == 0) return -1;
snprintf(tmp, tmplen, "%s/", lpath);
lpath = tmp;
}
fprintf(stderr, "pull: building file list...\n");
/* Recursively build the list of files to copy. */
if (remote_build_list(fd, &filelist, rpath, lpath)) {
return -1;
}
#if 0
if (checktimestamps) {
for (ci = filelist; ci != 0; ci = ci->next) {
if (sync_start_readtime(fd, ci->dst)) {
return 1;
}
}
for (ci = filelist; ci != 0; ci = ci->next) {
unsigned int timestamp, mode, size;
if (sync_finish_readtime(fd, ×tamp, &mode, &size))
return 1;
if (size == ci->size) {
/* for links, we cannot update the atime/mtime */
if ((S_ISREG(ci->mode & mode) && timestamp == ci->time) ||
(S_ISLNK(ci->mode & mode) && timestamp >= ci->time))
ci->flag = 1;
}
}
}
#endif
for (ci = filelist; ci != 0; ci = next) {
next = ci->next;
if (ci->flag == 0) {
fprintf(stderr, "pull: %s -> %s\n", ci->src, ci->dst);
if (sync_recv(fd, ci->src, ci->dst)) {
return 1;
}
pulled++;
} else {
skipped++;
}
free(ci);
}
fprintf(stderr, "%d file%s pulled. %d file%s skipped.\n",
pulled, (pulled == 1) ? "" : "s",
skipped, (skipped == 1) ? "" : "s");
return 0;
}
int do_sync_pull(const char *rpath, const char *lpath)
{
unsigned mode;
struct stat st;
int fd;
fd = adb_connect("sync:");
if(fd < 0) {
fprintf(stderr,"error: %s\n", adb_error());
return 1;
}
if(sync_readmode(fd, rpath, &mode)) {
return 1;
}
if(mode == 0) {
fprintf(stderr,"remote object '%s' does not exist\n", rpath);
return 1;
}
if(S_ISREG(mode) || S_ISLNK(mode) || S_ISCHR(mode) || S_ISBLK(mode)) {
if(stat(lpath, &st) == 0) {
if(S_ISDIR(st.st_mode)) {
/* if we're copying a remote file to a local directory,
** we *really* want to copy to localdir + "/" + remotefilename
*/
const char *name = adb_dirstop(rpath);
if(name == 0) {
name = rpath;
} else {
name++;
}
int tmplen = strlen(name) + strlen(lpath) + 2;
char *tmp = (char *)malloc(tmplen);
if(tmp == 0) return 1;
snprintf(tmp, tmplen, "%s/%s", lpath, name);
lpath = tmp;
}
}
BEGIN();
if(sync_recv(fd, rpath, lpath)) {
return 1;
} else {
END();
sync_quit(fd);
return 0;
}
} else if(S_ISDIR(mode)) {
BEGIN();
if (copy_remote_dir_local(fd, rpath, lpath, 0)) {
return 1;
} else {
END();
sync_quit(fd);
return 0;
}
} else {
fprintf(stderr,"remote object '%s' not a file or directory\n", rpath);
return 1;
}
}
int do_sync_sync(const char *lpath, const char *rpath, int listonly)
{
fprintf(stderr,"syncing %s...\n",rpath);
int fd = adb_connect("sync:");
if(fd < 0) {
fprintf(stderr,"error: %s\n", adb_error());
return 1;
}
BEGIN();
if(copy_local_dir_remote(fd, lpath, rpath, 1, listonly)){
return 1;
} else {
END();
sync_quit(fd);
return 0;
}
}
| [
"edward-lk@hotmail.com"
] | edward-lk@hotmail.com |
417809b187047f42b283d3619fc7b44c4d8615c3 | e51d009c6c6a1633c2c11ea4e89f289ea294ec7e | /xr2-dsgn/sources/xray/network/sources/network_world.cpp | 704b2485b5ab495bde909954b628a3e26c8dc628 | [] | no_license | avmal0-Cor/xr2-dsgn | a0c726a4d54a2ac8147a36549bc79620fead0090 | 14e9203ee26be7a3cb5ca5da7056ecb53c558c72 | refs/heads/master | 2023-07-03T02:05:00.566892 | 2021-08-06T03:10:53 | 2021-08-06T03:10:53 | 389,939,196 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,376 | cpp | ////////////////////////////////////////////////////////////////////////////
// Created : 20.11.2008
// Author : Dmitriy Iassenev
// Copyright (C) GSC Game World - 2009
////////////////////////////////////////////////////////////////////////////
#include "pch.h"
#include "network_world.h"
#if !XRAY_PLATFORM_PS3
# include "io_service.h"
#endif // #if !XRAY_PLATFORM_PS3
#ifndef MASTER_GOLD
static xray::command_line::key s_no_network_key ("no_network", "", "", "disable network");
#endif // #ifndef MASTER_GOLD
using xray::network::network_world;
network_world::network_world ( xray::network::engine& engine ) :
m_engine ( engine )
{
#ifndef MASTER_GOLD
if ( !s_no_network_key.is_set() )
#endif // #ifndef MASTER_GOLD
#if !XRAY_PLATFORM_PS3
m_ioservice = XN_NEW(lowlevel::io_service);
#else // #if !XRAY_PLATFORM_PS3
(void)0;
#endif // #if !XRAY_PLATFORM_PS3
}
network_world::~network_world ( )
{
#if !XRAY_PLATFORM_PS3
XN_DELETE ( m_ioservice );
#endif // #if !XRAY_PLATFORM_PS3
}
void network_world::tick ( u32 const logic_frame_id )
{
XRAY_UNREFERENCED_PARAMETER ( logic_frame_id );
#ifndef MASTER_GOLD
if ( !s_no_network_key.is_set() )
#endif // #ifndef MASTER_GOLD
#if !XRAY_PLATFORM_PS3
m_ioservice->tick ( );
#else // #if !XRAY_PLATFORM_PS3
(void)0;
#endif // #if !XRAY_PLATFORM_PS3
}
void network_world::clear_resources ( )
{
} | [
"youalexandrov@icloud.com"
] | youalexandrov@icloud.com |
b6e5033f5487275147f56b3c94be7382500da81b | e9cece0e85ba6fa881590c5a7ce1e4a21563f101 | /RayTracerNetworked/Server/Light.h | 1b1cd0271dc941d540575113567c8294a6c3b584 | [
"MIT"
] | permissive | NeutralNoise/RayTracerNetworked | 089572f0744b168ec780759241eefcdc2fbed88c | ffb1a93389a27a4c9a2c7e747046385a59fa315e | refs/heads/master | 2022-06-22T20:53:48.180039 | 2020-05-10T02:12:03 | 2020-05-10T02:12:03 | 259,077,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 599 | h | #ifndef LIGHT_H_INCLUDED
#define LIGHT_H_INCLUDED
#include "Vector.h"
#include "ColourRGBA.h"
class Light
{
public:
Light()
{
pos = Vector(0, 0, 0);
dir = Vector(0, 0, 0);
intesity = ColourRGBA(1.0f, 1.0f, 1.0f, 1.0f);
}
Light(const Vector &pos, const Vector &dir)
{
this->pos = pos;
this->dir = dir;
intesity = ColourRGBA(1.0f, 1.0f, 1.0f, 1.0f);
}
Light(const Vector &pos, const Vector &dir, const ColourRGBA &intesity)
{
this->pos = pos;
this->dir = dir;
this->intesity = intesity;
}
Vector pos;
Vector dir;
ColourRGBA intesity;
};
#endif // !LIGHT_H_INCLUDED
| [
"classicbrad24@gmail.com"
] | classicbrad24@gmail.com |
49a2d00af179a01b0ea7d55238e2b2dcbc1b99e7 | 1f195b775a279eeceadbbc9e5139870cba0d0de5 | /Chapter 8/Example 8-2/bubblesort/bubblesort.cpp | 41a3731a6eece1e2342c6dfe8272d9536fb8b4a8 | [] | no_license | CBreshears/ArtOfConcurrency | 26afb800e6f42034c00c3b6bd109fd803f8a753c | 9bbfa056feec680d89cb2f1853df973c5bd4c1d9 | refs/heads/master | 2020-09-21T06:13:38.737176 | 2019-11-28T18:55:32 | 2019-11-28T18:55:32 | 224,706,557 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,650 | cpp | // Bubblesrot.cpp : Threaded version of Bubblesort algorithm.
//
#include <windows.h>
#include <process.h>
#include <stdio.h>
#define N 100
#define NUM_LOCKS 3
#define NUM_THREADS 2
int A[N];
CRITICAL_SECTION BLock[NUM_LOCKS];
BOOL Done = FALSE;
int iCounter = N-1;
unsigned __stdcall BubbleSort(LPVOID pArg)
{
int i, j, k, releasePoint, temp, rpInc;
BOOL exch;
rpInc = N / NUM_LOCKS;
rpInc++;
while (!Done) {
k = 0;
exch = FALSE;
EnterCriticalSection(&BLock[k]);
i = iCounter--;
releasePoint = rpInc;
// rpInc++;
if (i <= 0) {
Done = TRUE;
LeaveCriticalSection(&BLock[k]);
break;
}
for (j = 0; j < i; j++) {
if (A[j] > A[j+1]) {
temp = A[j]; A[j] = A[j+1]; A[j+1] = temp;
exch = TRUE;
}
if (j == releasePoint) {
LeaveCriticalSection(&BLock[k++]);
EnterCriticalSection(&BLock[k]);
releasePoint += rpInc;
}
}
LeaveCriticalSection(&BLock[k]);
if (!exch) Done = TRUE;
}
return 0;
}
void init_data()
{
int i;
for (i = 0; i < N; i++)
A[i] = rand() % N;
}
int main(int argc, char* argv[])
{
int i, j;
HANDLE hThread[NUM_THREADS];
init_data();
for ( i = 0; i < N; i++) printf("%3d ",A[i]);
printf("\n\n");
for ( j = 0; j < NUM_LOCKS; j++)
InitializeCriticalSection(&BLock[j]);
// BubbleSort(NULL);
for ( i = 0; i < NUM_THREADS; i++)
hThread[i] = (HANDLE) _beginthreadex(NULL, 0, BubbleSort, NULL, 0, NULL);
WaitForMultipleObjects(NUM_THREADS, hThread, TRUE, INFINITE);
for ( j = 0; j < N; j++) printf("%3d ",A[j]);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
8f95113f6eb222003d67b0b90e7c039d636266b6 | 943b8a1d008eb51105167dd3f326c26c697e4a30 | /GT/gt_client/uis/formjoingame.cpp | 317ad3a499453bef01db385ccdd8660f03e34309 | [] | no_license | patadejaguar/GuerraDeTanques | 2f6ceb07388202afd550ef34cc6c2b04efee0cee | d78108baacd4cc0fbb7db46e957c3284cafba31b | refs/heads/master | 2016-09-02T20:01:18.138991 | 2014-08-30T11:50:50 | 2014-08-30T11:50:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,127 | cpp | #include "formjoingame.h"
#include "ui_formjoingame.h"
#include "forms.h"
FormJoinGame::FormJoinGame(QWidget *parent) :
Form(parent),
_ui(new Ui::FormJoinGame)
{
_ui->setupUi(this);
_model = new QStringListModel(this);
GameListDelegate *game_list_delegate = new GameListDelegate(this);
_ui->_lv_games->setItemDelegate(game_list_delegate);
_ui->_lv_games->installEventFilter(this);
connect(ConnectionTcp::instance(), &ConnectionTcp::notifyLogoutUser, this, &FormJoinGame::logoutUser);
connect(ConnectionTcp::instance(), &ConnectionTcp::notifyCreateGame, this, &FormJoinGame::createGame);
connect(ConnectionTcp::instance(), &ConnectionTcp::notifyCloseGame, this, &FormJoinGame::closeGame);
connect(ConnectionTcp::instance(), &ConnectionTcp::notifyGameStarted, this, &FormJoinGame::gameStarted);
connect(TcpGameConnectionClient::instance(), &TcpGameConnectionClient::notifyGameFull, this, &FormJoinGame::gameFull);
connect(TcpGameConnectionClient::instance(), &TcpGameConnectionClient::notifyGameReadyToStart, this, &FormJoinGame::gameReadyToStart);
connect(TcpGameConnectionClient::instance(), &TcpGameConnectionClient::notifyGameIsStarted, this, &FormJoinGame::gameIsStarted);
}
FormJoinGame::~FormJoinGame()
{
delete _ui;
}
void FormJoinGame::logoutUser(UserProperties user)
{
bool j = true;
for(int i = 0;j && i< _games_data.size(); ++i)
if(_games_data.at(i)._creator == user)
{
_games_data.removeAt(i);
j = false;
updateListOfGames();
}
}
void FormJoinGame::createGame(UserProperties user, int index_of_terrain, QString ip)
{
GameData game_data;
game_data._creator = user;
game_data._index_of_terrain = index_of_terrain;
game_data._ip = ip;
_games_data.append(game_data);
updateListOfGames();
}
void FormJoinGame::updateData(QByteArray data)
{
_games_data.clear();
QDataStream stream(&data,QIODevice::ReadOnly);
while(!stream.atEnd())
{
GameData game;
stream>>game._creator;
stream>>game._index_of_terrain;
stream>>game._ip;
_games_data.append(game);
}
}
void FormJoinGame::updateListOfGames()
{
QStringList games;
for(int i = 0;i< _games_data.size(); ++i)
games.append(QString("Juego de [%1]").arg(_games_data.at(i)._creator._nick));
_model->setStringList(games);
_ui->_lv_games->setModel(_model);
if(_model->index(0,0).isValid())
_ui->_lv_games->setCurrentIndex(_model->index(0,0));
}
void FormJoinGame::show()
{
disconnect(TcpGameConnectionClient::instance(), &TcpGameConnectionClient::notifyError, this, &FormJoinGame::gameJoinError);
connect(TcpGameConnectionClient::instance(), &TcpGameConnectionClient::notifyError, this, &FormJoinGame::gameJoinError);
Form::show();
}
void FormJoinGame::hide()
{
disconnect(TcpGameConnectionClient::instance(), &TcpGameConnectionClient::notifyError, this, &FormJoinGame::gameJoinError);
Form::hide();
}
void FormJoinGame::show(QByteArray data)
{
clearLabels();
updateData(data);
updateListOfGames();
show();
}
bool FormJoinGame::eventFilter(QObject *object, QEvent *event)
{
_ui->_pb_accept->setEnabled(_ui->_lv_games->currentIndex().isValid());
if(_ui->_lv_games->currentIndex().isValid())
{
preview(_ui->_lv_games->currentIndex());
return true;
}
return QObject::eventFilter(object, event);
}
void FormJoinGame::closeGame(QList<UserProperties> users)
{
for(int i = 0; i< _games_data.size(); ++i)
if(users.contains(_games_data.at(i)._creator))
{
_games_data.removeAt(i);
clearLabels();
updateListOfGames();
i = _games_data.size();
}
}
void FormJoinGame::gameStarted(UserProperties creator)
{
for(int i = 0; i< _games_data.size(); ++i)
if(creator == _games_data.at(i)._creator)
{
_games_data.removeAt(i);
clearLabels();
updateListOfGames();
i = _games_data.size();
}
}
void FormJoinGame::gameFull()
{
Forms* forms = Forms::instance();
forms->_form_join_game->disable();
((FormDialogMessage*)(forms->_form_message))->showError("Juego","El juego está completo.", false);
}
void FormJoinGame::gameJoinError(QString error, bool critical)
{
Q_UNUSED(critical);
Forms* forms = Forms::instance();
forms->_form_join_game->disable();
((FormDialogMessage*)(forms->_form_message))->showError("Juego",error, false);
}
void FormJoinGame::gameReadyToStart()
{
Forms* forms = Forms::instance();
forms->_form_join_game->disable();
((FormDialogMessage*)(forms->_form_message))->showError("Juego","El juego está listo para comenzar", false);
}
void FormJoinGame::gameIsStarted()
{
Forms* forms = Forms::instance();
forms->_form_join_game->disable();
((FormDialogMessage*)(forms->_form_message))->showError("Juego","El juego ya empezó.", false);
}
void FormJoinGame::on__pb_cancel_clicked()
{
Forms* forms = Forms::instance();
forms->_form_join_game->hide();
forms->_form_chat->show();
}
void FormJoinGame::on__pb_accept_clicked()
{
Forms* forms = Forms::instance();
forms->_form_join_game->disable();
TcpGameConnectionClient::instance()->connectToHost(QHostAddress(_games_data.at(_ui->_lv_games->currentIndex().row())._ip), TCP_GAME_SERVER_PORT);
}
void FormJoinGame::preview(QModelIndex index)
{
TerrainInfo terrain_info = ResourceManager::instance()->terrainsInfo().at(_games_data.at(index.row())._index_of_terrain);
_ui->_l_terrain_text->setText(terrain_info._name);
_ui->_l_terrain->setPixmap(terrain_info._image);
_ui->_l_counter_green->setText(QString::number(terrain_info._green_count));
_ui->_l_counter_red->setText(QString::number(terrain_info._red_count));
}
void FormJoinGame::clearLabels()
{
_ui->_l_terrain_text->clear();
_ui->_l_terrain->setPixmap(QPixmap());
_ui->_pb_accept->setEnabled(false);
_ui->_l_counter_green->clear();
_ui->_l_counter_red->clear();
}
| [
"patadejaguar@gmail.com"
] | patadejaguar@gmail.com |
344c040ed0ef05a83098b178fa1e9f7cd79a5dae | b7bc43281555caa1ee1db6a4fe2a83ebb2b17039 | /problem_solving/algorithms/easy/counting_valleys/solution.cpp | 2119eb9eb30772880ce5db4f2c5d562fac891b48 | [] | no_license | willpang/HackerRank | d33cb8b6d8af22df97287539450b79b594f4ca97 | 7eeb1d71d812d7219c4d6441510d2be009486e95 | refs/heads/main | 2023-08-09T18:34:15.663087 | 2023-07-22T16:46:13 | 2023-07-22T16:46:13 | 96,313,685 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 513 | cpp | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
cin >> n;
string step;
cin >> step;
int level = 0, valley = 0;
for(int i = 0; i < n; i++){
if(step[i] == 'U') level++;
else level--;
if(step[i] == 'U' && level == 0) valley++;
}
cout << valley;
return 0;
}
| [
"williampangiawan@gmail.com"
] | williampangiawan@gmail.com |
0fe2b54c2e79f057b2e993b800e1a5354fb6ad23 | 304760c5f12bc9402a7fed8027e998026f100a65 | /include/oneapi/dpl/internal/function.h | 3e29b82142bdb198b5a2cf9b098d55a11a862a9f | [
"Apache-2.0"
] | permissive | jiuyueshiwo/oneDPL | 45fc151e1d83d8c22c260a54296bf9dc14c0f718 | 739f65361d7770e4f49d4fdc444b6a48924d4904 | refs/heads/master | 2023-01-23T02:05:14.453224 | 2020-11-30T15:27:15 | 2020-11-30T15:27:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,816 | h | // -*- C++ -*-
//===-- function.h ---------------------------------------------------------===//
//
// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This file incorporates work covered by the following copyright and permission
// notice:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//
#ifndef DPCPP_INTERNAL_FUNCTION_H_
#define DPCPP_INTERNAL_FUNCTION_H_
#include <utility>
#if _ONEDPL_BACKEND_SYCL
# include <oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_utils.h>
#endif
#include <oneapi/dpl/functional>
#include <tuple>
namespace oneapi
{
namespace dpl
{
namespace internal
{
using ::std::get;
// Helper used to eliminate compile errors when an algorithm needs to pass a policy instance to
// multiple parallel STL functions.
template <typename Policy, typename NewName>
struct rebind_policy
{
using type = Policy;
};
#if _ONEDPL_BACKEND_SYCL
template <typename KernelName, typename NewName>
struct rebind_policy<oneapi::dpl::execution::device_policy<KernelName>, NewName>
{
using type = oneapi::dpl::execution::device_policy<NewName>;
};
# if _ONEDPL_FPGA_DEVICE
template <unsigned int factor, typename KernelName, typename NewName>
struct rebind_policy<oneapi::dpl::execution::fpga_policy<factor, KernelName>, NewName>
{
using type = oneapi::dpl::execution::fpga_policy<factor, NewName>;
};
# endif
using oneapi::dpl::__par_backend_hetero::__internal::__buffer;
using oneapi::dpl::__par_backend_hetero::__internal::is_hetero_iterator;
#else
using oneapi::dpl::__par_backend::__buffer;
#endif
#if _ONEDPL_BACKEND_SYCL
// Helpers used to get indexable access to the data passed to the SYCL implementation of an
// algorithm from either a SYCL iterator or a USM pointer.
template <cl::sycl::access::mode Mode, typename Iterator>
auto
get_access(Iterator i, typename ::std::enable_if<is_hetero_iterator<Iterator>::value, void>::type* = nullptr)
-> decltype(i.get_buffer().template get_access<Mode>())
{
return i.get_buffer().template get_access<Mode>();
}
template <cl::sycl::access::mode Mode, typename Iterator>
Iterator
get_access(Iterator i, typename ::std::enable_if<!is_hetero_iterator<Iterator>::value, void>::type* = nullptr)
{
return i;
}
template <cl::sycl::access::mode Mode, typename T>
counting_iterator<T>
get_access(counting_iterator<T> i)
{
return i;
}
template <cl::sycl::access::mode Mode, typename T>
T*
get_access(T* ptr)
{
return ptr;
}
#endif
// struct for checking if iterator is a discard_iterator or not
template <typename Iter, typename Void = void> // for non-discard iterators
struct is_discard_iterator : ::std::false_type
{
};
template <typename Iter> // for discard iterators
struct is_discard_iterator<Iter, typename ::std::enable_if<Iter::is_discard::value, void>::type> : ::std::true_type
{
};
// Used by: exclusive_scan_by_key
// Lambda: [pred, &new_value](Ref1 a, Ref2 s) {return pred(s) ? new_value : a; });
template <typename T, typename Predicate>
struct replace_if_fun
{
using result_of = T;
replace_if_fun(Predicate _pred, T _new_value) : pred(_pred), new_value(_new_value) {}
template <typename _T1, typename _T2>
T
operator()(_T1&& a, _T2&& s) const
{
return pred(s) ? new_value : a;
}
private:
Predicate pred;
const T new_value;
};
// Used by: exclusive_scan_by_key
template <typename ValueType, typename FlagType, typename BinaryOp>
struct scan_by_key_fun
{
using result_of = ::std::tuple<ValueType, FlagType>;
scan_by_key_fun(BinaryOp input) : binary_op(input) {}
template <typename _T1, typename _T2>
result_of
operator()(_T1&& x, _T2&& y) const
{
using ::std::get;
return ::std::make_tuple(get<1>(y) ? get<0>(y) : binary_op(get<0>(x), get<0>(y)), get<1>(x) | get<1>(y));
}
private:
BinaryOp binary_op;
};
// Used by: reduce_by_key
template <typename ValueType, typename FlagType, typename BinaryOp>
struct segmented_scan_fun
{
segmented_scan_fun(BinaryOp input) : binary_op(input) {}
template <typename _T1, typename _T2>
_T1
operator()(const _T1& x, const _T2& y) const
{
using ::std::get;
auto new_x = get<1>(y) ? get<0>(y) : binary_op(get<0>(x), get<0>(y));
auto new_y = get<1>(x) | get<1>(y);
return _T1(new_x, new_y);
}
private:
BinaryOp binary_op;
};
// Used by: reduce_by_key on host
template <typename Output1, typename Output2>
class scatter_and_accumulate_fun
{
public:
scatter_and_accumulate_fun(Output1 _result1, Output2 _result2) : result1(_result1), result2(_result2) {}
template <typename _T>
void
operator()(_T&& x) const
{
using ::std::get;
if (::std::get<2>(x))
{
result1[::std::get<1>(x)] = ::std::get<0>(x);
}
if (::std::get<4>(x))
{
result2[::std::get<1>(x)] = ::std::get<3>(x);
}
}
private:
Output1 result1;
Output2 result2;
};
// Used by: reduce_by_key, mapping rules for scatter_if and gather_if
template <typename T, typename Predicate, typename UnaryOperation = identity>
class transform_if_stencil_fun
{
public:
using result_of = T;
transform_if_stencil_fun(Predicate _pred, UnaryOperation _op = identity()) : pred(_pred), op(_op) {}
template <typename _T>
void
operator()(_T&& t) const
{
using ::std::get;
if (pred(get<1>(t)))
get<2>(t) = op(get<0>(t));
}
private:
Predicate pred;
UnaryOperation op;
};
} // namespace internal
} // namespace dpl
} // namespace oneapi
#endif
| [
"alexey.veprev@intel.com"
] | alexey.veprev@intel.com |
5767d8e1abaa16301ffab3a1956038102bfc8bdd | c0ed6003f3705d4fcf17ecc3efa67c3f65898b5e | /2dp/kernel2.h | 26e1c0f50899f9cac40c6424c97a746a45fe02af | [] | no_license | rioyokotalab/regfmm | 25959cf68476a53021b33ccc93c98f0dcb91676e | 69d37c3c1de8ad4445e37f6313454573489a6fbf | refs/heads/master | 2020-03-11T17:36:17.971644 | 2020-01-22T07:45:38 | 2020-01-22T07:45:38 | 130,151,793 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,808 | h | #ifndef kernel_h
#define kernel_h
#include "types.h"
#include <iostream>
namespace exafmm {
int P; //!< Order of expansions
real_t D; //!< Buffer size
real_t dX[2]; //!< Distance vector
real_t theta; //!< Multipole acceptance criterion
real_t R0;
real_t X0[2];
real_t Xperiodic[2]; //!< Periodic coordinate offset
#pragma omp threadprivate(dX,Xperiodic) //!< Make global variables private
//!< Weight of smoothing function
inline real_t weight(Body * B, Cell * C) {
real_t x = fmin(C->R - std::abs(B->X[0] - C->X[0]), D);
real_t y = fmin(C->R - std::abs(B->X[1] - C->X[1]), D);
if (R0 - std::abs(B->X[0] - X0[0]) < D) x = D;
if (R0 - std::abs(B->X[1] - X0[1]) < D) y = D;
assert(x >= -D);
assert(y >= -D);
x /= D;
y /= D;
real_t w = (2 + 3 * x - x * x * x) / 4;
w *= (2 + 3 * y - y * y * y) / 4;
return w;
}
//!< P2P kernel between cells Ci and Cj
void P2PX(Cell * Ci, Cell * Cj) {
Body * Bi = Ci->BODY; // Target body pointer
Body * Bj = Cj->BODY; // Source body pointer
for (int i=0; i<Ci->NBODY; i++) { // Loop over target bodies
real_t p = 0, F[2] = {0, 0}; // Initialize potential, force
for (int j=0; j<Cj->NBODY; j++) { // Loop over source bodies
for (int d=0; d<2; d++) dX[d] = Bi[i].X[d] - Bj[j].X[d] - Xperiodic[d];// Calculate distance vector
real_t R2 = norm(dX); // Calculate distance squared
if (R2 != 0) { // If not the same point
real_t invR = 1 / sqrt(R2); // 1 / R
real_t logR = Bj[j].q * log(invR); // q * log(R)
p += logR; // Potential
for (int d=0; d<2; d++) F[d] += dX[d] * Bj[j].q / R2; // Force
} // End if for same point
} // End loop over source points
#pragma omp atomic // OpenMP atomic add
Bi[i].p += p; // Accumulate potential
for (int d=0; d<2; d++) { // Loop over dimensions
#pragma omp atomic // OpenMP atomic add
Bi[i].F[d] -= F[d]; // Accumulate force
} // End loop over dimensions
} // End loop over target bodies
}
//!< P2P kernel between cells Ci and Cj
void P2P(Cell * Ci, Cell * Cj) {
Body * Bi = Ci->BODY; // Target body pointer
Body * Bj = Cj->BODY; // Source body pointer
for (int i=0; i<Ci->NBODY; i++) { // Loop over target bodies
real_t p = 0, F[2] = {0, 0}; // Initialize potential, force
real_t wi = weight(&Bi[i], Ci);
for (int j=0; j<Cj->NBODY; j++) { // Loop over source bodies
real_t wj = weight(&Bj[j], Cj);
for (int d=0; d<2; d++) dX[d] = Bi[i].X[d] - Bj[j].X[d] - Xperiodic[d];// Calculate distance vector
real_t R2 = norm(dX); // Calculate distance squared
if (R2 != 0) { // If not the same point
real_t invR = 1 / sqrt(R2); // 1 / R
real_t logR = Bj[j].q * log(invR); // q * log(R)
p += logR * wj; // Potential
for (int d=0; d<2; d++) F[d] += dX[d] * Bj[j].q / R2 * wj; // Force
} // End if for same point
} // End loop over source points
#pragma omp atomic // OpenMP atomic add
Bi[i].p += p * wi; // Accumulate potential
for (int d=0; d<2; d++) { // Loop over dimensions
#pragma omp atomic // OpenMP atomic add
Bi[i].F[d] -= F[d] * wi; // Accumulate force
} // End loop over dimensions
} // End loop over target bodies
}
//!< P2M kernel for cell C
void P2M(Cell * C) {
for (Body * B=C->BODY; B!=C->BODY+C->NBODY; B++) { // Loop over bodies
for (int d=0; d<2; d++) dX[d] = B->X[d] - C->X[d]; // Get distance vector
real_t w = weight(B, C);
complex_t Z(dX[0],dX[1]), powZ(1.0, 0.0); // Convert to complex plane
C->M[0] += B->q * w; // Add constant term
for (int n=1; n<P; n++) { // Loop over coefficients
powZ *= Z / real_t(n); // Store z^n / n!
C->M[n] += powZ * B->q * w; // Add to coefficient
} // End loop
} // End loop
}
//!< M2M kernel for one parent cell Ci
void M2M(Cell * Ci) {
for (Cell * Cj=Ci->CHILD; Cj!=Ci->CHILD+Ci->NCHILD; Cj++) { // Loop over child cells
for (int d=0; d<2; d++) dX[d] = Cj->X[d] - Ci->X[d]; // Get distance vector
for (int k=0; k<P; k++) { // Loop over coefficients
complex_t Z(dX[0],dX[1]), powZ(1.0, 0.0); // z^0 = 1
Ci->M[k] += Cj->M[k]; // Add constant term
for (int n=1; n<=k; n++) { // Loop over k-l
powZ *= Z / real_t(n); // Store z^(k-l) / (k-l)!
Ci->M[k] += Cj->M[k-n] * powZ; // Add to coefficient
} // End loop
} // End loop
} // End loop
}
//!< M2L kernel between cells Ci and Cj
void M2L(Cell * Ci, Cell * Cj) {
for (int d=0; d<2; d++) dX[d] = Ci->X[d] - Cj->X[d] - Xperiodic[d];// Get distance vector
complex_t Z(dX[0],dX[1]), powZn(1.0, 0.0), powZnk(1.0, 0.0), invZ(powZn/Z);// Convert to complex plane
Ci->L[0] += -Cj->M[0] * log(Z); // Log term (for 0th order)
Ci->L[0] += Cj->M[1] * invZ; // Constant term
powZn = invZ; // 1/z term
for (int k=2; k<P; k++) { // Loop over coefficients
powZn *= real_t(k-1) * invZ; // Store (k-1)! / z^k
Ci->L[0] += Cj->M[k] * powZn; // Add to coefficient
} // End loop
Ci->L[1] += -Cj->M[0] * invZ; // Constant term (for 1st order)
powZn = invZ; // 1/z term
for (int k=1; k<P; k++) { // Loop over coefficients
powZn *= real_t(k) * invZ; // Store (k)! / z^k
Ci->L[1] += -Cj->M[k] * powZn; // Add to coefficient
} // End loop
real_t Cnk = -1; // Fix sign term
for (int n=2; n<P; n++) { // Loop over
Cnk *= -1; // Flip sign
powZnk *= invZ; // Store 1 / z^n
powZn = Cnk * powZnk; // Combine terms
for (int k=0; k<P; k++) { // Loop over
powZn *= real_t(n+k-1) * invZ; // (n+k-1)! / z^k
Ci->L[n] += Cj->M[k] * powZn; // Add to coefficient
} // End loop
powZnk *= real_t(n-1); // Store (n-1)! / z^n
} // End loop
}
//!< L2L kernel for one parent cell Cj
void L2L(Cell * Cj) {
for (Cell * Ci=Cj->CHILD; Ci<Cj->CHILD+Cj->NCHILD; Ci++) { // Loop over child cells
for (int d=0; d<2; d++) dX[d] = Ci->X[d] - Cj->X[d]; // Get distance vector
complex_t Z(dX[0],dX[1]); // Convert to complex plane
for (int l=0; l<P; l++) { // Loop over coefficients
complex_t powZ(1.0, 0.0); // z^0 = 1
Ci->L[l] += Cj->L[l]; // Add constant term
for (int k=1; k<P-l; k++) { // Loop over coefficients
powZ *= Z / real_t(k); // Store z^k / k!
Ci->L[l] += Cj->L[l+k] * powZ; // Add to coefficient
} // End loop
} // End loop
} // End loop
}
//!< L2P kernel for cell C
void L2P(Cell * C) {
for (Body * B=C->BODY; B!=C->BODY+C->NBODY; B++) { // Loop over bodies
real_t w = weight(B, C);
for (int d=0; d<2; d++) dX[d] = B->X[d] - C->X[d]; // Get distance vector
complex_t Z(dX[0],dX[1]), powZ(1.0, 0.0); // Convert to complex plane
B->p += std::real(C->L[0]) * w; // Add constant term
B->F[0] += std::real(C->L[1]) * w; // Add constant term
B->F[1] -= std::imag(C->L[1]) * w; // Add constant term
for (int n=1; n<P; n++) { // Loop over coefficients
powZ *= Z / real_t(n); // Store z^n / n!
B->p += std::real(C->L[n] * powZ) * w; // Add real part to solution
if (n < P-1) { // Condition for force accumulation
B->F[0] += std::real(C->L[n+1] * powZ) * w; // Add real part to solution
B->F[1] -= std::imag(C->L[n+1] * powZ) * w; // Add real part to solution
} // End condition for force accumulation
} // End loop
} // End loop
}
}
#endif
| [
"rioyokota@gmail.com"
] | rioyokota@gmail.com |
9a2225e651a1b0054528bf5f20c8fe084c6b9db7 | 63c71060f36866bca4ac27304cef6d5755fdc35c | /src/TransUtil/MsgServerRobin.h | a722b5eb50bbc1332e49eeb475895a36859afeb2 | [] | no_license | 15831944/barry_dev | bc8441cbfbd4b62fbb42bee3dcb79ff7f5fcaf8a | d4a83421458aa28ca293caa7a5567433e9358596 | refs/heads/master | 2022-03-24T07:00:26.810732 | 2015-12-22T07:19:58 | 2015-12-22T07:19:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,003 | h | ////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2005
// Packet Engineering, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification is not permitted unless authorized in writing by a duly
// appointed officer of Packet Engineering, Inc. or its derivatives
//
//
// Modification History:
// 05/31/2011 Created by Ketty
////////////////////////////////////////////////////////////////////////////
#ifndef AOS_TransUtil_AosMsgServerRobin_h
#define AOS_TransUtil_AosMsgServerRobin_h
#include "TransUtil/TransDistributor.h"
#include "SEInterfaces/ServerInfo.h"
class AosMsgServerRobin : public AosTransDistributor
{
OmnDefineRCObject
private:
vector<u32> mSvrIds;
vector<u32>::iterator mCrtItr;
public:
AosMsgServerRobin();
//AosMsgServerRobin(const AosServerInfo::Type type);
~AosMsgServerRobin();
// TransDistributor Interface
virtual int routeReq(const u64 &distid);
};
#endif
| [
"barryniu@jimodb.com"
] | barryniu@jimodb.com |
46f0d01be6f8430baaf95f6b825a0e6a239c21aa | 0093f09780783dc78f9ec5937c14fded6b2f996a | /src/app/server/java/ChipFabricProvider-JNI.cpp | 8fea4d4c9ba47b3922f04dd47e3301b899585c4d | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | nrfconnect/sdk-connectedhomeip | ce49cccb4e8c05d7bb44723f964b8adc32e20cec | eeb7280620fff1e16a75cfa41338186fd952c432 | refs/heads/master | 2023-09-03T02:40:14.967648 | 2023-08-25T09:24:08 | 2023-08-30T06:51:00 | 319,609,059 | 49 | 42 | Apache-2.0 | 2023-09-13T12:00:20 | 2020-12-08T10:50:54 | C++ | UTF-8 | C++ | false | false | 4,514 | cpp | /*
* Copyright (c) 2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* @file
* Implementation of JNI bridge for CHIP App Server for Android TV apps
*
*/
#include "ChipFabricProvider-JNI.h"
#include "AndroidAppServerWrapper.h"
#include <app/server/Server.h>
#include <cstdlib>
#include <iostream>
#include <jni.h>
#include <lib/core/CHIPError.h>
#include <lib/support/CHIPJNIError.h>
#include <lib/support/JniTypeWrappers.h>
#include <platform/CHIPDeviceLayer.h>
#include <thread>
#include <trace/trace.h>
using namespace chip;
#define JNI_METHOD(RETURN, METHOD_NAME) extern "C" JNIEXPORT RETURN JNICALL Java_chip_appserver_ChipFabricProvider_##METHOD_NAME
namespace {
JavaVM * sJVM;
} // namespace
CHIP_ERROR AndroidChipFabricProviderJNI_OnLoad(JavaVM * jvm, void * reserved)
{
CHIP_ERROR err = CHIP_NO_ERROR;
JNIEnv * env;
ChipLogProgress(DeviceLayer, "ChipFabricProvider JNI_OnLoad() called");
chip::Platform::MemoryInit();
// Save a reference to the JVM. Will need this to call back into Java.
JniReferences::GetInstance().SetJavaVm(jvm, "chip/appserver/ChipFabricProvider");
sJVM = jvm;
// check if the JNI environment is correct
env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrExit(env != NULL, err = CHIP_JNI_ERROR_NO_ENV);
chip::InitializeTracing();
exit:
if (err != CHIP_NO_ERROR)
{
JNI_OnUnload(jvm, reserved);
}
return err;
}
void AndroidChipFabricProviderJNI_OnUnload(JavaVM * jvm, void * reserved)
{
ChipLogProgress(DeviceLayer, "ChipFabricProvider JNI_OnUnload() called");
chip::Platform::MemoryShutdown();
}
CHIP_ERROR ReadFabricList(JNIEnv * env, jobject & self)
{
CHIP_ERROR err = CHIP_NO_ERROR;
jclass jFabricCls = env->FindClass("chip/appserver/Fabric");
VerifyOrExit(self != nullptr, err = CHIP_JNI_ERROR_NULL_OBJECT);
VerifyOrExit(jFabricCls != nullptr, ChipLogError(NotSpecified, "could not find Class Fabric"));
for (auto & fabricInfo : Server::GetInstance().GetFabricTable())
{
jmethodID constructor = env->GetMethodID(jFabricCls, "<init>", "()V");
VerifyOrExit(constructor != nullptr, err = CHIP_JNI_ERROR_METHOD_NOT_FOUND);
jobject jFabric = env->NewObject(jFabricCls, constructor);
VerifyOrExit(!env->ExceptionCheck(), err = CHIP_JNI_ERROR_EXCEPTION_THROWN);
jfieldID jvendorId = env->GetFieldID(jFabricCls, "vendorId", "I");
VerifyOrExit(jvendorId != nullptr, err = CHIP_JNI_ERROR_FIELD_NOT_FOUND);
jfieldID jnodeId = env->GetFieldID(jFabricCls, "nodeId", "J");
VerifyOrExit(jnodeId != nullptr, err = CHIP_JNI_ERROR_FIELD_NOT_FOUND);
jfieldID jfabricIndex = env->GetFieldID(jFabricCls, "fabricIndex", "S");
VerifyOrExit(jfabricIndex != nullptr, err = CHIP_JNI_ERROR_FIELD_NOT_FOUND);
jfieldID jlabel = env->GetFieldID(jFabricCls, "label", "Ljava/lang/String;");
VerifyOrExit(jlabel != nullptr, err = CHIP_JNI_ERROR_FIELD_NOT_FOUND);
env->SetIntField(jFabric, jvendorId, fabricInfo.GetVendorId());
env->SetLongField(jFabric, jnodeId, static_cast<jlong>(fabricInfo.GetNodeId()));
env->SetShortField(jFabric, jfabricIndex, fabricInfo.GetFabricIndex());
UtfString jLabelStr(env, fabricInfo.GetFabricLabel());
env->SetObjectField(jFabric, jlabel, jLabelStr.jniValue());
JniReferences::GetInstance().AddToList(self, jFabric);
}
exit:
return err;
}
JNI_METHOD(jint, getFabricCount)(JNIEnv * env, jobject self)
{
// a simplified way to get fabric count,see /src/credentials/FabricTable.h#FabricCount
return chip::Server::GetInstance().GetFabricTable().FabricCount();
}
JNI_METHOD(jobject, getFabricList)(JNIEnv * env, jobject self)
{
jobject jFabricList;
JniReferences::GetInstance().CreateArrayList(jFabricList);
ReadFabricList(env, jFabricList);
return jFabricList;
}
| [
"noreply@github.com"
] | noreply@github.com |
cfbcb467ecb8b85d20b2f77c3489280e7f939a4b | 93b24e6296dade8306b88395648377e1b2a7bc8c | /client/boost/boost/mpl/list/list0.hpp | 8629e7a2168f31fb6b06d02d3488b8a0808818d8 | [] | no_license | dahahua/pap_wclinet | 79c5ac068cd93cbacca5b3d0b92e6c9cba11a893 | d0cde48be4d63df4c4072d4fde2e3ded28c5040f | refs/heads/master | 2022-01-19T21:41:22.000190 | 2013-10-12T04:27:59 | 2013-10-12T04:27:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,193 | hpp |
#ifndef BOOST_MPL_LIST_LIST0_HPP_INCLUDED
#define BOOST_MPL_LIST_LIST0_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source: /CVSROOT/boost/boost/mpl/list/list0.hpp,v $
// $Date: 2007/10/29 07:32:42 $
// $Revision: 1.1.1.1 $
#include <boost/mpl/long.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/list/aux_/push_front.hpp>
#include <boost/mpl/list/aux_/pop_front.hpp>
#include <boost/mpl/list/aux_/push_back.hpp>
#include <boost/mpl/list/aux_/front.hpp>
#include <boost/mpl/list/aux_/clear.hpp>
#include <boost/mpl/list/aux_/O1_size.hpp>
#include <boost/mpl/list/aux_/size.hpp>
#include <boost/mpl/list/aux_/empty.hpp>
#include <boost/mpl/list/aux_/begin_end.hpp>
#include <boost/mpl/list/aux_/item.hpp>
namespace boost { namespace mpl {
template< typename Dummy = na > struct list0;
template<> struct list0<na>
: l_end
{
typedef l_end type;
};
}}
#endif // BOOST_MPL_LIST_LIST0_HPP_INCLUDED
| [
"viticm@126.com"
] | viticm@126.com |
b4bdee115a8229fd09d2547f56af9f67b244e8bd | 2960105217a0e135259e15f220da121e089b4a74 | /FB/2020/QR/Alchemy/code.cpp | 0744fb354e64c60451e33c7745139f2c79e5b7c3 | [] | no_license | iCoder0020/Competitive-Coding | 7bf23122774128e1cdacf7c5a82ab65c41699dcd | a4fc60ec119e588dd69e2c040bd1aa7564c53e6a | refs/heads/master | 2021-08-26T08:56:51.066001 | 2021-08-15T05:24:07 | 2021-08-15T05:24:07 | 142,176,794 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 571 | cpp | #include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int TC;
cin>>TC;
for(int tc = 0; tc<TC; tc++)
{
int N;
cin>>N;
string S;
cin>>S;
int a = 0, b = 0;
for(auto it: S)
{
if(it == 'A')
a++;
else
b++;
}
char ans = 'N';
if(max(a,b)<=(N+1)/2)
ans = 'Y';
cout<<"Case #"<<tc+1<<": "<<ans<<endl;
}
return 0;
} | [
"ishansang1999@gmail.com"
] | ishansang1999@gmail.com |
525e3aa3a219025be99d00d346922496699e43e3 | 1c8e5a1fc7f9dfee4969194c1bd77918eea73095 | /Source/AllProjects/WndUtils/CIDCtrls/CIDCtrls_GestHandler.cpp | 4b2f9d980a26cd8e996d9d4730a365a48af49a02 | [] | no_license | naushad-rahman/CIDLib | bcb579a6f9517d23d25ad17a152cc99b7508330e | 577c343d33d01e0f064d76dfc0b3433d1686f488 | refs/heads/master | 2020-04-28T01:08:35.084154 | 2019-03-10T02:03:20 | 2019-03-10T02:03:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 39,538 | cpp | //
// FILE NAME: CIDCtrls_GestureEng.cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 04/26/2013
//
// COPYRIGHT: $_CIDLib_CopyRight_$
//
// $_CIDLib_CopyRight2_$
//
// DESCRIPTION:
//
// This file implements the gesture engine base class.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// $_CIDLib_Log_$
//
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "CIDCtrls_.hpp"
#include "CIDCtrls_XPGestHandler_.hpp"
#include "CIDCtrls_Win7GestHandler_.hpp"
// ---------------------------------------------------------------------------
// Local types and constants
// ---------------------------------------------------------------------------
namespace CIDCtrls_CIDGestureEng
{
// -----------------------------------------------------------------------
// The length of time we'll track a gesture before we assume it's not
// really a gesture.
// -----------------------------------------------------------------------
#if CID_DEBUG_ON
// const tCIDLib::TEncodedTime enctMaxTime(kCIDLib::enctOneSecond * 60);
const tCIDLib::TEncodedTime enctMaxTime(kCIDLib::enctOnePtFiveSec);
#else
const tCIDLib::TEncodedTime enctMaxTime(kCIDLib::enctOnePtFiveSec);
#endif
// -----------------------------------------------------------------------
// Some global init stuff that we will check for once upon the first init
// of a gesture engine.
// -----------------------------------------------------------------------
tCIDLib::TBoolean bGlobalInitDone = kCIDLib::False;
tCIDLib::TFloat4 f4InertiaScaler = 1.0F;
}
// ---------------------------------------------------------------------------
// CLASS: MCIDGestTarget
// PREFIX: mgestt
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// MCIDGestTarget: Constructors and Destructor
// ---------------------------------------------------------------------------
MCIDGestTarget::MCIDGestTarget()
{
}
MCIDGestTarget::~MCIDGestTarget()
{
}
// ---------------------------------------------------------------------------
// MCIDGestTarget: Public, virtual methods
// ---------------------------------------------------------------------------
//
// This one is optional, so we provide a default. It just allows them to do something
// in the idle time between the trailing inertial output events.
//
tCIDLib::TVoid
MCIDGestTarget::GestInertiaIdle(const tCIDLib::TEncodedTime
, const tCIDLib::TCard4
, const tCIDLib::EDirs)
{
// A no-op if not overridden
}
// ---------------------------------------------------------------------------
// CLASS: TCIDGestHandler
// PREFIX: gest
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// TCIDGestHandler: Public, static methods
// ---------------------------------------------------------------------------
//
// We get the maximum distance that is available to scroll in the direction
// that the gesture indicated. We get the 'page size', i.e. how many pixels
// are displayable in the direction of travel. And we get the speed factor
// that was returned with the gesture info.
//
// We return the actual distance to scroll. We return it as an int value,
// though it's always possible, since the caller will often want to apply
// it negatively as well.
//
// We have one that works in terms of indices and another that works in
// terms of pixels.
//
tCIDLib::TInt4
TCIDGestHandler::i4AdjustForSpeed( const tCIDLib::TInt4 i4MaxPels
, const tCIDLib::TInt4 i4SpanPels
, const tCIDLib::TFloat8 f8Speed)
{
tCIDLib::TFloat8 f8AdjSpeed;
tCIDLib::TInt4 i4Ret;
if (i4MaxPels < i4SpanPels)
{
//
// We have less than a full page, so we the distance we adjust is
// is the max distance, and we have to adjust the speed adjustment
// based on how much of a full page we have.
//
f8AdjSpeed = f8Speed
+ ((tCIDLib::TFloat8(i4SpanPels)
/ tCIDLib::TFloat8(i4MaxPels)) * 0.25);
if (f8AdjSpeed > 1.0)
f8AdjSpeed = 1.0;
i4Ret = i4MaxPels;
}
else
{
//
// At least a full page is available, so we can take the speed
// adjustment as is, and the value we adjust is a full span size
//
f8AdjSpeed = f8Speed;
i4Ret = i4SpanPels;
}
//
// And now multiply the travel we can do by the adjusted speed factor.
// Generally they are passing pixels, but sometimes it's indices, which
// are fairly small number ranges, so we round to the nearest in order
// to be more accurate.
//
tCIDLib::TFloat8 f8Ret(i4Ret * f8AdjSpeed);
TMathLib::Round(f8Ret);
// And return cast to an int
return tCIDLib::TInt4(f8Ret);
}
// ---------------------------------------------------------------------------
// TCIDGestHandler: Constructors and Destructor
// ---------------------------------------------------------------------------
TCIDGestHandler::TCIDGestHandler(MCIDGestTarget* const pmgesttToUse) :
m_bTwoFingers(kCIDLib::False)
, m_eCurState(EStates::Idle)
, m_eDir(tCIDLib::EDirs::Count)
, m_eGestOpts(tCIDCtrls::EGestOpts::Disable)
, m_enctStart(0)
, m_f4InertiaVelo(0)
, m_f4PerGestVScale(0)
, m_pmgesttToUse(pmgesttToUse)
{
}
TCIDGestHandler::~TCIDGestHandler()
{
}
// ---------------------------------------------------------------------------
// TCIDGestHandler: Public, non-virtual methods
// ---------------------------------------------------------------------------
//
// If we have an outstanding gesture, we just need to clean up and stop the
// gesture.
//
tCIDLib::TVoid TCIDGestHandler::CancelGesture()
{
if ((m_eCurState == EStates::DoingPan)
|| (m_eCurState == EStates::DoingInertia))
{
// Report an end of gesture to the target window and then reset
try
{
m_pntDelta.Set(0, 0);
m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::End
, m_pntStartPos
, m_pntLastPos
, m_pntDelta
, m_bTwoFingers
);
Reset(tCIDCtrls::EGestReset::Cancelled);
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
Reset(tCIDCtrls::EGestReset::Cancelled);
}
catch(...)
{
Reset(tCIDCtrls::EGestReset::Cancelled);
}
}
else if (m_eCurState == EStates::DoingFlick)
{
// We don't have to report anything in this case
Reset(tCIDCtrls::EGestReset::Cancelled);
}
}
//
// The derived gesture engine should call here first then do its own initialization
// processing. We will check for a scaler value that gets applied to inertia. We
// grab the value and, if valid, we store it. This is only done once and stored.
//
tCIDLib::TVoid TCIDGestHandler::Initialize()
{
if (!CIDCtrls_CIDGestureEng::bGlobalInitDone)
{
TBaseLock lockInit;
if (!CIDCtrls_CIDGestureEng::bGlobalInitDone)
{
TString strVal;
if (TProcEnvironment::bFind(L"CID_GESTSCALER", strVal))
{
// Convert to a floating point value
tCIDLib::TFloat4 f4Val;
if (strVal.bToFloat4(f4Val))
{
// Clip to the legal range
if (f4Val < 0.5F)
f4Val = 0.5;
else if (f4Val > 1.5F)
f4Val = 1.5F;
CIDCtrls_CIDGestureEng::f4InertiaScaler = f4Val;
}
}
// Set the flag last;
CIDCtrls_CIDGestureEng::bGlobalInitDone = kCIDLib::False;
}
}
}
//
// Return the original start point. Only meaningful if called between the
// start and end event states.
//
const TPoint& TCIDGestHandler::pntStart() const
{
return m_pntStartPos;
}
//
// The derived gesture engine should call here first then do its own termination
// processing.
//
tCIDLib::TVoid TCIDGestHandler::Terminate()
{
// A no-op so far
}
// ---------------------------------------------------------------------------
// TCIDGestHandler: Protected, virtual methods
// ---------------------------------------------------------------------------
//
// This is called for starting, ending, and cancelled. It's virtual so it
// goes to the derived class first, who calls us as well. We both needto
// potentially do something different for each case.
//
tCIDLib::TVoid TCIDGestHandler::Reset(const tCIDCtrls::EGestReset eType)
{
m_bTwoFingers = kCIDLib::False;
m_enctStart = 0;
m_eCurState = EStates::Idle;
m_eDir = tCIDLib::EDirs::Count;
m_eGestOpts = tCIDCtrls::EGestOpts::Disable;
m_f4InertiaVelo = 0;
m_pntLastPos.Set(0, 0);
m_pntStartPos.Set(0, 0);
tCIDLib::TCard4 c4Index = 0;
while (c4Index < kCIDCtrls::c4InertiaBufSz)
{
m_ac8InertiaBuf[c4Index] = 0;
m_ai4InertiaBuf[c4Index] = 0;
c4Index++;
}
// Let the gesture target know we are resetting
m_pmgesttToUse->GestReset(eType);
}
// ---------------------------------------------------------------------------
// TCIDGestHandler: Protected, non-virtual methods
// ---------------------------------------------------------------------------
//
// When the derived class sees a click starting, he'll ask us if it's ok to let it be
// dealt with. If we are currently in inertial mode, we'll cancel it and say no. If we
// are currently in a gesture otherwise, we'll just say no.
//
// Though it's a little kludgey, we cancel inertial by stting the current inertia value
// to 0, which will cause the inertial loop to get a zero delta and finish up.
//
// Note that we cannot allow Clicked() to just return a boolean value, since it doesn't
// get called until a release is done in place, so that wouldn't help for cancelling
// inertial scrolling.
//
// And, since in non-multi-touch mode, a regular mouse click starts a gesture, this lets
// us cancel there before even starting a faux gesture, though StartGesture() below also
// does this same sort of thing.
//
tCIDLib::TBoolean TCIDGestHandler::bAllowClickStart()
{
if (m_eCurState == EStates::DoingInertia)
{
m_f4InertiaVelo = 0;
return kCIDLib::False;
}
return (m_eCurState == EStates::Idle);
}
//
// The derived class calls us here upon start of a gesture. He gives us the
// point where the gesture started. We reset ourself back to default state,
// then set our state to indicate we are waiting for the first move and store
// teh starting point.
//
// If we are currently sending inertial messages, we'll start that cancelling
// and return false to not start a new gesture.
//
tCIDLib::TBoolean TCIDGestHandler::bStartGesture(const TPoint& pntAt)
{
//
// If we are doing inertia, then cancel that gesture so that we can
// start another one.
//
if (m_eCurState == EStates::DoingInertia)
CancelGesture();
// Reset and start waiting for the first move
Reset(tCIDCtrls::EGestReset::Starting);
m_eCurState = EStates::WaitFirst;
// Remember the start pos, and save it as the last pos as well
m_pntStartPos = pntAt;
m_pntLastPos = pntAt;
return kCIDLib::True;
}
//
// The derived class calls this when a click occurs. Generally this is a quick
// press/release, without moving, which differentiates it from a gesture.
//
tCIDLib::TVoid TCIDGestHandler::Clicked(const TPoint& pntAt)
{
try
{
m_pmgesttToUse->GestClick(pntAt);
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
}
}
//
// The derived class calls this when the current gesture ends. If we are in idle
// mode, then this is a gesture we are ignoring so we do nothing.
//
// If we are processing a flick, we finish off the flick processing and tell the
// target window about the flick that we got.
//
// If processing a pan, we send the end of gesture to the target. If we are doing an
// inertial pan, we set up to start generating inertia msgs.
//
tCIDLib::TVoid TCIDGestHandler::EndGesture(const TPoint& pntAt)
{
try
{
if (m_eCurState == EStates::Idle)
{
// Ignore this one
}
else if (m_eCurState == EStates::WaitFirst)
{
//
// Could happen if they pressed and released and never moved at
// all. The derived class will likely generate a click.
//
m_eCurState = EStates::Idle;
}
else if (m_eCurState == EStates::DoingFlick)
{
const tCIDLib::TBoolean bTimedout
(
TTime::enctNow()
>= (m_enctStart + CIDCtrls_CIDGestureEng::enctMaxTime)
);
// Save the direction and start pos, and reset
const tCIDLib::EDirs eDir = m_eDir;
const TPoint pntStart(m_pntStartPos);
Reset(tCIDCtrls::EGestReset::Ended);
//
// If we got to this point, then it's a valid flick, else we
// would have already cancelled the gesture processing. So we
// can tell the target window about the flick if we didn't
// timeout.
//
// We tell it where the gesture started, so that it can know
// what to apply it to.
//
if (!bTimedout)
m_pmgesttToUse->GestFlick(eDir, pntStart);
}
else if (m_eCurState == EStates::DoingPan)
{
//
// If this is an inertial pan, we don't send the end yet, we
// just enable inertia and move to that state. otherwise, we
// can send the end and reset.
//
if (m_eGestOpts == tCIDCtrls::EGestOpts::PanInertia)
{
// Store a last detla if any
if (bCalcDelta(pntAt, m_pntDelta, m_pntNewPos))
StoreInertiaPnt(m_pntDelta);
// And now we are doing inertia
m_eCurState = EStates::DoingInertia;
//
// Calculate the pixels per second starting point for our inerita
// calculation.
//
CalcInertialDelta();
//
// Now we run a loop that generates the inertial output.
// We call the target back regularly to let him update.
//
GenerateInertia();
}
else
{
//
// Calc the final delta, and the new point to report, and pass
// it on to the target window. We do this even if there's no
// delta in this case, since we need to send the end no matter
// what.
//
// There's generally no delta on this last one, but we also
// need to get the new position to report.
//
bCalcDelta(pntAt, m_pntDelta, m_pntNewPos);
m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::End
, m_pntStartPos
, m_pntNewPos
, m_pntDelta
, m_bTwoFingers
);
// We can end this gesture now
Reset(tCIDCtrls::EGestReset::Ended);
}
}
}
catch(TError& errToCatch)
{
if (facCIDCtrls().bShouldLog(errToCatch))
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
}
// Be safe and cancel
Reset(tCIDCtrls::EGestReset::Cancelled);
}
catch(...)
{
// Be safe and cancel
Reset(tCIDCtrls::EGestReset::Cancelled);
}
}
//
// The derived class calls us here if we get gesture move. He tells us
// the new point, and whether there are two fingers down or not.
//
// If we are waiting for the first move, then we determine the direction
// of the movement and ask the target window for options. If the direction
// isn't supported, we go back to idle state and will ignore this gesture.
// If the direction is supported, then we set up for a new gesture of the
// type allowed, and tell the derived class that a gesture is starting.
//
// If we are in idle mode, then this is a gesture we are ignoring so we
// do nothing.
//
// Else we process the move, either passing it on to the target window if
// doing a gesture, or just processing the movement if doing a flick.
//
// If doing a flick and the movement goes contrary to the target direction,
// then the gesture processing is cancelled and we go back to idle mode and
// ignore the rest. The derived class was never told anything, so we don't
// have to call it to do any sort of cancel of the gesture.
//
tCIDLib::TVoid
TCIDGestHandler::Move(const TPoint& pntAt, const tCIDLib::TBoolean bTwoFingers)
{
try
{
if (m_eCurState == EStates::Idle)
{
// Ignore this one
}
else if (m_eCurState == EStates::WaitFirst)
{
//
// Figure out the angle of movement from the start point to
// this first movement.
//
const tCIDLib::EDirs eDir = eCalcDirection(m_pntStartPos, pntAt);
//
// Let the target window set options for this direction. Set it
// to disabled in case they don't set it.
//
m_eGestOpts = tCIDCtrls::EGestOpts::Disable;
m_f4PerGestVScale = 1.0F;
m_pmgesttToUse->PerGestOpts
(
pntAt, eDir, bTwoFingers, m_eGestOpts, m_f4PerGestVScale
);
// If no gesture accepted, then cancel
if (m_eGestOpts == tCIDCtrls::EGestOpts::Disable)
{
// Not enabled for the direction we are going, so ignore
Reset(tCIDCtrls::EGestReset::Cancelled);
return;
}
// Looks like we are on, so start storing info
m_eDir = eDir;
m_bTwoFingers = bTwoFingers;
// So we now are either going to do a flick, or a pan
if (m_eGestOpts == tCIDCtrls::EGestOpts::Flick)
{
//
// Just set the state. We don't tell the window anything
// until the gesture ends. Store the new position as the
// last.
//
m_eCurState = EStates::DoingFlick;
//
// In this case just store the new point as the last
// point.
//
m_pntLastPos = pntAt;
// Set the start time stamp
m_enctStart = TTime::enctNow();
}
else
{
m_eCurState = EStates::DoingPan;
m_pntDelta.Zero();
//
// Store an initial inertial delta. Doesn't matter what the delta
// is in this case, since it's to provide an initial time stamp.
//
if (m_eGestOpts == tCIDCtrls::EGestOpts::PanInertia)
StoreInertiaPnt(m_pntDelta);
// Send a start event with zero delta
m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::Start
, m_pntStartPos
, m_pntStartPos
, m_pntDelta
, bTwoFingers
);
//
// Now calculate a delta and send a first drag if any
// delta exists.
//
if (bCalcDelta(pntAt, m_pntDelta, m_pntNewPos))
{
m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::Drag
, m_pntStartPos
, m_pntNewPos
, m_pntDelta
, bTwoFingers
);
StoreInertiaPnt(m_pntDelta);
}
}
}
else if (m_eCurState == EStates::DoingFlick)
{
//
// As long as we are still moving in the target direction, and
// we are within the time constraint for a flick, then keep
// going, else cancel.
//
tCIDLib::TEncodedTime enctCur = TTime::enctNow();
if (enctCur >= (m_enctStart + CIDCtrls_CIDGestureEng::enctMaxTime))
{
// We timed out, so cancel
Reset(tCIDCtrls::EGestReset::Cancelled);
}
else
{
//
// See if we are still moving in the target direction.
//
const tCIDLib::TInt4 i4Delta = i4CalcDelta(pntAt);
if ((m_eDir == tCIDLib::EDirs::Left) || (m_eDir == tCIDLib::EDirs::Up))
{
//
// Make sure it's either negative or if not only slightly
// not so.
//
if (i4Delta > 0)
Reset(tCIDCtrls::EGestReset::Cancelled);
}
else
{
// The delta has to be positive
if (i4Delta < 0)
Reset(tCIDCtrls::EGestReset::Cancelled);
}
}
}
else if (m_eCurState == EStates::DoingPan)
{
//
// Calculate the delta and store the new point as the last point.
// If there was any delta, then report it.
//
if (bCalcDelta(pntAt, m_pntDelta, m_pntNewPos))
{
// Store a delta for later inertial purposes if needed
if (m_eGestOpts == tCIDCtrls::EGestOpts::PanInertia)
StoreInertiaPnt(m_pntDelta);
m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::Drag
, m_pntStartPos
, m_pntNewPos
, m_pntDelta
, bTwoFingers
);
}
}
}
catch(TError& errToCatch)
{
if (facCIDCtrls().bShouldLog(errToCatch))
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
}
Reset(tCIDCtrls::EGestReset::Cancelled);
}
catch(...)
{
Reset(tCIDCtrls::EGestReset::Cancelled);
}
}
MCIDGestTarget& TCIDGestHandler::mgesttCur()
{
CIDAssert(m_pmgesttToUse!= nullptr, L"The gesture handler mixin is not set");
return *m_pmgesttToUse;
}
// ---------------------------------------------------------------------------
// TCIDGestHandler: Private, non-virtual methods
// ---------------------------------------------------------------------------
//
// Given a new position, calculate the delta from the previous point and
// give that back, and calculate a new position, which keeps the transverse
// axis coordinate the same as the start position and store that as the
// last position seen.
//
tCIDLib::TBoolean
TCIDGestHandler::bCalcDelta(const TPoint& pntAt
, TPoint& pntDelta
, TPoint& pntNew)
{
tCIDLib::TInt4 i4Delta;
if (bHorizontal())
{
i4Delta = pntAt.i4X() - m_pntLastPos.i4X();
pntDelta.Set(i4Delta, 0);
pntNew.Set(pntAt.i4X(), m_pntStartPos.i4Y());
}
else
{
i4Delta = pntAt.i4Y() - m_pntLastPos.i4Y();
pntDelta.Set(0, i4Delta);
pntNew.Set(m_pntStartPos.i4X(), pntAt.i4Y());
}
// Rmember new point as the last pos
m_pntLastPos = pntNew;
// Return true if there was any delta
return (i4Delta != 0);
}
// Based on the direction stored, return true if it's a horizontal direction
tCIDLib::TBoolean TCIDGestHandler::bHorizontal() const
{
return ((m_eDir == tCIDLib::EDirs::Left) || (m_eDir == tCIDLib::EDirs::Right));
}
//
// At the end this is called to calculate the initial inertial delta that
// we will use to generate the remaining inertial, if inertia is enabled.
//
tCIDLib::TVoid TCIDGestHandler::CalcInertialDelta()
{
//
// We had to have at least gotten two samples, since the first one is the
// initial one. If not, assume no movement.
//
if (!m_ac8InertiaBuf[0] || !m_ac8InertiaBuf[1])
{
m_f4InertiaVelo = 0;
return;
}
//
// Go through all of the samples that we collected and turn the abs time
// stamps into times relative to the one before it. And see how many it
// takes to reach our cutoff. That's how many we'll consider.
//
const tCIDLib::TEncodedTime enctCutoff(kCIDLib::enctOneMilliSec * 150);
tCIDLib::TCard4 c4DeltaCnt = 0;
tCIDLib::TEncodedTime enctAccum = 0;
while ((c4DeltaCnt < kCIDCtrls::c4InertiaBufSz - 1)
&& (enctAccum < enctCutoff))
{
// Break out if the next one is unused
if (!m_ac8InertiaBuf[c4DeltaCnt + 1])
break;
// Accumulate this time
enctAccum += m_ac8InertiaBuf[c4DeltaCnt]
- m_ac8InertiaBuf[c4DeltaCnt + 1];
c4DeltaCnt++;
}
// Sort the ones we are keeping
if (c4DeltaCnt > 1)
{
TArrayOps::TSort<tCIDLib::TInt4>
(
m_ai4InertiaBuf, c4DeltaCnt, tCIDLib::eComp<tCIDLib::TInt4>
);
}
//
// Throw out the low 2 if we have more than 6. They always tend to be slow
// as the gesture ramps up.
//
tCIDLib::TCard4 c4AccumInd = 0;
if (c4DeltaCnt > 6)
{
c4AccumInd += 2;
c4DeltaCnt -= 2;
}
// Accumulate the distance of those we are keeping
tCIDLib::TInt4 i4Accum = 0;
for (; c4AccumInd < c4DeltaCnt; c4AccumInd++)
i4Accum += m_ai4InertiaBuf[c4AccumInd];
// Make it negative if going left or up.
if ((m_eDir == tCIDLib::EDirs::Left) || (m_eDir == tCIDLib::EDirs::Up))
i4Accum *= -1;
//
// And divide by the count for an average, and multiply that by the scaler
// value.
//
m_f4InertiaVelo =
(
(tCIDLib::TFloat4(i4Accum) / tCIDLib::TFloat4(c4DeltaCnt))
* CIDCtrls_CIDGestureEng::f4InertiaScaler
);
}
//
// Given the start position and the first move position, we calculate a
// polar coordinate from the starting point. This gives us a degree slope,
// and we use that to determine the direction of movement.
//
tCIDLib::EDirs
TCIDGestHandler::eCalcDirection(const TPoint& pntStartPos
, const TPoint& pntNew)
{
//
// We need to get the new point relative to the origin. We subtract
// the original from the new, but because our coordinate system gets
// larger going downwards, we flip the Y component sign, to make the
// angle come out in the standard way.
//
TPoint pntDir(pntNew - pntStartPos);
pntDir.NegateY();
// And now convert to polar coordinates (in degrees)
tCIDLib::TCard4 c4Theta;
tCIDLib::TCard4 c4Radius;
pntDir.ToPolarDegrees(c4Theta, c4Radius);
//
// And now, based on the range of the degrees, decide which direction
// we are going.
//
// Note on the Right one, we are crossing the zero boundary, so we
// do an OR, not and AND. This is OK since anything else would have
// been caught already.
//
tCIDLib::EDirs eRet = tCIDLib::EDirs::Count;
if ((c4Theta > 45) && (c4Theta < 135))
eRet = tCIDLib::EDirs::Up;
else if ((c4Theta >= 135) && (c4Theta < 225))
eRet = tCIDLib::EDirs::Left;
else if ((c4Theta >= 225) && (c4Theta < 315))
eRet = tCIDLib::EDirs::Down;
else if ((c4Theta >= 315) || (c4Theta <= 45))
eRet = tCIDLib::EDirs::Right;
return eRet;
}
//
// When a pan gesture ends, and inertia is enabled, then this is called and we do
// an inertia generating loop. We call the gest target with with deltas until he
// says stop or we run out of inertia.
//
// We also call it back between events, with a time interval it can spend doing
// other things it needs to do. If we come back before that time has expired, we
// wait the rest of the time.
//
tCIDLib::TVoid TCIDGestHandler::GenerateInertia()
{
const tCIDLib::TCard4 c4IntervalMS = 16;
const tCIDLib::TEncodedTime enctIdleDiff = kCIDLib::enctOneMilliSec * 4;
//
// Set up a power value that we'll use to ramp down the effect over time.
//
tCIDLib::TFloat4 f4Power = 1.1F;
//
// And set up the per-round value that we'll use the power value above to
// scale down each round. We'll then multiply this by the velocity to generate
// the per-round delta. Since this is less than 1, the power operation will
// scale it downwards each time.
//
tCIDLib::TFloat4 f4Round = 0.99F;
//
// Use the per-gesture velocity scaling factor to adjust the round value.
// It's a percent value from 0 to 1.
//
f4Round *= m_f4PerGestVScale;
//
// Figure out the direction of the inertia. We pass this to the idle callback,
// so that the target handler can know which direction to adjust for new
// content to be displayed.
//
if ((m_eDir == tCIDLib::EDirs::Left) || (m_eDir == tCIDLib::EDirs::Right))
{
// It was horizontal, so negative velo means left, else right
if (m_f4InertiaVelo < 0)
m_eDir = tCIDLib::EDirs::Left;
else
m_eDir = tCIDLib::EDirs::Right;
}
else
{
// It was vertical, so negative velo means up, else down
if (m_f4InertiaVelo < 0)
m_eDir = tCIDLib::EDirs::Up;
else
m_eDir = tCIDLib::EDirs::Down;
}
// Elevate our thread priority during this, because it is time sensitive
TThreadPrioJan janPrio(tCIDLib::EPrioLevels::Highest);
// Make sure that the unused size of the delta point is zero
m_pntDelta.Zero();
try
{
while(kCIDLib::True)
{
//
// Wait for our inter-loop interval. We give the target a chance to spend
// that time doing something, but will eat any remainder if needed. They
// will typically use it to continue to draw ahead and keep their
// scrollable bitmap content updated to cover the next movements.
//
tCIDLib::TEncodedTime enctEnd = TTime::enctNowPlusMSs(c4IntervalMS);
m_pmgesttToUse->GestInertiaIdle(enctEnd - enctIdleDiff, c4IntervalMS - 4, m_eDir);
// Eat any remaining time
{
tCIDLib::TEncodedTime enctLeft = TTime::enctNow();
if (enctLeft < enctEnd)
{
tCIDLib::TCard4 c4MSs = tCIDLib::TCard4
(
(enctEnd - enctLeft) / kCIDLib::enctOneMilliSec
);
if (c4MSs > 4)
facCIDCtrls().MsgYield(c4MSs - 2);
}
}
//
// If they cancelled us during the callback, then we can stop now
// and send the end of gesture.
//
if (m_f4InertiaVelo == 0)
{
Reset(tCIDCtrls::EGestReset::Cancelled);
break;
}
// Apply our power to the inerital velocity
f4Round = TMathLib::f4Power(f4Round, f4Power);
//
// Multiply the new scaled velocity by the calculated MSs. This will
// tell us now many pixels we should move for the time expired.
//
tCIDLib::TInt4 i4Delta = tCIDLib::TInt4(m_f4InertiaVelo * f4Round);
// Set up the delta point with this change
if (bHorizontal())
m_pntDelta.i4X(i4Delta);
else
m_pntDelta.i4Y(i4Delta);
// Adjust the last pos by the delta
m_pntLastPos += m_pntDelta;
//
// When the delta hits two or less, we stop, else we send the next
// point and delta. We have to deal with both directions here.
//
if ((i4Delta > -3) && (i4Delta < 3))
{
m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::End
, m_pntStartPos
, m_pntLastPos
, m_pntDelta
, m_bTwoFingers
);
//
// Reset with end an ended status and break out, as long
// as we haven't already been killed. Otherwise, we might
// cancel a new one they started, which would have cancelled
// the current one.
//
if (m_eCurState == EStates::DoingInertia)
Reset(tCIDCtrls::EGestReset::Ended);
break;
}
else
{
//
// Send the current new info. Since it is inertial, they
// can tell us to stop or continue.
//
const tCIDLib::TBoolean bContinue = m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::Inertia
, m_pntStartPos
, m_pntLastPos
, m_pntDelta
, m_bTwoFingers
);
//
// If not continuing, then cancel the remaining inertial
// and break out. We first send an end gesture to finish it
// off, then we do a cancel.
//
if (!bContinue)
{
// SEnd an end with no delta
m_pntDelta.Set(0, 0);
m_pmgesttToUse->bProcessGestEv
(
tCIDCtrls::EGestEvs::End
, m_pntStartPos
, m_pntLastPos
, m_pntDelta
, m_bTwoFingers
);
Reset(tCIDCtrls::EGestReset::Cancelled);
break;
}
}
}
}
catch(TError& errToCatch)
{
if (facCIDCtrls().bShouldLog(errToCatch))
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
}
// Be safe and cancel
Reset(tCIDCtrls::EGestReset::Cancelled);
}
catch(...)
{
// Be safe and cancel
Reset(tCIDCtrls::EGestReset::Cancelled);
}
}
//
// For our internal use when doing flicks. Figure out the delta in the
// direction of travel. Then store the passed point as the new last point.
//
tCIDLib::TInt4 TCIDGestHandler::i4CalcDelta(const TPoint& pntAt)
{
tCIDLib::TInt4 i4Ret;
if (bHorizontal())
i4Ret = pntAt.i4X() - m_pntLastPos.i4X();
else
i4Ret = pntAt.i4Y() - m_pntLastPos.i4Y();
m_pntLastPos = pntAt;
return i4Ret;
}
//
// For each non-inertial position reported to the window, if we are doing an
// ineertial pan, this is called. We just store the new values away for
// later use in calculating a speed. The position info we get is a delta from
// the previous one.
//
tCIDLib::TVoid TCIDGestHandler::StoreInertiaPnt(const TPoint& pntNewPos)
{
tCIDLib::TInt4 i4New;
if (bHorizontal())
i4New = pntNewPos.i4X();
else
i4New = pntNewPos.i4Y();
if (i4New < 0)
i4New *= -1;
// Move the buffer items upwards. We want the newest ones at the start.
tCIDLib::TCard4 c4Index = kCIDCtrls::c4InertiaBufSz;
while (c4Index)
{
c4Index--;
m_ac8InertiaBuf[c4Index] = m_ac8InertiaBuf[c4Index - 1];
m_ai4InertiaBuf[c4Index] = m_ai4InertiaBuf[c4Index - 1];
}
// And store the new one
m_ac8InertiaBuf[0] = TTime::enctNow();
m_ai4InertiaBuf[0] = i4New;
}
// ---------------------------------------------------------------------------
// CLASS: TCIDWndGestHandler
// PREFIX: gesth
// ---------------------------------------------------------------------------
// -------------------------------------------------------------------
// TCIDWndGestHandler: Public, static methods
// -------------------------------------------------------------------
//
// Gen up a gesture handler based on local capabilities, and return it. We pass it the
// caller's desired gesture target, which he will mix into some class that he wants to
// get gesture callbacks on. The handler doesn't own it, it just references it.
//
// This is for the common, window based gesture application, so we return the object
// via the window-based gesture base class. Any non-window based gesture oriented
// applications will have to create their own gesture handler derivative.
//
TCIDWndGestHandler*
TCIDWndGestHandler::pgesthMakeNew( MCIDGestTarget* pmgesttToUse
, const tCIDCtrls::TWndHandle hwndTar)
{
// See if they want to force multi-touch off
TString strTmp;
const tCIDLib::TBoolean bMultiOK = !TProcEnvironment::bFind(L"CID_GESTNOMULTI", strTmp);
//
// If multi-ok and it appears to be available, then take that. Else load the
// mouse only stuff.
//
TCIDWndGestHandler* pgesthRet = nullptr;
const int iWantedFlags(NID_READY | NID_MULTI_INPUT);
if (bMultiOK
&& ((::GetSystemMetrics(SM_DIGITIZER) & iWantedFlags) == iWantedFlags))
{
pgesthRet = new TWin7GestHandler(pmgesttToUse, hwndTar);
}
else
{
pgesthRet = new TXPGestHandler(pmgesttToUse, hwndTar);
}
// Initialize it and return it
pgesthRet->Initialize();
return pgesthRet;
}
// -------------------------------------------------------------------
// TCIDWndGestHandler: Destructor
// -------------------------------------------------------------------
TCIDWndGestHandler::~TCIDWndGestHandler()
{
}
// -------------------------------------------------------------------
// TCIDWndGestHandler: Hidden constructors
// -------------------------------------------------------------------
TCIDWndGestHandler::TCIDWndGestHandler(MCIDGestTarget* const pmgesttToUse) :
TCIDGestHandler(pmgesttToUse)
{
}
| [
"droddey@charmedquark.com"
] | droddey@charmedquark.com |
29aa0e77e8f1df59a85c37d12a6ae7dce7976a6e | f4ba6ef6b737eca3de1e802b804f1ec9bba82aae | /original/giro-master/src/qt/optionsmodel.h | a7a6eea38e71b88cf10b516085e457a6ad197e29 | [
"LicenseRef-scancode-unknown-license-reference",
"CC0-1.0",
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | seraphcoin/seraph_paper_wallet | 1986fc3f8a3b850caee6dfc6468651a7da5b8169 | 63deccae9f2746a408549ae687aaee0d91a2619c | refs/heads/master | 2020-03-18T08:04:42.153203 | 2018-05-23T00:45:51 | 2018-05-23T00:45:51 | 134,488,332 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,237 | h | // Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_OPTIONSMODEL_H
#define BITCOIN_QT_OPTIONSMODEL_H
#include "amount.h"
#include <QAbstractListModel>
QT_BEGIN_NAMESPACE
class QNetworkProxy;
QT_END_NAMESPACE
/** Interface from Qt to configuration data structure for Bitcoin client.
To Qt, the options are presented as a list with the different options
laid out vertically.
This can be changed to a tree once the settings become sufficiently
complex.
*/
class OptionsModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit OptionsModel(QObject* parent = 0);
enum OptionID {
StartAtStartup, // bool
MinimizeToTray, // bool
MapPortUPnP, // bool
MinimizeOnClose, // bool
ProxyUse, // bool
ProxyIP, // QString
ProxyPort, // int
DisplayUnit, // BitcoinUnits::Unit
ThirdPartyTxUrls, // QString
Digits, // QString
Theme, // QString
Language, // QString
CoinControlFeatures, // bool
ThreadsScriptVerif, // int
DatabaseCache, // int
SpendZeroConfChange, // bool
ObfuscationRounds, // int
AnonymizegiroAmount, //int
ShowMasternodesTab, // bool
Listen, // bool
OptionIDRowCount,
};
void Init();
void Reset();
int rowCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
void setDisplayUnit(const QVariant& value);
/* Explicit getters */
bool getMinimizeToTray() { return fMinimizeToTray; }
bool getMinimizeOnClose() { return fMinimizeOnClose; }
int getDisplayUnit() { return nDisplayUnit; }
QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; }
bool getProxySettings(QNetworkProxy& proxy) const;
bool getCoinControlFeatures() { return fCoinControlFeatures; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
/* Restart flag helper */
void setRestartRequired(bool fRequired);
bool isRestartRequired();
bool resetSettings;
private:
/* Qt-only settings */
bool fMinimizeToTray;
bool fMinimizeOnClose;
QString language;
int nDisplayUnit;
QString strThirdPartyTxUrls;
bool fCoinControlFeatures;
/* settings that were overriden by command-line */
QString strOverriddenByCommandLine;
/// Add option to list of GUI options overridden through command line/config file
void addOverriddenOption(const std::string& option);
signals:
void displayUnitChanged(int unit);
void obfuscationRoundsChanged(int);
void anonymizegiroAmountChanged(int);
void coinControlFeaturesChanged(bool);
};
#endif // BITCOIN_QT_OPTIONSMODEL_H
| [
"seraphcoin@gmail.com"
] | seraphcoin@gmail.com |
43625a0190fae8d7ed38cd39fdaad92c47642a29 | 0ac6d82f3d96c90b2450b1c0f48349a59eaa7fd2 | /POJ/cleaning_shifts_poj_2376_greedy.cpp | 89598d83ade30981cf2faf56dff419cc6a736d89 | [] | no_license | AlexInTown/HackWorks | 4d1d087d1152559be3ed88348cb9a68c7d1460b5 | e2dd4b25d06510fd0da1be6bc474a60837f632c9 | refs/heads/master | 2020-04-11T04:20:20.993355 | 2016-02-25T09:24:42 | 2016-02-25T09:24:42 | 30,736,554 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,253 | cpp | #include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
struct Interval{
int start;
int end;
};
struct Comp{
bool operator()(const Interval& a, const Interval& b){
return a.start < b.start || a.start==b.start && a.end < b.end;
}
};
Interval intervals[25001];
int N, T;
int main(){
scanf("%d%d", &N, &T);
int i;
for(i = 0; i < N; ++i){
scanf("%d%d", &intervals[i].start, &intervals[i].end);
}
sort(intervals, intervals+N, Comp());
if(intervals[0].start > 1)
{
printf("-1\n");
return 0;
}
int max_end = intervals[0].end;
i = 1;
int j;
int res = 1;
while(max_end < T){
if(i >= N) break;
int end = -1;
// 注意条件是 intervals[j].start <= max_end+1
for(j = i; j < N && intervals[j].start <= max_end+1; j++){
if(intervals[j].end > end) end = intervals[j].end;
}
if(end <= max_end)
break;
else{
max_end = end;
++res;
}
i = j; //一旦此次过了这interval,那么下一次就没有必要了
}
if(max_end < T) {
printf("-1\n");
}else{
printf("%d\n", res);
}
return 0;
}
| [
"alex.oyzh@gmail.com"
] | alex.oyzh@gmail.com |
723380700b61fd2e83e5085db244388521cefe4d | def39f068050b234df9f6909d4277f96b740f11c | /E-olimp/1464. Simple Question .cpp | 442dd70f5378e9a893c5fd55e3f12590568f29ec | [] | no_license | azecoder/Problem-Solving | 41a9a4302c48c8de59412ab9175b253df99f1f28 | a920b7bac59830c7b798127f6eed0e2ab31a5fa2 | refs/heads/master | 2023-02-10T09:47:48.322849 | 2021-01-05T14:14:09 | 2021-01-05T14:14:09 | 157,236,604 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 338 | cpp | #include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
long long x;
while(cin>>x)
{
if(x==0)
break;
else if(x<0)
{
x=-x;
cout<<-x*(x+1)/2+1<<endl;
}
else cout<<x*(x+1)/2<<endl;
}
return EXIT_SUCCESS;
} | [
"tabriz.haji@gmail.com"
] | tabriz.haji@gmail.com |
3915d66fd434cccb6828d211bf1ef773eeb7329b | 0960fd7c0e3b8b9a73adc1922c8be58102bbace1 | /RPG/src/dungeon/dungeons/HardDungeon.h | 61218a461ff33a00a46772ee52deeec652065e25 | [] | no_license | StounhandJ/Working-in-Cpp | 88a62f48c25fc0146f578144fb88b655c1e67ad1 | 58ad8b4164c77b9582e70e8463941b433c45b7e6 | refs/heads/master | 2023-04-06T11:03:27.870071 | 2021-04-15T09:15:17 | 2021-04-15T09:15:17 | 344,390,647 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,289 | h | #include "src/dungeon/DungeonClass.h"
#include "src/bosses/LichClass.h"
#include "src/enemy/enemies/undead.h"
#ifndef RPG_HARDDUNGEON_H
#define RPG_HARDDUNGEON_H
DungeonClass HardDungeon = DungeonClass("Сложное подземелье", 4, 1,2,70,
std::vector{
HardUndeadEnemies::skeleton,
HardUndeadEnemies::skeleton,
HardUndeadEnemies::skeleton,
HardUndeadEnemies::ghoul,
HardUndeadEnemies::ghoul,
HardUndeadEnemies::ghoul,
HardUndeadEnemies::zombies,
HardUndeadEnemies::zombies,
HardUndeadEnemies::mummy,
HardUndeadEnemies::mummy,
HardUndeadEnemies::vampire
}, // Противники в данже
std::vector{
SkeletonArtifact::helmet,
SkeletonArtifact::armor,
SkeletonArtifact::hands,
SkeletonArtifact::legs,
VampireArtifact::helmet,
VampireArtifact::armor,
VampireArtifact::hands,
VampireArtifact::legs,
MummyArtifact::helmet,
MummyArtifact::armor,
MummyArtifact::hands,
MummyArtifact::legs,
}, // Выпадающие предметы
Lich
);
#endif //RPG_HARDDUNGEON_H
| [
"rmarinicev@gmail.com"
] | rmarinicev@gmail.com |
b8c1297595bb9833bb81f79f0407347a14f1b652 | 45393329d6f2fb76db6873b9ceac12352cbd73c4 | /PluginProcessor.cpp | 04d356f2cc9fd93d6a1dea15791c7ce87be94714 | [] | no_license | GavinRay97/JUCE-reaper-embedded-fx-gui | 080576b085c8c03a2b7c0ca2d35b128d0e4175ba | b64c670b9f135d5bb480dfeac4e927cba9be19a1 | refs/heads/master | 2023-04-11T18:03:52.026912 | 2021-05-01T16:15:32 | 2021-05-01T16:15:32 | 362,551,820 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,831 | cpp | #include "PluginProcessor.h"
#include "PluginEditor.h"
#include "juce_core/system/juce_PlatformDefs.h"
#include <cstddef>
#ifdef _WIN32
#include <basetsd.h>
#endif
// Provider IReaperHostApplication, IReaperUIEmbedInterface properly wrapped
#include "./ReaperVST3InterfaceWrapper.hpp"
DEF_CLASS_IID(IReaperHostApplication)
// Provides macro definitions for things like "REAPER_FXEMBED_WM_GETMINMAXINFO"
#include "include/vendor/reaper-sdk/sdk/reaper_plugin_fx_embed.h"
//==============================================================================
AudioPluginAudioProcessor::AudioPluginAudioProcessor()
: AudioProcessor(
BusesProperties()
#if !JucePlugin_IsMidiEffect
#if !JucePlugin_IsSynth
.withInput("Input", juce::AudioChannelSet::stereo(), true)
#endif
.withOutput("Output", juce::AudioChannelSet::stereo(), true)
#endif
)
{
}
AudioPluginAudioProcessor::~AudioPluginAudioProcessor() { }
void AudioPluginAudioProcessor::handleVST3HostContext(
Steinberg::FUnknown* hostContext,
Steinberg::Vst::IHostApplication* host,
juce::JuceAudioProcessor* comPluginInstance,
juce::JuceVST3EditController* juceVST3EditController)
{
// Credit: Robbert van der Helm (https://github.com/robbert-vdh)
auto reaper = FUnknownPtr<IReaperHostApplication>(hostContext);
auto showConsoleMsg = static_cast<void (*)(const char* msg)>(reaper->getReaperApi("ShowConsoleMsg"));
showConsoleMsg("Test from IReaperHostApplication");
return;
}
void AudioPluginAudioProcessor::timerCallback()
{
DBG("Timer callback invoked");
}
// Handle drawing embedded UI
Steinberg::TPtrInt AudioPluginAudioProcessor::handleReaperEmbedMessage(int msg, Steinberg::TPtrInt parm2, Steinberg::TPtrInt parm3)
{
DBG("[AudioPluginAudioProcessor::handleReaperEmbedMessage] msg = " << msg << " parm2 = " << parm2 << " parm3 = " << parm3);
auto* embedComponent = this->createEditor();
if (embedComponent == nullptr)
return 0;
switch (msg) {
/* return 1 if embedding is supported and available
* return -1 if embedding is supported and unavailable
* return 0 if embedding is not supported
*/
case REAPER_FXEMBED_WM_IS_SUPPORTED:
return 1;
// called when embedding begins (return value ignored)
case REAPER_FXEMBED_WM_CREATE: {
}
return 0;
// called when embedding ends (return value ignored)
case REAPER_FXEMBED_WM_DESTROY: {
}
return 0;
/*
* get size hints. parm3 = (REAPER_FXEMBED_SizeHints*). return 1 if supported
* note that these are just hints, the actual size may vary
*/
case REAPER_FXEMBED_WM_GETMINMAXINFO:
if (parm3) {
auto mmi = (REAPER_FXEMBED_SizeHints*)parm3;
mmi->min_width = 80;
mmi->min_height = 90;
mmi->max_width = 100;
mmi->max_height = 110;
mmi->preferred_aspect = 0;
mmi->minimum_aspect = 0;
}
return 1;
// [NOTE]: Not really sure what this does (Gavin)
// parm3: REAPER_FXEMBED_DrawInfo*. set mouse cursor and return REAPER_FXEMBED_RETNOTIFY_HANDLED, or return 0.
case REAPER_FXEMBED_WM_SETCURSOR:
if (parm3) {
auto drawInfo = (REAPER_FXEMBED_DrawInfo*)parm3;
return REAPER_FXEMBED_RETNOTIFY_HANDLED;
}
return 0;
/*
* mouse messages
* parm3 = (REAPER_FXEMBED_DrawInfo*)
* capture is automatically set on mouse down, released on mouse up
* when not captured, will always receive a mousemove when exiting the window
*
* if the mouse messages return with REAPER_FXEMBED_RETNOTIFY_INVALIDATE set, a non-optional
* redraw is initiated (generally sooner than the next timer-based redraw)
*/
case REAPER_FXEMBED_WM_MOUSEMOVE:
case REAPER_FXEMBED_WM_LBUTTONDOWN:
case REAPER_FXEMBED_WM_LBUTTONUP:
case REAPER_FXEMBED_WM_LBUTTONDBLCLK:
case REAPER_FXEMBED_WM_RBUTTONDOWN:
case REAPER_FXEMBED_WM_RBUTTONUP:
case REAPER_FXEMBED_WM_RBUTTONDBLCLK:
case REAPER_FXEMBED_WM_MOUSEWHEEL:
if (parm3) {
auto inf = (REAPER_FXEMBED_DrawInfo*)parm3;
auto point = juce::Point<float>(inf->mouse_x, inf->mouse_y);
juce::Desktop& desktop = juce::Desktop::getInstance();
auto mms = desktop.getMainMouseSource();
// using mouseEventParams = struct {
// juce::MouseInputSource source;
// juce::Point<float> position;
// juce::ModifierKeys modifiers;
// float pressure, orientation, rotation, tiltX, tiltY;
// juce::Component* eventComponent, originator;
// juce::Time eventTime;
// juce::Point<float> mouseDownPos;
// juce::Time mouseDownTime;
// int numberOfClicks;
// bool mouseWasDragged;
// };
// auto it = mouseEventParams{
// .source = mms,
// .position = point,
// };
auto ev = juce::MouseEvent(mms, point, 0, 0,
0, 0, 0, 0,
embedComponent, embedComponent,
juce::Time(0),
point, juce::Time(0),
1, false);
int w = inf->width, h = inf->height;
if (inf->mouse_x < 0 || inf->mouse_y < 0)
return 1;
juce::Point<float> ptDesktop = mms.getScreenPosition();
// calculate desktop position of BMP
juce::Point<float> mousePosDesktop = mms.getScreenPosition();
juce::Point<float> mousePosBmp = juce::Point<float>(inf->mouse_x, inf->mouse_y);
// posBmp = mousePosDesktop-mousePosBmp
juce::Point<float> posBmp = mousePosDesktop - mousePosBmp;
juce::Point<int> posBmpInt;
// posBmpInt.x = (int)posBmp.x;
// posBmpInt.y = (int)posBmp.y;
// posBmpInt.x = (int)0;
// posBmpInt.y = (int)0;
int rim = 10;
int lowerBorder_x = rim;
int upperBorder_x = w - rim;
int lowerBorder_y = rim;
int upperBorder_y = h - rim;
if ((lowerBorder_x < point.x && point.x < upperBorder_x) && (lowerBorder_y < point.y && point.y < upperBorder_y)) {
juce::Rectangle<int> rect = { (int)posBmp.x, (int)posBmp.y, w, h };
// embedComponent->setTopLeftPosition(posBmpInt);
embedComponent->setBounds(rect);
embedComponent->setVisible(true);
embedComponent->addToDesktop(0);
embedComponent->setAlwaysOnTop(true);
Timer::startTimer(1000);
} else {
embedComponent->setVisible(false);
embedComponent->removeFromDesktop();
embedComponent->setAlwaysOnTop(false);
}
}
return 1;
/* draw embedded UI.
*
* parm2: REAPER_FXEMBED_IBitmap * to draw into. note
* parm3: REAPER_FXEMBED_DrawInfo *
*
* if flags has REAPER_FXEMBED_DRAWINFO_FLAG_PAINT_OPTIONAL set, update is optional. if no change since last draw, return 0.
* if flags has REAPER_FXEMBED_DRAWINFO_FLAG_LBUTTON_CAPTURED set, left mouse button is down and captured
* if flags has REAPER_FXEMBED_DRAWINFO_FLAG_RBUTTON_CAPTURED set, right mouse button is down and captured
*
* HiDPI:
* if REAPER_FXEMBED_IBitmap::Extended(REAPER_FXEMBED_EXT_GET_ADVISORY_SCALING,NULL) returns nonzero, then it is a 24.8 scalefactor for UI drawing
*
* return 1 if drawing occurred, 0 otherwise.
*/
case REAPER_FXEMBED_WM_PAINT:
if ((void*)parm2 && parm3) {
auto inf = (REAPER_FXEMBED_DrawInfo*)parm3;
//inf->context = 1=TCP, 2=MCP
int inf_flags = (int)(INT_PTR)inf->flags;
//if (inf_flags & 1)
// if (!embedded_updated)
// return 0;
//embedded_updated = false;
REAPER_FXEMBED_IBitmap* bmp = (REAPER_FXEMBED_IBitmap*)(void*)parm2;
int w = bmp->getWidth();
int h = bmp->getHeight();
// bmp->resize(80, 90);
//copy img->bmp;
juce::Image img(juce::Image::PixelFormat::ARGB,
bmp->getWidth(), bmp->getHeight(), true);
juce::Graphics g(img);
embedComponent->paintEntireComponent(g, false);
int reaperBmpRowSpan = bmp->getRowSpan();
unsigned int* reaperBmpBits = bmp->getBits();
juce::Image::BitmapData juceBmpData { img, juce::Image::BitmapData::readOnly };
int ls = juceBmpData.lineStride;
if (ls != (reaperBmpRowSpan * sizeof(unsigned int))) {
uint8* lineStartPtr;
w *= sizeof(unsigned int);
for (int y = 0; y < h; y++) {
lineStartPtr = juceBmpData.getLinePointer(y);
for (int x = 0; x < w; x++) {
memcpy(reaperBmpBits, lineStartPtr, w);
}
reaperBmpBits += reaperBmpRowSpan;
}
} else {
uint8* lineStartPtr;
lineStartPtr = juceBmpData.getLinePointer(0);
memcpy(reaperBmpBits, lineStartPtr, ls * h);
}
return 1;
}
return 0;
}
return 0;
}
//==============================================================================
const juce::String AudioPluginAudioProcessor::getName() const
{
return JucePlugin_Name;
}
bool AudioPluginAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool AudioPluginAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool AudioPluginAudioProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double AudioPluginAudioProcessor::getTailLengthSeconds() const { return 0.0; }
int AudioPluginAudioProcessor::getNumPrograms()
{
return 1; // NB: some hosts don't cope very well if you tell them there are 0
// programs, so this should be at least 1, even if you're not really
// implementing programs.
}
int AudioPluginAudioProcessor::getCurrentProgram() { return 0; }
void AudioPluginAudioProcessor::setCurrentProgram(int index)
{
juce::ignoreUnused(index);
}
const juce::String AudioPluginAudioProcessor::getProgramName(int index)
{
juce::ignoreUnused(index);
return {};
}
void AudioPluginAudioProcessor::changeProgramName(int index,
const juce::String& newName)
{
juce::ignoreUnused(index, newName);
}
//==============================================================================
void AudioPluginAudioProcessor::prepareToPlay(double sampleRate,
int samplesPerBlock)
{
// Use this method as the place to do any pre-playback
// initialisation that you need..
juce::ignoreUnused(sampleRate, samplesPerBlock);
}
void AudioPluginAudioProcessor::releaseResources()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
}
bool AudioPluginAudioProcessor::isBusesLayoutSupported(
const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
juce::ignoreUnused(layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
// Some plugin hosts, such as certain GarageBand versions, will only
// load plugins that support stereo bus layouts.
if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
return false;
// This checks if the input layout matches the output layout
#if !JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
return false;
#endif
return true;
#endif
}
void AudioPluginAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer,
juce::MidiBuffer& midiMessages)
{
juce::ignoreUnused(midiMessages);
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear(i, 0, buffer.getNumSamples());
// This is the place where you'd normally do the guts of your plugin's
// audio processing...
// Make sure to reset the state if your inner loop is processing
// the samples and the outer loop is handling the channels.
// Alternatively, you can process the samples with the channels
// interleaved by keeping the same state.
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
auto* channelData = buffer.getWritePointer(channel);
juce::ignoreUnused(channelData);
// ..do something to the data...
}
}
//==============================================================================
bool AudioPluginAudioProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}
juce::AudioProcessorEditor* AudioPluginAudioProcessor::createEditor()
{
return new AudioPluginAudioProcessorEditor(*this);
}
//==============================================================================
void AudioPluginAudioProcessor::getStateInformation(
juce::MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
juce::ignoreUnused(destData);
}
void AudioPluginAudioProcessor::setStateInformation(const void* data,
int sizeInBytes)
{
// You should use this method to restore your parameters from this memory
// block, whose contents will have been created by the getStateInformation()
// call.
juce::ignoreUnused(data, sizeInBytes);
}
//==============================================================================
// This creates new instances of the plugin..
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new AudioPluginAudioProcessor();
}
| [
"ray.gavin97@gmail.com"
] | ray.gavin97@gmail.com |
1e0d6d424468fd60ba67ff9dd4ab93e48f515600 | 83d52929a0708e6dd798f21fd505b2b0645cda1e | /hw/hw02/3.Power/Power.h | efe0cfb6007ffa5a7bc327fe7c9ba56a88123797 | [] | no_license | DwarKapex/algo | 49110a315e92178b69cff972dc85f7ee62a4fca5 | 17542b3d98db8103881d4bb71808b4b8016f7aa6 | refs/heads/master | 2022-12-27T14:19:05.206447 | 2020-10-17T02:25:07 | 2020-10-17T02:25:07 | 260,804,354 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 640 | h | #pragma once
#include <ITask.h>
namespace OtusAlgo {
class Power: public ITask {
public:
using IntType = uint64_t;
using FloatType = long double;
std::string Run(const ITask::DataType&) override;
virtual FloatType Calculate(FloatType a, IntType b) const = 0;
};
class PowerMultiplication: public Power {
public:
FloatType Calculate(FloatType a, IntType b) const override;
};
class Power2: public Power {
public:
FloatType Calculate(FloatType a, IntType b) const override;
};
class PowerBinary: public Power {
public:
FloatType Calculate(FloatType a, IntType b) const override;
};
} //namespace OtusAlgo
| [
"vlad.kv.2002@gmail.com"
] | vlad.kv.2002@gmail.com |
6a5335fa7881310d52509a2d07f692d847adf0e8 | c9b454b7d95cb09c21fe133b00a8ae0daf99dcc8 | /DequeEx.cpp | 305fd6aa70b59569db98fc2cb0657f66dff31e3f | [] | no_license | thiyagu86/sample_projects | 1d472aa0a8c4dcb174be42f71efc928e8b90c3d3 | d5c2c93d96d0d11e6c2fe3c0a2c1ab611f0d94ed | refs/heads/master | 2021-07-14T14:01:09.568435 | 2020-08-25T15:10:54 | 2020-08-25T15:10:54 | 199,885,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 924 | cpp | #include <iostream>
#include <deque>
#include <sys/time.h>
#include <vector>
#include <algorithm>
#define COVERT_INTO_MICROSECS 1000000
using namespace std;
int main(int argc,char** argv)
{
//Main Buffer Declaration
deque<unsigned int> dqMainBuffer;
dqMainBuffer.clear();
//Buffer Deque Declaration
deque<unsigned int> dqAuxBuffer;
dqAuxBuffer.clear();
//Fill the Main buffer with Values
for (int i=1;i< 10;i++)
{
dqMainBuffer.push_back(i);
}
// 1 UeReg
dqMainBuffer.pop_front();
//2 Ue Reg
int unTempIndex = dqMainBuffer.front();
dqMainBuffer.pop_front();
cout << "Popped Element" << unTempIndex << endl;
cout << "Next Element in Main Buffer" << dqMainBuffer.at(0) << endl;
//2 Ue DeReg
dqMainBuffer.push_front(unTempIndex);
cout << "Pushed" << unTempIndex << "to Main buffer first element is: " << dqMainBuffer.front() << endl;
}
| [
"send2thiyagu@gmail.com"
] | send2thiyagu@gmail.com |
b3e9b3cdb643d8d5b79ea0ae1b45ed70f2104474 | e4ec5b6cf3cfe2568ef0b5654c019e398b4ecc67 | /aws-sdk-cpp/1.2.10/include/aws/glue/model/GetTriggersRequest.h | 60577964ad5e0854606bcf124dbf809e41f572f2 | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | EnjoyLifeFund/macHighSierra-cellars | 59051e496ed0e68d14e0d5d91367a2c92c95e1fb | 49a477d42f081e52f4c5bdd39535156a2df52d09 | refs/heads/master | 2022-12-25T19:28:29.992466 | 2017-10-10T13:00:08 | 2017-10-10T13:00:08 | 96,081,471 | 3 | 1 | null | 2022-12-17T02:26:21 | 2017-07-03T07:17:34 | null | UTF-8 | C++ | false | false | 4,964 | h | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/
#pragma once
#include <aws/glue/Glue_EXPORTS.h>
#include <aws/glue/GlueRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
namespace Glue
{
namespace Model
{
/**
*/
class AWS_GLUE_API GetTriggersRequest : public GlueRequest
{
public:
GetTriggersRequest();
// Service request name is the Operation name which will send this request out,
// each operation should has unique request name, so that we can get operation's name from this request.
// Note: this is not true for response, multiple operations may have the same response name,
// so we can not get operation's name from response.
inline virtual const char* GetServiceRequestName() const override { return "GetTriggers"; }
Aws::String SerializePayload() const override;
Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override;
/**
* <p>A continuation token, if this is a continuation call.</p>
*/
inline const Aws::String& GetNextToken() const{ return m_nextToken; }
/**
* <p>A continuation token, if this is a continuation call.</p>
*/
inline void SetNextToken(const Aws::String& value) { m_nextTokenHasBeenSet = true; m_nextToken = value; }
/**
* <p>A continuation token, if this is a continuation call.</p>
*/
inline void SetNextToken(Aws::String&& value) { m_nextTokenHasBeenSet = true; m_nextToken = std::move(value); }
/**
* <p>A continuation token, if this is a continuation call.</p>
*/
inline void SetNextToken(const char* value) { m_nextTokenHasBeenSet = true; m_nextToken.assign(value); }
/**
* <p>A continuation token, if this is a continuation call.</p>
*/
inline GetTriggersRequest& WithNextToken(const Aws::String& value) { SetNextToken(value); return *this;}
/**
* <p>A continuation token, if this is a continuation call.</p>
*/
inline GetTriggersRequest& WithNextToken(Aws::String&& value) { SetNextToken(std::move(value)); return *this;}
/**
* <p>A continuation token, if this is a continuation call.</p>
*/
inline GetTriggersRequest& WithNextToken(const char* value) { SetNextToken(value); return *this;}
/**
* <p>The name of the job for which to retrieve triggers.</p>
*/
inline const Aws::String& GetDependentJobName() const{ return m_dependentJobName; }
/**
* <p>The name of the job for which to retrieve triggers.</p>
*/
inline void SetDependentJobName(const Aws::String& value) { m_dependentJobNameHasBeenSet = true; m_dependentJobName = value; }
/**
* <p>The name of the job for which to retrieve triggers.</p>
*/
inline void SetDependentJobName(Aws::String&& value) { m_dependentJobNameHasBeenSet = true; m_dependentJobName = std::move(value); }
/**
* <p>The name of the job for which to retrieve triggers.</p>
*/
inline void SetDependentJobName(const char* value) { m_dependentJobNameHasBeenSet = true; m_dependentJobName.assign(value); }
/**
* <p>The name of the job for which to retrieve triggers.</p>
*/
inline GetTriggersRequest& WithDependentJobName(const Aws::String& value) { SetDependentJobName(value); return *this;}
/**
* <p>The name of the job for which to retrieve triggers.</p>
*/
inline GetTriggersRequest& WithDependentJobName(Aws::String&& value) { SetDependentJobName(std::move(value)); return *this;}
/**
* <p>The name of the job for which to retrieve triggers.</p>
*/
inline GetTriggersRequest& WithDependentJobName(const char* value) { SetDependentJobName(value); return *this;}
/**
* <p>The maximum size of the response.</p>
*/
inline int GetMaxResults() const{ return m_maxResults; }
/**
* <p>The maximum size of the response.</p>
*/
inline void SetMaxResults(int value) { m_maxResultsHasBeenSet = true; m_maxResults = value; }
/**
* <p>The maximum size of the response.</p>
*/
inline GetTriggersRequest& WithMaxResults(int value) { SetMaxResults(value); return *this;}
private:
Aws::String m_nextToken;
bool m_nextTokenHasBeenSet;
Aws::String m_dependentJobName;
bool m_dependentJobNameHasBeenSet;
int m_maxResults;
bool m_maxResultsHasBeenSet;
};
} // namespace Model
} // namespace Glue
} // namespace Aws
| [
"Raliclo@gmail.com"
] | Raliclo@gmail.com |
8ed21d157c93db922fef11f84f1bf77b447725a5 | 5ec06dab1409d790496ce082dacb321392b32fe9 | /clients/cpp-qt5/generated/client/OAIComAdobeCqAuditPurgePagesProperties.cpp | e42b7248d3eab0a96188b53fda239ce9a00887a3 | [
"Apache-2.0"
] | permissive | shinesolutions/swagger-aem-osgi | e9d2385f44bee70e5bbdc0d577e99a9f2525266f | c2f6e076971d2592c1cbd3f70695c679e807396b | refs/heads/master | 2022-10-29T13:07:40.422092 | 2021-04-09T07:46:03 | 2021-04-09T07:46:03 | 190,217,155 | 3 | 3 | Apache-2.0 | 2022-10-05T03:26:20 | 2019-06-04T14:23:28 | null | UTF-8 | C++ | false | false | 6,068 | cpp | /**
* Adobe Experience Manager OSGI config (AEM) API
* Swagger AEM OSGI is an OpenAPI specification for Adobe Experience Manager (AEM) OSGI Configurations API
*
* OpenAPI spec version: 1.0.0-pre.0
* Contact: opensource@shinesolutions.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "OAIComAdobeCqAuditPurgePagesProperties.h"
#include "OAIHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace OpenAPI {
OAIComAdobeCqAuditPurgePagesProperties::OAIComAdobeCqAuditPurgePagesProperties(QString json) {
init();
this->fromJson(json);
}
OAIComAdobeCqAuditPurgePagesProperties::OAIComAdobeCqAuditPurgePagesProperties() {
init();
}
OAIComAdobeCqAuditPurgePagesProperties::~OAIComAdobeCqAuditPurgePagesProperties() {
this->cleanup();
}
void
OAIComAdobeCqAuditPurgePagesProperties::init() {
auditlog_rule_name = new OAIConfigNodePropertyString();
m_auditlog_rule_name_isSet = false;
auditlog_rule_contentpath = new OAIConfigNodePropertyString();
m_auditlog_rule_contentpath_isSet = false;
auditlog_rule_minimumage = new OAIConfigNodePropertyInteger();
m_auditlog_rule_minimumage_isSet = false;
auditlog_rule_types = new OAIConfigNodePropertyDropDown();
m_auditlog_rule_types_isSet = false;
}
void
OAIComAdobeCqAuditPurgePagesProperties::cleanup() {
if(auditlog_rule_name != nullptr) {
delete auditlog_rule_name;
}
if(auditlog_rule_contentpath != nullptr) {
delete auditlog_rule_contentpath;
}
if(auditlog_rule_minimumage != nullptr) {
delete auditlog_rule_minimumage;
}
if(auditlog_rule_types != nullptr) {
delete auditlog_rule_types;
}
}
OAIComAdobeCqAuditPurgePagesProperties*
OAIComAdobeCqAuditPurgePagesProperties::fromJson(QString json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
OAIComAdobeCqAuditPurgePagesProperties::fromJsonObject(QJsonObject pJson) {
::OpenAPI::setValue(&auditlog_rule_name, pJson["auditlog.rule.name"], "OAIConfigNodePropertyString", "OAIConfigNodePropertyString");
::OpenAPI::setValue(&auditlog_rule_contentpath, pJson["auditlog.rule.contentpath"], "OAIConfigNodePropertyString", "OAIConfigNodePropertyString");
::OpenAPI::setValue(&auditlog_rule_minimumage, pJson["auditlog.rule.minimumage"], "OAIConfigNodePropertyInteger", "OAIConfigNodePropertyInteger");
::OpenAPI::setValue(&auditlog_rule_types, pJson["auditlog.rule.types"], "OAIConfigNodePropertyDropDown", "OAIConfigNodePropertyDropDown");
}
QString
OAIComAdobeCqAuditPurgePagesProperties::asJson ()
{
QJsonObject obj = this->asJsonObject();
QJsonDocument doc(obj);
QByteArray bytes = doc.toJson();
return QString(bytes);
}
QJsonObject
OAIComAdobeCqAuditPurgePagesProperties::asJsonObject() {
QJsonObject obj;
if((auditlog_rule_name != nullptr) && (auditlog_rule_name->isSet())){
toJsonValue(QString("auditlog.rule.name"), auditlog_rule_name, obj, QString("OAIConfigNodePropertyString"));
}
if((auditlog_rule_contentpath != nullptr) && (auditlog_rule_contentpath->isSet())){
toJsonValue(QString("auditlog.rule.contentpath"), auditlog_rule_contentpath, obj, QString("OAIConfigNodePropertyString"));
}
if((auditlog_rule_minimumage != nullptr) && (auditlog_rule_minimumage->isSet())){
toJsonValue(QString("auditlog.rule.minimumage"), auditlog_rule_minimumage, obj, QString("OAIConfigNodePropertyInteger"));
}
if((auditlog_rule_types != nullptr) && (auditlog_rule_types->isSet())){
toJsonValue(QString("auditlog.rule.types"), auditlog_rule_types, obj, QString("OAIConfigNodePropertyDropDown"));
}
return obj;
}
OAIConfigNodePropertyString*
OAIComAdobeCqAuditPurgePagesProperties::getAuditlogRuleName() {
return auditlog_rule_name;
}
void
OAIComAdobeCqAuditPurgePagesProperties::setAuditlogRuleName(OAIConfigNodePropertyString* auditlog_rule_name) {
this->auditlog_rule_name = auditlog_rule_name;
this->m_auditlog_rule_name_isSet = true;
}
OAIConfigNodePropertyString*
OAIComAdobeCqAuditPurgePagesProperties::getAuditlogRuleContentpath() {
return auditlog_rule_contentpath;
}
void
OAIComAdobeCqAuditPurgePagesProperties::setAuditlogRuleContentpath(OAIConfigNodePropertyString* auditlog_rule_contentpath) {
this->auditlog_rule_contentpath = auditlog_rule_contentpath;
this->m_auditlog_rule_contentpath_isSet = true;
}
OAIConfigNodePropertyInteger*
OAIComAdobeCqAuditPurgePagesProperties::getAuditlogRuleMinimumage() {
return auditlog_rule_minimumage;
}
void
OAIComAdobeCqAuditPurgePagesProperties::setAuditlogRuleMinimumage(OAIConfigNodePropertyInteger* auditlog_rule_minimumage) {
this->auditlog_rule_minimumage = auditlog_rule_minimumage;
this->m_auditlog_rule_minimumage_isSet = true;
}
OAIConfigNodePropertyDropDown*
OAIComAdobeCqAuditPurgePagesProperties::getAuditlogRuleTypes() {
return auditlog_rule_types;
}
void
OAIComAdobeCqAuditPurgePagesProperties::setAuditlogRuleTypes(OAIConfigNodePropertyDropDown* auditlog_rule_types) {
this->auditlog_rule_types = auditlog_rule_types;
this->m_auditlog_rule_types_isSet = true;
}
bool
OAIComAdobeCqAuditPurgePagesProperties::isSet(){
bool isObjectUpdated = false;
do{
if(auditlog_rule_name != nullptr && auditlog_rule_name->isSet()){ isObjectUpdated = true; break;}
if(auditlog_rule_contentpath != nullptr && auditlog_rule_contentpath->isSet()){ isObjectUpdated = true; break;}
if(auditlog_rule_minimumage != nullptr && auditlog_rule_minimumage->isSet()){ isObjectUpdated = true; break;}
if(auditlog_rule_types != nullptr && auditlog_rule_types->isSet()){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}
| [
"cliffano@gmail.com"
] | cliffano@gmail.com |
91c4552c5c4f0e2192767ff81caf1f8db2551117 | cfec910d55e239f2f5fd29bd830dc32ad383c717 | /EngineLayer/SFProtobufProtocol.cpp | f98c9e1b024f87262e48abd53ba235e4da2cc7b9 | [] | no_license | pdpdds/cgsf2019 | a7aef9ac29fde63125e80ef433f7b75b5f9c3841 | 9156cb79386e1d261b107b75339ce02e834daf55 | refs/heads/master | 2022-07-08T22:03:30.220719 | 2022-06-30T10:02:27 | 2022-06-30T10:02:27 | 214,360,553 | 8 | 0 | null | 2022-06-30T10:02:53 | 2019-10-11T06:30:39 | C++ | UTF-8 | C++ | false | false | 7,543 | cpp | #include "stdafx.h"
#include "SFProtobufProtocol.h"
#include "SFProtobufPacketImpl.h"
#include <EngineInterface/ISession.h>
#include "SFEngine.h"
#pragma warning (disable : 4100)
#define SignatureStart 16018
#define SignatureEnd 16108
#define nReceiveBufferSize 1024 * 8/*8192*/
#define nSendBufferSize 1024 * 8/*8192*/
SFProtobufProtocol::SFProtobufProtocol(void)
:oBuffer(nSendBufferSize), m_Buffer(nReceiveBufferSize)
{
}
SFProtobufProtocol::~SFProtobufProtocol(void)
{
}
bool SFProtobufProtocol::Initialize(int ioBufferSize, unsigned short packetSize, int packetOption)
{
m_ioSize = ioBufferSize;
m_packetSize = packetSize;
m_packetOption = packetOption;
return true;
}
bool SFProtobufProtocol::AddTransferredData(char* pBuffer, DWORD dwTransferred)
{
return m_Buffer.Append(pBuffer, dwTransferred);
}
bool SFProtobufProtocol::Reset()
{
return true;
}
bool SFProtobufProtocol::Encode(BasePacket* pPacket, char** ppBuffer, int& bufferSize)
{
unsigned int uWrittenBytes = 0;
int iResult = serializeOutgoingPacket(*pPacket, oBuffer, uWrittenBytes);
if (iResult != SFProtocol::Success)
{
return false;
}
unsigned int uSize = oBuffer.GetDataSize();
oBuffer.Pop(uSize);
*ppBuffer = oBuffer.GetBuffer();
bufferSize = uSize;
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
int SFProtobufProtocol::decodeIncomingPacket(BasePacket* pPacket, int& serviceId)
{
return SFProtocol::Success;
}
void SFProtobufProtocol::disposeOutgoingPacket(BasePacket* pPacket)
{
delete pPacket;
}
void SFProtobufProtocol::disposeIncomingPacket(BasePacket* pPacket)
{
delete pPacket;
}
bool SFProtobufProtocol::DisposePacket(BasePacket* pPacket)
{
delete pPacket;
return true;
}
BasePacket* SFProtobufProtocol::GetPacket(int& ErrorCode)
{
//The Processing Loop.
int uCommandID;
BasePacket* pPacket = NULL;
int iResult;
unsigned int uExtractedBytes;
ErrorCode = 0;
//watch.GetElapsedTime(false);
iResult = tryDeserializeIncomingPacket(m_Buffer, pPacket, uCommandID, uExtractedBytes);
//iResult = pProtocol->tryDeframeIncomingPacket(pChannel->GetReceiveBuffer().GetBuffer(), pChannel->GetReceiveBuffer().GetDataSize(),uCommandID, pPacket, uExtractedBytes);
//wcout << L"Packet deframed : " << watch.GetElapsedTime(false) << std::endl;
if (iResult == SFProtocol::Success)
{
m_Buffer.Pop(uExtractedBytes);
pPacket->SetPacketID(uCommandID);
}
else if (iResult == SFProtocol::eDecodingFailure)
{
m_Buffer.Pop(uExtractedBytes);
ErrorCode = -1;
return NULL;
}
return pPacket;
}
int SFProtobufProtocol::encodeOutgoingPacket(BasePacket& packet)
{
SFProtobufPacketImpl& gPacket = (SFProtobufPacketImpl&)packet;
return gPacket.Encode() ? SFProtocol::Success : SFProtocol::eEncodingFailure;
}
#ifdef PROTOBUF_PACKET_EXTENTION
int SFProtobufProtocol::tryDeframeIncomingPacket(DataBuffer& Buffer, BasePacket*& pPacket, int& packetId, unsigned int& nExtractedBytes)
{
if (Buffer.GetDataSize() < 8)
return SFProtocol::eIncompletePacket;
char* pBuffer = Buffer.GetBuffer();
unsigned int sStart = 0;
unsigned int packetLen = 0;
packetId = 0;
unsigned int extendedDataLen = 0;
unsigned int sEnd = 0;
for (int i = 0; i<2; i++)
{
*((BYTE*)(&sStart) + i) = pBuffer[i];
*((BYTE*)(&packetLen) + i) = pBuffer[i + 2];
*((BYTE*)(&packetId) + i) = pBuffer[i + 4];
*((BYTE*)(&extendedDataLen) + i) = pBuffer[i + 6];
}
if (sStart != SignatureStart)
return SFProtocol::eCorruptPacket;
if (packetLen > Buffer.GetDataSize())
return SFProtocol::eIncompletePacket;
for (int i = 0; i<2; i++)
*((BYTE*)(&sEnd) + i) = pBuffer[packetLen - 2 + i];
if (sEnd != SignatureEnd)
return SFProtocol::eCorruptPacket;
char* pData = pBuffer + 8;
int dataSize = packetLen - 10 - extendedDataLen;
if (dataSize <= 0)
return SFProtocol::eCorruptPacket;
nExtractedBytes = packetLen;
pPacket = CreateIncomingPacketFromPacketId(packetId);
SFProtobufPacketImpl& gPacket = (SFProtobufPacketImpl&)(*pPacket);
if (pPacket == NULL)
return SFProtocol::eUndefinedFailure;
if (!pPacket->Decode(pData, dataSize))
{
disposeIncomingPacket(pPacket);
return SFProtocol::eDecodingFailure;
}
pData = pBuffer + 8 + dataSize;
if (extendedDataLen > 0)
{
gPacket.getExtendedData()->Append(pData, extendedDataLen);
}
return SFProtocol::Success;
}
int SFProtobufProtocol::frameOutgoingPacket(BasePacket& packet, DataBuffer& buffer, unsigned int& nWrittenBytes)
{
SFProtobufPacketImpl& gPacket = (SFProtobufPacketImpl&)packet;
nWrittenBytes = (unsigned int)(8 + gPacket.getEncodedStream()->size() + gPacket.getExtendedDataSize() + 2);
if (nWrittenBytes > buffer.getRemainingSize())
return SFProtocol::eInsufficientBuffer;
//
unsigned int sStart = SignatureStart;
unsigned int extendedDataSize = gPacket.getExtendedDataSize();
unsigned int packetLen = gPacket.getEncodedStreamSize() + 10 + extendedDataSize;
unsigned int commandID = gPacket.getServiceId();
unsigned int sEnd = SignatureEnd;
buffer.Append((char*)&sStart, 2);
buffer.Append((char*)&packetLen, 2);
buffer.Append((char*)&commandID, 2);
buffer.Append((char*)&extendedDataSize, 2);
buffer.Append((char*)gPacket.getEncodedStream()->c_str(), gPacket.getEncodedStreamSize());
buffer.Append((char*)gPacket.getExtendedData()->GetBuffer(), gPacket.getExtendedDataSize());
buffer.Append((char*)&sEnd, 2);
return SFProtocol::Success;
}
#else
int SFProtobufProtocol::tryDeframeIncomingPacket(DataBuffer& Buffer, BasePacket*& pPacket, int& packetId, unsigned int& nExtractedBytes)
{
if (Buffer.GetDataSize() < 8)
return SFProtocol::eIncompletePacket;
char* pBuffer = Buffer.GetBuffer();
unsigned int sStart = 0;
unsigned int packetLen = 0;
packetId = 0;
unsigned int sEnd = 0;
for (int i = 0; i<2; i++)
{
*((BYTE*)(&sStart) + i) = pBuffer[i];
*((BYTE*)(&packetLen) + i) = pBuffer[i + 2];
*((BYTE*)(&packetId) + i) = pBuffer[i + 4];
}
if (sStart != SignatureStart)
return SFProtocol::eCorruptPacket;
if (packetLen > Buffer.GetDataSize())
return SFProtocol::eIncompletePacket;
for (int i = 0; i < 2; i++)
*((BYTE*)(&sEnd) + i) = pBuffer[packetLen - 2 + i];
if (sEnd != SignatureEnd)
return SFProtocol::eCorruptPacket;
char* pData = pBuffer + 6;
unsigned int dataSize = packetLen - 8;
nExtractedBytes = packetLen;
pPacket = CreateIncomingPacketFromPacketId(packetId);
if (pPacket == NULL)
return SFProtocol::eUndefinedFailure;
if (!pPacket->Decode(pData, dataSize))
{
disposeIncomingPacket(pPacket);
return SFProtocol::eDecodingFailure;
}
return SFProtocol::Success;
}
int SFProtobufProtocol::frameOutgoingPacket(BasePacket& packet, DataBuffer& buffer, unsigned int& nWrittenBytes)
{
SFProtobufPacketImpl& gPacket = (SFProtobufPacketImpl&)packet;
nWrittenBytes = (unsigned int)(6 + gPacket.getEncodedStream()->size() + 2);
if (nWrittenBytes > buffer.getRemainingSize())
return SFProtocol::eInsufficientBuffer;
//
unsigned int sStart = SignatureStart;
unsigned int packetLen = gPacket.getEncodedStreamSize() + 8;
unsigned int commandID = gPacket.getServiceId();
unsigned int sEnd = SignatureEnd;
buffer.Append((char*)&sStart, 2);
buffer.Append((char*)&packetLen, 2);
buffer.Append((char*)&commandID, 2);
buffer.Append((char*)gPacket.getEncodedStream()->c_str(), gPacket.getEncodedStreamSize());
buffer.Append((char*)&sEnd, 2);
return SFProtocol::Success;
}
#endif | [
"juhang3@daum.net"
] | juhang3@daum.net |
7be007e533fadeb25aab30c2163d2ef23f1ad107 | 2c93c789e2c7d4ad9e5104b98b0fb80ad69a2307 | /tools/Revitalize/seance/test/imports/funcs/charToUpper.cpp | 6bb52f9493685db221a0e21a0cff83725218c735 | [] | no_license | jkoppel/project-ironfist | 4faeaf8616084abe76696f4085776f26ff6ce212 | 0f8651d4305a4f982af8e43269dd6a8d7f86464d | refs/heads/master | 2023-05-26T09:14:29.594446 | 2023-05-11T07:11:28 | 2023-05-11T07:11:28 | 24,222,392 | 35 | 19 | null | 2023-05-11T04:52:17 | 2014-09-19T08:34:00 | Assembly | UTF-8 | C++ | false | false | 121 | cpp | {
char result; // al@3
if ( a1 < 'a' || a1 > 'z' )
result = a1;
else
result = a1 - 32;
return result;
}
| [
"kertwaii@gmail.com"
] | kertwaii@gmail.com |
d971c03fe857e4a8e2d751320887cbe4861ae0ff | b138ade73713fd8e2e64643ae2f7adb0b3e1b27a | /backtracking/Permutations II/Permutations II/stdafx.cpp | e29bccabac503e54a211967986ba323abee9dcb2 | [] | no_license | MF1523017/leetcode_self | 93529cb667091b025097b4882183a043052b1bed | 404413d35f39797611b1da7e69580c91d67d68ce | refs/heads/master | 2021-01-13T11:18:13.044270 | 2017-05-15T06:43:30 | 2017-05-15T06:43:30 | 76,948,531 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 266 | cpp | // stdafx.cpp : 只包括标准包含文件的源文件
// Permutations II.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
//而不是在此文件中引用
| [
"李培"
] | 李培 |
03ccf3af7e50bc1a186db959f13496d4f19fcae4 | 6debdf46efa2d21882607240fe8233be29ff4381 | /src/bitsplit.cpp | f1951cb9e22dc07a865441611c808926d8be97c2 | [] | no_license | maciek-slon/KODA | ebc1856e3a258b4e24bf8bd4046d98b20e0e7397 | 8d672101b839b112b3b4069efdb37f31dc5796a6 | refs/heads/master | 2020-03-30T01:53:22.184046 | 2011-01-27T12:38:40 | 2011-01-27T12:38:40 | 1,274,030 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,276 | cpp | /*!
* \file
* \brief
*/
#include <iostream>
#include <vector>
#include <cv.h>
#include <highgui.h>
cv::Mat getBitPlane(const cv::Mat & img, int plane) {
if (img.channels() != 1) {
std::cout << "getBitPlane: img must be one channel!\n";
return cv::Mat();
}
cv::Mat result = img.clone();
cv::Size size = img.size();
int mask = 1 << plane;
if (img.isContinuous() && result.isContinuous()) {
size.width *= size.height;
size.height = 1;
}
for (int y = 0; y < size.height; ++y) {
const uchar* img_p = img.ptr <uchar> (y);
uchar* res_p = result.ptr <uchar> (y);
for (int x = 0; x < size.width; ++x) {
res_p[x] = (img_p[x] & mask) ? 255 : 0;
}
}
return result;
}
int main(int argc, char * argv[]) {
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " IMAGE" << std::endl;
return 0;
}
cv::Mat img = cv::imread(argv[1], -1);
if (img.empty()) {
std::cout << "Can't load image from file: " << argv[1] << std::endl;
return 0;
}
if (img.channels() != 1) {
std::cout << "Image should have 1 channel!" << std::endl;
return 0;
}
std::string name = argv[1];
name = name.substr(0, name.find_first_of('.')) + '_';
for (int p = 0; p < 8; ++p)
imwrite(name + (char)(p+'0') + ".bmp", getBitPlane(img, p));
return 0;
}
| [
"maciek.slon@gmail.com"
] | maciek.slon@gmail.com |
6b5144bcd48d248f9a9d6a3a63ddbf7e56cca019 | e2847929f485edb74dda23e63dff0b59e93998d2 | /0774.minimize-max-distance-to-gas-station/minimize-max-distance-to-gas-station.cpp | f9b8855c9fd803f8b76af578c029c4b0fdab0e7a | [] | no_license | hbsun2113/LeetCodeCrawler | 36b068641fa0b485ac51c2cd151498ce7c27599f | 43507e04eb41160ecfd859de41fd42d798431d00 | refs/heads/master | 2020-05-23T21:11:32.158160 | 2019-10-18T07:20:39 | 2019-10-18T07:20:39 | 186,947,546 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 693 | cpp | class Solution {
public:
// https://leetcode.com/problems/minimize-max-distance-to-gas-station/discuss/113633/C++JavaPython-Binary-Search
double minmaxGasDist(vector<int>& stations, int K) {
if(stations.empty()) return 0;
double l=0,r=stations.back()-stations[0]; // ???????????D
while(l+1e-6<r){ // ?????1e-6
double mid=(l+r)/2.00;
int cnt=0;
for(int i=0;i+1<stations.size();i++){
cnt+=ceil((stations[i+1]-stations[i])/mid)-1; // ???[1,6],??mid=2
}
if(cnt<=K) r=mid; // ?????????????:cnt==K??????????????????(smallest)?mid
else l=mid;
}
return r;
}
}; | [
"sun710467272@outlook.com"
] | sun710467272@outlook.com |
910f3761e232cc3f21a8ce2da6d7e8a9b714fae3 | 96bb53a0237b720dbb56b287e2eb754d57819539 | /09 Assignment - Using References.cpp | d3aa3e0afda8d66d1c200b5814ca61a7c7376161 | [] | no_license | ZinGitHub/09-Assignment---Using-References-to-hack-and-Bankrupting-the-terrorists | 1de64a68d301bd7f3762bdf8066b8606ba2f6f41 | 5c5c21265dcc39d813b98c09b866f6eac68a4241 | refs/heads/master | 2020-05-03T17:57:24.049647 | 2019-03-31T23:31:36 | 2019-03-31T23:31:36 | 178,753,409 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,140 | cpp | #include <iostream>
using namespace std;
// All the function prototypes.
void safeTransaction(int x, int y);
void hackedTransaction(int& x, int& y);
void ScreenFormat();
int main()
{
// Changes the title of the program to NSA Agent Interactive Story.
system("title Hacking and Bankrupting Terrorists");
// Changes the background to black and the font color green.
system("color 0A");
// Integer value of terroristAccount.
int terroristAccount = 1000000;
// Integer value of whiteHatHackerAccount.
int whiteHatHackerAccount = 0;
// cout statement stating the status of the original values.
cout << "original values\n";
// cout statement for the original value of the terrorist account (terroristAccount).
cout << "Terrorist Account: " << terroristAccount << "\n";
// cout statement for the original value of the white hat hacker account (whiteHatHackerAccount).
cout << "White Hat Hacker Account: " << whiteHatHackerAccount << "\n";
// Function in charge of formatting the screen.
ScreenFormat(); // FUNCTION CALL.
// cout statement stating money is being transferred securely to terrorists.
cout << "Terrorists account securely transfering money...\n";
// cout statement stating the money transaction has been completed.
cout << "Money transaction to terrorist account complete.\n";
// Function in charge of the safe transaction (safeTransaction).
safeTransaction(terroristAccount, whiteHatHackerAccount); // FUNCTION CALL.
// cout statement for the value of the terrorist account (terroristAccount) when the safe transaction occurs.
cout << "Terrorist Account: " << terroristAccount + 500 << "\n";
// cout statement for the value of the white hat hacker account (whiteHatHackerAccount) when the safe transaction occurs.
cout << "White Hat Hacker Accout: " << whiteHatHackerAccount << "\n\n";
// Function in charge of formatting the screen.
ScreenFormat(); // FUNCTION CALL.
// cout statement stating that the white hat hacker and terrorist are switching all transactions.
cout << "Switching all transactions between white hat hacker and terrorist...\n";
// cout statement stating that transaction between the white hat hacker and terrorist is complete.
cout << "Money transaction between white hat hacker and terrorist complete.\n";
// Skull ASCII.
cout << "\t\t\t \n\n";
cout << "\t\t\t uu$$$$$$$$$$$uu \n\n";
cout << "\t\t\t uu$$$$$$$$$$$$$$$$$uu \n\n";
cout << "\t\t\t u$$$$$$$$$$$$$$$$$$$$$u \n\n";
cout << "\t\t\t u$$$$$$$$$$$$$$$$$$$$$$$u \n\n";
cout << "\t\t\t u$$$$$$$$$$$$$$$$$$$$$$$$$u \n\n";
cout << "\t\t\t u$$$$$$$$$$$$$$$$$$$$$$$$$u \n\n";
cout << "\t\t\t u$$$$$$" "$$$" "$$$$$$u \n\n";
cout << "\t\t\t $$$$ u$u $$$$ \n\n";
cout << "\t\t\t $$$u u$u u$$$ \n\n";
cout << "\t\t\t $$$u u$$$u u$$$ \n\n";
cout << "\t\t\t $$$$uu$$$ $$$uu$$$$ \n\n";
cout << "\t\t\t $$$$$$$ $$$$$$$ \n\n";
cout << "\t\t\t u$$$$$$$u$$$$$$$u \n\n";
cout << "\t\t\t u$ $ $ $ $ $ $u \n\n";
cout << "\t\t\t uuu $$u$ $ $ $ $u$$ uuu \n\n";
cout << "\t\t\t u$$$$ $$$$$u$u$u$$$ u$$$$ \n\n";
cout << "\t\t\t $$$$$uu $$$$$$$$$ uu$$$$$$ \n\n";
cout << "\t\t\t u$$$$$$$$$$$uu uuuu$$$$$$$$$$ \n\n";
cout << "\t\t\t $$$$$$$$$$$$$$$$$uuu uu$$$$$$$$$$$$$$ \n\n";
cout << "\t\t\t $$$$$$$$$$$uu$$$$ \n\n";
cout << "\t\t\t uuuu$$$$$$$$$$$$$uuu \n\n";
cout << "\t\t\t u$$$uuu$$$$$$$$$uu $$$$$$$$$$$uuu$$$ \n\n";
cout << "\t\t\t $$$$$$$$$$ $$$$$$$$$$$ \n\n";
cout << "\t\t\t $$$$$ $$$$ \n\n";
cout << "\t\t\t $$$ $$$$ \n\n";
// Function in charge of the hacked transaction (hackedTransaction).
hackedTransaction(terroristAccount, whiteHatHackerAccount); // FUNCTION CALL.
// cout statement for the value of the terrorist account (terroristAccount) when the hacked transaction occurs.
cout << "Terrorist Account: " << terroristAccount << "\n";
// cout statement for the value of central terrorists account (centralTerroristsAccount) when the hacked transaction occurs.
cout << "White Hat Hacker Account: " << whiteHatHackerAccount + 500 << "\n";
// Function in charge of formatting the screen.
ScreenFormat(); // FUNCTION CALL.
// Prevents the program from just running and not showing the user the console box.
system("pause");
// A exit number for the program. If zero is returned at the of the program, then the program ran successfully.
return 0;
}
// Function definition of safeTransaction.
void safeTransaction(int x, int y)
{
// int value is temporarily equal to x.
int temp = x;
// the value of x now equals the value of y.
x = y;
// the value of y now equals the value temp (tempoarily).
y = temp;
}
// Function definition of hackedTransaction.
void hackedTransaction(int& x, int& y) // REFERENCES FOR INT X AND INT Y.
{
// int value is temporarily equal to x.
int temp = x;
// the value of x now equals the value of y.
x = y;
// the value of y now equals the value temp (tempoarily).
y = temp;
}
// Function definition of ScreenFormat.
void ScreenFormat()
{
// cout used in formatting.
cout << "=====================================================================================================================\n";
cout << "=====================================================================================================================\n";
cout << "=====================================================================================================================\n";
}
| [
"noreply@github.com"
] | noreply@github.com |
0b958df01451084ecb6e64812e7f1b04ffe68a69 | 786de89be635eb21295070a6a3452f3a7fe6712c | /PSQt/tags/V00-00-06/src/WdgGeoTree.cpp | 4bc8e60d6183dac30c4d77d68c25bef83969a549 | [] | no_license | connectthefuture/psdmrepo | 85267cfe8d54564f99e17035efe931077c8f7a37 | f32870a987a7493e7bf0f0a5c1712a5a030ef199 | refs/heads/master | 2021-01-13T03:26:35.494026 | 2015-09-03T22:22:11 | 2015-09-03T22:22:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,744 | cpp | //--------------------------
#include "PSQt/WdgGeoTree.h"
#include "PSQt/QGUtils.h"
#include "PSQt/Logger.h"
//#include <string>
//#include <fstream> // ofstream
//#include <iomanip> // for setw, setfill
//#include <math.h>
//#include <stdio.h>
#include <sstream> // for stringstream
#include <iostream> // cout
#include <fstream> // ifstream(fname), ofstream
//#include <dirent.h> // for DIR, dirent
//using namespace std; // for cout without std::
namespace PSQt {
//--------------------------
WdgGeoTree::WdgGeoTree(QWidget *parent, const std::string& gfname, const unsigned& pbits) //, const std::string& gfname, const unsigned& pbits)
: Frame(parent)
, m_pbits(pbits)
{
m_geotree = new GeoTree(parent,gfname,m_pbits);
m_view = (QTreeView*) m_geotree;
QVBoxLayout *vbox = new QVBoxLayout();
vbox -> addWidget(m_view);
setLayout(vbox);
//move(100,50);
this -> setContentsMargins(-9,-9,-9,-9);
showTips();
}
//--------------------------
PSCalib::GeometryAccess*
WdgGeoTree::geoacc()
{
return m_geotree->geoacc();
}
//--------------------------
void
WdgGeoTree::showTips()
{
//m_file_geo -> setToolTip("Select \"geometry\" file");
//m_file_geo -> setToolTip("Select ndarray with image file");
//m_but_exit -> setToolTip("Exit application");
}
//--------------------------
void
WdgGeoTree::resizeEvent(QResizeEvent *event)
{
stringstream ss; ss << "w:" << event->size().width() << " h:" << event->size().height();
setWindowTitle(ss.str().c_str());
}
//--------------------------
void
WdgGeoTree::moveEvent(QMoveEvent *event)
{
stringstream ss; ss << "x:" << event->pos().x() << " y:" << event->pos().y();
setWindowTitle(ss.str().c_str());
}
//--------------------------
void
WdgGeoTree::closeEvent(QCloseEvent *event)
{
QWidget::closeEvent(event);
std::stringstream ss; ss << "closeEvent(...): type = " << event -> type();
MsgInLog(_name_(), INFO, ss.str());
}
//--------------------------
void
WdgGeoTree::mousePressEvent(QMouseEvent *event)
{
//int x = event->pos().x();
//int y = event->pos().y();
//QString text = "mousePressEvent: " + QString::number(x) + "," + QString::number(y);
//std::cout << text.toStdString() << std::endl;
}
//--------------------------
//--------------------------
//--------------------------
//--------------------------
//--------------------------
GeoTree::GeoTree(QWidget *parent, const std::string& gfname, const unsigned& pbits)
: QTreeView(parent)
, m_gfname(gfname)
, m_pbits(pbits)
, m_model(0)
, m_geoacc(0)
// : Frame(parent)
// : QWidget(parent)
{
if (m_pbits & 1) MsgInLog(_name_(), INFO, "In c-tor");
//setGeometry(100, 100, 200, 300);
setWindowTitle("Geo selection tree");
makeTreeModel();
m_view = this;
//m_view = new QTreeView();
m_view->setModel(m_model);
m_view->setAnimated(true);
m_view->setHeaderHidden(true);
m_view->expandAll();
//m_view->setMinimumWidth(200);
//QVBoxLayout *vbox = new QVBoxLayout();
//vbox -> addWidget(m_view);
//setLayout(vbox);
//move(100,50);
//connect(this, SIGNAL(selectedText(const std::string&)), this, SLOT(testSignalString(const std::string&)));
if(m_pbits & 4) connect(this, SIGNAL(selectedGO(shpGO&)), this, SLOT(testSignalGO(shpGO&)));
if(m_pbits & 4) connect(this, SIGNAL(collapsed(const QModelIndex&)), this, SLOT(testSignalCollapsed(const QModelIndex&)));
if(m_pbits & 4) connect(this, SIGNAL(expanded(const QModelIndex&)), this, SLOT(testSignalExpanded(const QModelIndex&)));
}
//--------------------------
void
GeoTree::makeTreeModel()
{
if ( m_model == 0 ) {
m_model = new QStandardItemModel();
//m_model->setHorizontalHeaderLabels(QStringList(QString('o')));
updateTreeModel(m_gfname);
}
}
//--------------------------
bool
GeoTree::loadGeometry(const std::string& gfname)
{
if (!file_exists(gfname)) {
stringstream ss; ss << "Geometry file \"" << gfname << "\" does not exist";
MsgInLog(_name_(), WARNING, ss.str());
return false;
}
if (! m_geoacc) delete m_geoacc;
m_geoacc = new PSCalib::GeometryAccess(gfname);
if (m_pbits & 2) m_geoacc->print_list_of_geos();
return true;
}
//--------------------------
void
GeoTree::updateTreeModel(const std::string& gfname)
{
//if(m_pbits & 4)
//std::cout << "updateTreeModel for file: " << gfname << '\n';
MsgInLog(_name_(), INFO, std::string("Update geometry-tree model for file: ") + gfname);
if(! loadGeometry(gfname)) return;
m_model->clear();
map_item_to_geo.clear();
map_geo_to_item.clear();
fillTreeModel(shpGO(),0,0,m_pbits);
//fillTreeModelTest();
//m_view->expandAll();
expandAll();
}
//--------------------------
void
GeoTree::fillTreeModel( shpGO geo_add
, QStandardItem* parent
, const unsigned& level
, const unsigned& pbits )
{
shpGO geo = (geo_add != shpGO()) ? geo_add : m_geoacc->get_top_geo();
QStandardItem* item_parent = (parent) ? parent : m_model->invisibleRootItem();
stringstream ss; ss << geo->get_geo_name() << "." << geo->get_geo_index();
std::string iname = ss.str();
QStandardItem* item_add = new QStandardItem(iname.c_str());
item_parent->appendRow(item_add);
map_item_to_geo[item_add] = geo;
map_geo_to_item[shpGO()] = item_add;
std::vector<shpGO> list = geo->get_list_of_children();
if(pbits & 1) {stringstream ss; ss << "==== Add item: \"" << iname << "\" number of children:" << list.size();}
if (list.size()) {
if(pbits & 1) ss << " add as a group\n";
//if (parent) item_add->setCheckable(true);
for(std::vector<shpGO>::iterator it=list.begin(); it!= list.end(); ++ it) {
//if(pbits & 2) cout << " add child from the list: " << (*it)->get_geo_name() << '/n';
fillTreeModel(*it, item_add, level+1, pbits);
}
}
else {
if(pbits & 1) {ss << " add as a set\n";
//item_add->setIcon(icon);
//item_add->setCheckable(true);
MsgInLog(_name_(), INFO, ss.str());
}
return;
}
if(pbits & 1) MsgInLog(_name_(), INFO, ss.str());
}
//--------------------------
void
GeoTree::fillTreeModelTest()
{
QStandardItem* item_parent = m_model->invisibleRootItem();
QStandardItem* item1 = new QStandardItem("item1");
QStandardItem* item2 = new QStandardItem("item2");
QStandardItem* item3 = new QStandardItem("item3");
item_parent->appendRow(item1);
item_parent->appendRow(item2);
item_parent->appendRow(item3);
QStandardItem* item31 = new QStandardItem("item31");
QStandardItem* item32 = new QStandardItem("item32");
item3->appendRow(item31);
item3->appendRow(item32);
}
//--------------------------
void
GeoTree::currentChanged(const QModelIndex & index, const QModelIndex & index_old)
{
//std::cout << "currentChanged:: new r:" << index.row() << " c:" << index.column()
// << " old r:" << index_old.row() << " c:" << index_old.column() << '\n';
QStandardItem *item = m_model->itemFromIndex(index);
std::string str(item->text().toStdString());
//if(m_pbits & 4) {
// stringstream ss; ss << "currentChanged::item"
// << " r:" << item->row()
// << " c:" << item->column()
// << " a:" << item->accessibleText().toStdString()
// << " t:" << str; }
MsgInLog(_name_(), INFO, "Selected item: " + str + " emit signal");
//emit selectedText(str);
emit selectedGO(map_item_to_geo[item]);
}
//--------------------------
void
GeoTree::testSignalString(const std::string& str)
{
MsgInLog(_name_(), INFO, std::string("GeoTree::testSignalString(string): str = ") + str);
}
//--------------------------
void
GeoTree::testSignalGO(shpGO& geo)
{
stringstream ss; ss << "GeoTree::testSignalGO(shpGO): "; // << geo.get()->get_geo_name() << ' ' << geo.get()->get_geo_index() << '\n'; // geo.get()->print_geo();
ss << geo->string_geo();
MsgInLog(_name_(), INFO, ss.str());
}
//--------------------------
void
GeoTree::testSignalCollapsed(const QModelIndex& index)
{
stringstream ss; ss << "GeoTree::testSignalCollapsed(shpGO): row:" << index.row() << " col:" << index.column();
MsgInLog(_name_(), INFO, ss.str());
}
//--------------------------
void
GeoTree::testSignalExpanded(const QModelIndex& index)
{
stringstream ss; ss << "GeoTree::testSignalExpanded(shpGO): row:" << index.row() << " col:" << index.column();
MsgInLog(_name_(), INFO, ss.str());
}
//--------------------------
//--------------------------
//--------------------------
//--------------------------
//--------------------------
//--------------------------
} // namespace PSQt
//--------------------------
| [
"dubrovin@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7"
] | dubrovin@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7 |
91cc83ea3bea2072ff295d3d06223b155b1f0cba | ed10dc841d5b4f6a038e8f24f603750992d9fae9 | /clang/lib/Driver/Driver.cpp | afa79660fd0fdda202017f81206b7683d53dc130 | [
"Apache-2.0",
"LLVM-exception",
"NCSA"
] | permissive | WYK15/swift-Ollvm10 | 90c2f0ade099a1cc545183eba5c5a69765320401 | ea68224ab23470963b68dfcc28b5ac769a070ea3 | refs/heads/main | 2023-03-30T20:02:58.305792 | 2021-04-07T02:41:01 | 2021-04-07T02:41:01 | 355,189,226 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 196,243 | cpp | //===--- Driver.cpp - Clang GCC Compatible Driver -------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "clang/Driver/Driver.h"
#include "InputInfo.h"
#include "ToolChains/AIX.h"
#include "ToolChains/AMDGPU.h"
#include "ToolChains/AVR.h"
#include "ToolChains/Ananas.h"
#include "ToolChains/BareMetal.h"
#include "ToolChains/Clang.h"
#include "ToolChains/CloudABI.h"
#include "ToolChains/Contiki.h"
#include "ToolChains/CrossWindows.h"
#include "ToolChains/Cuda.h"
#include "ToolChains/Darwin.h"
#include "ToolChains/DragonFly.h"
#include "ToolChains/FreeBSD.h"
#include "ToolChains/Fuchsia.h"
#include "ToolChains/Gnu.h"
#include "ToolChains/HIP.h"
#include "ToolChains/Haiku.h"
#include "ToolChains/Hexagon.h"
#include "ToolChains/Hurd.h"
#include "ToolChains/Lanai.h"
#include "ToolChains/Linux.h"
#include "ToolChains/MSP430.h"
#include "ToolChains/MSVC.h"
#include "ToolChains/MinGW.h"
#include "ToolChains/Minix.h"
#include "ToolChains/MipsLinux.h"
#include "ToolChains/Myriad.h"
#include "ToolChains/NaCl.h"
#include "ToolChains/NetBSD.h"
#include "ToolChains/OpenBSD.h"
#include "ToolChains/PS4CPU.h"
#include "ToolChains/PPCLinux.h"
#include "ToolChains/RISCVToolchain.h"
#include "ToolChains/Solaris.h"
#include "ToolChains/TCE.h"
#include "ToolChains/WebAssembly.h"
#include "ToolChains/XCore.h"
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptSpecifier.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
#include <memory>
#include <utility>
#if LLVM_ON_UNIX
#include <unistd.h> // getpid
#include <sysexits.h> // EX_IOERR
#endif
using namespace clang::driver;
using namespace clang;
using namespace llvm::opt;
// static
std::string Driver::GetResourcesPath(StringRef BinaryPath,
StringRef CustomResourceDir) {
// Since the resource directory is embedded in the module hash, it's important
// that all places that need it call this function, so that they get the
// exact same string ("a/../b/" and "b/" get different hashes, for example).
// Dir is bin/ or lib/, depending on where BinaryPath is.
std::string Dir = llvm::sys::path::parent_path(BinaryPath);
SmallString<128> P(Dir);
if (CustomResourceDir != "") {
llvm::sys::path::append(P, CustomResourceDir);
} else {
// On Windows, libclang.dll is in bin/.
// On non-Windows, libclang.so/.dylib is in lib/.
// With a static-library build of libclang, LibClangPath will contain the
// path of the embedding binary, which for LLVM binaries will be in bin/.
// ../lib gets us to lib/ in both cases.
P = llvm::sys::path::parent_path(Dir);
llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
CLANG_VERSION_STRING);
}
return P.str();
}
Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
: Diags(Diags), VFS(std::move(VFS)), Mode(GCCMode),
SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone), LTOMode(LTOK_None),
ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT),
DriverTitle("clang LLVM compiler"), CCPrintOptionsFilename(nullptr),
CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr),
CCCPrintBindings(false), CCPrintOptions(false), CCPrintHeaders(false),
CCLogDiagnostics(false), CCGenDiagnostics(false),
TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc),
CheckInputsExist(true), GenReproducer(false),
SuppressMissingInputWarning(false) {
// Provide a sane fallback if no VFS is specified.
if (!this->VFS)
this->VFS = llvm::vfs::getRealFileSystem();
Name = llvm::sys::path::filename(ClangExecutable);
Dir = llvm::sys::path::parent_path(ClangExecutable);
InstalledDir = Dir; // Provide a sensible default installed dir.
#if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
#endif
#if defined(CLANG_CONFIG_FILE_USER_DIR)
UserConfigDir = CLANG_CONFIG_FILE_USER_DIR;
#endif
// Compute the path to the resource directory.
ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
}
void Driver::ParseDriverMode(StringRef ProgramName,
ArrayRef<const char *> Args) {
if (ClangNameParts.isEmpty())
ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
setDriverModeFromOption(ClangNameParts.DriverMode);
for (const char *ArgPtr : Args) {
// Ignore nullptrs, they are the response file's EOL markers.
if (ArgPtr == nullptr)
continue;
const StringRef Arg = ArgPtr;
setDriverModeFromOption(Arg);
}
}
void Driver::setDriverModeFromOption(StringRef Opt) {
const std::string OptName =
getOpts().getOption(options::OPT_driver_mode).getPrefixedName();
if (!Opt.startswith(OptName))
return;
StringRef Value = Opt.drop_front(OptName.size());
if (auto M = llvm::StringSwitch<llvm::Optional<DriverMode>>(Value)
.Case("gcc", GCCMode)
.Case("g++", GXXMode)
.Case("cpp", CPPMode)
.Case("cl", CLMode)
.Case("flang", FlangMode)
.Default(None))
Mode = *M;
else
Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
}
InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
bool IsClCompatMode,
bool &ContainsError) {
llvm::PrettyStackTraceString CrashInfo("Command line argument parsing");
ContainsError = false;
unsigned IncludedFlagsBitmask;
unsigned ExcludedFlagsBitmask;
std::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) =
getIncludeExcludeOptionFlagMasks(IsClCompatMode);
unsigned MissingArgIndex, MissingArgCount;
InputArgList Args =
getOpts().ParseArgs(ArgStrings, MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask, ExcludedFlagsBitmask);
// Check for missing argument error.
if (MissingArgCount) {
Diag(diag::err_drv_missing_argument)
<< Args.getArgString(MissingArgIndex) << MissingArgCount;
ContainsError |=
Diags.getDiagnosticLevel(diag::err_drv_missing_argument,
SourceLocation()) > DiagnosticsEngine::Warning;
}
// Check for unsupported options.
for (const Arg *A : Args) {
if (A->getOption().hasFlag(options::Unsupported)) {
unsigned DiagID;
auto ArgString = A->getAsString(Args);
std::string Nearest;
if (getOpts().findNearest(
ArgString, Nearest, IncludedFlagsBitmask,
ExcludedFlagsBitmask | options::Unsupported) > 1) {
DiagID = diag::err_drv_unsupported_opt;
Diag(DiagID) << ArgString;
} else {
DiagID = diag::err_drv_unsupported_opt_with_suggestion;
Diag(DiagID) << ArgString << Nearest;
}
ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) >
DiagnosticsEngine::Warning;
continue;
}
// Warn about -mcpu= without an argument.
if (A->getOption().matches(options::OPT_mcpu_EQ) && A->containsValue("")) {
Diag(diag::warn_drv_empty_joined_argument) << A->getAsString(Args);
ContainsError |= Diags.getDiagnosticLevel(
diag::warn_drv_empty_joined_argument,
SourceLocation()) > DiagnosticsEngine::Warning;
}
}
for (const Arg *A : Args.filtered(options::OPT_UNKNOWN)) {
unsigned DiagID;
auto ArgString = A->getAsString(Args);
std::string Nearest;
if (getOpts().findNearest(
ArgString, Nearest, IncludedFlagsBitmask, ExcludedFlagsBitmask) > 1) {
DiagID = IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl
: diag::err_drv_unknown_argument;
Diags.Report(DiagID) << ArgString;
} else {
DiagID = IsCLMode()
? diag::warn_drv_unknown_argument_clang_cl_with_suggestion
: diag::err_drv_unknown_argument_with_suggestion;
Diags.Report(DiagID) << ArgString << Nearest;
}
ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) >
DiagnosticsEngine::Warning;
}
return Args;
}
// Determine which compilation mode we are in. We look for options which
// affect the phase, starting with the earliest phases, and record which
// option we used to determine the final phase.
phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
Arg **FinalPhaseArg) const {
Arg *PhaseArg = nullptr;
phases::ID FinalPhase;
// -{E,EP,P,M,MM} only run the preprocessor.
if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
(PhaseArg = DAL.getLastArg(options::OPT__SLASH_EP)) ||
(PhaseArg = DAL.getLastArg(options::OPT_M, options::OPT_MM)) ||
(PhaseArg = DAL.getLastArg(options::OPT__SLASH_P))) {
FinalPhase = phases::Preprocess;
// --precompile only runs up to precompilation.
} else if ((PhaseArg = DAL.getLastArg(options::OPT__precompile))) {
FinalPhase = phases::Precompile;
// -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
} else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) ||
(PhaseArg = DAL.getLastArg(options::OPT_print_supported_cpus)) ||
(PhaseArg = DAL.getLastArg(options::OPT_module_file_info)) ||
(PhaseArg = DAL.getLastArg(options::OPT_verify_pch)) ||
(PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||
(PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||
(PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
(PhaseArg = DAL.getLastArg(options::OPT__analyze)) ||
(PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {
FinalPhase = phases::Compile;
// -S only runs up to the backend.
} else if ((PhaseArg = DAL.getLastArg(options::OPT_S))) {
FinalPhase = phases::Backend;
// -c compilation only runs up to the assembler.
} else if ((PhaseArg = DAL.getLastArg(options::OPT_c))) {
FinalPhase = phases::Assemble;
// Otherwise do everything.
} else
FinalPhase = phases::Link;
if (FinalPhaseArg)
*FinalPhaseArg = PhaseArg;
return FinalPhase;
}
static Arg *MakeInputArg(DerivedArgList &Args, const OptTable &Opts,
StringRef Value, bool Claim = true) {
Arg *A = new Arg(Opts.getOption(options::OPT_INPUT), Value,
Args.getBaseArgs().MakeIndex(Value), Value.data());
Args.AddSynthesizedArg(A);
if (Claim)
A->claim();
return A;
}
DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
const llvm::opt::OptTable &Opts = getOpts();
DerivedArgList *DAL = new DerivedArgList(Args);
bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
bool HasNostdlibxx = Args.hasArg(options::OPT_nostdlibxx);
bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
for (Arg *A : Args) {
// Unfortunately, we have to parse some forwarding options (-Xassembler,
// -Xlinker, -Xpreprocessor) because we either integrate their functionality
// (assembler and preprocessor), or bypass a previous driver ('collect2').
// Rewrite linker options, to replace --no-demangle with a custom internal
// option.
if ((A->getOption().matches(options::OPT_Wl_COMMA) ||
A->getOption().matches(options::OPT_Xlinker)) &&
A->containsValue("--no-demangle")) {
// Add the rewritten no-demangle argument.
DAL->AddFlagArg(A, Opts.getOption(options::OPT_Z_Xlinker__no_demangle));
// Add the remaining values as Xlinker arguments.
for (StringRef Val : A->getValues())
if (Val != "--no-demangle")
DAL->AddSeparateArg(A, Opts.getOption(options::OPT_Xlinker), Val);
continue;
}
// Rewrite preprocessor options, to replace -Wp,-MD,FOO which is used by
// some build systems. We don't try to be complete here because we don't
// care to encourage this usage model.
if (A->getOption().matches(options::OPT_Wp_COMMA) &&
(A->getValue(0) == StringRef("-MD") ||
A->getValue(0) == StringRef("-MMD"))) {
// Rewrite to -MD/-MMD along with -MF.
if (A->getValue(0) == StringRef("-MD"))
DAL->AddFlagArg(A, Opts.getOption(options::OPT_MD));
else
DAL->AddFlagArg(A, Opts.getOption(options::OPT_MMD));
if (A->getNumValues() == 2)
DAL->AddSeparateArg(A, Opts.getOption(options::OPT_MF), A->getValue(1));
continue;
}
// Rewrite reserved library names.
if (A->getOption().matches(options::OPT_l)) {
StringRef Value = A->getValue();
// Rewrite unless -nostdlib is present.
if (!HasNostdlib && !HasNodefaultlib && !HasNostdlibxx &&
Value == "stdc++") {
DAL->AddFlagArg(A, Opts.getOption(options::OPT_Z_reserved_lib_stdcxx));
continue;
}
// Rewrite unconditionally.
if (Value == "cc_kext") {
DAL->AddFlagArg(A, Opts.getOption(options::OPT_Z_reserved_lib_cckext));
continue;
}
}
// Pick up inputs via the -- option.
if (A->getOption().matches(options::OPT__DASH_DASH)) {
A->claim();
for (StringRef Val : A->getValues())
DAL->append(MakeInputArg(*DAL, Opts, Val, false));
continue;
}
DAL->append(A);
}
// Enforce -static if -miamcu is present.
if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false))
DAL->AddFlagArg(0, Opts.getOption(options::OPT_static));
// Add a default value of -mlinker-version=, if one was given and the user
// didn't specify one.
#if defined(HOST_LINK_VERSION)
if (!Args.hasArg(options::OPT_mlinker_version_EQ) &&
strlen(HOST_LINK_VERSION) > 0) {
DAL->AddJoinedArg(0, Opts.getOption(options::OPT_mlinker_version_EQ),
HOST_LINK_VERSION);
DAL->getLastArg(options::OPT_mlinker_version_EQ)->claim();
}
#endif
return DAL;
}
/// Compute target triple from args.
///
/// This routine provides the logic to compute a target triple from various
/// args passed to the driver and the default triple string.
static llvm::Triple computeTargetTriple(const Driver &D,
StringRef TargetTriple,
const ArgList &Args,
StringRef DarwinArchName = "") {
// FIXME: Already done in Compilation *Driver::BuildCompilation
if (const Arg *A = Args.getLastArg(options::OPT_target))
TargetTriple = A->getValue();
llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
// GNU/Hurd's triples should have been -hurd-gnu*, but were historically made
// -gnu* only, and we can not change this, so we have to detect that case as
// being the Hurd OS.
if (TargetTriple.find("-unknown-gnu") != StringRef::npos ||
TargetTriple.find("-pc-gnu") != StringRef::npos)
Target.setOSName("hurd");
// Handle Apple-specific options available here.
if (Target.isOSBinFormatMachO()) {
// If an explicit Darwin arch name is given, that trumps all.
if (!DarwinArchName.empty()) {
tools::darwin::setTripleTypeForMachOArchName(Target, DarwinArchName);
return Target;
}
// Handle the Darwin '-arch' flag.
if (Arg *A = Args.getLastArg(options::OPT_arch)) {
StringRef ArchName = A->getValue();
tools::darwin::setTripleTypeForMachOArchName(Target, ArchName);
}
}
// Handle pseudo-target flags '-mlittle-endian'/'-EL' and
// '-mbig-endian'/'-EB'.
if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
options::OPT_mbig_endian)) {
if (A->getOption().matches(options::OPT_mlittle_endian)) {
llvm::Triple LE = Target.getLittleEndianArchVariant();
if (LE.getArch() != llvm::Triple::UnknownArch)
Target = std::move(LE);
} else {
llvm::Triple BE = Target.getBigEndianArchVariant();
if (BE.getArch() != llvm::Triple::UnknownArch)
Target = std::move(BE);
}
}
// Skip further flag support on OSes which don't support '-m32' or '-m64'.
if (Target.getArch() == llvm::Triple::tce ||
Target.getOS() == llvm::Triple::Minix)
return Target;
// Handle pseudo-target flags '-m64', '-mx32', '-m32' and '-m16'.
Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32,
options::OPT_m32, options::OPT_m16);
if (A) {
llvm::Triple::ArchType AT = llvm::Triple::UnknownArch;
if (A->getOption().matches(options::OPT_m64)) {
AT = Target.get64BitArchVariant().getArch();
if (Target.getEnvironment() == llvm::Triple::GNUX32)
Target.setEnvironment(llvm::Triple::GNU);
} else if (A->getOption().matches(options::OPT_mx32) &&
Target.get64BitArchVariant().getArch() == llvm::Triple::x86_64) {
AT = llvm::Triple::x86_64;
Target.setEnvironment(llvm::Triple::GNUX32);
} else if (A->getOption().matches(options::OPT_m32)) {
AT = Target.get32BitArchVariant().getArch();
if (Target.getEnvironment() == llvm::Triple::GNUX32)
Target.setEnvironment(llvm::Triple::GNU);
} else if (A->getOption().matches(options::OPT_m16) &&
Target.get32BitArchVariant().getArch() == llvm::Triple::x86) {
AT = llvm::Triple::x86;
Target.setEnvironment(llvm::Triple::CODE16);
}
if (AT != llvm::Triple::UnknownArch && AT != Target.getArch())
Target.setArch(AT);
}
// Handle -miamcu flag.
if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) {
if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
<< Target.str();
if (A && !A->getOption().matches(options::OPT_m32))
D.Diag(diag::err_drv_argument_not_allowed_with)
<< "-miamcu" << A->getBaseArg().getAsString(Args);
Target.setArch(llvm::Triple::x86);
Target.setArchName("i586");
Target.setEnvironment(llvm::Triple::UnknownEnvironment);
Target.setEnvironmentName("");
Target.setOS(llvm::Triple::ELFIAMCU);
Target.setVendor(llvm::Triple::UnknownVendor);
Target.setVendorName("intel");
}
// If target is MIPS adjust the target triple
// accordingly to provided ABI name.
A = Args.getLastArg(options::OPT_mabi_EQ);
if (A && Target.isMIPS()) {
StringRef ABIName = A->getValue();
if (ABIName == "32") {
Target = Target.get32BitArchVariant();
if (Target.getEnvironment() == llvm::Triple::GNUABI64 ||
Target.getEnvironment() == llvm::Triple::GNUABIN32)
Target.setEnvironment(llvm::Triple::GNU);
} else if (ABIName == "n32") {
Target = Target.get64BitArchVariant();
if (Target.getEnvironment() == llvm::Triple::GNU ||
Target.getEnvironment() == llvm::Triple::GNUABI64)
Target.setEnvironment(llvm::Triple::GNUABIN32);
} else if (ABIName == "64") {
Target = Target.get64BitArchVariant();
if (Target.getEnvironment() == llvm::Triple::GNU ||
Target.getEnvironment() == llvm::Triple::GNUABIN32)
Target.setEnvironment(llvm::Triple::GNUABI64);
}
}
// If target is RISC-V adjust the target triple according to
// provided architecture name
A = Args.getLastArg(options::OPT_march_EQ);
if (A && Target.isRISCV()) {
StringRef ArchName = A->getValue();
if (ArchName.startswith_lower("rv32"))
Target.setArch(llvm::Triple::riscv32);
else if (ArchName.startswith_lower("rv64"))
Target.setArch(llvm::Triple::riscv64);
}
return Target;
}
// Parse the LTO options and record the type of LTO compilation
// based on which -f(no-)?lto(=.*)? option occurs last.
void Driver::setLTOMode(const llvm::opt::ArgList &Args) {
LTOMode = LTOK_None;
if (!Args.hasFlag(options::OPT_flto, options::OPT_flto_EQ,
options::OPT_fno_lto, false))
return;
StringRef LTOName("full");
const Arg *A = Args.getLastArg(options::OPT_flto_EQ);
if (A)
LTOName = A->getValue();
LTOMode = llvm::StringSwitch<LTOKind>(LTOName)
.Case("full", LTOK_Full)
.Case("thin", LTOK_Thin)
.Default(LTOK_Unknown);
if (LTOMode == LTOK_Unknown) {
assert(A);
Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName()
<< A->getValue();
}
}
/// Compute the desired OpenMP runtime from the flags provided.
Driver::OpenMPRuntimeKind Driver::getOpenMPRuntime(const ArgList &Args) const {
StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME);
const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ);
if (A)
RuntimeName = A->getValue();
auto RT = llvm::StringSwitch<OpenMPRuntimeKind>(RuntimeName)
.Case("libomp", OMPRT_OMP)
.Case("libgomp", OMPRT_GOMP)
.Case("libiomp5", OMPRT_IOMP5)
.Default(OMPRT_Unknown);
if (RT == OMPRT_Unknown) {
if (A)
Diag(diag::err_drv_unsupported_option_argument)
<< A->getOption().getName() << A->getValue();
else
// FIXME: We could use a nicer diagnostic here.
Diag(diag::err_drv_unsupported_opt) << "-fopenmp";
}
return RT;
}
void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
InputList &Inputs) {
//
// CUDA/HIP
//
// We need to generate a CUDA/HIP toolchain if any of the inputs has a CUDA
// or HIP type. However, mixed CUDA/HIP compilation is not supported.
bool IsCuda =
llvm::any_of(Inputs, [](std::pair<types::ID, const llvm::opt::Arg *> &I) {
return types::isCuda(I.first);
});
bool IsHIP =
llvm::any_of(Inputs,
[](std::pair<types::ID, const llvm::opt::Arg *> &I) {
return types::isHIP(I.first);
}) ||
C.getInputArgs().hasArg(options::OPT_hip_link);
if (IsCuda && IsHIP) {
Diag(clang::diag::err_drv_mix_cuda_hip);
return;
}
if (IsCuda) {
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
const llvm::Triple &HostTriple = HostTC->getTriple();
StringRef DeviceTripleStr;
auto OFK = Action::OFK_Cuda;
DeviceTripleStr =
HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
llvm::Triple CudaTriple(DeviceTripleStr);
// Use the CUDA and host triples as the key into the ToolChains map,
// because the device toolchain we create depends on both.
auto &CudaTC = ToolChains[CudaTriple.str() + "/" + HostTriple.str()];
if (!CudaTC) {
CudaTC = std::make_unique<toolchains::CudaToolChain>(
*this, CudaTriple, *HostTC, C.getInputArgs(), OFK);
}
C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
} else if (IsHIP) {
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
const llvm::Triple &HostTriple = HostTC->getTriple();
StringRef DeviceTripleStr;
auto OFK = Action::OFK_HIP;
DeviceTripleStr = "amdgcn-amd-amdhsa";
llvm::Triple HIPTriple(DeviceTripleStr);
// Use the HIP and host triples as the key into the ToolChains map,
// because the device toolchain we create depends on both.
auto &HIPTC = ToolChains[HIPTriple.str() + "/" + HostTriple.str()];
if (!HIPTC) {
HIPTC = std::make_unique<toolchains::HIPToolChain>(
*this, HIPTriple, *HostTC, C.getInputArgs());
}
C.addOffloadDeviceToolChain(HIPTC.get(), OFK);
}
//
// OpenMP
//
// We need to generate an OpenMP toolchain if the user specified targets with
// the -fopenmp-targets option.
if (Arg *OpenMPTargets =
C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
if (OpenMPTargets->getNumValues()) {
// We expect that -fopenmp-targets is always used in conjunction with the
// option -fopenmp specifying a valid runtime with offloading support,
// i.e. libomp or libiomp.
bool HasValidOpenMPRuntime = C.getInputArgs().hasFlag(
options::OPT_fopenmp, options::OPT_fopenmp_EQ,
options::OPT_fno_openmp, false);
if (HasValidOpenMPRuntime) {
OpenMPRuntimeKind OpenMPKind = getOpenMPRuntime(C.getInputArgs());
HasValidOpenMPRuntime =
OpenMPKind == OMPRT_OMP || OpenMPKind == OMPRT_IOMP5;
}
if (HasValidOpenMPRuntime) {
llvm::StringMap<const char *> FoundNormalizedTriples;
for (const char *Val : OpenMPTargets->getValues()) {
llvm::Triple TT(Val);
std::string NormalizedName = TT.normalize();
// Make sure we don't have a duplicate triple.
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
if (Duplicate != FoundNormalizedTriples.end()) {
Diag(clang::diag::warn_drv_omp_offload_target_duplicate)
<< Val << Duplicate->second;
continue;
}
// Store the current triple so that we can check for duplicates in the
// following iterations.
FoundNormalizedTriples[NormalizedName] = Val;
// If the specified target is invalid, emit a diagnostic.
if (TT.getArch() == llvm::Triple::UnknownArch)
Diag(clang::diag::err_drv_invalid_omp_target) << Val;
else {
const ToolChain *TC;
// CUDA toolchains have to be selected differently. They pair host
// and device in their implementation.
if (TT.isNVPTX()) {
const ToolChain *HostTC =
C.getSingleOffloadToolChain<Action::OFK_Host>();
assert(HostTC && "Host toolchain should be always defined.");
auto &CudaTC =
ToolChains[TT.str() + "/" + HostTC->getTriple().normalize()];
if (!CudaTC)
CudaTC = std::make_unique<toolchains::CudaToolChain>(
*this, TT, *HostTC, C.getInputArgs(), Action::OFK_OpenMP);
TC = CudaTC.get();
} else
TC = &getToolChain(C.getInputArgs(), TT);
C.addOffloadDeviceToolChain(TC, Action::OFK_OpenMP);
}
}
} else
Diag(clang::diag::err_drv_expecting_fopenmp_with_fopenmp_targets);
} else
Diag(clang::diag::warn_drv_empty_joined_argument)
<< OpenMPTargets->getAsString(C.getInputArgs());
}
//
// TODO: Add support for other offloading programming models here.
//
}
/// Looks the given directories for the specified file.
///
/// \param[out] FilePath File path, if the file was found.
/// \param[in] Dirs Directories used for the search.
/// \param[in] FileName Name of the file to search for.
/// \return True if file was found.
///
/// Looks for file specified by FileName sequentially in directories specified
/// by Dirs.
///
static bool searchForFile(SmallVectorImpl<char> &FilePath,
ArrayRef<std::string> Dirs,
StringRef FileName) {
SmallString<128> WPath;
for (const std::string &Dir : Dirs) {
if (Dir.empty())
continue;
WPath.clear();
llvm::sys::path::append(WPath, Dir, FileName);
llvm::sys::path::native(WPath);
if (llvm::sys::fs::is_regular_file(WPath)) {
FilePath = std::move(WPath);
return true;
}
}
return false;
}
bool Driver::readConfigFile(StringRef FileName) {
// Try reading the given file.
SmallVector<const char *, 32> NewCfgArgs;
if (!llvm::cl::readConfigFile(FileName, Saver, NewCfgArgs)) {
Diag(diag::err_drv_cannot_read_config_file) << FileName;
return true;
}
// Read options from config file.
llvm::SmallString<128> CfgFileName(FileName);
llvm::sys::path::native(CfgFileName);
ConfigFile = CfgFileName.str();
bool ContainErrors;
CfgOptions = std::make_unique<InputArgList>(
ParseArgStrings(NewCfgArgs, IsCLMode(), ContainErrors));
if (ContainErrors) {
CfgOptions.reset();
return true;
}
if (CfgOptions->hasArg(options::OPT_config)) {
CfgOptions.reset();
Diag(diag::err_drv_nested_config_file);
return true;
}
// Claim all arguments that come from a configuration file so that the driver
// does not warn on any that is unused.
for (Arg *A : *CfgOptions)
A->claim();
return false;
}
bool Driver::loadConfigFile() {
std::string CfgFileName;
bool FileSpecifiedExplicitly = false;
// Process options that change search path for config files.
if (CLOptions) {
if (CLOptions->hasArg(options::OPT_config_system_dir_EQ)) {
SmallString<128> CfgDir;
CfgDir.append(
CLOptions->getLastArgValue(options::OPT_config_system_dir_EQ));
if (!CfgDir.empty()) {
if (llvm::sys::fs::make_absolute(CfgDir).value() != 0)
SystemConfigDir.clear();
else
SystemConfigDir = std::string(CfgDir.begin(), CfgDir.end());
}
}
if (CLOptions->hasArg(options::OPT_config_user_dir_EQ)) {
SmallString<128> CfgDir;
CfgDir.append(
CLOptions->getLastArgValue(options::OPT_config_user_dir_EQ));
if (!CfgDir.empty()) {
if (llvm::sys::fs::make_absolute(CfgDir).value() != 0)
UserConfigDir.clear();
else
UserConfigDir = std::string(CfgDir.begin(), CfgDir.end());
}
}
}
// First try to find config file specified in command line.
if (CLOptions) {
std::vector<std::string> ConfigFiles =
CLOptions->getAllArgValues(options::OPT_config);
if (ConfigFiles.size() > 1) {
Diag(diag::err_drv_duplicate_config);
return true;
}
if (!ConfigFiles.empty()) {
CfgFileName = ConfigFiles.front();
assert(!CfgFileName.empty());
// If argument contains directory separator, treat it as a path to
// configuration file.
if (llvm::sys::path::has_parent_path(CfgFileName)) {
SmallString<128> CfgFilePath;
if (llvm::sys::path::is_relative(CfgFileName))
llvm::sys::fs::current_path(CfgFilePath);
llvm::sys::path::append(CfgFilePath, CfgFileName);
if (!llvm::sys::fs::is_regular_file(CfgFilePath)) {
Diag(diag::err_drv_config_file_not_exist) << CfgFilePath;
return true;
}
return readConfigFile(CfgFilePath);
}
FileSpecifiedExplicitly = true;
}
}
// If config file is not specified explicitly, try to deduce configuration
// from executable name. For instance, an executable 'armv7l-clang' will
// search for config file 'armv7l-clang.cfg'.
if (CfgFileName.empty() && !ClangNameParts.TargetPrefix.empty())
CfgFileName = ClangNameParts.TargetPrefix + '-' + ClangNameParts.ModeSuffix;
if (CfgFileName.empty())
return false;
// Determine architecture part of the file name, if it is present.
StringRef CfgFileArch = CfgFileName;
size_t ArchPrefixLen = CfgFileArch.find('-');
if (ArchPrefixLen == StringRef::npos)
ArchPrefixLen = CfgFileArch.size();
llvm::Triple CfgTriple;
CfgFileArch = CfgFileArch.take_front(ArchPrefixLen);
CfgTriple = llvm::Triple(llvm::Triple::normalize(CfgFileArch));
if (CfgTriple.getArch() == llvm::Triple::ArchType::UnknownArch)
ArchPrefixLen = 0;
if (!StringRef(CfgFileName).endswith(".cfg"))
CfgFileName += ".cfg";
// If config file starts with architecture name and command line options
// redefine architecture (with options like -m32 -LE etc), try finding new
// config file with that architecture.
SmallString<128> FixedConfigFile;
size_t FixedArchPrefixLen = 0;
if (ArchPrefixLen) {
// Get architecture name from config file name like 'i386.cfg' or
// 'armv7l-clang.cfg'.
// Check if command line options changes effective triple.
llvm::Triple EffectiveTriple = computeTargetTriple(*this,
CfgTriple.getTriple(), *CLOptions);
if (CfgTriple.getArch() != EffectiveTriple.getArch()) {
FixedConfigFile = EffectiveTriple.getArchName();
FixedArchPrefixLen = FixedConfigFile.size();
// Append the rest of original file name so that file name transforms
// like: i386-clang.cfg -> x86_64-clang.cfg.
if (ArchPrefixLen < CfgFileName.size())
FixedConfigFile += CfgFileName.substr(ArchPrefixLen);
}
}
// Prepare list of directories where config file is searched for.
SmallVector<std::string, 3> CfgFileSearchDirs;
CfgFileSearchDirs.push_back(UserConfigDir);
CfgFileSearchDirs.push_back(SystemConfigDir);
CfgFileSearchDirs.push_back(Dir);
// Try to find config file. First try file with corrected architecture.
llvm::SmallString<128> CfgFilePath;
if (!FixedConfigFile.empty()) {
if (searchForFile(CfgFilePath, CfgFileSearchDirs, FixedConfigFile))
return readConfigFile(CfgFilePath);
// If 'x86_64-clang.cfg' was not found, try 'x86_64.cfg'.
FixedConfigFile.resize(FixedArchPrefixLen);
FixedConfigFile.append(".cfg");
if (searchForFile(CfgFilePath, CfgFileSearchDirs, FixedConfigFile))
return readConfigFile(CfgFilePath);
}
// Then try original file name.
if (searchForFile(CfgFilePath, CfgFileSearchDirs, CfgFileName))
return readConfigFile(CfgFilePath);
// Finally try removing driver mode part: 'x86_64-clang.cfg' -> 'x86_64.cfg'.
if (!ClangNameParts.ModeSuffix.empty() &&
!ClangNameParts.TargetPrefix.empty()) {
CfgFileName.assign(ClangNameParts.TargetPrefix);
CfgFileName.append(".cfg");
if (searchForFile(CfgFilePath, CfgFileSearchDirs, CfgFileName))
return readConfigFile(CfgFilePath);
}
// Report error but only if config file was specified explicitly, by option
// --config. If it was deduced from executable name, it is not an error.
if (FileSpecifiedExplicitly) {
Diag(diag::err_drv_config_file_not_found) << CfgFileName;
for (const std::string &SearchDir : CfgFileSearchDirs)
if (!SearchDir.empty())
Diag(diag::note_drv_config_file_searched_in) << SearchDir;
return true;
}
return false;
}
Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
llvm::PrettyStackTraceString CrashInfo("Compilation construction");
// FIXME: Handle environment options which affect driver behavior, somewhere
// (client?). GCC_EXEC_PREFIX, LPATH, CC_PRINT_OPTIONS.
if (Optional<std::string> CompilerPathValue =
llvm::sys::Process::GetEnv("COMPILER_PATH")) {
StringRef CompilerPath = *CompilerPathValue;
while (!CompilerPath.empty()) {
std::pair<StringRef, StringRef> Split =
CompilerPath.split(llvm::sys::EnvPathSeparator);
PrefixDirs.push_back(Split.first);
CompilerPath = Split.second;
}
}
// We look for the driver mode option early, because the mode can affect
// how other options are parsed.
ParseDriverMode(ClangExecutable, ArgList.slice(1));
// FIXME: What are we going to do with -V and -b?
// Arguments specified in command line.
bool ContainsError;
CLOptions = std::make_unique<InputArgList>(
ParseArgStrings(ArgList.slice(1), IsCLMode(), ContainsError));
// Try parsing configuration file.
if (!ContainsError)
ContainsError = loadConfigFile();
bool HasConfigFile = !ContainsError && (CfgOptions.get() != nullptr);
// All arguments, from both config file and command line.
InputArgList Args = std::move(HasConfigFile ? std::move(*CfgOptions)
: std::move(*CLOptions));
// The args for config files or /clang: flags belong to different InputArgList
// objects than Args. This copies an Arg from one of those other InputArgLists
// to the ownership of Args.
auto appendOneArg = [&Args](const Arg *Opt, const Arg *BaseArg) {
unsigned Index = Args.MakeIndex(Opt->getSpelling());
Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Opt->getSpelling(),
Index, BaseArg);
Copy->getValues() = Opt->getValues();
if (Opt->isClaimed())
Copy->claim();
Args.append(Copy);
};
if (HasConfigFile)
for (auto *Opt : *CLOptions) {
if (Opt->getOption().matches(options::OPT_config))
continue;
const Arg *BaseArg = &Opt->getBaseArg();
if (BaseArg == Opt)
BaseArg = nullptr;
appendOneArg(Opt, BaseArg);
}
// In CL mode, look for any pass-through arguments
if (IsCLMode() && !ContainsError) {
SmallVector<const char *, 16> CLModePassThroughArgList;
for (const auto *A : Args.filtered(options::OPT__SLASH_clang)) {
A->claim();
CLModePassThroughArgList.push_back(A->getValue());
}
if (!CLModePassThroughArgList.empty()) {
// Parse any pass through args using default clang processing rather
// than clang-cl processing.
auto CLModePassThroughOptions = std::make_unique<InputArgList>(
ParseArgStrings(CLModePassThroughArgList, false, ContainsError));
if (!ContainsError)
for (auto *Opt : *CLModePassThroughOptions) {
appendOneArg(Opt, nullptr);
}
}
}
// Check for working directory option before accessing any files
if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
if (VFS->setCurrentWorkingDirectory(WD->getValue()))
Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
// FIXME: This stuff needs to go into the Compilation, not the driver.
bool CCCPrintPhases;
// Silence driver warnings if requested
Diags.setIgnoreAllWarnings(Args.hasArg(options::OPT_w));
// -no-canonical-prefixes is used very early in main.
Args.ClaimAllArgs(options::OPT_no_canonical_prefixes);
// Ignore -pipe.
Args.ClaimAllArgs(options::OPT_pipe);
// Extract -ccc args.
//
// FIXME: We need to figure out where this behavior should live. Most of it
// should be outside in the client; the parts that aren't should have proper
// options, either by introducing new ones or by overloading gcc ones like -V
// or -b.
CCCPrintPhases = Args.hasArg(options::OPT_ccc_print_phases);
CCCPrintBindings = Args.hasArg(options::OPT_ccc_print_bindings);
if (const Arg *A = Args.getLastArg(options::OPT_ccc_gcc_name))
CCCGenericGCCName = A->getValue();
GenReproducer = Args.hasFlag(options::OPT_gen_reproducer,
options::OPT_fno_crash_diagnostics,
!!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"));
// FIXME: TargetTriple is used by the target-prefixed calls to as/ld
// and getToolChain is const.
if (IsCLMode()) {
// clang-cl targets MSVC-style Win32.
llvm::Triple T(TargetTriple);
T.setOS(llvm::Triple::Win32);
T.setVendor(llvm::Triple::PC);
T.setEnvironment(llvm::Triple::MSVC);
T.setObjectFormat(llvm::Triple::COFF);
TargetTriple = T.str();
}
if (const Arg *A = Args.getLastArg(options::OPT_target))
TargetTriple = A->getValue();
if (const Arg *A = Args.getLastArg(options::OPT_ccc_install_dir))
Dir = InstalledDir = A->getValue();
for (const Arg *A : Args.filtered(options::OPT_B)) {
A->claim();
PrefixDirs.push_back(A->getValue(0));
}
if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
SysRoot = A->getValue();
if (const Arg *A = Args.getLastArg(options::OPT__dyld_prefix_EQ))
DyldPrefix = A->getValue();
if (const Arg *A = Args.getLastArg(options::OPT_resource_dir))
ResourceDir = A->getValue();
if (const Arg *A = Args.getLastArg(options::OPT_save_temps_EQ)) {
SaveTemps = llvm::StringSwitch<SaveTempsMode>(A->getValue())
.Case("cwd", SaveTempsCwd)
.Case("obj", SaveTempsObj)
.Default(SaveTempsCwd);
}
setLTOMode(Args);
// Process -fembed-bitcode= flags.
if (Arg *A = Args.getLastArg(options::OPT_fembed_bitcode_EQ)) {
StringRef Name = A->getValue();
unsigned Model = llvm::StringSwitch<unsigned>(Name)
.Case("off", EmbedNone)
.Case("all", EmbedBitcode)
.Case("bitcode", EmbedBitcode)
.Case("marker", EmbedMarker)
.Default(~0U);
if (Model == ~0U) {
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
<< Name;
} else
BitcodeEmbed = static_cast<BitcodeEmbedMode>(Model);
}
std::unique_ptr<llvm::opt::InputArgList> UArgs =
std::make_unique<InputArgList>(std::move(Args));
// Perform the default argument translations.
DerivedArgList *TranslatedArgs = TranslateInputArgs(*UArgs);
// Owned by the host.
const ToolChain &TC = getToolChain(
*UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));
// The compilation takes ownership of Args.
Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs,
ContainsError);
if (!HandleImmediateArgs(*C))
return C;
// Construct the list of inputs.
InputList Inputs;
BuildInputs(C->getDefaultToolChain(), *TranslatedArgs, Inputs);
// Populate the tool chains for the offloading devices, if any.
CreateOffloadingDeviceToolChains(*C, Inputs);
// Construct the list of abstract actions to perform for this compilation. On
// MachO targets this uses the driver-driver and universal actions.
if (TC.getTriple().isOSBinFormatMachO())
BuildUniversalActions(*C, C->getDefaultToolChain(), Inputs);
else
BuildActions(*C, C->getArgs(), Inputs, C->getActions());
if (CCCPrintPhases) {
PrintActions(*C);
return C;
}
BuildJobs(*C);
return C;
}
static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) {
llvm::opt::ArgStringList ASL;
for (const auto *A : Args)
A->render(Args, ASL);
for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) {
if (I != ASL.begin())
OS << ' ';
Command::printArg(OS, *I, true);
}
OS << '\n';
}
bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
SmallString<128> &CrashDiagDir) {
using namespace llvm::sys;
assert(llvm::Triple(llvm::sys::getProcessTriple()).isOSDarwin() &&
"Only knows about .crash files on Darwin");
// The .crash file can be found on at ~/Library/Logs/DiagnosticReports/
// (or /Library/Logs/DiagnosticReports for root) and has the filename pattern
// clang-<VERSION>_<YYYY-MM-DD-HHMMSS>_<hostname>.crash.
path::home_directory(CrashDiagDir);
if (CrashDiagDir.startswith("/var/root"))
CrashDiagDir = "/";
path::append(CrashDiagDir, "Library/Logs/DiagnosticReports");
int PID =
#if LLVM_ON_UNIX
getpid();
#else
0;
#endif
std::error_code EC;
fs::file_status FileStatus;
TimePoint<> LastAccessTime;
SmallString<128> CrashFilePath;
// Lookup the .crash files and get the one generated by a subprocess spawned
// by this driver invocation.
for (fs::directory_iterator File(CrashDiagDir, EC), FileEnd;
File != FileEnd && !EC; File.increment(EC)) {
StringRef FileName = path::filename(File->path());
if (!FileName.startswith(Name))
continue;
if (fs::status(File->path(), FileStatus))
continue;
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> CrashFile =
llvm::MemoryBuffer::getFile(File->path());
if (!CrashFile)
continue;
// The first line should start with "Process:", otherwise this isn't a real
// .crash file.
StringRef Data = CrashFile.get()->getBuffer();
if (!Data.startswith("Process:"))
continue;
// Parse parent process pid line, e.g: "Parent Process: clang-4.0 [79141]"
size_t ParentProcPos = Data.find("Parent Process:");
if (ParentProcPos == StringRef::npos)
continue;
size_t LineEnd = Data.find_first_of("\n", ParentProcPos);
if (LineEnd == StringRef::npos)
continue;
StringRef ParentProcess = Data.slice(ParentProcPos+15, LineEnd).trim();
int OpenBracket = -1, CloseBracket = -1;
for (size_t i = 0, e = ParentProcess.size(); i < e; ++i) {
if (ParentProcess[i] == '[')
OpenBracket = i;
if (ParentProcess[i] == ']')
CloseBracket = i;
}
// Extract the parent process PID from the .crash file and check whether
// it matches this driver invocation pid.
int CrashPID;
if (OpenBracket < 0 || CloseBracket < 0 ||
ParentProcess.slice(OpenBracket + 1, CloseBracket)
.getAsInteger(10, CrashPID) || CrashPID != PID) {
continue;
}
// Found a .crash file matching the driver pid. To avoid getting an older
// and misleading crash file, continue looking for the most recent.
// FIXME: the driver can dispatch multiple cc1 invocations, leading to
// multiple crashes poiting to the same parent process. Since the driver
// does not collect pid information for the dispatched invocation there's
// currently no way to distinguish among them.
const auto FileAccessTime = FileStatus.getLastModificationTime();
if (FileAccessTime > LastAccessTime) {
CrashFilePath.assign(File->path());
LastAccessTime = FileAccessTime;
}
}
// If found, copy it over to the location of other reproducer files.
if (!CrashFilePath.empty()) {
EC = fs::copy_file(CrashFilePath, ReproCrashFilename);
if (EC)
return false;
return true;
}
return false;
}
// When clang crashes, produce diagnostic information including the fully
// preprocessed source file(s). Request that the developer attach the
// diagnostic information to a bug report.
void Driver::generateCompilationDiagnostics(
Compilation &C, const Command &FailingCommand,
StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
return;
// Don't try to generate diagnostics for link or dsymutil jobs.
if (FailingCommand.getCreator().isLinkJob() ||
FailingCommand.getCreator().isDsymutilJob())
return;
// Print the version of the compiler.
PrintVersion(C, llvm::errs());
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "PLEASE submit a bug report to " BUG_REPORT_URL " and include the "
"crash backtrace, preprocessed source, and associated run script.";
// Suppress driver output and emit preprocessor output to temp file.
Mode = CPPMode;
CCGenDiagnostics = true;
// Save the original job command(s).
Command Cmd = FailingCommand;
// Keep track of whether we produce any errors while trying to produce
// preprocessed sources.
DiagnosticErrorTrap Trap(Diags);
// Suppress tool output.
C.initCompilationForDiagnostics();
// Construct the list of inputs.
InputList Inputs;
BuildInputs(C.getDefaultToolChain(), C.getArgs(), Inputs);
for (InputList::iterator it = Inputs.begin(), ie = Inputs.end(); it != ie;) {
bool IgnoreInput = false;
// Ignore input from stdin or any inputs that cannot be preprocessed.
// Check type first as not all linker inputs have a value.
if (types::getPreprocessedType(it->first) == types::TY_INVALID) {
IgnoreInput = true;
} else if (!strcmp(it->second->getValue(), "-")) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating preprocessed source(s) - "
"ignoring input from stdin.";
IgnoreInput = true;
}
if (IgnoreInput) {
it = Inputs.erase(it);
ie = Inputs.end();
} else {
++it;
}
}
if (Inputs.empty()) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating preprocessed source(s) - "
"no preprocessable inputs.";
return;
}
// Don't attempt to generate preprocessed files if multiple -arch options are
// used, unless they're all duplicates.
llvm::StringSet<> ArchNames;
for (const Arg *A : C.getArgs()) {
if (A->getOption().matches(options::OPT_arch)) {
StringRef ArchName = A->getValue();
ArchNames.insert(ArchName);
}
}
if (ArchNames.size() > 1) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating preprocessed source(s) - cannot generate "
"preprocessed source with multiple -arch options.";
return;
}
// Construct the list of abstract actions to perform for this compilation. On
// Darwin OSes this uses the driver-driver and builds universal actions.
const ToolChain &TC = C.getDefaultToolChain();
if (TC.getTriple().isOSBinFormatMachO())
BuildUniversalActions(C, TC, Inputs);
else
BuildActions(C, C.getArgs(), Inputs, C.getActions());
BuildJobs(C);
// If there were errors building the compilation, quit now.
if (Trap.hasErrorOccurred()) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating preprocessed source(s).";
return;
}
// Generate preprocessed output.
SmallVector<std::pair<int, const Command *>, 4> FailingCommands;
C.ExecuteJobs(C.getJobs(), FailingCommands);
// If any of the preprocessing commands failed, clean up and exit.
if (!FailingCommands.empty()) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating preprocessed source(s).";
return;
}
const ArgStringList &TempFiles = C.getTempFiles();
if (TempFiles.empty()) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating preprocessed source(s).";
return;
}
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "\n********************\n\n"
"PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
"Preprocessed source(s) and associated run script(s) are located at:";
SmallString<128> VFS;
SmallString<128> ReproCrashFilename;
for (const char *TempFile : TempFiles) {
Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
if (Report)
Report->TemporaryFiles.push_back(TempFile);
if (ReproCrashFilename.empty()) {
ReproCrashFilename = TempFile;
llvm::sys::path::replace_extension(ReproCrashFilename, ".crash");
}
if (StringRef(TempFile).endswith(".cache")) {
// In some cases (modules) we'll dump extra data to help with reproducing
// the crash into a directory next to the output.
VFS = llvm::sys::path::filename(TempFile);
llvm::sys::path::append(VFS, "vfs", "vfs.yaml");
}
}
// Assume associated files are based off of the first temporary file.
CrashReportInfo CrashInfo(
TempFiles[0], VFS,
C.getArgs().getLastArgValue(options::OPT_index_store_path));
llvm::SmallString<128> Script(CrashInfo.Filename);
llvm::sys::path::replace_extension(Script, "sh");
std::error_code EC;
llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
if (EC) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Error generating run script: " << Script << " " << EC.message();
} else {
ScriptOS << "# Crash reproducer for " << getClangFullVersion() << "\n"
<< "# Driver args: ";
printArgList(ScriptOS, C.getInputArgs());
ScriptOS << "# Original command: ";
Cmd.Print(ScriptOS, "\n", /*Quote=*/true);
Cmd.Print(ScriptOS, "\n", /*Quote=*/true, &CrashInfo);
if (!AdditionalInformation.empty())
ScriptOS << "\n# Additional information: " << AdditionalInformation
<< "\n";
if (Report)
Report->TemporaryFiles.push_back(Script.str());
Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
}
// On darwin, provide information about the .crash diagnostic report.
if (llvm::Triple(llvm::sys::getProcessTriple()).isOSDarwin()) {
SmallString<128> CrashDiagDir;
if (getCrashDiagnosticFile(ReproCrashFilename, CrashDiagDir)) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< ReproCrashFilename.str();
} else { // Suggest a directory for the user to look for .crash files.
llvm::sys::path::append(CrashDiagDir, Name);
CrashDiagDir += "_<YYYY-MM-DD-HHMMSS>_<hostname>.crash";
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "Crash backtrace is located in";
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< CrashDiagDir.str();
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "(choose the .crash file that corresponds to your crash)";
}
}
for (const auto &A : C.getArgs().filtered(options::OPT_frewrite_map_file,
options::OPT_frewrite_map_file_EQ))
Diag(clang::diag::note_drv_command_failed_diag_msg) << A->getValue();
Diag(clang::diag::note_drv_command_failed_diag_msg)
<< "\n\n********************";
}
void Driver::setUpResponseFiles(Compilation &C, Command &Cmd) {
// Since commandLineFitsWithinSystemLimits() may underestimate system's
// capacity if the tool does not support response files, there is a chance/
// that things will just work without a response file, so we silently just
// skip it.
if (Cmd.getCreator().getResponseFilesSupport() == Tool::RF_None ||
llvm::sys::commandLineFitsWithinSystemLimits(Cmd.getExecutable(),
Cmd.getArguments()))
return;
std::string TmpName = GetTemporaryPath("response", "txt");
Cmd.setResponseFile(C.addTempFile(C.getArgs().MakeArgString(TmpName)));
}
int Driver::ExecuteCompilation(
Compilation &C,
SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) {
// Just print if -### was present.
if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
C.getJobs().Print(llvm::errs(), "\n", true);
return 0;
}
// If there were errors building the compilation, quit now.
if (Diags.hasErrorOccurred())
return 1;
// Set up response file names for each command, if necessary
for (auto &Job : C.getJobs())
setUpResponseFiles(C, Job);
C.ExecuteJobs(C.getJobs(), FailingCommands);
// If the command succeeded, we are done.
if (FailingCommands.empty())
return 0;
// Otherwise, remove result files and print extra information about abnormal
// failures.
int Res = 0;
for (const auto &CmdPair : FailingCommands) {
int CommandRes = CmdPair.first;
const Command *FailingCommand = CmdPair.second;
// Remove result files if we're not saving temps.
if (!isSaveTempsEnabled()) {
const JobAction *JA = cast<JobAction>(&FailingCommand->getSource());
C.CleanupFileMap(C.getResultFiles(), JA, true);
// Failure result files are valid unless we crashed.
if (CommandRes < 0)
C.CleanupFileMap(C.getFailureResultFiles(), JA, true);
}
#if LLVM_ON_UNIX
// llvm/lib/Support/Unix/Signals.inc will exit with a special return code
// for SIGPIPE. Do not print diagnostics for this case.
if (CommandRes == EX_IOERR) {
Res = CommandRes;
continue;
}
#endif
// Print extra information about abnormal failures, if possible.
//
// This is ad-hoc, but we don't want to be excessively noisy. If the result
// status was 1, assume the command failed normally. In particular, if it
// was the compiler then assume it gave a reasonable error code. Failures
// in other tools are less common, and they generally have worse
// diagnostics, so always print the diagnostic there.
const Tool &FailingTool = FailingCommand->getCreator();
if (!FailingCommand->getCreator().hasGoodDiagnostics() || CommandRes != 1) {
// FIXME: See FIXME above regarding result code interpretation.
if (CommandRes < 0)
Diag(clang::diag::err_drv_command_signalled)
<< FailingTool.getShortName();
else
Diag(clang::diag::err_drv_command_failed)
<< FailingTool.getShortName() << CommandRes;
}
}
return Res;
}
void Driver::PrintHelp(bool ShowHidden) const {
unsigned IncludedFlagsBitmask;
unsigned ExcludedFlagsBitmask;
std::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) =
getIncludeExcludeOptionFlagMasks(IsCLMode());
ExcludedFlagsBitmask |= options::NoDriverOption;
if (!ShowHidden)
ExcludedFlagsBitmask |= HelpHidden;
std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
IncludedFlagsBitmask, ExcludedFlagsBitmask,
/*ShowAllAliases=*/false);
}
void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
// FIXME: The following handlers should use a callback mechanism, we don't
// know what the client would like to do.
OS << getClangFullVersion() << '\n';
const ToolChain &TC = C.getDefaultToolChain();
OS << "Target: " << TC.getTripleString() << '\n';
// Print the threading model.
if (Arg *A = C.getArgs().getLastArg(options::OPT_mthread_model)) {
// Don't print if the ToolChain would have barfed on it already
if (TC.isThreadModelSupported(A->getValue()))
OS << "Thread model: " << A->getValue();
} else
OS << "Thread model: " << TC.getThreadModel();
OS << '\n';
// Print out the install directory.
OS << "InstalledDir: " << InstalledDir << '\n';
// If configuration file was used, print its path.
if (!ConfigFile.empty())
OS << "Configuration file: " << ConfigFile << '\n';
}
/// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
/// option.
static void PrintDiagnosticCategories(raw_ostream &OS) {
// Skip the empty category.
for (unsigned i = 1, max = DiagnosticIDs::getNumberOfCategories(); i != max;
++i)
OS << i << ',' << DiagnosticIDs::getCategoryNameFromID(i) << '\n';
}
void Driver::HandleAutocompletions(StringRef PassedFlags) const {
if (PassedFlags == "")
return;
// Print out all options that start with a given argument. This is used for
// shell autocompletion.
std::vector<std::string> SuggestedCompletions;
std::vector<std::string> Flags;
unsigned short DisableFlags =
options::NoDriverOption | options::Unsupported | options::Ignored;
// Distinguish "--autocomplete=-someflag" and "--autocomplete=-someflag,"
// because the latter indicates that the user put space before pushing tab
// which should end up in a file completion.
const bool HasSpace = PassedFlags.endswith(",");
// Parse PassedFlags by "," as all the command-line flags are passed to this
// function separated by ","
StringRef TargetFlags = PassedFlags;
while (TargetFlags != "") {
StringRef CurFlag;
std::tie(CurFlag, TargetFlags) = TargetFlags.split(",");
Flags.push_back(std::string(CurFlag));
}
// We want to show cc1-only options only when clang is invoked with -cc1 or
// -Xclang.
if (llvm::is_contained(Flags, "-Xclang") || llvm::is_contained(Flags, "-cc1"))
DisableFlags &= ~options::NoDriverOption;
const llvm::opt::OptTable &Opts = getOpts();
StringRef Cur;
Cur = Flags.at(Flags.size() - 1);
StringRef Prev;
if (Flags.size() >= 2) {
Prev = Flags.at(Flags.size() - 2);
SuggestedCompletions = Opts.suggestValueCompletions(Prev, Cur);
}
if (SuggestedCompletions.empty())
SuggestedCompletions = Opts.suggestValueCompletions(Cur, "");
// If Flags were empty, it means the user typed `clang [tab]` where we should
// list all possible flags. If there was no value completion and the user
// pressed tab after a space, we should fall back to a file completion.
// We're printing a newline to be consistent with what we print at the end of
// this function.
if (SuggestedCompletions.empty() && HasSpace && !Flags.empty()) {
llvm::outs() << '\n';
return;
}
// When flag ends with '=' and there was no value completion, return empty
// string and fall back to the file autocompletion.
if (SuggestedCompletions.empty() && !Cur.endswith("=")) {
// If the flag is in the form of "--autocomplete=-foo",
// we were requested to print out all option names that start with "-foo".
// For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
SuggestedCompletions = Opts.findByPrefix(Cur, DisableFlags);
// We have to query the -W flags manually as they're not in the OptTable.
// TODO: Find a good way to add them to OptTable instead and them remove
// this code.
for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
if (S.startswith(Cur))
SuggestedCompletions.push_back(S);
}
// Sort the autocomplete candidates so that shells print them out in a
// deterministic order. We could sort in any way, but we chose
// case-insensitive sorting for consistency with the -help option
// which prints out options in the case-insensitive alphabetical order.
llvm::sort(SuggestedCompletions, [](StringRef A, StringRef B) {
if (int X = A.compare_lower(B))
return X < 0;
return A.compare(B) > 0;
});
llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
}
bool Driver::HandleImmediateArgs(const Compilation &C) {
// The order these options are handled in gcc is all over the place, but we
// don't expect inconsistencies w.r.t. that to matter in practice.
if (C.getArgs().hasArg(options::OPT_dumpmachine)) {
llvm::outs() << C.getDefaultToolChain().getTripleString() << '\n';
return false;
}
if (C.getArgs().hasArg(options::OPT_dumpversion)) {
// Since -dumpversion is only implemented for pedantic GCC compatibility, we
// return an answer which matches our definition of __VERSION__.
llvm::outs() << CLANG_VERSION_STRING << "\n";
return false;
}
if (C.getArgs().hasArg(options::OPT__print_diagnostic_categories)) {
PrintDiagnosticCategories(llvm::outs());
return false;
}
if (C.getArgs().hasArg(options::OPT_help) ||
C.getArgs().hasArg(options::OPT__help_hidden)) {
PrintHelp(C.getArgs().hasArg(options::OPT__help_hidden));
return false;
}
if (C.getArgs().hasArg(options::OPT__version)) {
// Follow gcc behavior and use stdout for --version and stderr for -v.
PrintVersion(C, llvm::outs());
return false;
}
if (C.getArgs().hasArg(options::OPT_v) ||
C.getArgs().hasArg(options::OPT__HASH_HASH_HASH) ||
C.getArgs().hasArg(options::OPT_print_supported_cpus)) {
PrintVersion(C, llvm::errs());
SuppressMissingInputWarning = true;
}
if (C.getArgs().hasArg(options::OPT_v)) {
if (!SystemConfigDir.empty())
llvm::errs() << "System configuration file directory: "
<< SystemConfigDir << "\n";
if (!UserConfigDir.empty())
llvm::errs() << "User configuration file directory: "
<< UserConfigDir << "\n";
}
const ToolChain &TC = C.getDefaultToolChain();
if (C.getArgs().hasArg(options::OPT_v))
TC.printVerboseInfo(llvm::errs());
if (C.getArgs().hasArg(options::OPT_print_resource_dir)) {
llvm::outs() << ResourceDir << '\n';
return false;
}
if (C.getArgs().hasArg(options::OPT_print_search_dirs)) {
llvm::outs() << "programs: =";
bool separator = false;
for (const std::string &Path : TC.getProgramPaths()) {
if (separator)
llvm::outs() << llvm::sys::EnvPathSeparator;
llvm::outs() << Path;
separator = true;
}
llvm::outs() << "\n";
llvm::outs() << "libraries: =" << ResourceDir;
StringRef sysroot = C.getSysRoot();
for (const std::string &Path : TC.getFilePaths()) {
// Always print a separator. ResourceDir was the first item shown.
llvm::outs() << llvm::sys::EnvPathSeparator;
// Interpretation of leading '=' is needed only for NetBSD.
if (Path[0] == '=')
llvm::outs() << sysroot << Path.substr(1);
else
llvm::outs() << Path;
}
llvm::outs() << "\n";
return false;
}
// FIXME: The following handlers should use a callback mechanism, we don't
// know what the client would like to do.
if (Arg *A = C.getArgs().getLastArg(options::OPT_print_file_name_EQ)) {
llvm::outs() << GetFilePath(A->getValue(), TC) << "\n";
return false;
}
if (Arg *A = C.getArgs().getLastArg(options::OPT_print_prog_name_EQ)) {
StringRef ProgName = A->getValue();
// Null program name cannot have a path.
if (! ProgName.empty())
llvm::outs() << GetProgramPath(ProgName, TC);
llvm::outs() << "\n";
return false;
}
if (Arg *A = C.getArgs().getLastArg(options::OPT_autocomplete)) {
StringRef PassedFlags = A->getValue();
HandleAutocompletions(PassedFlags);
return false;
}
if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(C.getArgs()));
RegisterEffectiveTriple TripleRAII(TC, Triple);
switch (RLT) {
case ToolChain::RLT_CompilerRT:
llvm::outs() << TC.getCompilerRT(C.getArgs(), "builtins") << "\n";
break;
case ToolChain::RLT_Libgcc:
llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
break;
}
return false;
}
if (C.getArgs().hasArg(options::OPT_print_multi_lib)) {
for (const Multilib &Multilib : TC.getMultilibs())
llvm::outs() << Multilib << "\n";
return false;
}
if (C.getArgs().hasArg(options::OPT_print_multi_directory)) {
const Multilib &Multilib = TC.getMultilib();
if (Multilib.gccSuffix().empty())
llvm::outs() << ".\n";
else {
StringRef Suffix(Multilib.gccSuffix());
assert(Suffix.front() == '/');
llvm::outs() << Suffix.substr(1) << "\n";
}
return false;
}
if (C.getArgs().hasArg(options::OPT_print_target_triple)) {
llvm::outs() << TC.getTripleString() << "\n";
return false;
}
if (C.getArgs().hasArg(options::OPT_print_effective_triple)) {
const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(C.getArgs()));
llvm::outs() << Triple.getTriple() << "\n";
return false;
}
return true;
}
enum {
TopLevelAction = 0,
HeadSibAction = 1,
OtherSibAction = 2,
};
// Display an action graph human-readably. Action A is the "sink" node
// and latest-occuring action. Traversal is in pre-order, visiting the
// inputs to each action before printing the action itself.
static unsigned PrintActions1(const Compilation &C, Action *A,
std::map<Action *, unsigned> &Ids,
Twine Indent = {}, int Kind = TopLevelAction) {
if (Ids.count(A)) // A was already visited.
return Ids[A];
std::string str;
llvm::raw_string_ostream os(str);
auto getSibIndent = [](int K) -> Twine {
return (K == HeadSibAction) ? " " : (K == OtherSibAction) ? "| " : "";
};
Twine SibIndent = Indent + getSibIndent(Kind);
int SibKind = HeadSibAction;
os << Action::getClassName(A->getKind()) << ", ";
if (InputAction *IA = dyn_cast<InputAction>(A)) {
os << "\"" << IA->getInputArg().getValue() << "\"";
} else if (BindArchAction *BIA = dyn_cast<BindArchAction>(A)) {
os << '"' << BIA->getArchName() << '"' << ", {"
<< PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << "}";
} else if (OffloadAction *OA = dyn_cast<OffloadAction>(A)) {
bool IsFirst = true;
OA->doOnEachDependence(
[&](Action *A, const ToolChain *TC, const char *BoundArch) {
// E.g. for two CUDA device dependences whose bound arch is sm_20 and
// sm_35 this will generate:
// "cuda-device" (nvptx64-nvidia-cuda:sm_20) {#ID}, "cuda-device"
// (nvptx64-nvidia-cuda:sm_35) {#ID}
if (!IsFirst)
os << ", ";
os << '"';
if (TC)
os << A->getOffloadingKindPrefix();
else
os << "host";
os << " (";
os << TC->getTriple().normalize();
if (BoundArch)
os << ":" << BoundArch;
os << ")";
os << '"';
os << " {" << PrintActions1(C, A, Ids, SibIndent, SibKind) << "}";
IsFirst = false;
SibKind = OtherSibAction;
});
} else {
const ActionList *AL = &A->getInputs();
if (AL->size()) {
const char *Prefix = "{";
for (Action *PreRequisite : *AL) {
os << Prefix << PrintActions1(C, PreRequisite, Ids, SibIndent, SibKind);
Prefix = ", ";
SibKind = OtherSibAction;
}
os << "}";
} else
os << "{}";
}
// Append offload info for all options other than the offloading action
// itself (e.g. (cuda-device, sm_20) or (cuda-host)).
std::string offload_str;
llvm::raw_string_ostream offload_os(offload_str);
if (!isa<OffloadAction>(A)) {
auto S = A->getOffloadingKindPrefix();
if (!S.empty()) {
offload_os << ", (" << S;
if (A->getOffloadingArch())
offload_os << ", " << A->getOffloadingArch();
offload_os << ")";
}
}
auto getSelfIndent = [](int K) -> Twine {
return (K == HeadSibAction) ? "+- " : (K == OtherSibAction) ? "|- " : "";
};
unsigned Id = Ids.size();
Ids[A] = Id;
llvm::errs() << Indent + getSelfIndent(Kind) << Id << ": " << os.str() << ", "
<< types::getTypeName(A->getType()) << offload_os.str() << "\n";
return Id;
}
// Print the action graphs in a compilation C.
// For example "clang -c file1.c file2.c" is composed of two subgraphs.
void Driver::PrintActions(const Compilation &C) const {
std::map<Action *, unsigned> Ids;
for (Action *A : C.getActions())
PrintActions1(C, A, Ids);
}
/// Check whether the given input tree contains any compilation or
/// assembly actions.
static bool ContainsCompileOrAssembleAction(const Action *A) {
if (isa<CompileJobAction>(A) || isa<BackendJobAction>(A) ||
isa<AssembleJobAction>(A))
return true;
for (const Action *Input : A->inputs())
if (ContainsCompileOrAssembleAction(Input))
return true;
return false;
}
void Driver::BuildUniversalActions(Compilation &C, const ToolChain &TC,
const InputList &BAInputs) const {
DerivedArgList &Args = C.getArgs();
ActionList &Actions = C.getActions();
llvm::PrettyStackTraceString CrashInfo("Building universal build actions");
// Collect the list of architectures. Duplicates are allowed, but should only
// be handled once (in the order seen).
llvm::StringSet<> ArchNames;
SmallVector<const char *, 4> Archs;
for (Arg *A : Args) {
if (A->getOption().matches(options::OPT_arch)) {
// Validate the option here; we don't save the type here because its
// particular spelling may participate in other driver choices.
llvm::Triple::ArchType Arch =
tools::darwin::getArchTypeForMachOArchName(A->getValue());
if (Arch == llvm::Triple::UnknownArch) {
Diag(clang::diag::err_drv_invalid_arch_name) << A->getAsString(Args);
continue;
}
A->claim();
if (ArchNames.insert(A->getValue()).second)
Archs.push_back(A->getValue());
}
}
// When there is no explicit arch for this platform, make sure we still bind
// the architecture (to the default) so that -Xarch_ is handled correctly.
if (!Archs.size())
Archs.push_back(Args.MakeArgString(TC.getDefaultUniversalArchName()));
ActionList SingleActions;
BuildActions(C, Args, BAInputs, SingleActions);
// Add in arch bindings for every top level action, as well as lipo and
// dsymutil steps if needed.
for (Action* Act : SingleActions) {
// Make sure we can lipo this kind of output. If not (and it is an actual
// output) then we disallow, since we can't create an output file with the
// right name without overwriting it. We could remove this oddity by just
// changing the output names to include the arch, which would also fix
// -save-temps. Compatibility wins for now.
if (Archs.size() > 1 && !types::canLipoType(Act->getType()))
Diag(clang::diag::err_drv_invalid_output_with_multiple_archs)
<< types::getTypeName(Act->getType());
ActionList Inputs;
for (unsigned i = 0, e = Archs.size(); i != e; ++i)
Inputs.push_back(C.MakeAction<BindArchAction>(Act, Archs[i]));
// Lipo if necessary, we do it this way because we need to set the arch flag
// so that -Xarch_ gets overwritten.
if (Inputs.size() == 1 || Act->getType() == types::TY_Nothing)
Actions.append(Inputs.begin(), Inputs.end());
else
Actions.push_back(C.MakeAction<LipoJobAction>(Inputs, Act->getType()));
// Handle debug info queries.
Arg *A = Args.getLastArg(options::OPT_g_Group);
bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
!A->getOption().matches(options::OPT_gstabs);
if ((enablesDebugInfo || willEmitRemarks(Args)) &&
ContainsCompileOrAssembleAction(Actions.back())) {
// Add a 'dsymutil' step if necessary, when debug info is enabled and we
// have a compile input. We need to run 'dsymutil' ourselves in such cases
// because the debug info will refer to a temporary object file which
// will be removed at the end of the compilation process.
if (Act->getType() == types::TY_Image) {
ActionList Inputs;
Inputs.push_back(Actions.back());
Actions.pop_back();
Actions.push_back(
C.MakeAction<DsymutilJobAction>(Inputs, types::TY_dSYM));
}
// Verify the debug info output.
if (Args.hasArg(options::OPT_verify_debug_info)) {
Action* LastAction = Actions.back();
Actions.pop_back();
Actions.push_back(C.MakeAction<VerifyDebugInfoJobAction>(
LastAction, types::TY_Nothing));
}
}
}
}
bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value,
types::ID Ty, bool TypoCorrect) const {
if (!getCheckInputsExist())
return true;
// stdin always exists.
if (Value == "-")
return true;
if (getVFS().exists(Value))
return true;
if (IsCLMode()) {
if (!llvm::sys::path::is_absolute(Twine(Value)) &&
llvm::sys::Process::FindInEnvPath("LIB", Value))
return true;
if (Args.hasArg(options::OPT__SLASH_link) && Ty == types::TY_Object) {
// Arguments to the /link flag might cause the linker to search for object
// and library files in paths we don't know about. Don't error in such
// cases.
return true;
}
}
if (TypoCorrect) {
// Check if the filename is a typo for an option flag. OptTable thinks
// that all args that are not known options and that start with / are
// filenames, but e.g. `/diagnostic:caret` is more likely a typo for
// the option `/diagnostics:caret` than a reference to a file in the root
// directory.
unsigned IncludedFlagsBitmask;
unsigned ExcludedFlagsBitmask;
std::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) =
getIncludeExcludeOptionFlagMasks(IsCLMode());
std::string Nearest;
if (getOpts().findNearest(Value, Nearest, IncludedFlagsBitmask,
ExcludedFlagsBitmask) <= 1) {
Diag(clang::diag::err_drv_no_such_file_with_suggestion)
<< Value << Nearest;
return false;
}
}
Diag(clang::diag::err_drv_no_such_file) << Value;
return false;
}
// Construct a the list of inputs and their types.
void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
InputList &Inputs) const {
const llvm::opt::OptTable &Opts = getOpts();
// Track the current user specified (-x) input. We also explicitly track the
// argument used to set the type; we only want to claim the type when we
// actually use it, so we warn about unused -x arguments.
types::ID InputType = types::TY_Nothing;
Arg *InputTypeArg = nullptr;
// The last /TC or /TP option sets the input type to C or C++ globally.
if (Arg *TCTP = Args.getLastArgNoClaim(options::OPT__SLASH_TC,
options::OPT__SLASH_TP)) {
InputTypeArg = TCTP;
InputType = TCTP->getOption().matches(options::OPT__SLASH_TC)
? types::TY_C
: types::TY_CXX;
Arg *Previous = nullptr;
bool ShowNote = false;
for (Arg *A :
Args.filtered(options::OPT__SLASH_TC, options::OPT__SLASH_TP)) {
if (Previous) {
Diag(clang::diag::warn_drv_overriding_flag_option)
<< Previous->getSpelling() << A->getSpelling();
ShowNote = true;
}
Previous = A;
}
if (ShowNote)
Diag(clang::diag::note_drv_t_option_is_global);
// No driver mode exposes -x and /TC or /TP; we don't support mixing them.
assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed");
}
for (Arg *A : Args) {
if (A->getOption().getKind() == Option::InputClass) {
const char *Value = A->getValue();
types::ID Ty = types::TY_INVALID;
// Infer the input type if necessary.
if (InputType == types::TY_Nothing) {
// If there was an explicit arg for this, claim it.
if (InputTypeArg)
InputTypeArg->claim();
// stdin must be handled specially.
if (memcmp(Value, "-", 2) == 0) {
// If running with -E, treat as a C input (this changes the builtin
// macros, for example). This may be overridden by -ObjC below.
//
// Otherwise emit an error but still use a valid type to avoid
// spurious errors (e.g., no inputs).
if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl
: clang::diag::err_drv_unknown_stdin_type);
Ty = types::TY_C;
} else {
// Otherwise lookup by extension.
// Fallback is C if invoked as C preprocessor, C++ if invoked with
// clang-cl /E, or Object otherwise.
// We use a host hook here because Darwin at least has its own
// idea of what .s is.
if (const char *Ext = strrchr(Value, '.'))
Ty = TC.LookupTypeForExtension(Ext + 1);
if (Ty == types::TY_INVALID) {
if (CCCIsCPP())
Ty = types::TY_C;
else if (IsCLMode() && Args.hasArgNoClaim(options::OPT_E))
Ty = types::TY_CXX;
else
Ty = types::TY_Object;
}
// If the driver is invoked as C++ compiler (like clang++ or c++) it
// should autodetect some input files as C++ for g++ compatibility.
if (CCCIsCXX()) {
types::ID OldTy = Ty;
Ty = types::lookupCXXTypeForCType(Ty);
if (Ty != OldTy)
Diag(clang::diag::warn_drv_treating_input_as_cxx)
<< getTypeName(OldTy) << getTypeName(Ty);
}
// If running with -fthinlto-index=, extensions that normally identify
// native object files actually identify LLVM bitcode files.
if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
Ty == types::TY_Object)
Ty = types::TY_LLVM_BC;
}
// -ObjC and -ObjC++ override the default language, but only for "source
// files". We just treat everything that isn't a linker input as a
// source file.
//
// FIXME: Clean this up if we move the phase sequence into the type.
if (Ty != types::TY_Object) {
if (Args.hasArg(options::OPT_ObjC))
Ty = types::TY_ObjC;
else if (Args.hasArg(options::OPT_ObjCXX))
Ty = types::TY_ObjCXX;
}
} else {
assert(InputTypeArg && "InputType set w/o InputTypeArg");
if (!InputTypeArg->getOption().matches(options::OPT_x)) {
// If emulating cl.exe, make sure that /TC and /TP don't affect input
// object files.
const char *Ext = strrchr(Value, '.');
if (Ext && TC.LookupTypeForExtension(Ext + 1) == types::TY_Object)
Ty = types::TY_Object;
}
if (Ty == types::TY_INVALID) {
Ty = InputType;
InputTypeArg->claim();
}
}
if (DiagnoseInputExistence(Args, Value, Ty, /*TypoCorrect=*/true))
Inputs.push_back(std::make_pair(Ty, A));
} else if (A->getOption().matches(options::OPT__SLASH_Tc)) {
StringRef Value = A->getValue();
if (DiagnoseInputExistence(Args, Value, types::TY_C,
/*TypoCorrect=*/false)) {
Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
Inputs.push_back(std::make_pair(types::TY_C, InputArg));
}
A->claim();
} else if (A->getOption().matches(options::OPT__SLASH_Tp)) {
StringRef Value = A->getValue();
if (DiagnoseInputExistence(Args, Value, types::TY_CXX,
/*TypoCorrect=*/false)) {
Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
Inputs.push_back(std::make_pair(types::TY_CXX, InputArg));
}
A->claim();
} else if (A->getOption().hasFlag(options::LinkerInput)) {
// Just treat as object type, we could make a special type for this if
// necessary.
Inputs.push_back(std::make_pair(types::TY_Object, A));
} else if (A->getOption().matches(options::OPT_x)) {
InputTypeArg = A;
InputType = types::lookupTypeForTypeSpecifier(A->getValue());
A->claim();
// Follow gcc behavior and treat as linker input for invalid -x
// options. Its not clear why we shouldn't just revert to unknown; but
// this isn't very important, we might as well be bug compatible.
if (!InputType) {
Diag(clang::diag::err_drv_unknown_language) << A->getValue();
InputType = types::TY_Object;
}
} else if (A->getOption().getID() == options::OPT_U) {
assert(A->getNumValues() == 1 && "The /U option has one value.");
StringRef Val = A->getValue(0);
if (Val.find_first_of("/\\") != StringRef::npos) {
// Warn about e.g. "/Users/me/myfile.c".
Diag(diag::warn_slash_u_filename) << Val;
Diag(diag::note_use_dashdash);
}
}
}
if (CCCIsCPP() && Inputs.empty()) {
// If called as standalone preprocessor, stdin is processed
// if no other input is present.
Arg *A = MakeInputArg(Args, Opts, "-");
Inputs.push_back(std::make_pair(types::TY_C, A));
}
}
namespace {
/// Provides a convenient interface for different programming models to generate
/// the required device actions.
class OffloadingActionBuilder final {
/// Flag used to trace errors in the builder.
bool IsValid = false;
/// The compilation that is using this builder.
Compilation &C;
/// Map between an input argument and the offload kinds used to process it.
std::map<const Arg *, unsigned> InputArgToOffloadKindMap;
/// Builder interface. It doesn't build anything or keep any state.
class DeviceActionBuilder {
public:
typedef const llvm::SmallVectorImpl<phases::ID> PhasesTy;
enum ActionBuilderReturnCode {
// The builder acted successfully on the current action.
ABRT_Success,
// The builder didn't have to act on the current action.
ABRT_Inactive,
// The builder was successful and requested the host action to not be
// generated.
ABRT_Ignore_Host,
};
protected:
/// Compilation associated with this builder.
Compilation &C;
/// Tool chains associated with this builder. The same programming
/// model may have associated one or more tool chains.
SmallVector<const ToolChain *, 2> ToolChains;
/// The derived arguments associated with this builder.
DerivedArgList &Args;
/// The inputs associated with this builder.
const Driver::InputList &Inputs;
/// The associated offload kind.
Action::OffloadKind AssociatedOffloadKind = Action::OFK_None;
public:
DeviceActionBuilder(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs,
Action::OffloadKind AssociatedOffloadKind)
: C(C), Args(Args), Inputs(Inputs),
AssociatedOffloadKind(AssociatedOffloadKind) {}
virtual ~DeviceActionBuilder() {}
/// Fill up the array \a DA with all the device dependences that should be
/// added to the provided host action \a HostAction. By default it is
/// inactive.
virtual ActionBuilderReturnCode
getDeviceDependences(OffloadAction::DeviceDependences &DA,
phases::ID CurPhase, phases::ID FinalPhase,
PhasesTy &Phases) {
return ABRT_Inactive;
}
/// Update the state to include the provided host action \a HostAction as a
/// dependency of the current device action. By default it is inactive.
virtual ActionBuilderReturnCode addDeviceDepences(Action *HostAction) {
return ABRT_Inactive;
}
/// Append top level actions generated by the builder.
virtual void appendTopLevelActions(ActionList &AL) {}
/// Append linker actions generated by the builder.
virtual void appendLinkActions(ActionList &AL) {}
/// Append linker actions generated by the builder.
virtual void appendLinkDependences(OffloadAction::DeviceDependences &DA) {}
/// Initialize the builder. Return true if any initialization errors are
/// found.
virtual bool initialize() { return false; }
/// Return true if the builder can use bundling/unbundling.
virtual bool canUseBundlerUnbundler() const { return false; }
/// Return true if this builder is valid. We have a valid builder if we have
/// associated device tool chains.
bool isValid() { return !ToolChains.empty(); }
/// Return the associated offload kind.
Action::OffloadKind getAssociatedOffloadKind() {
return AssociatedOffloadKind;
}
};
/// Base class for CUDA/HIP action builder. It injects device code in
/// the host backend action.
class CudaActionBuilderBase : public DeviceActionBuilder {
protected:
/// Flags to signal if the user requested host-only or device-only
/// compilation.
bool CompileHostOnly = false;
bool CompileDeviceOnly = false;
bool EmitLLVM = false;
bool EmitAsm = false;
/// List of GPU architectures to use in this compilation.
SmallVector<CudaArch, 4> GpuArchList;
/// The CUDA actions for the current input.
ActionList CudaDeviceActions;
/// The CUDA fat binary if it was generated for the current input.
Action *CudaFatBinary = nullptr;
/// Flag that is set to true if this builder acted on the current input.
bool IsActive = false;
/// Flag for -fgpu-rdc.
bool Relocatable = false;
/// Default GPU architecture if there's no one specified.
CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
public:
CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs,
Action::OffloadKind OFKind)
: DeviceActionBuilder(C, Args, Inputs, OFKind) {}
ActionBuilderReturnCode addDeviceDepences(Action *HostAction) override {
// While generating code for CUDA, we only depend on the host input action
// to trigger the creation of all the CUDA device actions.
// If we are dealing with an input action, replicate it for each GPU
// architecture. If we are in host-only mode we return 'success' so that
// the host uses the CUDA offload kind.
if (auto *IA = dyn_cast<InputAction>(HostAction)) {
assert(!GpuArchList.empty() &&
"We should have at least one GPU architecture.");
// If the host input is not CUDA or HIP, we don't need to bother about
// this input.
if (IA->getType() != types::TY_CUDA &&
IA->getType() != types::TY_HIP) {
// The builder will ignore this input.
IsActive = false;
return ABRT_Inactive;
}
// Set the flag to true, so that the builder acts on the current input.
IsActive = true;
if (CompileHostOnly)
return ABRT_Success;
// Replicate inputs for each GPU architecture.
auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE
: types::TY_CUDA_DEVICE;
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
CudaDeviceActions.push_back(
C.MakeAction<InputAction>(IA->getInputArg(), Ty));
}
return ABRT_Success;
}
// If this is an unbundling action use it as is for each CUDA toolchain.
if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction)) {
// If -fgpu-rdc is disabled, should not unbundle since there is no
// device code to link.
if (!Relocatable)
return ABRT_Inactive;
CudaDeviceActions.clear();
auto *IA = cast<InputAction>(UA->getInputs().back());
std::string FileName = IA->getInputArg().getAsString(Args);
// Check if the type of the file is the same as the action. Do not
// unbundle it if it is not. Do not unbundle .so files, for example,
// which are not object files.
if (IA->getType() == types::TY_Object &&
(!llvm::sys::path::has_extension(FileName) ||
types::lookupTypeForExtension(
llvm::sys::path::extension(FileName).drop_front()) !=
types::TY_Object))
return ABRT_Inactive;
for (auto Arch : GpuArchList) {
CudaDeviceActions.push_back(UA);
UA->registerDependentActionInfo(ToolChains[0], CudaArchToString(Arch),
AssociatedOffloadKind);
}
return ABRT_Success;
}
return IsActive ? ABRT_Success : ABRT_Inactive;
}
void appendTopLevelActions(ActionList &AL) override {
// Utility to append actions to the top level list.
auto AddTopLevel = [&](Action *A, CudaArch BoundArch) {
OffloadAction::DeviceDependences Dep;
Dep.add(*A, *ToolChains.front(), CudaArchToString(BoundArch),
AssociatedOffloadKind);
AL.push_back(C.MakeAction<OffloadAction>(Dep, A->getType()));
};
// If we have a fat binary, add it to the list.
if (CudaFatBinary) {
AddTopLevel(CudaFatBinary, CudaArch::UNKNOWN);
CudaDeviceActions.clear();
CudaFatBinary = nullptr;
return;
}
if (CudaDeviceActions.empty())
return;
// If we have CUDA actions at this point, that's because we have a have
// partial compilation, so we should have an action for each GPU
// architecture.
assert(CudaDeviceActions.size() == GpuArchList.size() &&
"Expecting one action per GPU architecture.");
assert(ToolChains.size() == 1 &&
"Expecting to have a sing CUDA toolchain.");
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
AddTopLevel(CudaDeviceActions[I], GpuArchList[I]);
CudaDeviceActions.clear();
}
bool initialize() override {
assert(AssociatedOffloadKind == Action::OFK_Cuda ||
AssociatedOffloadKind == Action::OFK_HIP);
// We don't need to support CUDA.
if (AssociatedOffloadKind == Action::OFK_Cuda &&
!C.hasOffloadToolChain<Action::OFK_Cuda>())
return false;
// We don't need to support HIP.
if (AssociatedOffloadKind == Action::OFK_HIP &&
!C.hasOffloadToolChain<Action::OFK_HIP>())
return false;
Relocatable = Args.hasFlag(options::OPT_fgpu_rdc,
options::OPT_fno_gpu_rdc, /*Default=*/false);
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
assert(HostTC && "No toolchain for host compilation.");
if (HostTC->getTriple().isNVPTX() ||
HostTC->getTriple().getArch() == llvm::Triple::amdgcn) {
// We do not support targeting NVPTX/AMDGCN for host compilation. Throw
// an error and abort pipeline construction early so we don't trip
// asserts that assume device-side compilation.
C.getDriver().Diag(diag::err_drv_cuda_host_arch)
<< HostTC->getTriple().getArchName();
return true;
}
ToolChains.push_back(
AssociatedOffloadKind == Action::OFK_Cuda
? C.getSingleOffloadToolChain<Action::OFK_Cuda>()
: C.getSingleOffloadToolChain<Action::OFK_HIP>());
Arg *PartialCompilationArg = Args.getLastArg(
options::OPT_cuda_host_only, options::OPT_cuda_device_only,
options::OPT_cuda_compile_host_device);
CompileHostOnly = PartialCompilationArg &&
PartialCompilationArg->getOption().matches(
options::OPT_cuda_host_only);
CompileDeviceOnly = PartialCompilationArg &&
PartialCompilationArg->getOption().matches(
options::OPT_cuda_device_only);
EmitLLVM = Args.getLastArg(options::OPT_emit_llvm);
EmitAsm = Args.getLastArg(options::OPT_S);
// Collect all cuda_gpu_arch parameters, removing duplicates.
std::set<CudaArch> GpuArchs;
bool Error = false;
for (Arg *A : Args) {
if (!(A->getOption().matches(options::OPT_cuda_gpu_arch_EQ) ||
A->getOption().matches(options::OPT_no_cuda_gpu_arch_EQ)))
continue;
A->claim();
const StringRef ArchStr = A->getValue();
if (A->getOption().matches(options::OPT_no_cuda_gpu_arch_EQ) &&
ArchStr == "all") {
GpuArchs.clear();
continue;
}
CudaArch Arch = StringToCudaArch(ArchStr);
if (Arch == CudaArch::UNKNOWN) {
C.getDriver().Diag(clang::diag::err_drv_cuda_bad_gpu_arch) << ArchStr;
Error = true;
} else if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
GpuArchs.insert(Arch);
else if (A->getOption().matches(options::OPT_no_cuda_gpu_arch_EQ))
GpuArchs.erase(Arch);
else
llvm_unreachable("Unexpected option.");
}
// Collect list of GPUs remaining in the set.
for (CudaArch Arch : GpuArchs)
GpuArchList.push_back(Arch);
// Default to sm_20 which is the lowest common denominator for
// supported GPUs. sm_20 code should work correctly, if
// suboptimally, on all newer GPUs.
if (GpuArchList.empty())
GpuArchList.push_back(DefaultCudaArch);
return Error;
}
};
/// \brief CUDA action builder. It injects device code in the host backend
/// action.
class CudaActionBuilder final : public CudaActionBuilderBase {
public:
CudaActionBuilder(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs)
: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
DefaultCudaArch = CudaArch::SM_20;
}
ActionBuilderReturnCode
getDeviceDependences(OffloadAction::DeviceDependences &DA,
phases::ID CurPhase, phases::ID FinalPhase,
PhasesTy &Phases) override {
if (!IsActive)
return ABRT_Inactive;
// If we don't have more CUDA actions, we don't have any dependences to
// create for the host.
if (CudaDeviceActions.empty())
return ABRT_Success;
assert(CudaDeviceActions.size() == GpuArchList.size() &&
"Expecting one action per GPU architecture.");
assert(!CompileHostOnly &&
"Not expecting CUDA actions in host-only compilation.");
// If we are generating code for the device or we are in a backend phase,
// we attempt to generate the fat binary. We compile each arch to ptx and
// assemble to cubin, then feed the cubin *and* the ptx into a device
// "link" action, which uses fatbinary to combine these cubins into one
// fatbin. The fatbin is then an input to the host action if not in
// device-only mode.
if (CompileDeviceOnly || CurPhase == phases::Backend) {
ActionList DeviceActions;
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
// Produce the device action from the current phase up to the assemble
// phase.
for (auto Ph : Phases) {
// Skip the phases that were already dealt with.
if (Ph < CurPhase)
continue;
// We have to be consistent with the host final phase.
if (Ph > FinalPhase)
break;
CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
C, Args, Ph, CudaDeviceActions[I], Action::OFK_Cuda);
if (Ph == phases::Assemble)
break;
}
// If we didn't reach the assemble phase, we can't generate the fat
// binary. We don't need to generate the fat binary if we are not in
// device-only mode.
if (!isa<AssembleJobAction>(CudaDeviceActions[I]) ||
CompileDeviceOnly)
continue;
Action *AssembleAction = CudaDeviceActions[I];
assert(AssembleAction->getType() == types::TY_Object);
assert(AssembleAction->getInputs().size() == 1);
Action *BackendAction = AssembleAction->getInputs()[0];
assert(BackendAction->getType() == types::TY_PP_Asm);
for (auto &A : {AssembleAction, BackendAction}) {
OffloadAction::DeviceDependences DDep;
DDep.add(*A, *ToolChains.front(), CudaArchToString(GpuArchList[I]),
Action::OFK_Cuda);
DeviceActions.push_back(
C.MakeAction<OffloadAction>(DDep, A->getType()));
}
}
// We generate the fat binary if we have device input actions.
if (!DeviceActions.empty()) {
CudaFatBinary =
C.MakeAction<LinkJobAction>(DeviceActions, types::TY_CUDA_FATBIN);
if (!CompileDeviceOnly) {
DA.add(*CudaFatBinary, *ToolChains.front(), /*BoundArch=*/nullptr,
Action::OFK_Cuda);
// Clear the fat binary, it is already a dependence to an host
// action.
CudaFatBinary = nullptr;
}
// Remove the CUDA actions as they are already connected to an host
// action or fat binary.
CudaDeviceActions.clear();
}
// We avoid creating host action in device-only mode.
return CompileDeviceOnly ? ABRT_Ignore_Host : ABRT_Success;
} else if (CurPhase > phases::Backend) {
// If we are past the backend phase and still have a device action, we
// don't have to do anything as this action is already a device
// top-level action.
return ABRT_Success;
}
assert(CurPhase < phases::Backend && "Generating single CUDA "
"instructions should only occur "
"before the backend phase!");
// By default, we produce an action for each device arch.
for (Action *&A : CudaDeviceActions)
A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A);
return ABRT_Success;
}
};
/// \brief HIP action builder. It injects device code in the host backend
/// action.
class HIPActionBuilder final : public CudaActionBuilderBase {
/// The linker inputs obtained for each device arch.
SmallVector<ActionList, 8> DeviceLinkerInputs;
public:
HIPActionBuilder(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs)
: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
DefaultCudaArch = CudaArch::GFX803;
}
bool canUseBundlerUnbundler() const override { return true; }
ActionBuilderReturnCode
getDeviceDependences(OffloadAction::DeviceDependences &DA,
phases::ID CurPhase, phases::ID FinalPhase,
PhasesTy &Phases) override {
// amdgcn does not support linking of object files, therefore we skip
// backend and assemble phases to output LLVM IR. Except for generating
// non-relocatable device coee, where we generate fat binary for device
// code and pass to host in Backend phase.
if (CudaDeviceActions.empty() ||
(CurPhase == phases::Backend && Relocatable) ||
CurPhase == phases::Assemble)
return ABRT_Success;
assert(((CurPhase == phases::Link && Relocatable) ||
CudaDeviceActions.size() == GpuArchList.size()) &&
"Expecting one action per GPU architecture.");
assert(!CompileHostOnly &&
"Not expecting CUDA actions in host-only compilation.");
if (!Relocatable && CurPhase == phases::Backend && !EmitLLVM &&
!EmitAsm) {
// If we are in backend phase, we attempt to generate the fat binary.
// We compile each arch to IR and use a link action to generate code
// object containing ISA. Then we use a special "link" action to create
// a fat binary containing all the code objects for different GPU's.
// The fat binary is then an input to the host action.
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
// Create a link action to link device IR with device library
// and generate ISA.
ActionList AL;
AL.push_back(CudaDeviceActions[I]);
CudaDeviceActions[I] =
C.MakeAction<LinkJobAction>(AL, types::TY_Image);
// OffloadingActionBuilder propagates device arch until an offload
// action. Since the next action for creating fatbin does
// not have device arch, whereas the above link action and its input
// have device arch, an offload action is needed to stop the null
// device arch of the next action being propagated to the above link
// action.
OffloadAction::DeviceDependences DDep;
DDep.add(*CudaDeviceActions[I], *ToolChains.front(),
CudaArchToString(GpuArchList[I]), AssociatedOffloadKind);
CudaDeviceActions[I] = C.MakeAction<OffloadAction>(
DDep, CudaDeviceActions[I]->getType());
}
// Create HIP fat binary with a special "link" action.
CudaFatBinary =
C.MakeAction<LinkJobAction>(CudaDeviceActions,
types::TY_HIP_FATBIN);
if (!CompileDeviceOnly) {
DA.add(*CudaFatBinary, *ToolChains.front(), /*BoundArch=*/nullptr,
AssociatedOffloadKind);
// Clear the fat binary, it is already a dependence to an host
// action.
CudaFatBinary = nullptr;
}
// Remove the CUDA actions as they are already connected to an host
// action or fat binary.
CudaDeviceActions.clear();
return CompileDeviceOnly ? ABRT_Ignore_Host : ABRT_Success;
} else if (CurPhase == phases::Link) {
// Save CudaDeviceActions to DeviceLinkerInputs for each GPU subarch.
// This happens to each device action originated from each input file.
// Later on, device actions in DeviceLinkerInputs are used to create
// device link actions in appendLinkDependences and the created device
// link actions are passed to the offload action as device dependence.
DeviceLinkerInputs.resize(CudaDeviceActions.size());
auto LI = DeviceLinkerInputs.begin();
for (auto *A : CudaDeviceActions) {
LI->push_back(A);
++LI;
}
// We will pass the device action as a host dependence, so we don't
// need to do anything else with them.
CudaDeviceActions.clear();
return ABRT_Success;
}
// By default, we produce an action for each device arch.
for (Action *&A : CudaDeviceActions)
A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A,
AssociatedOffloadKind);
return (CompileDeviceOnly && CurPhase == FinalPhase) ? ABRT_Ignore_Host
: ABRT_Success;
}
void appendLinkDependences(OffloadAction::DeviceDependences &DA) override {
// Append a new link action for each device.
unsigned I = 0;
for (auto &LI : DeviceLinkerInputs) {
auto *DeviceLinkAction =
C.MakeAction<LinkJobAction>(LI, types::TY_Image);
DA.add(*DeviceLinkAction, *ToolChains[0],
CudaArchToString(GpuArchList[I]), AssociatedOffloadKind);
++I;
}
}
};
/// OpenMP action builder. The host bitcode is passed to the device frontend
/// and all the device linked images are passed to the host link phase.
class OpenMPActionBuilder final : public DeviceActionBuilder {
/// The OpenMP actions for the current input.
ActionList OpenMPDeviceActions;
/// The linker inputs obtained for each toolchain.
SmallVector<ActionList, 8> DeviceLinkerInputs;
public:
OpenMPActionBuilder(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs)
: DeviceActionBuilder(C, Args, Inputs, Action::OFK_OpenMP) {}
ActionBuilderReturnCode
getDeviceDependences(OffloadAction::DeviceDependences &DA,
phases::ID CurPhase, phases::ID FinalPhase,
PhasesTy &Phases) override {
if (OpenMPDeviceActions.empty())
return ABRT_Inactive;
// We should always have an action for each input.
assert(OpenMPDeviceActions.size() == ToolChains.size() &&
"Number of OpenMP actions and toolchains do not match.");
// The host only depends on device action in the linking phase, when all
// the device images have to be embedded in the host image.
if (CurPhase == phases::Link) {
assert(ToolChains.size() == DeviceLinkerInputs.size() &&
"Toolchains and linker inputs sizes do not match.");
auto LI = DeviceLinkerInputs.begin();
for (auto *A : OpenMPDeviceActions) {
LI->push_back(A);
++LI;
}
// We passed the device action as a host dependence, so we don't need to
// do anything else with them.
OpenMPDeviceActions.clear();
return ABRT_Success;
}
// By default, we produce an action for each device arch.
for (Action *&A : OpenMPDeviceActions)
A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A);
return ABRT_Success;
}
ActionBuilderReturnCode addDeviceDepences(Action *HostAction) override {
// If this is an input action replicate it for each OpenMP toolchain.
if (auto *IA = dyn_cast<InputAction>(HostAction)) {
OpenMPDeviceActions.clear();
for (unsigned I = 0; I < ToolChains.size(); ++I)
OpenMPDeviceActions.push_back(
C.MakeAction<InputAction>(IA->getInputArg(), IA->getType()));
return ABRT_Success;
}
// If this is an unbundling action use it as is for each OpenMP toolchain.
if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction)) {
OpenMPDeviceActions.clear();
auto *IA = cast<InputAction>(UA->getInputs().back());
std::string FileName = IA->getInputArg().getAsString(Args);
// Check if the type of the file is the same as the action. Do not
// unbundle it if it is not. Do not unbundle .so files, for example,
// which are not object files.
if (IA->getType() == types::TY_Object &&
(!llvm::sys::path::has_extension(FileName) ||
types::lookupTypeForExtension(
llvm::sys::path::extension(FileName).drop_front()) !=
types::TY_Object))
return ABRT_Inactive;
for (unsigned I = 0; I < ToolChains.size(); ++I) {
OpenMPDeviceActions.push_back(UA);
UA->registerDependentActionInfo(
ToolChains[I], /*BoundArch=*/StringRef(), Action::OFK_OpenMP);
}
return ABRT_Success;
}
// When generating code for OpenMP we use the host compile phase result as
// a dependence to the device compile phase so that it can learn what
// declarations should be emitted. However, this is not the only use for
// the host action, so we prevent it from being collapsed.
if (isa<CompileJobAction>(HostAction)) {
HostAction->setCannotBeCollapsedWithNextDependentAction();
assert(ToolChains.size() == OpenMPDeviceActions.size() &&
"Toolchains and device action sizes do not match.");
OffloadAction::HostDependence HDep(
*HostAction, *C.getSingleOffloadToolChain<Action::OFK_Host>(),
/*BoundArch=*/nullptr, Action::OFK_OpenMP);
auto TC = ToolChains.begin();
for (Action *&A : OpenMPDeviceActions) {
assert(isa<CompileJobAction>(A));
OffloadAction::DeviceDependences DDep;
DDep.add(*A, **TC, /*BoundArch=*/nullptr, Action::OFK_OpenMP);
A = C.MakeAction<OffloadAction>(HDep, DDep);
++TC;
}
}
return ABRT_Success;
}
void appendTopLevelActions(ActionList &AL) override {
if (OpenMPDeviceActions.empty())
return;
// We should always have an action for each input.
assert(OpenMPDeviceActions.size() == ToolChains.size() &&
"Number of OpenMP actions and toolchains do not match.");
// Append all device actions followed by the proper offload action.
auto TI = ToolChains.begin();
for (auto *A : OpenMPDeviceActions) {
OffloadAction::DeviceDependences Dep;
Dep.add(*A, **TI, /*BoundArch=*/nullptr, Action::OFK_OpenMP);
AL.push_back(C.MakeAction<OffloadAction>(Dep, A->getType()));
++TI;
}
// We no longer need the action stored in this builder.
OpenMPDeviceActions.clear();
}
void appendLinkActions(ActionList &AL) override {
assert(ToolChains.size() == DeviceLinkerInputs.size() &&
"Toolchains and linker inputs sizes do not match.");
// Append a new link action for each device.
auto TC = ToolChains.begin();
for (auto &LI : DeviceLinkerInputs) {
auto *DeviceLinkAction =
C.MakeAction<LinkJobAction>(LI, types::TY_Image);
OffloadAction::DeviceDependences DeviceLinkDeps;
DeviceLinkDeps.add(*DeviceLinkAction, **TC, /*BoundArch=*/nullptr,
Action::OFK_OpenMP);
AL.push_back(C.MakeAction<OffloadAction>(DeviceLinkDeps,
DeviceLinkAction->getType()));
++TC;
}
DeviceLinkerInputs.clear();
}
void appendLinkDependences(OffloadAction::DeviceDependences &DA) override {}
bool initialize() override {
// Get the OpenMP toolchains. If we don't get any, the action builder will
// know there is nothing to do related to OpenMP offloading.
auto OpenMPTCRange = C.getOffloadToolChains<Action::OFK_OpenMP>();
for (auto TI = OpenMPTCRange.first, TE = OpenMPTCRange.second; TI != TE;
++TI)
ToolChains.push_back(TI->second);
DeviceLinkerInputs.resize(ToolChains.size());
return false;
}
bool canUseBundlerUnbundler() const override {
// OpenMP should use bundled files whenever possible.
return true;
}
};
///
/// TODO: Add the implementation for other specialized builders here.
///
/// Specialized builders being used by this offloading action builder.
SmallVector<DeviceActionBuilder *, 4> SpecializedBuilders;
/// Flag set to true if all valid builders allow file bundling/unbundling.
bool CanUseBundler;
public:
OffloadingActionBuilder(Compilation &C, DerivedArgList &Args,
const Driver::InputList &Inputs)
: C(C) {
// Create a specialized builder for each device toolchain.
IsValid = true;
// Create a specialized builder for CUDA.
SpecializedBuilders.push_back(new CudaActionBuilder(C, Args, Inputs));
// Create a specialized builder for HIP.
SpecializedBuilders.push_back(new HIPActionBuilder(C, Args, Inputs));
// Create a specialized builder for OpenMP.
SpecializedBuilders.push_back(new OpenMPActionBuilder(C, Args, Inputs));
//
// TODO: Build other specialized builders here.
//
// Initialize all the builders, keeping track of errors. If all valid
// builders agree that we can use bundling, set the flag to true.
unsigned ValidBuilders = 0u;
unsigned ValidBuildersSupportingBundling = 0u;
for (auto *SB : SpecializedBuilders) {
IsValid = IsValid && !SB->initialize();
// Update the counters if the builder is valid.
if (SB->isValid()) {
++ValidBuilders;
if (SB->canUseBundlerUnbundler())
++ValidBuildersSupportingBundling;
}
}
CanUseBundler =
ValidBuilders && ValidBuilders == ValidBuildersSupportingBundling;
}
~OffloadingActionBuilder() {
for (auto *SB : SpecializedBuilders)
delete SB;
}
/// Generate an action that adds device dependences (if any) to a host action.
/// If no device dependence actions exist, just return the host action \a
/// HostAction. If an error is found or if no builder requires the host action
/// to be generated, return nullptr.
Action *
addDeviceDependencesToHostAction(Action *HostAction, const Arg *InputArg,
phases::ID CurPhase, phases::ID FinalPhase,
DeviceActionBuilder::PhasesTy &Phases) {
if (!IsValid)
return nullptr;
if (SpecializedBuilders.empty())
return HostAction;
assert(HostAction && "Invalid host action!");
OffloadAction::DeviceDependences DDeps;
// Check if all the programming models agree we should not emit the host
// action. Also, keep track of the offloading kinds employed.
auto &OffloadKind = InputArgToOffloadKindMap[InputArg];
unsigned InactiveBuilders = 0u;
unsigned IgnoringBuilders = 0u;
for (auto *SB : SpecializedBuilders) {
if (!SB->isValid()) {
++InactiveBuilders;
continue;
}
auto RetCode =
SB->getDeviceDependences(DDeps, CurPhase, FinalPhase, Phases);
// If the builder explicitly says the host action should be ignored,
// we need to increment the variable that tracks the builders that request
// the host object to be ignored.
if (RetCode == DeviceActionBuilder::ABRT_Ignore_Host)
++IgnoringBuilders;
// Unless the builder was inactive for this action, we have to record the
// offload kind because the host will have to use it.
if (RetCode != DeviceActionBuilder::ABRT_Inactive)
OffloadKind |= SB->getAssociatedOffloadKind();
}
// If all builders agree that the host object should be ignored, just return
// nullptr.
if (IgnoringBuilders &&
SpecializedBuilders.size() == (InactiveBuilders + IgnoringBuilders))
return nullptr;
if (DDeps.getActions().empty())
return HostAction;
// We have dependences we need to bundle together. We use an offload action
// for that.
OffloadAction::HostDependence HDep(
*HostAction, *C.getSingleOffloadToolChain<Action::OFK_Host>(),
/*BoundArch=*/nullptr, DDeps);
return C.MakeAction<OffloadAction>(HDep, DDeps);
}
/// Generate an action that adds a host dependence to a device action. The
/// results will be kept in this action builder. Return true if an error was
/// found.
bool addHostDependenceToDeviceActions(Action *&HostAction,
const Arg *InputArg) {
if (!IsValid)
return true;
// If we are supporting bundling/unbundling and the current action is an
// input action of non-source file, we replace the host action by the
// unbundling action. The bundler tool has the logic to detect if an input
// is a bundle or not and if the input is not a bundle it assumes it is a
// host file. Therefore it is safe to create an unbundling action even if
// the input is not a bundle.
if (CanUseBundler && isa<InputAction>(HostAction) &&
InputArg->getOption().getKind() == llvm::opt::Option::InputClass &&
!types::isSrcFile(HostAction->getType())) {
auto UnbundlingHostAction =
C.MakeAction<OffloadUnbundlingJobAction>(HostAction);
UnbundlingHostAction->registerDependentActionInfo(
C.getSingleOffloadToolChain<Action::OFK_Host>(),
/*BoundArch=*/StringRef(), Action::OFK_Host);
HostAction = UnbundlingHostAction;
}
assert(HostAction && "Invalid host action!");
// Register the offload kinds that are used.
auto &OffloadKind = InputArgToOffloadKindMap[InputArg];
for (auto *SB : SpecializedBuilders) {
if (!SB->isValid())
continue;
auto RetCode = SB->addDeviceDepences(HostAction);
// Host dependences for device actions are not compatible with that same
// action being ignored.
assert(RetCode != DeviceActionBuilder::ABRT_Ignore_Host &&
"Host dependence not expected to be ignored.!");
// Unless the builder was inactive for this action, we have to record the
// offload kind because the host will have to use it.
if (RetCode != DeviceActionBuilder::ABRT_Inactive)
OffloadKind |= SB->getAssociatedOffloadKind();
}
// Do not use unbundler if the Host does not depend on device action.
if (OffloadKind == Action::OFK_None && CanUseBundler)
if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction))
HostAction = UA->getInputs().back();
return false;
}
/// Add the offloading top level actions to the provided action list. This
/// function can replace the host action by a bundling action if the
/// programming models allow it.
bool appendTopLevelActions(ActionList &AL, Action *HostAction,
const Arg *InputArg) {
// Get the device actions to be appended.
ActionList OffloadAL;
for (auto *SB : SpecializedBuilders) {
if (!SB->isValid())
continue;
SB->appendTopLevelActions(OffloadAL);
}
// If we can use the bundler, replace the host action by the bundling one in
// the resulting list. Otherwise, just append the device actions. For
// device only compilation, HostAction is a null pointer, therefore only do
// this when HostAction is not a null pointer.
if (CanUseBundler && HostAction &&
HostAction->getType() != types::TY_Nothing && !OffloadAL.empty()) {
// Add the host action to the list in order to create the bundling action.
OffloadAL.push_back(HostAction);
// We expect that the host action was just appended to the action list
// before this method was called.
assert(HostAction == AL.back() && "Host action not in the list??");
HostAction = C.MakeAction<OffloadBundlingJobAction>(OffloadAL);
AL.back() = HostAction;
} else
AL.append(OffloadAL.begin(), OffloadAL.end());
// Propagate to the current host action (if any) the offload information
// associated with the current input.
if (HostAction)
HostAction->propagateHostOffloadInfo(InputArgToOffloadKindMap[InputArg],
/*BoundArch=*/nullptr);
return false;
}
Action* makeHostLinkAction() {
// Build a list of device linking actions.
ActionList DeviceAL;
for (DeviceActionBuilder *SB : SpecializedBuilders) {
if (!SB->isValid())
continue;
SB->appendLinkActions(DeviceAL);
}
if (DeviceAL.empty())
return nullptr;
// Create wrapper bitcode from the result of device link actions and compile
// it to an object which will be added to the host link command.
auto *BC = C.MakeAction<OffloadWrapperJobAction>(DeviceAL, types::TY_LLVM_BC);
auto *ASM = C.MakeAction<BackendJobAction>(BC, types::TY_PP_Asm);
return C.MakeAction<AssembleJobAction>(ASM, types::TY_Object);
}
/// Processes the host linker action. This currently consists of replacing it
/// with an offload action if there are device link objects and propagate to
/// the host action all the offload kinds used in the current compilation. The
/// resulting action is returned.
Action *processHostLinkAction(Action *HostAction) {
// Add all the dependences from the device linking actions.
OffloadAction::DeviceDependences DDeps;
for (auto *SB : SpecializedBuilders) {
if (!SB->isValid())
continue;
SB->appendLinkDependences(DDeps);
}
// Calculate all the offload kinds used in the current compilation.
unsigned ActiveOffloadKinds = 0u;
for (auto &I : InputArgToOffloadKindMap)
ActiveOffloadKinds |= I.second;
// If we don't have device dependencies, we don't have to create an offload
// action.
if (DDeps.getActions().empty()) {
// Propagate all the active kinds to host action. Given that it is a link
// action it is assumed to depend on all actions generated so far.
HostAction->propagateHostOffloadInfo(ActiveOffloadKinds,
/*BoundArch=*/nullptr);
return HostAction;
}
// Create the offload action with all dependences. When an offload action
// is created the kinds are propagated to the host action, so we don't have
// to do that explicitly here.
OffloadAction::HostDependence HDep(
*HostAction, *C.getSingleOffloadToolChain<Action::OFK_Host>(),
/*BoundArch*/ nullptr, ActiveOffloadKinds);
return C.MakeAction<OffloadAction>(HDep, DDeps);
}
};
} // anonymous namespace.
void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
const InputList &Inputs,
ActionList &Actions) const {
// Ignore /Yc/Yu if both /Yc and /Yu passed but with different filenames.
Arg *YcArg = Args.getLastArg(options::OPT__SLASH_Yc);
Arg *YuArg = Args.getLastArg(options::OPT__SLASH_Yu);
if (YcArg && YuArg && strcmp(YcArg->getValue(), YuArg->getValue()) != 0) {
Diag(clang::diag::warn_drv_ycyu_different_arg_clang_cl);
Args.eraseArg(options::OPT__SLASH_Yc);
Args.eraseArg(options::OPT__SLASH_Yu);
YcArg = YuArg = nullptr;
}
if (YcArg && Inputs.size() > 1) {
Diag(clang::diag::warn_drv_yc_multiple_inputs_clang_cl);
Args.eraseArg(options::OPT__SLASH_Yc);
YcArg = nullptr;
}
Arg *FinalPhaseArg;
phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg);
if (FinalPhase == phases::Link) {
if (Args.hasArg(options::OPT_emit_llvm))
Diag(clang::diag::err_drv_emit_llvm_link);
if (IsCLMode() && LTOMode != LTOK_None &&
!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld"))
Diag(clang::diag::err_drv_lto_without_lld);
}
if (FinalPhase == phases::Preprocess || Args.hasArg(options::OPT__SLASH_Y_)) {
// If only preprocessing or /Y- is used, all pch handling is disabled.
// Rather than check for it everywhere, just remove clang-cl pch-related
// flags here.
Args.eraseArg(options::OPT__SLASH_Fp);
Args.eraseArg(options::OPT__SLASH_Yc);
Args.eraseArg(options::OPT__SLASH_Yu);
YcArg = YuArg = nullptr;
}
unsigned LastPLSize = 0;
for (auto &I : Inputs) {
types::ID InputType = I.first;
const Arg *InputArg = I.second;
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PL;
types::getCompilationPhases(InputType, PL);
LastPLSize = PL.size();
// If the first step comes after the final phase we are doing as part of
// this compilation, warn the user about it.
phases::ID InitialPhase = PL[0];
if (InitialPhase > FinalPhase) {
if (InputArg->isClaimed())
continue;
// Claim here to avoid the more general unused warning.
InputArg->claim();
// Suppress all unused style warnings with -Qunused-arguments
if (Args.hasArg(options::OPT_Qunused_arguments))
continue;
// Special case when final phase determined by binary name, rather than
// by a command-line argument with a corresponding Arg.
if (CCCIsCPP())
Diag(clang::diag::warn_drv_input_file_unused_by_cpp)
<< InputArg->getAsString(Args) << getPhaseName(InitialPhase);
// Special case '-E' warning on a previously preprocessed file to make
// more sense.
else if (InitialPhase == phases::Compile &&
(Args.getLastArg(options::OPT__SLASH_EP,
options::OPT__SLASH_P) ||
Args.getLastArg(options::OPT_E) ||
Args.getLastArg(options::OPT_M, options::OPT_MM)) &&
getPreprocessedType(InputType) == types::TY_INVALID)
Diag(clang::diag::warn_drv_preprocessed_input_file_unused)
<< InputArg->getAsString(Args) << !!FinalPhaseArg
<< (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : "");
else
Diag(clang::diag::warn_drv_input_file_unused)
<< InputArg->getAsString(Args) << getPhaseName(InitialPhase)
<< !!FinalPhaseArg
<< (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : "");
continue;
}
if (YcArg) {
// Add a separate precompile phase for the compile phase.
if (FinalPhase >= phases::Compile) {
const types::ID HeaderType = lookupHeaderTypeForSourceType(InputType);
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PCHPL;
types::getCompilationPhases(HeaderType, PCHPL);
// Build the pipeline for the pch file.
Action *ClangClPch = C.MakeAction<InputAction>(*InputArg, HeaderType);
for (phases::ID Phase : PCHPL)
ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
assert(ClangClPch);
Actions.push_back(ClangClPch);
// The driver currently exits after the first failed command. This
// relies on that behavior, to make sure if the pch generation fails,
// the main compilation won't run.
// FIXME: If the main compilation fails, the PCH generation should
// probably not be considered successful either.
}
}
}
// If we are linking, claim any options which are obviously only used for
// compilation.
// FIXME: Understand why the last Phase List length is used here.
if (FinalPhase == phases::Link && LastPLSize == 1) {
Args.ClaimAllArgs(options::OPT_CompileOnly_Group);
Args.ClaimAllArgs(options::OPT_cl_compile_Group);
}
}
void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
const InputList &Inputs, ActionList &Actions) const {
llvm::PrettyStackTraceString CrashInfo("Building compilation actions");
if (!SuppressMissingInputWarning && Inputs.empty()) {
Diag(clang::diag::err_drv_no_input_files);
return;
}
// Reject -Z* at the top level, these options should never have been exposed
// by gcc.
if (Arg *A = Args.getLastArg(options::OPT_Z_Joined))
Diag(clang::diag::err_drv_use_of_Z_option) << A->getAsString(Args);
// Diagnose misuse of /Fo.
if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fo)) {
StringRef V = A->getValue();
if (Inputs.size() > 1 && !V.empty() &&
!llvm::sys::path::is_separator(V.back())) {
// Check whether /Fo tries to name an output file for multiple inputs.
Diag(clang::diag::err_drv_out_file_argument_with_multiple_sources)
<< A->getSpelling() << V;
Args.eraseArg(options::OPT__SLASH_Fo);
}
}
// Diagnose misuse of /Fa.
if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fa)) {
StringRef V = A->getValue();
if (Inputs.size() > 1 && !V.empty() &&
!llvm::sys::path::is_separator(V.back())) {
// Check whether /Fa tries to name an asm file for multiple inputs.
Diag(clang::diag::err_drv_out_file_argument_with_multiple_sources)
<< A->getSpelling() << V;
Args.eraseArg(options::OPT__SLASH_Fa);
}
}
// Diagnose misuse of /o.
if (Arg *A = Args.getLastArg(options::OPT__SLASH_o)) {
if (A->getValue()[0] == '\0') {
// It has to have a value.
Diag(clang::diag::err_drv_missing_argument) << A->getSpelling() << 1;
Args.eraseArg(options::OPT__SLASH_o);
}
}
handleArguments(C, Args, Inputs, Actions);
// Builder to be used to build offloading actions.
OffloadingActionBuilder OffloadBuilder(C, Args, Inputs);
// Construct the actions to perform.
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr;
ActionList LinkerInputs;
ActionList MergerInputs;
for (auto &I : Inputs) {
types::ID InputType = I.first;
const Arg *InputArg = I.second;
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PL;
types::getCompilationPhases(*this, Args, InputType, PL);
if (PL.empty())
continue;
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> FullPL;
types::getCompilationPhases(InputType, FullPL);
// Build the pipeline for this file.
Action *Current = C.MakeAction<InputAction>(*InputArg, InputType);
// Use the current host action in any of the offloading actions, if
// required.
if (OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg))
break;
for (phases::ID Phase : PL) {
// Add any offload action the host action depends on.
Current = OffloadBuilder.addDeviceDependencesToHostAction(
Current, InputArg, Phase, PL.back(), FullPL);
if (!Current)
break;
// Queue linker inputs.
if (Phase == phases::Link) {
assert(Phase == PL.back() && "linking must be final compilation step.");
LinkerInputs.push_back(Current);
Current = nullptr;
break;
}
// TODO: Consider removing this because the merged may not end up being
// the final Phase in the pipeline. Perhaps the merged could just merge
// and then pass an artifact of some sort to the Link Phase.
// Queue merger inputs.
if (Phase == phases::IfsMerge) {
assert(Phase == PL.back() && "merging must be final compilation step.");
MergerInputs.push_back(Current);
Current = nullptr;
break;
}
// Each precompiled header file after a module file action is a module
// header of that same module file, rather than being compiled to a
// separate PCH.
if (Phase == phases::Precompile && HeaderModuleAction &&
getPrecompiledType(InputType) == types::TY_PCH) {
HeaderModuleAction->addModuleHeaderInput(Current);
Current = nullptr;
break;
}
// FIXME: Should we include any prior module file outputs as inputs of
// later actions in the same command line?
// Otherwise construct the appropriate action.
Action *NewCurrent = ConstructPhaseAction(C, Args, Phase, Current);
// We didn't create a new action, so we will just move to the next phase.
if (NewCurrent == Current)
continue;
if (auto *HMA = dyn_cast<HeaderModulePrecompileJobAction>(NewCurrent))
HeaderModuleAction = HMA;
Current = NewCurrent;
// Use the current host action in any of the offloading actions, if
// required.
if (OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg))
break;
if (Current->getType() == types::TY_Nothing)
break;
}
// If we ended with something, add to the output list.
if (Current)
Actions.push_back(Current);
// Add any top level actions generated for offloading.
OffloadBuilder.appendTopLevelActions(Actions, Current, InputArg);
}
// Add a link action if necessary.
if (!LinkerInputs.empty()) {
if (Action *Wrapper = OffloadBuilder.makeHostLinkAction())
LinkerInputs.push_back(Wrapper);
Action *LA = C.MakeAction<LinkJobAction>(LinkerInputs, types::TY_Image);
LA = OffloadBuilder.processHostLinkAction(LA);
Actions.push_back(LA);
}
// Add an interface stubs merge action if necessary.
if (!MergerInputs.empty())
Actions.push_back(
C.MakeAction<IfsMergeJobAction>(MergerInputs, types::TY_Image));
if (Args.hasArg(options::OPT_emit_interface_stubs)) {
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PhaseList;
if (Args.hasArg(options::OPT_c)) {
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> CompilePhaseList;
types::getCompilationPhases(types::TY_IFS_CPP, CompilePhaseList);
llvm::copy_if(CompilePhaseList, std::back_inserter(PhaseList),
[&](phases::ID Phase) { return Phase <= phases::Compile; });
} else {
types::getCompilationPhases(types::TY_IFS_CPP, PhaseList);
}
ActionList MergerInputs;
for (auto &I : Inputs) {
types::ID InputType = I.first;
const Arg *InputArg = I.second;
// Currently clang and the llvm assembler do not support generating symbol
// stubs from assembly, so we skip the input on asm files. For ifs files
// we rely on the normal pipeline setup in the pipeline setup code above.
if (InputType == types::TY_IFS || InputType == types::TY_PP_Asm ||
InputType == types::TY_Asm)
continue;
Action *Current = C.MakeAction<InputAction>(*InputArg, InputType);
for (auto Phase : PhaseList) {
switch (Phase) {
default:
llvm_unreachable(
"IFS Pipeline can only consist of Compile followed by IfsMerge.");
case phases::Compile: {
// Only IfsMerge (llvm-ifs) can handle .o files by looking for ifs
// files where the .o file is located. The compile action can not
// handle this.
if (InputType == types::TY_Object)
break;
Current = C.MakeAction<CompileJobAction>(Current, types::TY_IFS_CPP);
break;
}
case phases::IfsMerge: {
assert(Phase == PhaseList.back() &&
"merging must be final compilation step.");
MergerInputs.push_back(Current);
Current = nullptr;
break;
}
}
}
// If we ended with something, add to the output list.
if (Current)
Actions.push_back(Current);
}
// Add an interface stubs merge action if necessary.
if (!MergerInputs.empty())
Actions.push_back(
C.MakeAction<IfsMergeJobAction>(MergerInputs, types::TY_Image));
}
// If --print-supported-cpus, -mcpu=? or -mtune=? is specified, build a custom
// Compile phase that prints out supported cpu models and quits.
if (Arg *A = Args.getLastArg(options::OPT_print_supported_cpus)) {
// Use the -mcpu=? flag as the dummy input to cc1.
Actions.clear();
Action *InputAc = C.MakeAction<InputAction>(*A, types::TY_C);
Actions.push_back(
C.MakeAction<PrecompileJobAction>(InputAc, types::TY_Nothing));
for (auto &I : Inputs)
I.second->claim();
}
// Claim ignored clang-cl options.
Args.ClaimAllArgs(options::OPT_cl_ignored_Group);
// Claim --cuda-host-only and --cuda-compile-host-device, which may be passed
// to non-CUDA compilations and should not trigger warnings there.
Args.ClaimAllArgs(options::OPT_cuda_host_only);
Args.ClaimAllArgs(options::OPT_cuda_compile_host_device);
}
Action *Driver::ConstructPhaseAction(
Compilation &C, const ArgList &Args, phases::ID Phase, Action *Input,
Action::OffloadKind TargetDeviceOffloadKind) const {
llvm::PrettyStackTraceString CrashInfo("Constructing phase actions");
// Some types skip the assembler phase (e.g., llvm-bc), but we can't
// encode this in the steps because the intermediate type depends on
// arguments. Just special case here.
if (Phase == phases::Assemble && Input->getType() != types::TY_PP_Asm)
return Input;
// Build the appropriate action.
switch (Phase) {
case phases::Link:
llvm_unreachable("link action invalid here.");
case phases::IfsMerge:
llvm_unreachable("ifsmerge action invalid here.");
case phases::Preprocess: {
types::ID OutputTy;
// -M and -MM specify the dependency file name by altering the output type,
// -if -MD and -MMD are not specified.
if (Args.hasArg(options::OPT_M, options::OPT_MM) &&
!Args.hasArg(options::OPT_MD, options::OPT_MMD)) {
OutputTy = types::TY_Dependencies;
} else {
OutputTy = Input->getType();
if (!Args.hasFlag(options::OPT_frewrite_includes,
options::OPT_fno_rewrite_includes, false) &&
!Args.hasFlag(options::OPT_frewrite_imports,
options::OPT_fno_rewrite_imports, false) &&
!CCGenDiagnostics)
OutputTy = types::getPreprocessedType(OutputTy);
assert(OutputTy != types::TY_INVALID &&
"Cannot preprocess this input type!");
}
return C.MakeAction<PreprocessJobAction>(Input, OutputTy);
}
case phases::Precompile: {
types::ID OutputTy = getPrecompiledType(Input->getType());
assert(OutputTy != types::TY_INVALID &&
"Cannot precompile this input type!");
// If we're given a module name, precompile header file inputs as a
// module, not as a precompiled header.
const char *ModName = nullptr;
if (OutputTy == types::TY_PCH) {
if (Arg *A = Args.getLastArg(options::OPT_fmodule_name_EQ))
ModName = A->getValue();
if (ModName)
OutputTy = types::TY_ModuleFile;
}
if (Args.hasArg(options::OPT_fsyntax_only)) {
// Syntax checks should not emit a PCH file
OutputTy = types::TY_Nothing;
}
if (ModName)
return C.MakeAction<HeaderModulePrecompileJobAction>(Input, OutputTy,
ModName);
return C.MakeAction<PrecompileJobAction>(Input, OutputTy);
}
case phases::Compile: {
if (Args.hasArg(options::OPT_fsyntax_only))
return C.MakeAction<CompileJobAction>(Input, types::TY_Nothing);
if (Args.hasArg(options::OPT_rewrite_objc))
return C.MakeAction<CompileJobAction>(Input, types::TY_RewrittenObjC);
if (Args.hasArg(options::OPT_rewrite_legacy_objc))
return C.MakeAction<CompileJobAction>(Input,
types::TY_RewrittenLegacyObjC);
if (Args.hasArg(options::OPT__analyze))
return C.MakeAction<AnalyzeJobAction>(Input, types::TY_Plist);
if (Args.hasArg(options::OPT__migrate))
return C.MakeAction<MigrateJobAction>(Input, types::TY_Remap);
if (Args.hasArg(options::OPT_emit_ast))
return C.MakeAction<CompileJobAction>(Input, types::TY_AST);
if (Args.hasArg(options::OPT_module_file_info))
return C.MakeAction<CompileJobAction>(Input, types::TY_ModuleFile);
if (Args.hasArg(options::OPT_verify_pch))
return C.MakeAction<VerifyPCHJobAction>(Input, types::TY_Nothing);
return C.MakeAction<CompileJobAction>(Input, types::TY_LLVM_BC);
}
case phases::Backend: {
if (isUsingLTO() && TargetDeviceOffloadKind == Action::OFK_None) {
types::ID Output =
Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
return C.MakeAction<BackendJobAction>(Input, Output);
}
if (Args.hasArg(options::OPT_emit_llvm)) {
types::ID Output =
Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
return C.MakeAction<BackendJobAction>(Input, Output);
}
return C.MakeAction<BackendJobAction>(Input, types::TY_PP_Asm);
}
case phases::Assemble:
return C.MakeAction<AssembleJobAction>(std::move(Input), types::TY_Object);
}
llvm_unreachable("invalid phase in ConstructPhaseAction");
}
void Driver::BuildJobs(Compilation &C) const {
llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");
Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o);
// It is an error to provide a -o option if we are making multiple output
// files. There are exceptions:
//
// IfsMergeJob: when generating interface stubs enabled we want to be able to
// generate the stub file at the same time that we generate the real
// library/a.out. So when a .o, .so, etc are the output, with clang interface
// stubs there will also be a .ifs and .ifso at the same location.
//
// CompileJob of type TY_IFS_CPP: when generating interface stubs is enabled
// and -c is passed, we still want to be able to generate a .ifs file while
// we are also generating .o files. So we allow more than one output file in
// this case as well.
//
if (FinalOutput) {
unsigned NumOutputs = 0;
unsigned NumIfsOutputs = 0;
for (const Action *A : C.getActions())
if (A->getType() != types::TY_Nothing &&
!(A->getKind() == Action::IfsMergeJobClass ||
(A->getType() == clang::driver::types::TY_IFS_CPP &&
A->getKind() == clang::driver::Action::CompileJobClass &&
0 == NumIfsOutputs++) ||
(A->getKind() == Action::BindArchClass && A->getInputs().size() &&
A->getInputs().front()->getKind() == Action::IfsMergeJobClass)))
++NumOutputs;
if (NumOutputs > 1) {
Diag(clang::diag::err_drv_output_argument_with_multiple_files);
FinalOutput = nullptr;
}
}
// Collect the list of architectures.
llvm::StringSet<> ArchNames;
if (C.getDefaultToolChain().getTriple().isOSBinFormatMachO())
for (const Arg *A : C.getArgs())
if (A->getOption().matches(options::OPT_arch))
ArchNames.insert(A->getValue());
// Set of (Action, canonical ToolChain triple) pairs we've built jobs for.
std::map<std::pair<const Action *, std::string>, InputInfo> CachedResults;
for (Action *A : C.getActions()) {
// If we are linking an image for multiple archs then the linker wants
// -arch_multiple and -final_output <final image name>. Unfortunately, this
// doesn't fit in cleanly because we have to pass this information down.
//
// FIXME: This is a hack; find a cleaner way to integrate this into the
// process.
const char *LinkingOutput = nullptr;
if (isa<LipoJobAction>(A)) {
if (FinalOutput)
LinkingOutput = FinalOutput->getValue();
else
LinkingOutput = getDefaultImageName();
}
BuildJobsForAction(C, A, &C.getDefaultToolChain(),
/*BoundArch*/ StringRef(),
/*AtTopLevel*/ true,
/*MultipleArchs*/ ArchNames.size() > 1,
/*LinkingOutput*/ LinkingOutput, CachedResults,
/*TargetDeviceOffloadKind*/ Action::OFK_None);
}
// If the user passed -Qunused-arguments or there were errors, don't warn
// about any unused arguments.
if (Diags.hasErrorOccurred() ||
C.getArgs().hasArg(options::OPT_Qunused_arguments))
return;
// Claim -### here.
(void)C.getArgs().hasArg(options::OPT__HASH_HASH_HASH);
// Claim --driver-mode, --rsp-quoting, it was handled earlier.
(void)C.getArgs().hasArg(options::OPT_driver_mode);
(void)C.getArgs().hasArg(options::OPT_rsp_quoting);
for (Arg *A : C.getArgs()) {
// FIXME: It would be nice to be able to send the argument to the
// DiagnosticsEngine, so that extra values, position, and so on could be
// printed.
if (!A->isClaimed()) {
if (A->getOption().hasFlag(options::NoArgumentUnused))
continue;
// Suppress the warning automatically if this is just a flag, and it is an
// instance of an argument we already claimed.
const Option &Opt = A->getOption();
if (Opt.getKind() == Option::FlagClass) {
bool DuplicateClaimed = false;
for (const Arg *AA : C.getArgs().filtered(&Opt)) {
if (AA->isClaimed()) {
DuplicateClaimed = true;
break;
}
}
if (DuplicateClaimed)
continue;
}
// In clang-cl, don't mention unknown arguments here since they have
// already been warned about.
if (!IsCLMode() || !A->getOption().matches(options::OPT_UNKNOWN))
Diag(clang::diag::warn_drv_unused_argument)
<< A->getAsString(C.getArgs());
}
}
}
namespace {
/// Utility class to control the collapse of dependent actions and select the
/// tools accordingly.
class ToolSelector final {
/// The tool chain this selector refers to.
const ToolChain &TC;
/// The compilation this selector refers to.
const Compilation &C;
/// The base action this selector refers to.
const JobAction *BaseAction;
/// Set to true if the current toolchain refers to host actions.
bool IsHostSelector;
/// Set to true if save-temps and embed-bitcode functionalities are active.
bool SaveTemps;
bool EmbedBitcode;
/// Get previous dependent action or null if that does not exist. If
/// \a CanBeCollapsed is false, that action must be legal to collapse or
/// null will be returned.
const JobAction *getPrevDependentAction(const ActionList &Inputs,
ActionList &SavedOffloadAction,
bool CanBeCollapsed = true) {
// An option can be collapsed only if it has a single input.
if (Inputs.size() != 1)
return nullptr;
Action *CurAction = *Inputs.begin();
if (CanBeCollapsed &&
!CurAction->isCollapsingWithNextDependentActionLegal())
return nullptr;
// If the input action is an offload action. Look through it and save any
// offload action that can be dropped in the event of a collapse.
if (auto *OA = dyn_cast<OffloadAction>(CurAction)) {
// If the dependent action is a device action, we will attempt to collapse
// only with other device actions. Otherwise, we would do the same but
// with host actions only.
if (!IsHostSelector) {
if (OA->hasSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)) {
CurAction =
OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true);
if (CanBeCollapsed &&
!CurAction->isCollapsingWithNextDependentActionLegal())
return nullptr;
SavedOffloadAction.push_back(OA);
return dyn_cast<JobAction>(CurAction);
}
} else if (OA->hasHostDependence()) {
CurAction = OA->getHostDependence();
if (CanBeCollapsed &&
!CurAction->isCollapsingWithNextDependentActionLegal())
return nullptr;
SavedOffloadAction.push_back(OA);
return dyn_cast<JobAction>(CurAction);
}
return nullptr;
}
return dyn_cast<JobAction>(CurAction);
}
/// Return true if an assemble action can be collapsed.
bool canCollapseAssembleAction() const {
return TC.useIntegratedAs() && !SaveTemps &&
!C.getArgs().hasArg(options::OPT_via_file_asm) &&
!C.getArgs().hasArg(options::OPT__SLASH_FA) &&
!C.getArgs().hasArg(options::OPT__SLASH_Fa);
}
/// Return true if a preprocessor action can be collapsed.
bool canCollapsePreprocessorAction() const {
return !C.getArgs().hasArg(options::OPT_no_integrated_cpp) &&
!C.getArgs().hasArg(options::OPT_traditional_cpp) && !SaveTemps &&
!C.getArgs().hasArg(options::OPT_rewrite_objc);
}
/// Struct that relates an action with the offload actions that would be
/// collapsed with it.
struct JobActionInfo final {
/// The action this info refers to.
const JobAction *JA = nullptr;
/// The offload actions we need to take care off if this action is
/// collapsed.
ActionList SavedOffloadAction;
};
/// Append collapsed offload actions from the give nnumber of elements in the
/// action info array.
static void AppendCollapsedOffloadAction(ActionList &CollapsedOffloadAction,
ArrayRef<JobActionInfo> &ActionInfo,
unsigned ElementNum) {
assert(ElementNum <= ActionInfo.size() && "Invalid number of elements.");
for (unsigned I = 0; I < ElementNum; ++I)
CollapsedOffloadAction.append(ActionInfo[I].SavedOffloadAction.begin(),
ActionInfo[I].SavedOffloadAction.end());
}
/// Functions that attempt to perform the combining. They detect if that is
/// legal, and if so they update the inputs \a Inputs and the offload action
/// that were collapsed in \a CollapsedOffloadAction. A tool that deals with
/// the combined action is returned. If the combining is not legal or if the
/// tool does not exist, null is returned.
/// Currently three kinds of collapsing are supported:
/// - Assemble + Backend + Compile;
/// - Assemble + Backend ;
/// - Backend + Compile.
const Tool *
combineAssembleBackendCompile(ArrayRef<JobActionInfo> ActionInfo,
ActionList &Inputs,
ActionList &CollapsedOffloadAction) {
if (ActionInfo.size() < 3 || !canCollapseAssembleAction())
return nullptr;
auto *AJ = dyn_cast<AssembleJobAction>(ActionInfo[0].JA);
auto *BJ = dyn_cast<BackendJobAction>(ActionInfo[1].JA);
auto *CJ = dyn_cast<CompileJobAction>(ActionInfo[2].JA);
if (!AJ || !BJ || !CJ)
return nullptr;
// Get compiler tool.
const Tool *T = TC.SelectTool(*CJ);
if (!T)
return nullptr;
// When using -fembed-bitcode, it is required to have the same tool (clang)
// for both CompilerJA and BackendJA. Otherwise, combine two stages.
if (EmbedBitcode) {
const Tool *BT = TC.SelectTool(*BJ);
if (BT == T)
return nullptr;
}
if (!T->hasIntegratedAssembler())
return nullptr;
Inputs = CJ->getInputs();
AppendCollapsedOffloadAction(CollapsedOffloadAction, ActionInfo,
/*NumElements=*/3);
return T;
}
const Tool *combineAssembleBackend(ArrayRef<JobActionInfo> ActionInfo,
ActionList &Inputs,
ActionList &CollapsedOffloadAction) {
if (ActionInfo.size() < 2 || !canCollapseAssembleAction())
return nullptr;
auto *AJ = dyn_cast<AssembleJobAction>(ActionInfo[0].JA);
auto *BJ = dyn_cast<BackendJobAction>(ActionInfo[1].JA);
if (!AJ || !BJ)
return nullptr;
// Get backend tool.
const Tool *T = TC.SelectTool(*BJ);
if (!T)
return nullptr;
if (!T->hasIntegratedAssembler())
return nullptr;
Inputs = BJ->getInputs();
AppendCollapsedOffloadAction(CollapsedOffloadAction, ActionInfo,
/*NumElements=*/2);
return T;
}
const Tool *combineBackendCompile(ArrayRef<JobActionInfo> ActionInfo,
ActionList &Inputs,
ActionList &CollapsedOffloadAction) {
if (ActionInfo.size() < 2)
return nullptr;
auto *BJ = dyn_cast<BackendJobAction>(ActionInfo[0].JA);
auto *CJ = dyn_cast<CompileJobAction>(ActionInfo[1].JA);
if (!BJ || !CJ)
return nullptr;
// Check if the initial input (to the compile job or its predessor if one
// exists) is LLVM bitcode. In that case, no preprocessor step is required
// and we can still collapse the compile and backend jobs when we have
// -save-temps. I.e. there is no need for a separate compile job just to
// emit unoptimized bitcode.
bool InputIsBitcode = true;
for (size_t i = 1; i < ActionInfo.size(); i++)
if (ActionInfo[i].JA->getType() != types::TY_LLVM_BC &&
ActionInfo[i].JA->getType() != types::TY_LTO_BC) {
InputIsBitcode = false;
break;
}
if (!InputIsBitcode && !canCollapsePreprocessorAction())
return nullptr;
// Get compiler tool.
const Tool *T = TC.SelectTool(*CJ);
if (!T)
return nullptr;
if (T->canEmitIR() && ((SaveTemps && !InputIsBitcode) || EmbedBitcode))
return nullptr;
Inputs = CJ->getInputs();
AppendCollapsedOffloadAction(CollapsedOffloadAction, ActionInfo,
/*NumElements=*/2);
return T;
}
/// Updates the inputs if the obtained tool supports combining with
/// preprocessor action, and the current input is indeed a preprocessor
/// action. If combining results in the collapse of offloading actions, those
/// are appended to \a CollapsedOffloadAction.
void combineWithPreprocessor(const Tool *T, ActionList &Inputs,
ActionList &CollapsedOffloadAction) {
if (!T || !canCollapsePreprocessorAction() || !T->hasIntegratedCPP())
return;
// Attempt to get a preprocessor action dependence.
ActionList PreprocessJobOffloadActions;
ActionList NewInputs;
for (Action *A : Inputs) {
auto *PJ = getPrevDependentAction({A}, PreprocessJobOffloadActions);
if (!PJ || !isa<PreprocessJobAction>(PJ)) {
NewInputs.push_back(A);
continue;
}
// This is legal to combine. Append any offload action we found and add the
// current input to preprocessor inputs.
CollapsedOffloadAction.append(PreprocessJobOffloadActions.begin(),
PreprocessJobOffloadActions.end());
NewInputs.append(PJ->input_begin(), PJ->input_end());
}
Inputs = NewInputs;
}
public:
ToolSelector(const JobAction *BaseAction, const ToolChain &TC,
const Compilation &C, bool SaveTemps, bool EmbedBitcode)
: TC(TC), C(C), BaseAction(BaseAction), SaveTemps(SaveTemps),
EmbedBitcode(EmbedBitcode) {
assert(BaseAction && "Invalid base action.");
IsHostSelector = BaseAction->getOffloadingDeviceKind() == Action::OFK_None;
}
/// Check if a chain of actions can be combined and return the tool that can
/// handle the combination of actions. The pointer to the current inputs \a
/// Inputs and the list of offload actions \a CollapsedOffloadActions
/// connected to collapsed actions are updated accordingly. The latter enables
/// the caller of the selector to process them afterwards instead of just
/// dropping them. If no suitable tool is found, null will be returned.
const Tool *getTool(ActionList &Inputs,
ActionList &CollapsedOffloadAction) {
//
// Get the largest chain of actions that we could combine.
//
SmallVector<JobActionInfo, 5> ActionChain(1);
ActionChain.back().JA = BaseAction;
while (ActionChain.back().JA) {
const Action *CurAction = ActionChain.back().JA;
// Grow the chain by one element.
ActionChain.resize(ActionChain.size() + 1);
JobActionInfo &AI = ActionChain.back();
// Attempt to fill it with the
AI.JA =
getPrevDependentAction(CurAction->getInputs(), AI.SavedOffloadAction);
}
// Pop the last action info as it could not be filled.
ActionChain.pop_back();
//
// Attempt to combine actions. If all combining attempts failed, just return
// the tool of the provided action. At the end we attempt to combine the
// action with any preprocessor action it may depend on.
//
const Tool *T = combineAssembleBackendCompile(ActionChain, Inputs,
CollapsedOffloadAction);
if (!T)
T = combineAssembleBackend(ActionChain, Inputs, CollapsedOffloadAction);
if (!T)
T = combineBackendCompile(ActionChain, Inputs, CollapsedOffloadAction);
if (!T) {
Inputs = BaseAction->getInputs();
T = TC.SelectTool(*BaseAction);
}
combineWithPreprocessor(T, Inputs, CollapsedOffloadAction);
return T;
}
};
}
/// Return a string that uniquely identifies the result of a job. The bound arch
/// is not necessarily represented in the toolchain's triple -- for example,
/// armv7 and armv7s both map to the same triple -- so we need both in our map.
/// Also, we need to add the offloading device kind, as the same tool chain can
/// be used for host and device for some programming models, e.g. OpenMP.
static std::string GetTriplePlusArchString(const ToolChain *TC,
StringRef BoundArch,
Action::OffloadKind OffloadKind) {
std::string TriplePlusArch = TC->getTriple().normalize();
if (!BoundArch.empty()) {
TriplePlusArch += "-";
TriplePlusArch += BoundArch;
}
TriplePlusArch += "-";
TriplePlusArch += Action::GetOffloadKindName(OffloadKind);
return TriplePlusArch;
}
InputInfo Driver::BuildJobsForAction(
Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults,
Action::OffloadKind TargetDeviceOffloadKind) const {
std::pair<const Action *, std::string> ActionTC = {
A, GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
auto CachedResult = CachedResults.find(ActionTC);
if (CachedResult != CachedResults.end()) {
return CachedResult->second;
}
InputInfo Result = BuildJobsForActionNoCache(
C, A, TC, BoundArch, AtTopLevel, MultipleArchs, LinkingOutput,
CachedResults, TargetDeviceOffloadKind);
CachedResults[ActionTC] = Result;
return Result;
}
InputInfo Driver::BuildJobsForActionNoCache(
Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
std::map<std::pair<const Action *, std::string>, InputInfo> &CachedResults,
Action::OffloadKind TargetDeviceOffloadKind) const {
llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");
InputInfoList OffloadDependencesInputInfo;
bool BuildingForOffloadDevice = TargetDeviceOffloadKind != Action::OFK_None;
if (const OffloadAction *OA = dyn_cast<OffloadAction>(A)) {
// The 'Darwin' toolchain is initialized only when its arguments are
// computed. Get the default arguments for OFK_None to ensure that
// initialization is performed before processing the offload action.
// FIXME: Remove when darwin's toolchain is initialized during construction.
C.getArgsForToolChain(TC, BoundArch, Action::OFK_None);
// The offload action is expected to be used in four different situations.
//
// a) Set a toolchain/architecture/kind for a host action:
// Host Action 1 -> OffloadAction -> Host Action 2
//
// b) Set a toolchain/architecture/kind for a device action;
// Device Action 1 -> OffloadAction -> Device Action 2
//
// c) Specify a device dependence to a host action;
// Device Action 1 _
// \
// Host Action 1 ---> OffloadAction -> Host Action 2
//
// d) Specify a host dependence to a device action.
// Host Action 1 _
// \
// Device Action 1 ---> OffloadAction -> Device Action 2
//
// For a) and b), we just return the job generated for the dependence. For
// c) and d) we override the current action with the host/device dependence
// if the current toolchain is host/device and set the offload dependences
// info with the jobs obtained from the device/host dependence(s).
// If there is a single device option, just generate the job for it.
if (OA->hasSingleDeviceDependence()) {
InputInfo DevA;
OA->doOnEachDeviceDependence([&](Action *DepA, const ToolChain *DepTC,
const char *DepBoundArch) {
DevA =
BuildJobsForAction(C, DepA, DepTC, DepBoundArch, AtTopLevel,
/*MultipleArchs*/ !!DepBoundArch, LinkingOutput,
CachedResults, DepA->getOffloadingDeviceKind());
});
return DevA;
}
// If 'Action 2' is host, we generate jobs for the device dependences and
// override the current action with the host dependence. Otherwise, we
// generate the host dependences and override the action with the device
// dependence. The dependences can't therefore be a top-level action.
OA->doOnEachDependence(
/*IsHostDependence=*/BuildingForOffloadDevice,
[&](Action *DepA, const ToolChain *DepTC, const char *DepBoundArch) {
OffloadDependencesInputInfo.push_back(BuildJobsForAction(
C, DepA, DepTC, DepBoundArch, /*AtTopLevel=*/false,
/*MultipleArchs*/ !!DepBoundArch, LinkingOutput, CachedResults,
DepA->getOffloadingDeviceKind()));
});
A = BuildingForOffloadDevice
? OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)
: OA->getHostDependence();
}
if (const InputAction *IA = dyn_cast<InputAction>(A)) {
// FIXME: It would be nice to not claim this here; maybe the old scheme of
// just using Args was better?
const Arg &Input = IA->getInputArg();
Input.claim();
if (Input.getOption().matches(options::OPT_INPUT)) {
const char *Name = Input.getValue();
return InputInfo(A, Name, /* _BaseInput = */ Name);
}
return InputInfo(A, &Input, /* _BaseInput = */ "");
}
if (const BindArchAction *BAA = dyn_cast<BindArchAction>(A)) {
const ToolChain *TC;
StringRef ArchName = BAA->getArchName();
if (!ArchName.empty())
TC = &getToolChain(C.getArgs(),
computeTargetTriple(*this, TargetTriple,
C.getArgs(), ArchName));
else
TC = &C.getDefaultToolChain();
return BuildJobsForAction(C, *BAA->input_begin(), TC, ArchName, AtTopLevel,
MultipleArchs, LinkingOutput, CachedResults,
TargetDeviceOffloadKind);
}
ActionList Inputs = A->getInputs();
const JobAction *JA = cast<JobAction>(A);
ActionList CollapsedOffloadActions;
ToolSelector TS(JA, *TC, C, isSaveTempsEnabled(),
embedBitcodeInObject() && !isUsingLTO());
const Tool *T = TS.getTool(Inputs, CollapsedOffloadActions);
if (!T)
return InputInfo();
// If we've collapsed action list that contained OffloadAction we
// need to build jobs for host/device-side inputs it may have held.
for (const auto *OA : CollapsedOffloadActions)
cast<OffloadAction>(OA)->doOnEachDependence(
/*IsHostDependence=*/BuildingForOffloadDevice,
[&](Action *DepA, const ToolChain *DepTC, const char *DepBoundArch) {
OffloadDependencesInputInfo.push_back(BuildJobsForAction(
C, DepA, DepTC, DepBoundArch, /* AtTopLevel */ false,
/*MultipleArchs=*/!!DepBoundArch, LinkingOutput, CachedResults,
DepA->getOffloadingDeviceKind()));
});
// Only use pipes when there is exactly one input.
InputInfoList InputInfos;
for (const Action *Input : Inputs) {
// Treat dsymutil and verify sub-jobs as being at the top-level too, they
// shouldn't get temporary output names.
// FIXME: Clean this up.
bool SubJobAtTopLevel =
AtTopLevel && (isa<DsymutilJobAction>(A) || isa<VerifyJobAction>(A));
InputInfos.push_back(BuildJobsForAction(
C, Input, TC, BoundArch, SubJobAtTopLevel, MultipleArchs, LinkingOutput,
CachedResults, A->getOffloadingDeviceKind()));
}
// Always use the first input as the base input.
const char *BaseInput = InputInfos[0].getBaseInput();
// ... except dsymutil actions, which use their actual input as the base
// input.
if (JA->getType() == types::TY_dSYM)
BaseInput = InputInfos[0].getFilename();
// ... and in header module compilations, which use the module name.
if (auto *ModuleJA = dyn_cast<HeaderModulePrecompileJobAction>(JA))
BaseInput = ModuleJA->getModuleName();
// Append outputs of offload device jobs to the input list
if (!OffloadDependencesInputInfo.empty())
InputInfos.append(OffloadDependencesInputInfo.begin(),
OffloadDependencesInputInfo.end());
// Set the effective triple of the toolchain for the duration of this job.
llvm::Triple EffectiveTriple;
const ToolChain &ToolTC = T->getToolChain();
const ArgList &Args =
C.getArgsForToolChain(TC, BoundArch, A->getOffloadingDeviceKind());
if (InputInfos.size() != 1) {
EffectiveTriple = llvm::Triple(ToolTC.ComputeEffectiveClangTriple(Args));
} else {
// Pass along the input type if it can be unambiguously determined.
EffectiveTriple = llvm::Triple(
ToolTC.ComputeEffectiveClangTriple(Args, InputInfos[0].getType()));
}
RegisterEffectiveTriple TripleRAII(ToolTC, EffectiveTriple);
// Determine the place to write output to, if any.
InputInfo Result;
InputInfoList UnbundlingResults;
if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(JA)) {
// If we have an unbundling job, we need to create results for all the
// outputs. We also update the results cache so that other actions using
// this unbundling action can get the right results.
for (auto &UI : UA->getDependentActionsInfo()) {
assert(UI.DependentOffloadKind != Action::OFK_None &&
"Unbundling with no offloading??");
// Unbundling actions are never at the top level. When we generate the
// offloading prefix, we also do that for the host file because the
// unbundling action does not change the type of the output which can
// cause a overwrite.
std::string OffloadingPrefix = Action::GetOffloadingFileNamePrefix(
UI.DependentOffloadKind,
UI.DependentToolChain->getTriple().normalize(),
/*CreatePrefixForHost=*/true);
auto CurI = InputInfo(
UA,
GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
/*AtTopLevel=*/false,
MultipleArchs ||
UI.DependentOffloadKind == Action::OFK_HIP,
OffloadingPrefix),
BaseInput);
// Save the unbundling result.
UnbundlingResults.push_back(CurI);
// Get the unique string identifier for this dependence and cache the
// result.
StringRef Arch;
if (TargetDeviceOffloadKind == Action::OFK_HIP) {
if (UI.DependentOffloadKind == Action::OFK_Host)
Arch = StringRef();
else
Arch = UI.DependentBoundArch;
} else
Arch = BoundArch;
CachedResults[{A, GetTriplePlusArchString(UI.DependentToolChain, Arch,
UI.DependentOffloadKind)}] =
CurI;
}
// Now that we have all the results generated, select the one that should be
// returned for the current depending action.
std::pair<const Action *, std::string> ActionTC = {
A, GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
assert(CachedResults.find(ActionTC) != CachedResults.end() &&
"Result does not exist??");
Result = CachedResults[ActionTC];
} else if (JA->getType() == types::TY_Nothing)
Result = InputInfo(A, BaseInput);
else {
// We only have to generate a prefix for the host if this is not a top-level
// action.
std::string OffloadingPrefix = Action::GetOffloadingFileNamePrefix(
A->getOffloadingDeviceKind(), TC->getTriple().normalize(),
/*CreatePrefixForHost=*/!!A->getOffloadingHostActiveKinds() &&
!AtTopLevel);
if (isa<OffloadWrapperJobAction>(JA)) {
OffloadingPrefix += "-wrapper";
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
BaseInput = FinalOutput->getValue();
else
BaseInput = getDefaultImageName();
}
Result = InputInfo(A, GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
AtTopLevel, MultipleArchs,
OffloadingPrefix),
BaseInput);
}
if (CCCPrintBindings && !CCGenDiagnostics) {
llvm::errs() << "# \"" << T->getToolChain().getTripleString() << '"'
<< " - \"" << T->getName() << "\", inputs: [";
for (unsigned i = 0, e = InputInfos.size(); i != e; ++i) {
llvm::errs() << InputInfos[i].getAsString();
if (i + 1 != e)
llvm::errs() << ", ";
}
if (UnbundlingResults.empty())
llvm::errs() << "], output: " << Result.getAsString() << "\n";
else {
llvm::errs() << "], outputs: [";
for (unsigned i = 0, e = UnbundlingResults.size(); i != e; ++i) {
llvm::errs() << UnbundlingResults[i].getAsString();
if (i + 1 != e)
llvm::errs() << ", ";
}
llvm::errs() << "] \n";
}
} else {
if (UnbundlingResults.empty())
T->ConstructJob(
C, *JA, Result, InputInfos,
C.getArgsForToolChain(TC, BoundArch, JA->getOffloadingDeviceKind()),
LinkingOutput);
else
T->ConstructJobMultipleOutputs(
C, *JA, UnbundlingResults, InputInfos,
C.getArgsForToolChain(TC, BoundArch, JA->getOffloadingDeviceKind()),
LinkingOutput);
}
return Result;
}
const char *Driver::getDefaultImageName() const {
llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
return Target.isOSWindows() ? "a.exe" : "a.out";
}
/// Create output filename based on ArgValue, which could either be a
/// full filename, filename without extension, or a directory. If ArgValue
/// does not provide a filename, then use BaseName, and use the extension
/// suitable for FileType.
static const char *MakeCLOutputFilename(const ArgList &Args, StringRef ArgValue,
StringRef BaseName,
types::ID FileType) {
SmallString<128> Filename = ArgValue;
if (ArgValue.empty()) {
// If the argument is empty, output to BaseName in the current dir.
Filename = BaseName;
} else if (llvm::sys::path::is_separator(Filename.back())) {
// If the argument is a directory, output to BaseName in that dir.
llvm::sys::path::append(Filename, BaseName);
}
if (!llvm::sys::path::has_extension(ArgValue)) {
// If the argument didn't provide an extension, then set it.
const char *Extension = types::getTypeTempSuffix(FileType, true);
if (FileType == types::TY_Image &&
Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd)) {
// The output file is a dll.
Extension = "dll";
}
llvm::sys::path::replace_extension(Filename, Extension);
}
return Args.MakeArgString(Filename.c_str());
}
const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,
StringRef BoundArch, bool AtTopLevel,
bool MultipleArchs,
StringRef OffloadingPrefix) const {
llvm::PrettyStackTraceString CrashInfo("Computing output path");
// Output to a user requested destination?
if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
return C.addResultFile(FinalOutput->getValue(), &JA);
}
// For /P, preprocess to file named after BaseInput.
if (C.getArgs().hasArg(options::OPT__SLASH_P)) {
assert(AtTopLevel && isa<PreprocessJobAction>(JA));
StringRef BaseName = llvm::sys::path::filename(BaseInput);
StringRef NameArg;
if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi))
NameArg = A->getValue();
return C.addResultFile(
MakeCLOutputFilename(C.getArgs(), NameArg, BaseName, types::TY_PP_C),
&JA);
}
// Default to writing to stdout?
if (AtTopLevel && !CCGenDiagnostics && isa<PreprocessJobAction>(JA))
return "-";
// Is this the assembly listing for /FA?
if (JA.getType() == types::TY_PP_Asm &&
(C.getArgs().hasArg(options::OPT__SLASH_FA) ||
C.getArgs().hasArg(options::OPT__SLASH_Fa))) {
// Use /Fa and the input filename to determine the asm file name.
StringRef BaseName = llvm::sys::path::filename(BaseInput);
StringRef FaValue = C.getArgs().getLastArgValue(options::OPT__SLASH_Fa);
return C.addResultFile(
MakeCLOutputFilename(C.getArgs(), FaValue, BaseName, JA.getType()),
&JA);
}
// Output to a temporary file?
if ((!AtTopLevel && !isSaveTempsEnabled() &&
!C.getArgs().hasArg(options::OPT__SLASH_Fo)) ||
CCGenDiagnostics) {
StringRef Name = llvm::sys::path::filename(BaseInput);
std::pair<StringRef, StringRef> Split = Name.split('.');
SmallString<128> TmpName;
const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
if (CCGenDiagnostics && A) {
SmallString<128> CrashDirectory(A->getValue());
if (!getVFS().exists(CrashDirectory))
llvm::sys::fs::create_directories(CrashDirectory);
llvm::sys::path::append(CrashDirectory, Split.first);
const char *Middle = Suffix ? "-%%%%%%." : "-%%%%%%";
std::error_code EC = llvm::sys::fs::createUniqueFile(
CrashDirectory + Middle + Suffix, TmpName);
if (EC) {
Diag(clang::diag::err_unable_to_make_temp) << EC.message();
return "";
}
} else {
TmpName = GetTemporaryPath(Split.first, Suffix);
}
return C.addTempFile(C.getArgs().MakeArgString(TmpName));
}
SmallString<128> BasePath(BaseInput);
StringRef BaseName;
// Dsymutil actions should use the full path.
if (isa<DsymutilJobAction>(JA) || isa<VerifyJobAction>(JA))
BaseName = BasePath;
else
BaseName = llvm::sys::path::filename(BasePath);
// Determine what the derived output name should be.
const char *NamedOutput;
if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC) &&
C.getArgs().hasArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)) {
// The /Fo or /o flag decides the object filename.
StringRef Val =
C.getArgs()
.getLastArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)
->getValue();
NamedOutput =
MakeCLOutputFilename(C.getArgs(), Val, BaseName, types::TY_Object);
} else if (JA.getType() == types::TY_Image &&
C.getArgs().hasArg(options::OPT__SLASH_Fe,
options::OPT__SLASH_o)) {
// The /Fe or /o flag names the linked file.
StringRef Val =
C.getArgs()
.getLastArg(options::OPT__SLASH_Fe, options::OPT__SLASH_o)
->getValue();
NamedOutput =
MakeCLOutputFilename(C.getArgs(), Val, BaseName, types::TY_Image);
} else if (JA.getType() == types::TY_Image) {
if (IsCLMode()) {
// clang-cl uses BaseName for the executable name.
NamedOutput =
MakeCLOutputFilename(C.getArgs(), "", BaseName, types::TY_Image);
} else {
SmallString<128> Output(getDefaultImageName());
// HIP image for device compilation with -fno-gpu-rdc is per compilation
// unit.
bool IsHIPNoRDC = JA.getOffloadingDeviceKind() == Action::OFK_HIP &&
!C.getArgs().hasFlag(options::OPT_fgpu_rdc,
options::OPT_fno_gpu_rdc, false);
if (IsHIPNoRDC) {
Output = BaseName;
llvm::sys::path::replace_extension(Output, "");
}
Output += OffloadingPrefix;
if (MultipleArchs && !BoundArch.empty()) {
Output += "-";
Output.append(BoundArch);
}
if (IsHIPNoRDC)
Output += ".out";
NamedOutput = C.getArgs().MakeArgString(Output.c_str());
}
} else if (JA.getType() == types::TY_PCH && IsCLMode()) {
NamedOutput = C.getArgs().MakeArgString(GetClPchPath(C, BaseName));
} else {
const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
assert(Suffix && "All types used for output should have a suffix.");
std::string::size_type End = std::string::npos;
if (!types::appendSuffixForType(JA.getType()))
End = BaseName.rfind('.');
SmallString<128> Suffixed(BaseName.substr(0, End));
Suffixed += OffloadingPrefix;
if (MultipleArchs && !BoundArch.empty()) {
Suffixed += "-";
Suffixed.append(BoundArch);
}
// When using both -save-temps and -emit-llvm, use a ".tmp.bc" suffix for
// the unoptimized bitcode so that it does not get overwritten by the ".bc"
// optimized bitcode output.
if (!AtTopLevel && C.getArgs().hasArg(options::OPT_emit_llvm) &&
JA.getType() == types::TY_LLVM_BC)
Suffixed += ".tmp";
Suffixed += '.';
Suffixed += Suffix;
NamedOutput = C.getArgs().MakeArgString(Suffixed.c_str());
}
// Prepend object file path if -save-temps=obj
if (!AtTopLevel && isSaveTempsObj() && C.getArgs().hasArg(options::OPT_o) &&
JA.getType() != types::TY_PCH) {
Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o);
SmallString<128> TempPath(FinalOutput->getValue());
llvm::sys::path::remove_filename(TempPath);
StringRef OutputFileName = llvm::sys::path::filename(NamedOutput);
llvm::sys::path::append(TempPath, OutputFileName);
NamedOutput = C.getArgs().MakeArgString(TempPath.c_str());
}
// If we're saving temps and the temp file conflicts with the input file,
// then avoid overwriting input file.
if (!AtTopLevel && isSaveTempsEnabled() && NamedOutput == BaseName) {
bool SameFile = false;
SmallString<256> Result;
llvm::sys::fs::current_path(Result);
llvm::sys::path::append(Result, BaseName);
llvm::sys::fs::equivalent(BaseInput, Result.c_str(), SameFile);
// Must share the same path to conflict.
if (SameFile) {
StringRef Name = llvm::sys::path::filename(BaseInput);
std::pair<StringRef, StringRef> Split = Name.split('.');
std::string TmpName = GetTemporaryPath(
Split.first, types::getTypeTempSuffix(JA.getType(), IsCLMode()));
return C.addTempFile(C.getArgs().MakeArgString(TmpName));
}
}
// As an annoying special case, PCH generation doesn't strip the pathname.
if (JA.getType() == types::TY_PCH && !IsCLMode()) {
llvm::sys::path::remove_filename(BasePath);
if (BasePath.empty())
BasePath = NamedOutput;
else
llvm::sys::path::append(BasePath, NamedOutput);
return C.addResultFile(C.getArgs().MakeArgString(BasePath.c_str()), &JA);
} else {
return C.addResultFile(NamedOutput, &JA);
}
}
std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
// Search for Name in a list of paths.
auto SearchPaths = [&](const llvm::SmallVectorImpl<std::string> &P)
-> llvm::Optional<std::string> {
// Respect a limited subset of the '-Bprefix' functionality in GCC by
// attempting to use this prefix when looking for file paths.
for (const auto &Dir : P) {
if (Dir.empty())
continue;
SmallString<128> P(Dir[0] == '=' ? SysRoot + Dir.substr(1) : Dir);
llvm::sys::path::append(P, Name);
if (llvm::sys::fs::exists(Twine(P)))
return P.str().str();
}
return None;
};
if (auto P = SearchPaths(PrefixDirs))
return *P;
SmallString<128> R(ResourceDir);
llvm::sys::path::append(R, Name);
if (llvm::sys::fs::exists(Twine(R)))
return R.str();
SmallString<128> P(TC.getCompilerRTPath());
llvm::sys::path::append(P, Name);
if (llvm::sys::fs::exists(Twine(P)))
return P.str();
SmallString<128> D(Dir);
llvm::sys::path::append(D, "..", Name);
if (llvm::sys::fs::exists(Twine(D)))
return D.str();
if (auto P = SearchPaths(TC.getLibraryPaths()))
return *P;
if (auto P = SearchPaths(TC.getFilePaths()))
return *P;
return Name;
}
void Driver::generatePrefixedToolNames(
StringRef Tool, const ToolChain &TC,
SmallVectorImpl<std::string> &Names) const {
// FIXME: Needs a better variable than TargetTriple
Names.emplace_back((TargetTriple + "-" + Tool).str());
Names.emplace_back(Tool);
// Allow the discovery of tools prefixed with LLVM's default target triple.
std::string DefaultTargetTriple = llvm::sys::getDefaultTargetTriple();
if (DefaultTargetTriple != TargetTriple)
Names.emplace_back((DefaultTargetTriple + "-" + Tool).str());
}
static bool ScanDirForExecutable(SmallString<128> &Dir,
ArrayRef<std::string> Names) {
for (const auto &Name : Names) {
llvm::sys::path::append(Dir, Name);
if (llvm::sys::fs::can_execute(Twine(Dir)))
return true;
llvm::sys::path::remove_filename(Dir);
}
return false;
}
std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const {
SmallVector<std::string, 2> TargetSpecificExecutables;
generatePrefixedToolNames(Name, TC, TargetSpecificExecutables);
// Respect a limited subset of the '-Bprefix' functionality in GCC by
// attempting to use this prefix when looking for program paths.
for (const auto &PrefixDir : PrefixDirs) {
if (llvm::sys::fs::is_directory(PrefixDir)) {
SmallString<128> P(PrefixDir);
if (ScanDirForExecutable(P, TargetSpecificExecutables))
return P.str();
} else {
SmallString<128> P((PrefixDir + Name).str());
if (llvm::sys::fs::can_execute(Twine(P)))
return P.str();
}
}
const ToolChain::path_list &List = TC.getProgramPaths();
for (const auto &Path : List) {
SmallString<128> P(Path);
if (ScanDirForExecutable(P, TargetSpecificExecutables))
return P.str();
}
// If all else failed, search the path.
for (const auto &TargetSpecificExecutable : TargetSpecificExecutables)
if (llvm::ErrorOr<std::string> P =
llvm::sys::findProgramByName(TargetSpecificExecutable))
return *P;
return Name;
}
std::string Driver::GetTemporaryPath(StringRef Prefix, StringRef Suffix) const {
SmallString<128> Path;
std::error_code EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, Path);
if (EC) {
Diag(clang::diag::err_unable_to_make_temp) << EC.message();
return "";
}
return Path.str();
}
std::string Driver::GetTemporaryDirectory(StringRef Prefix) const {
SmallString<128> Path;
std::error_code EC = llvm::sys::fs::createUniqueDirectory(Prefix, Path);
if (EC) {
Diag(clang::diag::err_unable_to_make_temp) << EC.message();
return "";
}
return Path.str();
}
std::string Driver::GetClPchPath(Compilation &C, StringRef BaseName) const {
SmallString<128> Output;
if (Arg *FpArg = C.getArgs().getLastArg(options::OPT__SLASH_Fp)) {
// FIXME: If anybody needs it, implement this obscure rule:
// "If you specify a directory without a file name, the default file name
// is VCx0.pch., where x is the major version of Visual C++ in use."
Output = FpArg->getValue();
// "If you do not specify an extension as part of the path name, an
// extension of .pch is assumed. "
if (!llvm::sys::path::has_extension(Output))
Output += ".pch";
} else {
if (Arg *YcArg = C.getArgs().getLastArg(options::OPT__SLASH_Yc))
Output = YcArg->getValue();
if (Output.empty())
Output = BaseName;
llvm::sys::path::replace_extension(Output, ".pch");
}
return Output.str();
}
const ToolChain &Driver::getToolChain(const ArgList &Args,
const llvm::Triple &Target) const {
auto &TC = ToolChains[Target.str()];
if (!TC) {
switch (Target.getOS()) {
case llvm::Triple::AIX:
TC = std::make_unique<toolchains::AIX>(*this, Target, Args);
break;
case llvm::Triple::Haiku:
TC = std::make_unique<toolchains::Haiku>(*this, Target, Args);
break;
case llvm::Triple::Ananas:
TC = std::make_unique<toolchains::Ananas>(*this, Target, Args);
break;
case llvm::Triple::CloudABI:
TC = std::make_unique<toolchains::CloudABI>(*this, Target, Args);
break;
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
TC = std::make_unique<toolchains::DarwinClang>(*this, Target, Args);
break;
case llvm::Triple::DragonFly:
TC = std::make_unique<toolchains::DragonFly>(*this, Target, Args);
break;
case llvm::Triple::OpenBSD:
TC = std::make_unique<toolchains::OpenBSD>(*this, Target, Args);
break;
case llvm::Triple::NetBSD:
TC = std::make_unique<toolchains::NetBSD>(*this, Target, Args);
break;
case llvm::Triple::FreeBSD:
TC = std::make_unique<toolchains::FreeBSD>(*this, Target, Args);
break;
case llvm::Triple::Minix:
TC = std::make_unique<toolchains::Minix>(*this, Target, Args);
break;
case llvm::Triple::Linux:
case llvm::Triple::ELFIAMCU:
if (Target.getArch() == llvm::Triple::hexagon)
TC = std::make_unique<toolchains::HexagonToolChain>(*this, Target,
Args);
else if ((Target.getVendor() == llvm::Triple::MipsTechnologies) &&
!Target.hasEnvironment())
TC = std::make_unique<toolchains::MipsLLVMToolChain>(*this, Target,
Args);
else if (Target.getArch() == llvm::Triple::ppc ||
Target.getArch() == llvm::Triple::ppc64 ||
Target.getArch() == llvm::Triple::ppc64le)
TC = std::make_unique<toolchains::PPCLinuxToolChain>(*this, Target,
Args);
else
TC = std::make_unique<toolchains::Linux>(*this, Target, Args);
break;
case llvm::Triple::NaCl:
TC = std::make_unique<toolchains::NaClToolChain>(*this, Target, Args);
break;
case llvm::Triple::Fuchsia:
TC = std::make_unique<toolchains::Fuchsia>(*this, Target, Args);
break;
case llvm::Triple::Solaris:
TC = std::make_unique<toolchains::Solaris>(*this, Target, Args);
break;
case llvm::Triple::AMDHSA:
case llvm::Triple::AMDPAL:
case llvm::Triple::Mesa3D:
TC = std::make_unique<toolchains::AMDGPUToolChain>(*this, Target, Args);
break;
case llvm::Triple::Win32:
switch (Target.getEnvironment()) {
default:
if (Target.isOSBinFormatELF())
TC = std::make_unique<toolchains::Generic_ELF>(*this, Target, Args);
else if (Target.isOSBinFormatMachO())
TC = std::make_unique<toolchains::MachO>(*this, Target, Args);
else
TC = std::make_unique<toolchains::Generic_GCC>(*this, Target, Args);
break;
case llvm::Triple::GNU:
TC = std::make_unique<toolchains::MinGW>(*this, Target, Args);
break;
case llvm::Triple::Itanium:
TC = std::make_unique<toolchains::CrossWindowsToolChain>(*this, Target,
Args);
break;
case llvm::Triple::MSVC:
case llvm::Triple::UnknownEnvironment:
if (Args.getLastArgValue(options::OPT_fuse_ld_EQ)
.startswith_lower("bfd"))
TC = std::make_unique<toolchains::CrossWindowsToolChain>(
*this, Target, Args);
else
TC =
std::make_unique<toolchains::MSVCToolChain>(*this, Target, Args);
break;
}
break;
case llvm::Triple::PS4:
TC = std::make_unique<toolchains::PS4CPU>(*this, Target, Args);
break;
case llvm::Triple::Contiki:
TC = std::make_unique<toolchains::Contiki>(*this, Target, Args);
break;
case llvm::Triple::Hurd:
TC = std::make_unique<toolchains::Hurd>(*this, Target, Args);
break;
default:
// Of these targets, Hexagon is the only one that might have
// an OS of Linux, in which case it got handled above already.
switch (Target.getArch()) {
case llvm::Triple::tce:
TC = std::make_unique<toolchains::TCEToolChain>(*this, Target, Args);
break;
case llvm::Triple::tcele:
TC = std::make_unique<toolchains::TCELEToolChain>(*this, Target, Args);
break;
case llvm::Triple::hexagon:
TC = std::make_unique<toolchains::HexagonToolChain>(*this, Target,
Args);
break;
case llvm::Triple::lanai:
TC = std::make_unique<toolchains::LanaiToolChain>(*this, Target, Args);
break;
case llvm::Triple::xcore:
TC = std::make_unique<toolchains::XCoreToolChain>(*this, Target, Args);
break;
case llvm::Triple::wasm32:
case llvm::Triple::wasm64:
TC = std::make_unique<toolchains::WebAssembly>(*this, Target, Args);
break;
case llvm::Triple::avr:
TC = std::make_unique<toolchains::AVRToolChain>(*this, Target, Args);
break;
case llvm::Triple::msp430:
TC =
std::make_unique<toolchains::MSP430ToolChain>(*this, Target, Args);
break;
case llvm::Triple::riscv32:
case llvm::Triple::riscv64:
TC = std::make_unique<toolchains::RISCVToolChain>(*this, Target, Args);
break;
default:
if (Target.getVendor() == llvm::Triple::Myriad)
TC = std::make_unique<toolchains::MyriadToolChain>(*this, Target,
Args);
else if (toolchains::BareMetal::handlesTarget(Target))
TC = std::make_unique<toolchains::BareMetal>(*this, Target, Args);
else if (Target.isOSBinFormatELF())
TC = std::make_unique<toolchains::Generic_ELF>(*this, Target, Args);
else if (Target.isOSBinFormatMachO())
TC = std::make_unique<toolchains::MachO>(*this, Target, Args);
else
TC = std::make_unique<toolchains::Generic_GCC>(*this, Target, Args);
}
}
}
// Intentionally omitted from the switch above: llvm::Triple::CUDA. CUDA
// compiles always need two toolchains, the CUDA toolchain and the host
// toolchain. So the only valid way to create a CUDA toolchain is via
// CreateOffloadingDeviceToolChains.
return *TC;
}
bool Driver::ShouldUseClangCompiler(const JobAction &JA) const {
// Say "no" if there is not exactly one input of a type clang understands.
if (JA.size() != 1 ||
!types::isAcceptedByClang((*JA.input_begin())->getType()))
return false;
// And say "no" if this is not a kind of action clang understands.
if (!isa<PreprocessJobAction>(JA) && !isa<PrecompileJobAction>(JA) &&
!isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA))
return false;
return true;
}
bool Driver::ShouldUseFlangCompiler(const JobAction &JA) const {
// Say "no" if there is not exactly one input of a type flang understands.
if (JA.size() != 1 ||
!types::isFortran((*JA.input_begin())->getType()))
return false;
// And say "no" if this is not a kind of action flang understands.
if (!isa<PreprocessJobAction>(JA) && !isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA))
return false;
return true;
}
/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and return the
/// grouped values as integers. Numbers which are not provided are set to 0.
///
/// \return True if the entire string was parsed (9.2), or all groups were
/// parsed (10.3.5extrastuff).
bool Driver::GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
unsigned &Micro, bool &HadExtra) {
HadExtra = false;
Major = Minor = Micro = 0;
if (Str.empty())
return false;
if (Str.consumeInteger(10, Major))
return false;
if (Str.empty())
return true;
if (Str[0] != '.')
return false;
Str = Str.drop_front(1);
if (Str.consumeInteger(10, Minor))
return false;
if (Str.empty())
return true;
if (Str[0] != '.')
return false;
Str = Str.drop_front(1);
if (Str.consumeInteger(10, Micro))
return false;
if (!Str.empty())
HadExtra = true;
return true;
}
/// Parse digits from a string \p Str and fulfill \p Digits with
/// the parsed numbers. This method assumes that the max number of
/// digits to look for is equal to Digits.size().
///
/// \return True if the entire string was parsed and there are
/// no extra characters remaining at the end.
bool Driver::GetReleaseVersion(StringRef Str,
MutableArrayRef<unsigned> Digits) {
if (Str.empty())
return false;
unsigned CurDigit = 0;
while (CurDigit < Digits.size()) {
unsigned Digit;
if (Str.consumeInteger(10, Digit))
return false;
Digits[CurDigit] = Digit;
if (Str.empty())
return true;
if (Str[0] != '.')
return false;
Str = Str.drop_front(1);
CurDigit++;
}
// More digits than requested, bail out...
return false;
}
std::pair<unsigned, unsigned>
Driver::getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const {
unsigned IncludedFlagsBitmask = 0;
unsigned ExcludedFlagsBitmask = options::NoDriverOption;
if (IsClCompatMode) {
// Include CL and Core options.
IncludedFlagsBitmask |= options::CLOption;
IncludedFlagsBitmask |= options::CoreOption;
} else {
ExcludedFlagsBitmask |= options::CLOption;
}
return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
}
bool clang::driver::isOptimizationLevelFast(const ArgList &Args) {
return Args.hasFlag(options::OPT_Ofast, options::OPT_O_Group, false);
}
bool clang::driver::willEmitRemarks(const ArgList &Args) {
// -fsave-optimization-record enables it.
if (Args.hasFlag(options::OPT_fsave_optimization_record,
options::OPT_fno_save_optimization_record, false))
return true;
// -fsave-optimization-record=<format> enables it as well.
if (Args.hasFlag(options::OPT_fsave_optimization_record_EQ,
options::OPT_fno_save_optimization_record, false))
return true;
// -foptimization-record-file alone enables it too.
if (Args.hasFlag(options::OPT_foptimization_record_file_EQ,
options::OPT_fno_save_optimization_record, false))
return true;
// -foptimization-record-passes alone enables it too.
if (Args.hasFlag(options::OPT_foptimization_record_passes_EQ,
options::OPT_fno_save_optimization_record, false))
return true;
return false;
}
| [
"wangyankun@ishumei.com"
] | wangyankun@ishumei.com |
1c85454a5c61e325956db36d0bea29b14f8269bf | 555eb9c234f86911df70188914d45c358c67bb62 | /tensorflow/lite/experimental/ruy/path.h | 15f4755cfad3f446fcd9e50db083e14c6e3e7263 | [
"Apache-2.0"
] | permissive | obeshor/tensorflow | 64b99bfec161e8680535104e7e90834b1060c5c3 | 0fd570848f7cd08904907640111d435dcb7fba8a | refs/heads/master | 2020-05-18T09:44:13.516187 | 2019-04-30T20:33:02 | 2019-04-30T21:32:19 | 184,335,557 | 2 | 1 | Apache-2.0 | 2019-04-30T21:43:01 | 2019-04-30T21:43:00 | null | UTF-8 | C++ | false | false | 3,461 | h | /* Copyright 2019 Google LLC. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_EXPERIMENTAL_RUY_PATH_H_
#define TENSORFLOW_LITE_EXPERIMENTAL_RUY_PATH_H_
#include <cstdint>
#include "tensorflow/lite/experimental/ruy/size_util.h"
namespace ruy {
// A Path is a choice of implementation path, e.g. between reference code
// and optimized code, or between different optimized code paths using different
// instruction sets.
//
// It's important that any symbol that depends on such implementation
// details, is somehow templatized in such a Path, so that different Path values
// yield different symbols, so we never have the situation where a symbols has
// multiple inequivalent definitions based on which code paths are compiled.
// That would be a violation of the ODR (One Definition Rule) which is Undefined
// Behavior, and one of the most serious issues plaguing both Eigen and
// gemmlowp.
//
// This enum is actually a bit-field: aside from kNone, all other values are
// powers of two, thus are one bit each. We define bit-wise operators below
// for this enum. Some places in Ruy accept a Path bit-field where multiple
// Paths may be selected, while some other places require a single Path (i.e.
// just one of the enum values here). Typically, user-facing parts of Ruy
// accept arbitrary bit-fields, allowing the user to compile support for
// multiple paths and to inform Ruy of all the paths that are to be enabled
// at runtime; then, typically in dispatch.h, we internally pick one
// specific path and from there on, internal Ruy code deals with only one
// path.
enum class Path : std::uint8_t {
// Higher values have higher precedence.
kNone = 0,
kReference = 0x1, // reference code.
kStandardCpp = 0x2, // Standard C++ only. No SIMD or other arch features.
kNeon = 0x4,
kNeonDotprod = 0x8,
};
inline constexpr Path operator|(Path p, Path q) {
return static_cast<Path>(static_cast<std::uint32_t>(p) |
static_cast<std::uint32_t>(q));
}
inline constexpr Path operator&(Path p, Path q) {
return static_cast<Path>(static_cast<std::uint32_t>(p) &
static_cast<std::uint32_t>(q));
}
inline constexpr Path operator^(Path p, Path q) {
return static_cast<Path>(static_cast<std::uint32_t>(p) ^
static_cast<std::uint32_t>(q));
}
inline constexpr Path operator~(Path p) {
return static_cast<Path>(~static_cast<std::uint32_t>(p));
}
inline Path GetMostSignificantPath(Path path_mask) {
return static_cast<Path>(round_down_pot(static_cast<int>(path_mask)));
}
#ifdef __aarch64__
constexpr Path kAllPaths =
Path::kReference | Path::kStandardCpp | Path::kNeon | Path::kNeonDotprod;
#else
constexpr Path kAllPaths = Path::kReference | Path::kStandardCpp;
#endif
} // namespace ruy
#endif // TENSORFLOW_LITE_EXPERIMENTAL_RUY_PATH_H_
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
b60478862a14df90007056ea93123b0dc26ecae4 | 6b433c5b8bc8d61e989be05b0eb94a37aabaae73 | /SDK/PUBG_BP_MapCharacterIconWidget_classes.hpp | e1aea9eac4a17947a4bbdeda389d2ce24aea447a | [] | no_license | baiyfcu/PUBG-SDK | de6ff1b9b0acaa82aa9aac3e5825020e3b354029 | f8d157801a705000fa6f5dd1801e211dbc9938dd | refs/heads/master | 2021-06-26T17:50:53.665702 | 2017-09-14T04:45:52 | 2017-09-14T04:45:52 | 104,999,838 | 0 | 1 | null | 2017-09-27T09:33:57 | 2017-09-27T09:33:56 | null | UTF-8 | C++ | false | false | 5,092 | hpp | #pragma once
// PLAYERUNKNOWN BattleGrounds SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace Classes
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// WidgetBlueprintGeneratedClass BP_MapCharacterIconWidget.BP_MapCharacterIconWidget_C
// 0x0030 (0x0428 - 0x03F8)
class UBP_MapCharacterIconWidget_C : public UMapCharacterIconBaseWidget
{
public:
class UWidgetAnimation* NewAnimation_2; // 0x03F8(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_Transient, CPF_IsPlainOldData, CPF_RepSkip, CPF_RepNotify, CPF_Interp, CPF_NonTransactional, CPF_EditorOnly, CPF_NoDestructor, CPF_AutoWeak, CPF_ContainsInstancedReference, CPF_AssetRegistrySearchable, CPF_SimpleDisplay, CPF_AdvancedDisplay, CPF_Protected, CPF_BlueprintCallable, CPF_BlueprintAuthorityOnly, CPF_TextExportTransient, CPF_NonPIEDuplicateTransient, CPF_ExposeOnSpawn, CPF_PersistentInstance, CPF_UObjectWrapper, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic, CPF_NativeAccessSpecifierProtected, CPF_NativeAccessSpecifierPrivate)
class UWidgetAnimation* FadeOut; // 0x0400(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_Transient, CPF_IsPlainOldData, CPF_RepSkip, CPF_RepNotify, CPF_Interp, CPF_NonTransactional, CPF_EditorOnly, CPF_NoDestructor, CPF_AutoWeak, CPF_ContainsInstancedReference, CPF_AssetRegistrySearchable, CPF_SimpleDisplay, CPF_AdvancedDisplay, CPF_Protected, CPF_BlueprintCallable, CPF_BlueprintAuthorityOnly, CPF_TextExportTransient, CPF_NonPIEDuplicateTransient, CPF_ExposeOnSpawn, CPF_PersistentInstance, CPF_UObjectWrapper, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic, CPF_NativeAccessSpecifierProtected, CPF_NativeAccessSpecifierPrivate)
class UWidgetAnimation* GroggyWarning; // 0x0408(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_Transient, CPF_IsPlainOldData, CPF_RepSkip, CPF_RepNotify, CPF_Interp, CPF_NonTransactional, CPF_EditorOnly, CPF_NoDestructor, CPF_AutoWeak, CPF_ContainsInstancedReference, CPF_AssetRegistrySearchable, CPF_SimpleDisplay, CPF_AdvancedDisplay, CPF_Protected, CPF_BlueprintCallable, CPF_BlueprintAuthorityOnly, CPF_TextExportTransient, CPF_NonPIEDuplicateTransient, CPF_ExposeOnSpawn, CPF_PersistentInstance, CPF_UObjectWrapper, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic, CPF_NativeAccessSpecifierProtected, CPF_NativeAccessSpecifierPrivate)
class UWidgetAnimation* Hitted; // 0x0410(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_Transient, CPF_IsPlainOldData, CPF_RepSkip, CPF_RepNotify, CPF_Interp, CPF_NonTransactional, CPF_EditorOnly, CPF_NoDestructor, CPF_AutoWeak, CPF_ContainsInstancedReference, CPF_AssetRegistrySearchable, CPF_SimpleDisplay, CPF_AdvancedDisplay, CPF_Protected, CPF_BlueprintCallable, CPF_BlueprintAuthorityOnly, CPF_TextExportTransient, CPF_NonPIEDuplicateTransient, CPF_ExposeOnSpawn, CPF_PersistentInstance, CPF_UObjectWrapper, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic, CPF_NativeAccessSpecifierProtected, CPF_NativeAccessSpecifierPrivate)
class UWidgetAnimation* Attacked; // 0x0418(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_Transient, CPF_IsPlainOldData, CPF_RepSkip, CPF_RepNotify, CPF_Interp, CPF_NonTransactional, CPF_EditorOnly, CPF_NoDestructor, CPF_AutoWeak, CPF_ContainsInstancedReference, CPF_AssetRegistrySearchable, CPF_SimpleDisplay, CPF_AdvancedDisplay, CPF_Protected, CPF_BlueprintCallable, CPF_BlueprintAuthorityOnly, CPF_TextExportTransient, CPF_NonPIEDuplicateTransient, CPF_ExposeOnSpawn, CPF_PersistentInstance, CPF_UObjectWrapper, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic, CPF_NativeAccessSpecifierProtected, CPF_NativeAccessSpecifierPrivate)
class UBP_LifeGaugeTemplateWidget_C* LifeGauge; // 0x0420(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_Transient, CPF_IsPlainOldData, CPF_RepSkip, CPF_RepNotify, CPF_Interp, CPF_NonTransactional, CPF_EditorOnly, CPF_NoDestructor, CPF_AutoWeak, CPF_ContainsInstancedReference, CPF_AssetRegistrySearchable, CPF_SimpleDisplay, CPF_AdvancedDisplay, CPF_Protected, CPF_BlueprintCallable, CPF_BlueprintAuthorityOnly, CPF_TextExportTransient, CPF_NonPIEDuplicateTransient, CPF_ExposeOnSpawn, CPF_PersistentInstance, CPF_UObjectWrapper, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic, CPF_NativeAccessSpecifierProtected, CPF_NativeAccessSpecifierPrivate)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("WidgetBlueprintGeneratedClass BP_MapCharacterIconWidget.BP_MapCharacterIconWidget_C");
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"tj8@live.com.au"
] | tj8@live.com.au |
cfea4824d7421c3429b9c7f6c240f75fbba61471 | dd8b82308ec71c8172188296e1d3afc7b7927c5b | /main.cpp | 6623a10e6b1a45326c0a575ef9b197f1ef689cb9 | [] | no_license | paswd/da-lab8 | 21696a5d7a331c6d218793e6c921d8be01bc905c | 1e29344b69e7271d8fac26d839beb8c59ddce9f1 | refs/heads/master | 2021-01-21T10:45:50.546216 | 2017-10-28T13:46:25 | 2017-10-28T13:46:25 | 101,984,988 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,990 | cpp | #include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long double TNumber;
const size_t MAX_NUM = 51;
const TNumber EPS = numeric_limits<TNumber>::epsilon();
class TBag {
public:
size_t Supple[MAX_NUM];
size_t InitIndex;
size_t Length;
size_t Cost;
TBag(void) {
this->Cost = 0;
}
void Get(void) {
for (size_t i = 0; i < this->Length; i++) {
cin >> this->Supple[i];
}
cin >> this->Cost;
}
};
size_t gcd(size_t a, size_t b) {
while (a > 0 && b > 0) {
if (a > b) {
a %= b;
} else {
b %= a;
}
}
return a + b;
}
size_t gcda(size_t *arr, size_t size) {
size_t res = 0;
for (size_t i = 0; i < size; i++) {
res = gcd(res, arr[i]);
}
if (res == 0) {
res = 1;
}
return res;
}
bool IsRowZero(TNumber *arr, size_t size) {
for (size_t i = 0; i < size; i++) {
if (arr[i] != 0) {
return false;
}
}
return true;
}
size_t GetRank(TNumber map[MAX_NUM][MAX_NUM], size_t m, size_t n) {
vector <int> where(n, -1);
for (size_t col = 0, row = 0; col < n && row < m; col++) {
size_t sel = row;
for (size_t i = row; i < m; i++) {
if (fabs(map[i][col]) > fabs(map[sel][col])) {
sel = i;
}
}
if (fabs(map[sel][col]) < EPS) {
continue;
}
for (size_t i = col; i <= n; i++) {
swap(map[sel][i], map[row][i]);
}
where[col] = row;
for (size_t i = 0; i < m; i++) {
if (i != row) {
TNumber tmp = map[i][col] / map[row][col];
for (size_t j = col; j <= n; j++) {
map[i][j] -= map[row][j] * tmp;
}
}
}
row++;
}
size_t rank = 0;
for (size_t i = 0; i < m; i++) {
if (!IsRowZero(map[i], n)) {
rank++;
}
}
return rank;
}
bool IsLinearIndependent(TBag *base, size_t size, size_t current_independent) {
TNumber matrix[MAX_NUM][MAX_NUM];
for (size_t i = 0; i < size; i++) {
for (size_t j = 0; j < base[i].Length; j++) {
matrix[i][j] = (TNumber) base[i].Supple[j];
}
}
size_t rank = GetRank(matrix, size, base[0].Length);
if (rank > current_independent) {
return true;
}
return false;
}
int main(void) {
size_t m, n;
cin >> m >> n;
TBag base[MAX_NUM];
for (size_t i = 0; i < m; i++) { //Getting values
base[i].Length = n;
base[i].Get();
base[i].InitIndex = i;
size_t current_gcd = gcda(base[i].Supple, base[i].Length);
for (size_t j = 0; j < base[i].Length; j++) {
base[i].Supple[j] /= current_gcd;
}
}
for (size_t i = m; i > 0; i--) { //Bubble sort
bool change = false;
for (size_t j = 1; j < i; j++) {
if (base[j - 1].Cost > base[j].Cost) {
TBag tmp = base[j - 1];
base[j - 1] = base[j];
base[j] = tmp;
change = true;
}
}
if (!change) {
break;
}
}
vector <size_t> res(0);
size_t current = 0;
for (size_t i = 0; i < m && current < n; i++) {
if (IsLinearIndependent(base, i + 1, current)) {
size_t pos = res.size();
res.resize(res.size() + 1);
res[pos] = base[i].InitIndex;
current++;
}
}
if (current < n) {
cout << "-1" << endl;
return 0;
}
sort(res.begin(), res.end());
bool first = true;
for (size_t i = 0; i < res.size(); i++) {
if (!first) {
cout << " ";
} else {
first = false;
}
cout << res[i] + 1;
}
cout << endl;
return 0;
}
| [
"paswd@yandex.ru"
] | paswd@yandex.ru |
341981dc07cd63f395901951c666486fc7d90bbb | 3b3695e41914492bd235ccc2e2ea7099360b60ed | /Algorithm/Sort/insert.cpp | 10c214538b73ce527c03333c928bf11dd6623ab0 | [] | no_license | NewBirdOrganization/All-about-data-structure-and-algorithmn | 61f314d2ed8151ff73385d401d577bc1990d2da1 | 54209fefea1ec175acb4ba61a41d1de619f84578 | refs/heads/master | 2021-01-18T19:39:10.071016 | 2016-02-14T17:45:39 | 2016-02-14T17:45:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 199 | cpp | void InsertionSort(int array[], int num)
{
int i, j;
int Temp;
for (i = 0; i < num; i++)
{
Temp = array[i];
for (j = i; j > 0 && array[j-1] > Temp;j++)
{
array[j] = array[j-1];
}
}
} | [
"pengbowen@whut.edu.cn"
] | pengbowen@whut.edu.cn |
1ad5445cc844dd23da8af5b486757e01b035d7fd | 39ab815dfdbab9628ede8ec3b4aedb5da3fd456a | /aql/benchmark/lib_29/class_6.cpp | e1c03b8a324ccec0ba2475c8471e45f5cbd85d5c | [
"MIT"
] | permissive | menify/sandbox | c03b1bf24c1527b47eb473f1acc433f17bfb1d4f | 32166c71044f0d5b414335b2b6559adc571f568c | refs/heads/master | 2016-09-05T21:46:53.369065 | 2015-04-20T06:35:27 | 2015-04-20T06:35:27 | 25,891,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 310 | cpp | #include "class_6.h"
#include "class_4.h"
#include "class_2.h"
#include "class_9.h"
#include "class_8.h"
#include "class_7.h"
#include <lib_11/class_9.h>
#include <lib_2/class_5.h>
#include <lib_25/class_0.h>
#include <lib_0/class_4.h>
#include <lib_19/class_7.h>
class_6::class_6() {}
class_6::~class_6() {}
| [
"menify@a28edc5c-ec3e-0410-a3da-1b30b3a8704b"
] | menify@a28edc5c-ec3e-0410-a3da-1b30b3a8704b |
a252ff211b55acedc89a0a8d264c9d84631cda85 | b3348362483036add4b3e85358a3d4e28f0ec49f | /Practice/FLOW007.cpp | 0c596486e090e166fd4237ecd9b7635debb2cd6d | [] | no_license | khushikhokharr/CodeChef-Beginer- | 89e14bbf2a07ed933e08957c0ac6f01f6d140489 | f393785d1111e7283f63c6bbf93790763407cf8e | refs/heads/main | 2023-02-03T03:14:58.951443 | 2020-12-20T18:24:08 | 2020-12-20T18:24:08 | 322,799,795 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 467 | cpp | #include "iostream"
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int change=0, digits[15];
while(n)
{
int digit= n%10;
digits[change]=digit;
change++;
n=n/10;
}
bool flag = false;
for(int i=0;i<change;i++){
if(digits[i]==0 && flag==false)
continue;
else
if(digits[i]!=0)
flag = true;
cout<<digits[i];
}
cout<<"\n";
}
return 0;
}
| [
"khushikhokhar@Khushis-MacBook-Air.local"
] | khushikhokhar@Khushis-MacBook-Air.local |
e66973b3fe34240c496aea1fef802cb814c01870 | 79d11d81ffacf6fad9cf271256eda8ae4b30bdbc | /external/physx/include/foundation/PxBounds3.h | ef8ead25cd139e572382185e74bd805d44cf82de | [
"MIT"
] | permissive | nem0/LumixEngine | d6c46d8febc54ff41e5bc5e6d71d861410f5b155 | e6314612df50c6f37b34fb0dfcad9683cc506ec7 | refs/heads/master | 2023-09-02T09:14:49.212586 | 2023-08-23T21:01:37 | 2023-08-23T21:01:37 | 14,590,125 | 3,660 | 518 | MIT | 2023-09-14T14:49:32 | 2013-11-21T14:43:55 | C++ | UTF-8 | C++ | false | false | 15,147 | h | //
// 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 NVIDIA CORPORATION 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 ``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 OWNER 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.
//
// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PXFOUNDATION_PXBOUNDS3_H
#define PXFOUNDATION_PXBOUNDS3_H
/** \addtogroup foundation
@{
*/
#include "foundation/PxTransform.h"
#include "foundation/PxMat33.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
// maximum extents defined such that floating point exceptions are avoided for standard use cases
#define PX_MAX_BOUNDS_EXTENTS (PX_MAX_REAL * 0.25f)
/**
\brief Class representing 3D range or axis aligned bounding box.
Stored as minimum and maximum extent corners. Alternate representation
would be center and dimensions.
May be empty or nonempty. For nonempty bounds, minimum <= maximum has to hold for all axes.
Empty bounds have to be represented as minimum = PX_MAX_BOUNDS_EXTENTS and maximum = -PX_MAX_BOUNDS_EXTENTS for all
axes.
All other representations are invalid and the behavior is undefined.
*/
class PxBounds3
{
public:
/**
\brief Default constructor, not performing any initialization for performance reason.
\remark Use empty() function below to construct empty bounds.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3()
{
}
/**
\brief Construct from two bounding points
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3(const PxVec3& minimum, const PxVec3& maximum);
/**
\brief Return empty bounds.
*/
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 empty();
/**
\brief returns the AABB containing v0 and v1.
\param v0 first point included in the AABB.
\param v1 second point included in the AABB.
*/
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 boundsOfPoints(const PxVec3& v0, const PxVec3& v1);
/**
\brief returns the AABB from center and extents vectors.
\param center Center vector
\param extent Extents vector
*/
static PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 centerExtents(const PxVec3& center, const PxVec3& extent);
/**
\brief Construct from center, extent, and (not necessarily orthogonal) basis
*/
static PX_CUDA_CALLABLE PX_INLINE PxBounds3
basisExtent(const PxVec3& center, const PxMat33& basis, const PxVec3& extent);
/**
\brief Construct from pose and extent
*/
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 poseExtent(const PxTransform& pose, const PxVec3& extent);
/**
\brief gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
This version is safe to call for empty bounds.
\param[in] matrix Transform to apply, can contain scaling as well
\param[in] bounds The bounds to transform.
*/
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformSafe(const PxMat33& matrix, const PxBounds3& bounds);
/**
\brief gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
Calling this method for empty bounds leads to undefined behavior. Use #transformSafe() instead.
\param[in] matrix Transform to apply, can contain scaling as well
\param[in] bounds The bounds to transform.
*/
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformFast(const PxMat33& matrix, const PxBounds3& bounds);
/**
\brief gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
This version is safe to call for empty bounds.
\param[in] transform Transform to apply, can contain scaling as well
\param[in] bounds The bounds to transform.
*/
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformSafe(const PxTransform& transform, const PxBounds3& bounds);
/**
\brief gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
Calling this method for empty bounds leads to undefined behavior. Use #transformSafe() instead.
\param[in] transform Transform to apply, can contain scaling as well
\param[in] bounds The bounds to transform.
*/
static PX_CUDA_CALLABLE PX_INLINE PxBounds3 transformFast(const PxTransform& transform, const PxBounds3& bounds);
/**
\brief Sets empty to true
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void setEmpty();
/**
\brief Sets the bounds to maximum size [-PX_MAX_BOUNDS_EXTENTS, PX_MAX_BOUNDS_EXTENTS].
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void setMaximal();
/**
\brief expands the volume to include v
\param v Point to expand to.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void include(const PxVec3& v);
/**
\brief expands the volume to include b.
\param b Bounds to perform union with.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void include(const PxBounds3& b);
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isEmpty() const;
/**
\brief indicates whether the intersection of this and b is empty or not.
\param b Bounds to test for intersection.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE bool intersects(const PxBounds3& b) const;
/**
\brief computes the 1D-intersection between two AABBs, on a given axis.
\param a the other AABB
\param axis the axis (0, 1, 2)
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE bool intersects1D(const PxBounds3& a, uint32_t axis) const;
/**
\brief indicates if these bounds contain v.
\param v Point to test against bounds.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE bool contains(const PxVec3& v) const;
/**
\brief checks a box is inside another box.
\param box the other AABB
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isInside(const PxBounds3& box) const;
/**
\brief returns the center of this axis aligned box.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getCenter() const;
/**
\brief get component of the box's center along a given axis
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE float getCenter(uint32_t axis) const;
/**
\brief get component of the box's extents along a given axis
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE float getExtents(uint32_t axis) const;
/**
\brief returns the dimensions (width/height/depth) of this axis aligned box.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getDimensions() const;
/**
\brief returns the extents, which are half of the width/height/depth.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getExtents() const;
/**
\brief scales the AABB.
This version is safe to call for empty bounds.
\param scale Factor to scale AABB by.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void scaleSafe(float scale);
/**
\brief scales the AABB.
Calling this method for empty bounds leads to undefined behavior. Use #scaleSafe() instead.
\param scale Factor to scale AABB by.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void scaleFast(float scale);
/**
fattens the AABB in all 3 dimensions by the given distance.
This version is safe to call for empty bounds.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void fattenSafe(float distance);
/**
fattens the AABB in all 3 dimensions by the given distance.
Calling this method for empty bounds leads to undefined behavior. Use #fattenSafe() instead.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void fattenFast(float distance);
/**
checks that the AABB values are not NaN
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite() const;
/**
checks that the AABB values describe a valid configuration.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isValid() const;
PxVec3 minimum, maximum;
};
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3::PxBounds3(const PxVec3& minimum_, const PxVec3& maximum_)
: minimum(minimum_), maximum(maximum_)
{
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 PxBounds3::empty()
{
return PxBounds3(PxVec3(PX_MAX_BOUNDS_EXTENTS), PxVec3(-PX_MAX_BOUNDS_EXTENTS));
}
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxBounds3::isFinite() const
{
return minimum.isFinite() && maximum.isFinite();
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 PxBounds3::boundsOfPoints(const PxVec3& v0, const PxVec3& v1)
{
return PxBounds3(v0.minimum(v1), v0.maximum(v1));
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxBounds3 PxBounds3::centerExtents(const PxVec3& center, const PxVec3& extent)
{
return PxBounds3(center - extent, center + extent);
}
PX_CUDA_CALLABLE PX_INLINE PxBounds3
PxBounds3::basisExtent(const PxVec3& center, const PxMat33& basis, const PxVec3& extent)
{
// extended basis vectors
PxVec3 c0 = basis.column0 * extent.x;
PxVec3 c1 = basis.column1 * extent.y;
PxVec3 c2 = basis.column2 * extent.z;
PxVec3 w;
// find combination of base vectors that produces max. distance for each component = sum of abs()
w.x = PxAbs(c0.x) + PxAbs(c1.x) + PxAbs(c2.x);
w.y = PxAbs(c0.y) + PxAbs(c1.y) + PxAbs(c2.y);
w.z = PxAbs(c0.z) + PxAbs(c1.z) + PxAbs(c2.z);
return PxBounds3(center - w, center + w);
}
PX_CUDA_CALLABLE PX_INLINE PxBounds3 PxBounds3::poseExtent(const PxTransform& pose, const PxVec3& extent)
{
return basisExtent(pose.p, PxMat33(pose.q), extent);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::setEmpty()
{
minimum = PxVec3(PX_MAX_BOUNDS_EXTENTS);
maximum = PxVec3(-PX_MAX_BOUNDS_EXTENTS);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::setMaximal()
{
minimum = PxVec3(-PX_MAX_BOUNDS_EXTENTS);
maximum = PxVec3(PX_MAX_BOUNDS_EXTENTS);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::include(const PxVec3& v)
{
PX_SHARED_ASSERT(isValid());
minimum = minimum.minimum(v);
maximum = maximum.maximum(v);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::include(const PxBounds3& b)
{
PX_SHARED_ASSERT(isValid());
minimum = minimum.minimum(b.minimum);
maximum = maximum.maximum(b.maximum);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxBounds3::isEmpty() const
{
PX_SHARED_ASSERT(isValid());
return minimum.x > maximum.x;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxBounds3::intersects(const PxBounds3& b) const
{
PX_SHARED_ASSERT(isValid() && b.isValid());
return !(b.minimum.x > maximum.x || minimum.x > b.maximum.x || b.minimum.y > maximum.y || minimum.y > b.maximum.y ||
b.minimum.z > maximum.z || minimum.z > b.maximum.z);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxBounds3::intersects1D(const PxBounds3& a, uint32_t axis) const
{
PX_SHARED_ASSERT(isValid() && a.isValid());
return maximum[axis] >= a.minimum[axis] && a.maximum[axis] >= minimum[axis];
}
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxBounds3::contains(const PxVec3& v) const
{
PX_SHARED_ASSERT(isValid());
return !(v.x < minimum.x || v.x > maximum.x || v.y < minimum.y || v.y > maximum.y || v.z < minimum.z ||
v.z > maximum.z);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxBounds3::isInside(const PxBounds3& box) const
{
PX_SHARED_ASSERT(isValid() && box.isValid());
if(box.minimum.x > minimum.x)
return false;
if(box.minimum.y > minimum.y)
return false;
if(box.minimum.z > minimum.z)
return false;
if(box.maximum.x < maximum.x)
return false;
if(box.maximum.y < maximum.y)
return false;
if(box.maximum.z < maximum.z)
return false;
return true;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 PxBounds3::getCenter() const
{
PX_SHARED_ASSERT(isValid());
return (minimum + maximum) * 0.5f;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxBounds3::getCenter(uint32_t axis) const
{
PX_SHARED_ASSERT(isValid());
return (minimum[axis] + maximum[axis]) * 0.5f;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE float PxBounds3::getExtents(uint32_t axis) const
{
PX_SHARED_ASSERT(isValid());
return (maximum[axis] - minimum[axis]) * 0.5f;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 PxBounds3::getDimensions() const
{
PX_SHARED_ASSERT(isValid());
return maximum - minimum;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 PxBounds3::getExtents() const
{
PX_SHARED_ASSERT(isValid());
return getDimensions() * 0.5f;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::scaleSafe(float scale)
{
PX_SHARED_ASSERT(isValid());
if(!isEmpty())
scaleFast(scale);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::scaleFast(float scale)
{
PX_SHARED_ASSERT(isValid());
*this = centerExtents(getCenter(), getExtents() * scale);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::fattenSafe(float distance)
{
PX_SHARED_ASSERT(isValid());
if(!isEmpty())
fattenFast(distance);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE void PxBounds3::fattenFast(float distance)
{
PX_SHARED_ASSERT(isValid());
minimum.x -= distance;
minimum.y -= distance;
minimum.z -= distance;
maximum.x += distance;
maximum.y += distance;
maximum.z += distance;
}
PX_CUDA_CALLABLE PX_INLINE PxBounds3 PxBounds3::transformSafe(const PxMat33& matrix, const PxBounds3& bounds)
{
PX_SHARED_ASSERT(bounds.isValid());
return !bounds.isEmpty() ? transformFast(matrix, bounds) : bounds;
}
PX_CUDA_CALLABLE PX_INLINE PxBounds3 PxBounds3::transformFast(const PxMat33& matrix, const PxBounds3& bounds)
{
PX_SHARED_ASSERT(bounds.isValid());
return PxBounds3::basisExtent(matrix * bounds.getCenter(), matrix, bounds.getExtents());
}
PX_CUDA_CALLABLE PX_INLINE PxBounds3 PxBounds3::transformSafe(const PxTransform& transform, const PxBounds3& bounds)
{
PX_SHARED_ASSERT(bounds.isValid());
return !bounds.isEmpty() ? transformFast(transform, bounds) : bounds;
}
PX_CUDA_CALLABLE PX_INLINE PxBounds3 PxBounds3::transformFast(const PxTransform& transform, const PxBounds3& bounds)
{
PX_SHARED_ASSERT(bounds.isValid());
return PxBounds3::basisExtent(transform.transform(bounds.getCenter()), PxMat33(transform.q), bounds.getExtents());
}
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxBounds3::isValid() const
{
return (isFinite() && (((minimum.x <= maximum.x) && (minimum.y <= maximum.y) && (minimum.z <= maximum.z)) ||
((minimum.x == PX_MAX_BOUNDS_EXTENTS) && (minimum.y == PX_MAX_BOUNDS_EXTENTS) &&
(minimum.z == PX_MAX_BOUNDS_EXTENTS) && (maximum.x == -PX_MAX_BOUNDS_EXTENTS) &&
(maximum.y == -PX_MAX_BOUNDS_EXTENTS) && (maximum.z == -PX_MAX_BOUNDS_EXTENTS))));
}
#if !PX_DOXYGEN
} // namespace physx
#endif
/** @} */
#endif // #ifndef PXFOUNDATION_PXBOUNDS3_H
| [
"mikulas.florek@gamedev.sk"
] | mikulas.florek@gamedev.sk |
a5651942011ec4a6a2c7c0dc301c9d93aa667f67 | 647aa111a36f8636d3a5559aa28de8d731fa2ad7 | /xdriver-1.0/src/interpolation.cc | 35b6d1997783fa45565c7c6da3422fe6263e4c35 | [] | no_license | ESiWACE/esdm-gpu-dev | 758dba04aa413b553d0518429d83b399bc54f6c8 | b91a02d13e24983de7cdfea8f69d3281b0b807f5 | refs/heads/main | 2023-04-24T03:33:41.178914 | 2021-04-27T13:51:38 | 2021-04-27T13:51:38 | 317,849,748 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,106 | cc | #include <cstddef>
#include <iostream>
#include "compare.h"
#pragma acc routine
static float
s_vert_interp_lev_kernel(float w1, float w2, float var1L1, float var1L2, float missval)
{
float var2 = missval;
if (DBL_IS_EQUAL(var1L1, missval)) w1 = 0;
if (DBL_IS_EQUAL(var1L2, missval)) w2 = 0;
if (IS_EQUAL(w1, 0) && IS_EQUAL(w2, 0))
{
var2 = missval;
}
else if (IS_EQUAL(w1, 0))
{
var2 = (w2 >= 0.5) ? var1L2 : missval;
}
else if (IS_EQUAL(w2, 0))
{
var2 = (w1 >= 0.5) ? var1L1 : missval;
}
else
{
var2 = var1L1 * w1 + var1L2 * w2;
}
return var2;
}
#pragma acc routine
static float
s_vert_interp_lev_kernel_noisnan(float w1, float w2, float var1L1, float var1L2, float missval)
{
float var2 = missval;
if (IS_EQUAL(var1L1, missval)) w1 = 0;
if (IS_EQUAL(var1L2, missval)) w2 = 0;
if (IS_EQUAL(w1, 0) && IS_EQUAL(w2, 0))
{
var2 = missval;
}
else if (IS_EQUAL(w1, 0))
{
var2 = (w2 >= 0.5) ? var1L2 : missval;
}
else if (IS_EQUAL(w2, 0))
{
var2 = (w1 >= 0.5) ? var1L1 : missval;
}
else
{
var2 = var1L1 * w1 + var1L2 * w2;
}
return var2;
}
#pragma acc routine
static float
s_vert_interp_lev_kernel_nomissval(float w1, float w2, float var1L1, float var1L2, float missval)
{
return var1L1 * w1 + var1L2 * w2;
}
#pragma acc routine
static double
d_vert_interp_lev_kernel(double w1, double w2, double var1L1, double var1L2, double missval)
{
double var2 = missval;
if (DBL_IS_EQUAL(var1L1, missval)) w1 = 0;
if (DBL_IS_EQUAL(var1L2, missval)) w2 = 0;
if (IS_EQUAL(w1, 0) && IS_EQUAL(w2, 0))
{
var2 = missval;
}
else if (IS_EQUAL(w1, 0))
{
var2 = (w2 >= 0.5) ? var1L2 : missval;
}
else if (IS_EQUAL(w2, 0))
{
var2 = (w1 >= 0.5) ? var1L1 : missval;
}
else
{
var2 = var1L1 * w1 + var1L2 * w2;
}
return var2;
}
#pragma acc routine
static double
d_vert_interp_lev_kernel_noisnan(double w1, double w2, double var1L1, double var1L2, double missval)
{
double var2 = missval;
if (IS_EQUAL(var1L1, missval)) w1 = 0;
if (IS_EQUAL(var1L2, missval)) w2 = 0;
if (IS_EQUAL(w1, 0) && IS_EQUAL(w2, 0))
{
var2 = missval;
}
else if (IS_EQUAL(w1, 0))
{
var2 = (w2 >= 0.5) ? var1L2 : missval;
}
else if (IS_EQUAL(w2, 0))
{
var2 = (w1 >= 0.5) ? var1L1 : missval;
}
else
{
var2 = var1L1 * w1 + var1L2 * w2;
}
return var2;
}
#pragma acc routine
static double
d_vert_interp_lev_kernel_nomissval(double w1, double w2, double var1L1, double var1L2, double missval)
{
return var1L1 * w1 + var1L2 * w2;
}
void
CPUs_vert_interp_lev(const size_t gridsize, const float missval,
float *vardata1, float *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const float *lev_wgt1, const float *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
float *var2 = vardata2 + gridsize * ilev;
const float *var1L1 = vardata1 + gridsize * idx1;
const float *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = s_vert_interp_lev_kernel(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
CPUs_vert_interp_lev_noisnan(const size_t gridsize, const float missval,
float *vardata1, float *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const float *lev_wgt1, const float *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
float *var2 = vardata2 + gridsize * ilev;
const float *var1L1 = vardata1 + gridsize * idx1;
const float *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = s_vert_interp_lev_kernel_noisnan(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
CPUs_vert_interp_lev_nomissval(const size_t gridsize, const float missval,
float *vardata1, float *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const float *lev_wgt1, const float *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
float *var2 = vardata2 + gridsize * ilev;
const float *var1L1 = vardata1 + gridsize * idx1;
const float *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = s_vert_interp_lev_kernel_nomissval(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
GPUs_vert_interp_lev(const size_t gridsize, const float missval,
float *vardata1, float *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const float *lev_wgt1, const float *lev_wgt2)
{
/*
for (int ilev = 0; ilev < nlev2; ++ilev)
{
for (size_t i = 0; i < gridsize; ++i)
{
printf("GPU before %f %f\n",*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i));
}
}
*/
#pragma acc data copyin(vardata1[:gridsize*nlev2])
#pragma acc data copyout(vardata2[:gridsize*nlev2])
#pragma acc parallel loop collapse(2)
for (int ilev = 0; ilev < nlev2; ++ilev)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
*(vardata2+gridsize*ilev+i) = s_vert_interp_lev_kernel(lev_wgt1[ilev], lev_wgt2[ilev],
*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i), missval);
}
}
/*
for (int ilev = 0; ilev < nlev2; ++ilev)
{
for (size_t i = 0; i < gridsize; ++i)
{
printf("GPU after %f\n", *(vardata2+gridsize*ilev+i));
}
}
*/
}
void
CPUd_vert_interp_lev_original(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
double *var2 = vardata2 + gridsize * ilev;
const double *var1L1 = vardata1 + gridsize * idx1;
const double *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = d_vert_interp_lev_kernel(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
CPUd_vert_interp_lev_noisnan(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
double *var2 = vardata2 + gridsize * ilev;
const double *var1L1 = vardata1 + gridsize * idx1;
const double *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = d_vert_interp_lev_kernel_noisnan(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
CPUd_vert_interp_lev_nomissval(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
double *var2 = vardata2 + gridsize * ilev;
const double *var1L1 = vardata1 + gridsize * idx1;
const double *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = d_vert_interp_lev_kernel_nomissval(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
CPUd_vert_interp_lev(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
/*
for (int ilev = 0; ilev < nlev2; ++ilev)
{
for (size_t i = 0; i < gridsize; ++i)
{
printf("CPU before %f %f\n",*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i));
}
}
*/
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
double *var2 = vardata2 + gridsize * ilev;
const double *var1L1 = vardata1 + gridsize * idx1;
const double *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = d_vert_interp_lev_kernel(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
/*
for (int ilev = 0; ilev < nlev2; ++ilev)
{
for (size_t i = 0; i < gridsize; ++i)
{
printf("CPU after %f\n", *(vardata2+gridsize*ilev+i));
}
}
*/
}
void
GPUs_vert_interp_lev_original(const size_t gridsize, const float missval,
float *vardata1, float *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const float *lev_wgt1, const float *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
float *var2 = vardata2 + gridsize * ilev;
const float *var1L1 = vardata1 + gridsize * idx1;
const float *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
#pragma acc parallel loop
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = s_vert_interp_lev_kernel(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
GPUs_vert_interp_lev_noisnan(const size_t gridsize, const float missval,
float *vardata1, float *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const float *lev_wgt1, const float *lev_wgt2)
{
#pragma acc data copyin(vardata1[:gridsize*nlev2])
#pragma acc data copyout(vardata2[:gridsize*nlev2])
#pragma acc parallel loop collapse(2)
for (int ilev = 0; ilev < nlev2; ++ilev)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
*(vardata2+gridsize*ilev+i) = s_vert_interp_lev_kernel_noisnan(lev_wgt1[ilev], lev_wgt2[ilev],
*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i), missval);
}
}
}
void
GPUs_vert_interp_lev_nomissval(const size_t gridsize, const float missval,
float *vardata1, float *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const float *lev_wgt1, const float *lev_wgt2)
{
#pragma acc data copyin(vardata1[:gridsize*nlev2])
#pragma acc data copyout(vardata2[:gridsize*nlev2])
#pragma acc parallel loop collapse(2)
for (int ilev = 0; ilev < nlev2; ++ilev)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
*(vardata2+gridsize*ilev+i) = s_vert_interp_lev_kernel_nomissval(lev_wgt1[ilev], lev_wgt2[ilev],
*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i), missval);
}
}
}
void
GPUd_vert_interp_lev_original(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
for (int ilev = 0; ilev < nlev2; ++ilev)
{
const auto idx1 = lev_idx1[ilev];
const auto idx2 = lev_idx2[ilev];
auto wgt1 = lev_wgt1[ilev];
auto wgt2 = lev_wgt2[ilev];
double *var2 = vardata2 + gridsize * ilev;
const double *var1L1 = vardata1 + gridsize * idx1;
const double *var1L2 = vardata1 + gridsize * idx2;
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
#pragma acc parallel loop
for (size_t i = 0; i < gridsize; ++i)
{
var2[i] = d_vert_interp_lev_kernel(wgt1, wgt2, var1L1[i], var1L2[i], missval);
}
}
}
void
GPUd_vert_interp_lev_noisnan(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
#pragma acc data copyin(vardata1[:gridsize*nlev2])
#pragma acc data copyout(vardata2[:gridsize*nlev2])
#pragma acc parallel loop collapse(2)
for (int ilev = 0; ilev < nlev2; ++ilev)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
*(vardata2+gridsize*ilev+i) = d_vert_interp_lev_kernel_noisnan(lev_wgt1[ilev], lev_wgt2[ilev],
*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i), missval);
}
}
}
void
GPUd_vert_interp_lev_nomissval(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
#pragma acc data copyin(vardata1[:gridsize*nlev2])
#pragma acc data copyout(vardata2[:gridsize*nlev2])
#pragma acc parallel loop collapse(2)
for (int ilev = 0; ilev < nlev2; ++ilev)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
*(vardata2+gridsize*ilev+i) = d_vert_interp_lev_kernel_nomissval(lev_wgt1[ilev], lev_wgt2[ilev],
*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i), missval);
}
}
}
void
GPUd_vert_interp_lev(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
/*
for (int ilev = 0; ilev < nlev2; ++ilev)
{
for (size_t i = 0; i < gridsize; ++i)
{
printf("GPU before %f %f\n",*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i));
}
}
*/
#pragma acc data copyin(vardata1[:gridsize*nlev2])
#pragma acc data copyout(vardata2[:gridsize*nlev2])
#pragma acc parallel loop collapse(2)
for (int ilev = 0; ilev < nlev2; ++ilev)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, missval, wgt1, wgt2)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
*(vardata2+gridsize*ilev+i) = d_vert_interp_lev_kernel(lev_wgt1[ilev], lev_wgt2[ilev],
*(vardata1+gridsize*lev_idx1[ilev]+i), *(vardata1+gridsize*lev_idx2[ilev]+i), missval);
}
}
/*
for (int ilev = 0; ilev < nlev2; ++ilev)
{
for (size_t i = 0; i < gridsize; ++i)
{
printf("GPU after %f\n", *(vardata2+gridsize*ilev+i));
}
}
*/
}
/*
#define MAXGRID 10000
#define MAXLEV 8
void
tiled_GPUd_vert_interp_lev(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
if ( nlev2>MAXLEV ) {
printf("ERROR in GPUd_vert_interp_lev number of levels %i exceeds design %i\n",nlev2,MAXGRID);
exit (1);
}
int tilesize = MAXGRID;
for (int istart=0;istart<gridsize;istart=istart+MAXGRID) {
if ( istart+MAXGRID>gridsize ) tilesize = gridsize-istart;
printf("executing tile starting %i of size %i\n",istart,tilesize);
#pragma acc data copyin(vardata1[istart:MAXGRID*MAXLEV],vardata2[istart:MAXGRID*MAXLEV])
#pragma acc data copyin(lev_idx1[:MAXLEV],lev_idx2[:MAXLEV],lev_wgt1[:MAXLEV],lev_wgt2[:MAXLEV])
#pragma acc parallel loop
for (int ilev = 0; ilev < nlev2; ++ilev)
{
double wgt1 = lev_wgt1[ilev];
double wgt2 = lev_wgt2[ilev];
const int lev1 = lev_idx1[ilev];
const int lev2 = lev_idx2[ilev];
#pragma acc data copyin (vardata1[MAXGRID*lev1+istart:MAXGRID*lev1+MAXGRID])
#pragma acc data copyin (vardata2[MAXGRID*lev2+istart:MAXGRID*lev2+MAXGRID])
#pragma acc data copyout(vardata2[MAXGRID*ilev+istart:MAXGRID*ilev+MAXGRID])
#pragma acc loop independent
for (size_t i = istart; i < istart+tilesize; ++i)
{
if (vardata1[i+gridsize*lev1]==missval) wgt1 = 0;
if (vardata2[i+gridsize*lev2]==missval) wgt2 = 0;
if ((wgt1==0) && (wgt2==0))
{
vardata2[i+gridsize*ilev] = missval;
}
else if (wgt1==0)
{
vardata2[i+gridsize*ilev] = (wgt2 >= 0.5) ? vardata2[i+gridsize*lev2] : missval;
}
else if (wgt2==0)
{
vardata2[i+gridsize*ilev] = (wgt1 >= 0.5) ? vardata1[i+gridsize*lev1] : missval;
}
else
{
vardata2[i+gridsize*ilev] = vardata1[i+gridsize*lev1] * wgt1
+ vardata2[i+gridsize*lev2] * wgt2;
}
}
}
}
}
void
mask_GPUd_vert_interp_lev(const size_t gridsize, const double missval,
double *vardata1, double *vardata2,
const int nlev2, const int *lev_idx1, const int *lev_idx2,
const double *lev_wgt1, const double *lev_wgt2)
{
//#pragma acc data copyin(vardata1[:gridsize*nlev2],vardata2[:gridsize*nlev2])
//#pragma acc data copyin(lev_idx1[:nlev2],lev_idx2[:nlev2],lev_wgt1[:nlev2],lev_wgt2[:nlev2])
//#pragma acc parallel loop
for (int ilev = 0; ilev < nlev2; ++ilev)
{
double wgt1 = lev_wgt1[ilev];
double wgt2 = lev_wgt2[ilev];
const int lev1 = lev_idx1[ilev];
const int lev2 = lev_idx2[ilev];
#pragma acc data copyin(vardata1[gridsize*lev1:gridsize*lev1+gridsize])
#pragma acc data copyin(vardata2[gridsize*lev2:gridsize*lev2+gridsize])
#pragma acc data copyout(vardata2[gridsize*ilev:gridsize*ilev+gridsize])
#pragma acc loop independent
for (size_t i = 0; i < gridsize; ++i) {
int wm = ((vardata1[i+gridsize*lev1]==missval) && (vardata2[i+gridsize*lev2]==missval))
|| ((vardata1[i+gridsize*lev1]==missval) && (vardata2[i+gridsize*lev2]!=missval)
&& wgt2<0.5)
|| ((vardata1[i+gridsize*lev1]!=missval) && (vardata2[i+gridsize*lev2]==missval)
&& wgt1<0.5);
int w1 = ((vardata1[i+gridsize*lev1]!=missval) && (vardata2[i+gridsize*lev2]==missval)
&& wgt1>=0.5);
int w2 = ((vardata1[i+gridsize*lev1]==missval) && (vardata2[i+gridsize*lev2]!=missval)
&& wgt2>=0.5);
int wb = ((vardata1[i+gridsize*lev1]!=missval) && (vardata2[i+gridsize*lev2]!=missval));
if ( wm ) vardata2[i+gridsize*ilev] = missval;
if ( w1 ) vardata2[i+gridsize*ilev] = vardata1[i+gridsize*lev1];
if ( w2 ) vardata2[i+gridsize*ilev] = vardata2[i+gridsize*lev2];
if ( wb ) vardata2[i+gridsize*ilev] =
(vardata1[i+gridsize*lev1]*wgt1 + vardata2[i+gridsize*lev2]*wgt2);
// Original code or a version of it
if (vardata1[i+gridsize*lev1]==missval) wgt1 = 0;
if (vardata2[i+gridsize*lev2]==missval) wgt2 = 0;
if ((wgt1==0) && (wgt2==0))
{
vardata2[i+gridsize*ilev] = missval;
}
else if (wgt1==0)
{
vardata2[i+gridsize*ilev] = (wgt2 >= 0.5) ? vardata2[i+gridsize*lev2] : missval;
}
else if (wgt2==0)
{
vardata2[i+gridsize*ilev] = (wgt1 >= 0.5) ? vardata1[i+gridsize*lev1] : missval;
}
else
{
vardata2[i+gridsize*ilev] = vardata1[i+gridsize*lev1] * wgt1
+ vardata2[i+gridsize*lev2] * wgt2;
}
//
}
}
}
*/
| [
"mike.ashworth.compsci@manchester.ac.uk"
] | mike.ashworth.compsci@manchester.ac.uk |
3d56f70a082592e8a42df1243b9963bcff06cb04 | 8273325be37ca8d303f036cd38a10612fad93d9b | /preview_with_no_render/program_manager.h | 79fa6614696b960657519cfd48ed568fde79887d | [] | no_license | JiyuanLi/power_measurement_tool | 0be0c39f921c4e7aec64ac3b9267331139950651 | 7cf449f69d3111d7abb197df329b1bc4975e74db | refs/heads/master | 2021-01-20T18:02:39.149861 | 2016-06-21T14:48:51 | 2016-06-21T14:48:51 | 61,541,267 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 888 | h | #ifndef PROGRAM_MANAGER_H
#define PROGRAM_MANAGER_H
#include "camera_control.h"
#include <fstream>
#include <algorithm>
#include <set>
#include <map>
#include <regex>
class Program_Manager
{
private:
int int_width;
int int_height;
int int_frame_rate;
int int_duration;
std::string str_arg_0;
std::string str_sensor_name;
std::string str_resolution;
std::string str_frame_rate;
std::string str_format;
std::string str_duration_in_second;
std::set<std::string> set_supported_sensor;
bool Is_sensor_name_valid();
bool Is_resolution_valid();
bool Is_frame_rate_valid();
bool Is_format_valid();
bool Is_duration_valid();
CameraControl selected_sensor_control;
public:
Program_Manager(char *ch_arg_0, char *ch_sensor_name, char *ch_resolution, char *ch_frame_rate, char *ch_format, char *ch_duration);
void Start_Running();
};
#endif | [
"lijiyuan2013@sina.com"
] | lijiyuan2013@sina.com |
7c60de7de4e2433d8697638ed429f0cc5b5fd09e | 4b59e9b06b12615ac294b0103546b9bfdc4721f3 | /src/buffer.cpp | b014d6b46be0bb221f160952fb3670d7665d8f3b | [
"MIT"
] | permissive | zzmcdc/cpp-ipc | 32f59908c03943b3cfb86817e762a4ebb63125ab | d3afbdedc642ccca7a15b76cf5ab20ea32c70240 | refs/heads/master | 2020-08-14T16:20:53.889624 | 2019-10-07T12:32:12 | 2019-10-07T12:32:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,673 | cpp | #include "buffer.h"
#include "pimpl.h"
#include <cstring>
namespace ipc {
bool operator==(buffer const & b1, buffer const & b2) {
return (b1.size() == b2.size()) && (std::memcmp(b1.data(), b2.data(), b1.size()) == 0);
}
class buffer::buffer_ : public pimpl<buffer_> {
public:
void* p_;
std::size_t s_;
void* a_;
buffer::destructor_t d_;
buffer_(void* p, std::size_t s, buffer::destructor_t d, void* a)
: p_(p), s_(s), a_(a), d_(d) {
}
~buffer_() {
if (d_ == nullptr) return;
d_((a_ == nullptr) ? p_ : a_, s_);
}
};
buffer::buffer()
: buffer(nullptr, 0, nullptr, nullptr) {
}
buffer::buffer(void* p, std::size_t s, destructor_t d)
: p_(p_->make(p, s, d, nullptr)) {
}
buffer::buffer(void* p, std::size_t s, destructor_t d, void* additional)
: p_(p_->make(p, s, d, additional)) {
}
buffer::buffer(void* p, std::size_t s)
: buffer(p, s, nullptr) {
}
buffer::buffer(char const & c)
: buffer(const_cast<char*>(&c), 1) {
}
buffer::buffer(buffer&& rhs)
: buffer() {
swap(rhs);
}
buffer::~buffer() {
p_->clear();
}
void buffer::swap(buffer& rhs) {
std::swap(p_, rhs.p_);
}
buffer& buffer::operator=(buffer rhs) {
swap(rhs);
return *this;
}
bool buffer::empty() const noexcept {
return (impl(p_)->p_ == nullptr) || (impl(p_)->s_ == 0);
}
void* buffer::data() noexcept {
return impl(p_)->p_;
}
void const * buffer::data() const noexcept {
return impl(p_)->p_;
}
std::size_t buffer::size() const noexcept {
return impl(p_)->s_;
}
} // namespace ipc
| [
"zhangyi@hangsheng.com.cn"
] | zhangyi@hangsheng.com.cn |
a7cde343a274e40de42e90defcaa3d3dcbfe2164 | 202d65fc8de056b070baad6f80a440f68da4bdbb | /src/main/tpch/tpch_workload.cpp | d4721d9b08008eb053c7123b175646ae05966065 | [
"Apache-2.0"
] | permissive | alphalzh/peloton | b9880b771313bc9b7be0bac83f2a095ccd0c0a1e | db07ff13362976393a8e2b68b0dd5d3c9d3f6872 | refs/heads/master | 2021-01-25T14:49:34.483768 | 2018-04-29T21:20:57 | 2018-04-29T21:20:57 | 123,730,816 | 1 | 0 | Apache-2.0 | 2018-05-11T03:44:58 | 2018-03-03T20:58:18 | C++ | UTF-8 | C++ | false | false | 5,672 | cpp | //===----------------------------------------------------------------------===//
//
// Peloton
//
// tpch_workload.cpp
//
// Identification: src/main/tpch/tpch_workload.cpp
//
// Copyright (c) 2015-17, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include "benchmark/tpch/tpch_workload.h"
#include "codegen/query.h"
#include "concurrency/transaction_manager_factory.h"
#include "executor/plan_executor.h"
#include "planner/abstract_plan.h"
#include "planner/binding_context.h"
#include "codegen/counting_consumer.h"
namespace peloton {
namespace benchmark {
namespace tpch {
TPCHBenchmark::TPCHBenchmark(const Configuration &config, TPCHDatabase &db)
: config_(config), db_(db) {
query_configs_ = {
{"Q1",
QueryId::Q1,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q2",
QueryId::Q2,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q3",
QueryId::Q3,
{TableId::Lineitem, TableId::Customer, TableId::Orders},
[&]() { return ConstructQ3Plan(); }},
{"Q4",
QueryId::Q4,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q5",
QueryId::Q5,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q6",
QueryId::Q6,
{TableId::Lineitem},
[&]() { return ConstructQ6Plan(); }},
{"Q7",
QueryId::Q7,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q8",
QueryId::Q8,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q9",
QueryId::Q9,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q10",
QueryId::Q10,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q11",
QueryId::Q11,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q12",
QueryId::Q12,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q13",
QueryId::Q13,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q14",
QueryId::Q14,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q15",
QueryId::Q15,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q16",
QueryId::Q16,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q17",
QueryId::Q17,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q18",
QueryId::Q18,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q19",
QueryId::Q19,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q20",
QueryId::Q20,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q21",
QueryId::Q21,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
{"Q22",
QueryId::Q22,
{TableId::Lineitem},
[&]() { return ConstructQ1Plan(); }},
};
}
void TPCHBenchmark::RunBenchmark() {
for (uint32_t i = 0; i < 22; i++) {
const auto &query_config = query_configs_[i];
if (config_.ShouldRunQuery(query_config.query_id)) {
RunQuery(query_config);
}
}
}
void TPCHBenchmark::RunQuery(const TPCHBenchmark::QueryConfig &query_config) {
LOG_INFO("Running TPCH %s", query_config.query_name.c_str());
// Load all the necessary tables
for (auto tid : query_config.required_tables) {
db_.LoadTable(tid);
}
// Construct the plan for Q1
std::unique_ptr<planner::AbstractPlan> plan = query_config.PlanConstructor();
// Do attribute binding
planner::BindingContext binding_context;
plan->PerformBinding(binding_context);
// The consumer
codegen::CountingConsumer counter;
// Compile
codegen::QueryCompiler::CompileStats compile_stats;
codegen::QueryCompiler compiler;
auto compiled_query = compiler.Compile(*plan, counter, &compile_stats);
codegen::Query::RuntimeStats overall_stats;
overall_stats.init_ms = 0.0;
overall_stats.plan_ms = 0.0;
overall_stats.tear_down_ms = 0.0;
for (uint32_t i = 0; i < config_.num_runs; i++) {
// Reset the counter for this run
counter.ResetCount();
// Begin a transaction
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
auto *txn = txn_manager.BeginTransaction();
// Execute query in a transaction
codegen::Query::RuntimeStats runtime_stats;
compiled_query->Execute(*txn, counter.GetCountAsState(), &runtime_stats);
// Commit transaction
txn_manager.CommitTransaction(txn);
// Collect stats
overall_stats.init_ms += runtime_stats.init_ms;
overall_stats.plan_ms += runtime_stats.plan_ms;
overall_stats.tear_down_ms += runtime_stats.tear_down_ms;
}
LOG_INFO("%s: %s",
query_config.query_name.c_str(), peloton::GETINFO_THICK_LINE.c_str());
LOG_INFO("# Runs: %u, # Result tuples: %lu", config_.num_runs,
counter.GetCount());
LOG_INFO("Setup: %.2lf, IR Gen: %.2lf, Compile: %.2lf",
compile_stats.setup_ms, compile_stats.ir_gen_ms,
compile_stats.jit_ms);
LOG_INFO("Init: %.2lf ms, Plan: %.2lf ms, TearDown: %.2lf ms",
overall_stats.init_ms / config_.num_runs,
overall_stats.plan_ms / config_.num_runs,
overall_stats.tear_down_ms / config_.num_runs);
}
} // namespace tpch
} // namespace benchmark
} // namespace peloton | [
"pavlo@cs.brown.edu"
] | pavlo@cs.brown.edu |
082c5aef4e78e30477384252cfb13f784eb6788e | eb7283d80697fd760497aa8523f826d19bbb2e8d | /cs/engine/xrGame/ui/UIVote.cpp | f7e7ea0a23831ad7a3e1d4546e88a5db8caef863 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
] | permissive | Xetrill/xray | 018e427f212eba36af20bb132ad8c23bf258cb6d | 75461ca6faa6783e93bc2aaa04f03e3cae81e82a | refs/heads/master | 2020-04-01T15:06:32.852348 | 2014-09-09T16:32:01 | 2014-09-09T16:32:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,582 | cpp | #include "stdafx.h"
#include "UIVote.h"
#include "UIStatic.h"
#include "UI3tButton.h"
#include "UIListBox.h"
#include "UIFrameWindow.h"
#include "UIXmlInit.h"
#include "Level.h"
#include "game_cl_base.h"
#include "game_cl_teamdeathmatch.h"
#include "xrEngine/xr_IOConsole.h"
CUIVote::CUIVote()
{
m_prev_upd_time = 0;
bkgrnd = new CUIStatic(); bkgrnd->SetAutoDelete(true); AttachChild(bkgrnd);
msg_back = new CUIStatic(); msg_back->SetAutoDelete(true); AttachChild(msg_back);
msg = new CUIStatic(); msg->SetAutoDelete(true); AttachChild(msg);
for (int i = 0; i<3; i++)
{
cap[i] = new CUIStatic(); cap[i]->SetAutoDelete(true); AttachChild(cap[i]);
frame[i] = new CUIFrameWindow(); frame[i]->SetAutoDelete(true); AttachChild(frame[i]);
list[i] = new CUIListBox(); list[i]->SetAutoDelete(true); AttachChild(list[i]);
}
btn_yes = new CUI3tButtonEx(); btn_yes->SetAutoDelete(true); AttachChild(btn_yes);
btn_no = new CUI3tButtonEx(); btn_no->SetAutoDelete(true); AttachChild(btn_no);
btn_cancel = new CUI3tButtonEx(); btn_cancel->SetAutoDelete(true); AttachChild(btn_cancel);
Init();
}
void CUIVote::Init()
{
CUIXml xml_doc;
xml_doc.Load (CONFIG_PATH, UI_PATH, "voting_category.xml");
CUIXmlInit::InitWindow (xml_doc, "vote", 0, this);
CUIXmlInit::InitStatic (xml_doc, "vote:background", 0, bkgrnd);
CUIXmlInit::InitStatic (xml_doc, "vote:msg_back", 0, msg_back);
CUIXmlInit::InitStatic (xml_doc, "vote:msg", 0, msg);
string256 path;
for (int i = 0; i<3; i++)
{
sprintf_s (path, "vote:list_cap_%d", i+1);
CUIXmlInit::InitStatic (xml_doc, path, 0, cap[i]);
sprintf_s (path, "vote:list_back_%d", i+1);
CUIXmlInit::InitFrameWindow (xml_doc, path, 0, frame[i]);
sprintf_s (path, "vote:list_%d", i+1);
CUIXmlInit::InitListBox (xml_doc, path, 0, list[i]);
}
CUIXmlInit::Init3tButtonEx(xml_doc, "vote:btn_yes", 0, btn_yes);
CUIXmlInit::Init3tButtonEx(xml_doc, "vote:btn_no", 0, btn_no);
CUIXmlInit::Init3tButtonEx(xml_doc, "vote:btn_cancel", 0, btn_cancel);
}
void CUIVote::SetVoting(LPCSTR txt)
{
msg->SetText(txt);
}
void CUIVote::Update()
{
CUIDialogWnd::Update();
static string512 teaminfo;
if (m_prev_upd_time > Device.dwTimeContinual - 1000)
return;
m_prev_upd_time = Device.dwTimeContinual;
game_cl_GameState::PLAYERS_MAP_IT I=Game().players.begin();
game_cl_GameState::PLAYERS_MAP_IT E=Game().players.end();
DEFINE_VECTOR (game_PlayerState*,ItemVec,ItemIt);
ItemVec items;
for (;I!=E;++I)
{
items.push_back(I->second);
};
std::sort(items.begin(), items.end(), DM_Compare_Players);
list[0]->Clear();
list[1]->Clear();
list[2]->Clear();
for (u32 i = 0; i<items.size(); i++){
game_PlayerState* p = items[i];
if (p->m_bCurrentVoteAgreed == 1)
list[0]->AddItem(p->name);
else if (p->m_bCurrentVoteAgreed == 0)
list[1]->AddItem(p->name);
else
list[2]->AddItem(p->name);
}
}
void CUIVote::SendMessage(CUIWindow* pWnd, s16 msg, void* pData)
{
if (BUTTON_CLICKED == msg)
{
if (btn_yes == pWnd)
OnBtnYes();
else if (btn_no == pWnd)
OnBtnNo();
else if (btn_cancel == pWnd)
OnBtnCancel();
}
}
void CUIVote::OnBtnYes()
{
Console->Execute("cl_voteyes");
game_cl_mp* game = smart_cast<game_cl_mp*>(&Game());
game->StartStopMenu(this, true);
}
void CUIVote::OnBtnNo()
{
Console->Execute("cl_voteno");
game_cl_mp* game = smart_cast<game_cl_mp*>(&Game());
game->StartStopMenu(this, true);
}
void CUIVote::OnBtnCancel()
{
game_cl_mp* game = smart_cast<game_cl_mp*>(&Game());
game->StartStopMenu(this, true);
}
| [
"paul-kv@yandex.ru"
] | paul-kv@yandex.ru |
9dd4639fe220b78c704c01118624fcae3626e155 | 31ac07ecd9225639bee0d08d00f037bd511e9552 | /externals/OCCTLib/inc/RWStepRepr_RWShapeRepresentationRelationshipWithTransformation.hxx | 2ea3597a4cb5334b99bcf1d7079826e5a24f745e | [] | no_license | litao1009/SimpleRoom | 4520e0034e4f90b81b922657b27f201842e68e8e | 287de738c10b86ff8f61b15e3b8afdfedbcb2211 | refs/heads/master | 2021-01-20T19:56:39.507899 | 2016-07-29T08:01:57 | 2016-07-29T08:01:57 | 64,462,604 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,208 | hxx | // This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to
// this header file considered to be the "object code" form of the original source.
#ifndef _RWStepRepr_RWShapeRepresentationRelationshipWithTransformation_HeaderFile
#define _RWStepRepr_RWShapeRepresentationRelationshipWithTransformation_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_DefineAlloc_HeaderFile
#include <Standard_DefineAlloc.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Handle_StepData_StepReaderData_HeaderFile
#include <Handle_StepData_StepReaderData.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Handle_Interface_Check_HeaderFile
#include <Handle_Interface_Check.hxx>
#endif
#ifndef _Handle_StepRepr_ShapeRepresentationRelationshipWithTransformation_HeaderFile
#include <Handle_StepRepr_ShapeRepresentationRelationshipWithTransformation.hxx>
#endif
class StepData_StepReaderData;
class Interface_Check;
class StepRepr_ShapeRepresentationRelationshipWithTransformation;
class StepData_StepWriter;
class Interface_EntityIterator;
//! Read & Write Module for ShapeRepresentationRelationshipWithTransformation <br>
class RWStepRepr_RWShapeRepresentationRelationshipWithTransformation {
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT RWStepRepr_RWShapeRepresentationRelationshipWithTransformation();
Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& data,const Standard_Integer num,Handle(Interface_Check)& ach,const Handle(StepRepr_ShapeRepresentationRelationshipWithTransformation)& ent) const;
Standard_EXPORT void WriteStep(StepData_StepWriter& SW,const Handle(StepRepr_ShapeRepresentationRelationshipWithTransformation)& ent) const;
Standard_EXPORT void Share(const Handle(StepRepr_ShapeRepresentationRelationshipWithTransformation)& ent,Interface_EntityIterator& iter) const;
protected:
private:
};
// other Inline functions and methods (like "C++: function call" methods)
#endif
| [
"litao1009@gmail.com"
] | litao1009@gmail.com |
dc63f6bebed9193384854e47ca29f72ee34db168 | 7d127c13a3a4f9a3b1c01e135811768f89c98666 | /include/c++/v1/vector | de7de093d585b274d7e27d56d028724ac231609b | [
"MIT",
"NCSA",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-arm-llvm-sga"
] | permissive | MiguelNdeCarvalho/clang8 | c1267d5a7c61f1837e1182a11d29663dd8b29b89 | f012d3b7702cd2776d119e6ddfd212ec8037cb98 | refs/heads/master | 2020-04-11T13:56:28.091951 | 2018-12-06T19:35:05 | 2018-12-06T19:35:05 | 161,835,718 | 0 | 1 | NOASSERTION | 2018-12-14T20:13:28 | 2018-12-14T20:13:28 | null | UTF-8 | C++ | false | false | 111,205 | // -*- C++ -*-
//===------------------------------ vector --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_VECTOR
#define _LIBCPP_VECTOR
/*
vector synopsis
namespace std
{
template <class T, class Allocator = allocator<T> >
class vector
{
public:
typedef T value_type;
typedef Allocator allocator_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::difference_type difference_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
vector()
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit vector(const allocator_type&);
explicit vector(size_type n);
explicit vector(size_type n, const allocator_type&); // C++14
vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
template <class InputIterator>
vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
vector(const vector& x);
vector(vector&& x)
noexcept(is_nothrow_move_constructible<allocator_type>::value);
vector(initializer_list<value_type> il);
vector(initializer_list<value_type> il, const allocator_type& a);
~vector();
vector& operator=(const vector& x);
vector& operator=(vector&& x)
noexcept(
allocator_type::propagate_on_container_move_assignment::value ||
allocator_type::is_always_equal::value); // C++17
vector& operator=(initializer_list<value_type> il);
template <class InputIterator>
void assign(InputIterator first, InputIterator last);
void assign(size_type n, const value_type& u);
void assign(initializer_list<value_type> il);
allocator_type get_allocator() const noexcept;
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
size_type capacity() const noexcept;
bool empty() const noexcept;
void reserve(size_type n);
void shrink_to_fit() noexcept;
reference operator[](size_type n);
const_reference operator[](size_type n) const;
reference at(size_type n);
const_reference at(size_type n) const;
reference front();
const_reference front() const;
reference back();
const_reference back() const;
value_type* data() noexcept;
const value_type* data() const noexcept;
void push_back(const value_type& x);
void push_back(value_type&& x);
template <class... Args>
reference emplace_back(Args&&... args); // reference in C++17
void pop_back();
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
iterator insert(const_iterator position, const value_type& x);
iterator insert(const_iterator position, value_type&& x);
iterator insert(const_iterator position, size_type n, const value_type& x);
template <class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<value_type> il);
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void resize(size_type sz);
void resize(size_type sz, const value_type& c);
void swap(vector&)
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
allocator_traits<allocator_type>::is_always_equal::value); // C++17
bool __invariants() const;
};
template <class Allocator = allocator<T> >
class vector<bool, Allocator>
{
public:
typedef bool value_type;
typedef Allocator allocator_type;
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::difference_type difference_type;
typedef iterator pointer;
typedef const_iterator const_pointer;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
class reference
{
public:
reference(const reference&) noexcept;
operator bool() const noexcept;
reference& operator=(const bool x) noexcept;
reference& operator=(const reference& x) noexcept;
iterator operator&() const noexcept;
void flip() noexcept;
};
class const_reference
{
public:
const_reference(const reference&) noexcept;
operator bool() const noexcept;
const_iterator operator&() const noexcept;
};
vector()
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit vector(const allocator_type&);
explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14
vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
template <class InputIterator>
vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
vector(const vector& x);
vector(vector&& x)
noexcept(is_nothrow_move_constructible<allocator_type>::value);
vector(initializer_list<value_type> il);
vector(initializer_list<value_type> il, const allocator_type& a);
~vector();
vector& operator=(const vector& x);
vector& operator=(vector&& x)
noexcept(
allocator_type::propagate_on_container_move_assignment::value ||
allocator_type::is_always_equal::value); // C++17
vector& operator=(initializer_list<value_type> il);
template <class InputIterator>
void assign(InputIterator first, InputIterator last);
void assign(size_type n, const value_type& u);
void assign(initializer_list<value_type> il);
allocator_type get_allocator() const noexcept;
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
size_type capacity() const noexcept;
bool empty() const noexcept;
void reserve(size_type n);
void shrink_to_fit() noexcept;
reference operator[](size_type n);
const_reference operator[](size_type n) const;
reference at(size_type n);
const_reference at(size_type n) const;
reference front();
const_reference front() const;
reference back();
const_reference back() const;
void push_back(const value_type& x);
template <class... Args> reference emplace_back(Args&&... args); // C++14; reference in C++17
void pop_back();
template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14
iterator insert(const_iterator position, const value_type& x);
iterator insert(const_iterator position, size_type n, const value_type& x);
template <class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<value_type> il);
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void resize(size_type sz);
void resize(size_type sz, value_type x);
void swap(vector&)
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
allocator_traits<allocator_type>::is_always_equal::value); // C++17
void flip() noexcept;
bool __invariants() const;
};
template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
vector(InputIterator, InputIterator, Allocator = Allocator())
-> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
template <class Allocator> struct hash<std::vector<bool, Allocator>>;
template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
template <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y);
template <class T, class Allocator> bool operator!=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
template <class T, class Allocator> bool operator> (const vector<T,Allocator>& x, const vector<T,Allocator>& y);
template <class T, class Allocator> bool operator>=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
template <class T, class Allocator> bool operator<=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
template <class T, class Allocator>
void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
noexcept(noexcept(x.swap(y)));
} // std
*/
#include <__config>
#include <iosfwd> // for forward declaration of vector
#include <__bit_reference>
#include <type_traits>
#include <climits>
#include <limits>
#include <initializer_list>
#include <memory>
#include <stdexcept>
#include <algorithm>
#include <cstring>
#include <version>
#include <__split_buffer>
#include <__functional_base>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
template <bool>
class __vector_base_common
{
protected:
_LIBCPP_INLINE_VISIBILITY __vector_base_common() {}
_LIBCPP_NORETURN void __throw_length_error() const;
_LIBCPP_NORETURN void __throw_out_of_range() const;
};
template <bool __b>
void
__vector_base_common<__b>::__throw_length_error() const
{
_VSTD::__throw_length_error("vector");
}
template <bool __b>
void
__vector_base_common<__b>::__throw_out_of_range() const
{
_VSTD::__throw_out_of_range("vector");
}
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>)
template <class _Tp, class _Allocator>
class __vector_base
: protected __vector_base_common<true>
{
public:
typedef _Allocator allocator_type;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __alloc_traits::size_type size_type;
protected:
typedef _Tp value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename __alloc_traits::difference_type difference_type;
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
typedef pointer iterator;
typedef const_pointer const_iterator;
pointer __begin_;
pointer __end_;
__compressed_pair<pointer, allocator_type> __end_cap_;
_LIBCPP_INLINE_VISIBILITY
allocator_type& __alloc() _NOEXCEPT
{return __end_cap_.second();}
_LIBCPP_INLINE_VISIBILITY
const allocator_type& __alloc() const _NOEXCEPT
{return __end_cap_.second();}
_LIBCPP_INLINE_VISIBILITY
pointer& __end_cap() _NOEXCEPT
{return __end_cap_.first();}
_LIBCPP_INLINE_VISIBILITY
const pointer& __end_cap() const _NOEXCEPT
{return __end_cap_.first();}
_LIBCPP_INLINE_VISIBILITY
__vector_base()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
_LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT;
#endif
~__vector_base();
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT {__destruct_at_end(__begin_);}
_LIBCPP_INLINE_VISIBILITY
size_type capacity() const _NOEXCEPT
{return static_cast<size_type>(__end_cap() - __begin_);}
_LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __vector_base& __c)
{__copy_assign_alloc(__c, integral_constant<bool,
__alloc_traits::propagate_on_container_copy_assignment::value>());}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__vector_base& __c)
_NOEXCEPT_(
!__alloc_traits::propagate_on_container_move_assignment::value ||
is_nothrow_move_assignable<allocator_type>::value)
{__move_assign_alloc(__c, integral_constant<bool,
__alloc_traits::propagate_on_container_move_assignment::value>());}
private:
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __vector_base& __c, true_type)
{
if (__alloc() != __c.__alloc())
{
clear();
__alloc_traits::deallocate(__alloc(), __begin_, capacity());
__begin_ = __end_ = __end_cap() = nullptr;
}
__alloc() = __c.__alloc();
}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __vector_base&, false_type)
{}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__vector_base& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__vector_base&, false_type)
_NOEXCEPT
{}
};
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
{
pointer __soon_to_be_end = __end_;
while (__new_last != __soon_to_be_end)
__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end));
__end_ = __new_last;
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
__vector_base<_Tp, _Allocator>::__vector_base()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
__end_(nullptr),
__end_cap_(nullptr)
{
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
__vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a)
: __begin_(nullptr),
__end_(nullptr),
__end_cap_(nullptr, __a)
{
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT
: __begin_(nullptr),
__end_(nullptr),
__end_cap_(nullptr, std::move(__a)) {}
#endif
template <class _Tp, class _Allocator>
__vector_base<_Tp, _Allocator>::~__vector_base()
{
if (__begin_ != nullptr)
{
clear();
__alloc_traits::deallocate(__alloc(), __begin_, capacity());
}
}
template <class _Tp, class _Allocator /* = allocator<_Tp> */>
class _LIBCPP_TEMPLATE_VIS vector
: private __vector_base<_Tp, _Allocator>
{
private:
typedef __vector_base<_Tp, _Allocator> __base;
typedef allocator<_Tp> __default_allocator_type;
public:
typedef vector __self;
typedef _Tp value_type;
typedef _Allocator allocator_type;
typedef typename __base::__alloc_traits __alloc_traits;
typedef typename __base::reference reference;
typedef typename __base::const_reference const_reference;
typedef typename __base::size_type size_type;
typedef typename __base::difference_type difference_type;
typedef typename __base::pointer pointer;
typedef typename __base::const_pointer const_pointer;
typedef __wrap_iter<pointer> iterator;
typedef __wrap_iter<const_pointer> const_iterator;
typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
_LIBCPP_INLINE_VISIBILITY
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
}
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
}
explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
explicit vector(size_type __n, const allocator_type& __a);
#endif
vector(size_type __n, const value_type& __x);
vector(size_type __n, const value_type& __x, const allocator_type& __a);
template <class _InputIterator>
vector(_InputIterator __first,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
_InputIterator>::type __last);
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
_ForwardIterator>::type __last);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
_LIBCPP_INLINE_VISIBILITY
~vector()
{
__annotate_delete();
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__erase_c(this);
#endif
}
vector(const vector& __x);
vector(const vector& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(const vector& __x);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il);
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
_LIBCPP_INLINE_VISIBILITY
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // !_LIBCPP_CXX03_LANG
template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
void
>::type
assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
void
>::type
assign(_ForwardIterator __first, _ForwardIterator __last);
void assign(size_type __n, const_reference __u);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
{return this->__alloc();}
_LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const _NOEXCEPT
{return begin();}
_LIBCPP_INLINE_VISIBILITY
const_iterator cend() const _NOEXCEPT
{return end();}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT
{return static_cast<size_type>(this->__end_ - this->__begin_);}
_LIBCPP_INLINE_VISIBILITY
size_type capacity() const _NOEXCEPT
{return __base::capacity();}
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return this->__begin_ == this->__end_;}
size_type max_size() const _NOEXCEPT;
void reserve(size_type __n);
void shrink_to_fit() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n);
_LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const;
reference at(size_type __n);
const_reference at(size_type __n) const;
_LIBCPP_INLINE_VISIBILITY reference front()
{
_LIBCPP_ASSERT(!empty(), "front() called for empty vector");
return *this->__begin_;
}
_LIBCPP_INLINE_VISIBILITY const_reference front() const
{
_LIBCPP_ASSERT(!empty(), "front() called for empty vector");
return *this->__begin_;
}
_LIBCPP_INLINE_VISIBILITY reference back()
{
_LIBCPP_ASSERT(!empty(), "back() called for empty vector");
return *(this->__end_ - 1);
}
_LIBCPP_INLINE_VISIBILITY const_reference back() const
{
_LIBCPP_ASSERT(!empty(), "back() called for empty vector");
return *(this->__end_ - 1);
}
_LIBCPP_INLINE_VISIBILITY
value_type* data() _NOEXCEPT
{return _VSTD::__to_raw_pointer(this->__begin_);}
_LIBCPP_INLINE_VISIBILITY
const value_type* data() const _NOEXCEPT
{return _VSTD::__to_raw_pointer(this->__begin_);}
#ifdef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void __emplace_back(const value_type& __x) { push_back(__x); }
#else
template <class _Arg>
_LIBCPP_INLINE_VISIBILITY
void __emplace_back(_Arg&& __arg) {
emplace_back(_VSTD::forward<_Arg>(__arg));
}
#endif
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER > 14
reference emplace_back(_Args&&... __args);
#else
void emplace_back(_Args&&... __args);
#endif
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void pop_back();
iterator insert(const_iterator __position, const_reference __x);
#ifndef _LIBCPP_CXX03_LANG
iterator insert(const_iterator __position, value_type&& __x);
template <class... _Args>
iterator emplace(const_iterator __position, _Args&&... __args);
#endif // !_LIBCPP_CXX03_LANG
iterator insert(const_iterator __position, size_type __n, const_reference __x);
template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
iterator
>::type
insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
iterator
>::type
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif
_LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
iterator erase(const_iterator __first, const_iterator __last);
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{
size_type __old_size = size();
__base::clear();
__annotate_shrink(__old_size);
__invalidate_all_iterators();
}
void resize(size_type __sz);
void resize(size_type __sz, const_reference __x);
void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT_DEBUG;
#else
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
bool __invariants() const;
#if _LIBCPP_DEBUG_LEVEL >= 2
bool __dereferenceable(const const_iterator* __i) const;
bool __decrementable(const const_iterator* __i) const;
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
#endif // _LIBCPP_DEBUG_LEVEL >= 2
private:
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
void __vallocate(size_type __n);
void __vdeallocate() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
void __construct_at_end(size_type __n);
_LIBCPP_INLINE_VISIBILITY
void __construct_at_end(size_type __n, const_reference __x);
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
void __append(size_type __n);
void __append(size_type __n, const_reference __x);
_LIBCPP_INLINE_VISIBILITY
iterator __make_iter(pointer __p) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
void __move_range(pointer __from_s, pointer __from_e, pointer __to);
void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
void __move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value);
_LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{
__invalidate_iterators_past(__new_last);
size_type __old_size = size();
__base::__destruct_at_end(__new_last);
__annotate_shrink(__old_size);
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Up> void __push_back_slow_path(_Up&& __x);
template <class... _Args>
void __emplace_back_slow_path(_Args&&... __args);
#else
template <class _Up> void __push_back_slow_path(_Up& __x);
#endif
// The following functions are no-ops outside of AddressSanitizer mode.
// We call annotatations only for the default Allocator because other allocators
// may not meet the AddressSanitizer alignment constraints.
// See the documentation for __sanitizer_annotate_contiguous_container for more details.
#ifndef _LIBCPP_HAS_NO_ASAN
void __annotate_contiguous_container(const void *__beg, const void *__end,
const void *__old_mid,
const void *__new_mid) const
{
if (__beg && is_same<allocator_type, __default_allocator_type>::value)
__sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
}
#else
_LIBCPP_INLINE_VISIBILITY
void __annotate_contiguous_container(const void*, const void*, const void*,
const void*) const {}
#endif
_LIBCPP_INLINE_VISIBILITY
void __annotate_new(size_type __current_size) const {
__annotate_contiguous_container(data(), data() + capacity(),
data() + capacity(), data() + __current_size);
}
_LIBCPP_INLINE_VISIBILITY
void __annotate_delete() const {
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + capacity());
}
_LIBCPP_INLINE_VISIBILITY
void __annotate_increase(size_type __n) const
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + size() + __n);
}
_LIBCPP_INLINE_VISIBILITY
void __annotate_shrink(size_type __old_size) const
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + __old_size, data() + size());
}
#ifndef _LIBCPP_HAS_NO_ASAN
// The annotation for size increase should happen before the actual increase,
// but if an exception is thrown after that the annotation has to be undone.
struct __RAII_IncreaseAnnotator {
__RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1)
: __commit(false), __v(__v), __old_size(__v.size() + __n) {
__v.__annotate_increase(__n);
}
void __done() { __commit = true; }
~__RAII_IncreaseAnnotator() {
if (__commit) return;
__v.__annotate_shrink(__old_size);
}
bool __commit;
const vector &__v;
size_type __old_size;
};
#else
struct __RAII_IncreaseAnnotator {
_LIBCPP_INLINE_VISIBILITY
__RAII_IncreaseAnnotator(const vector &, size_type = 1) {}
_LIBCPP_INLINE_VISIBILITY void __done() {}
};
#endif
};
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
>
vector(_InputIterator, _InputIterator)
-> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
template<class _InputIterator,
class _Alloc,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
>
vector(_InputIterator, _InputIterator, _Alloc)
-> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
#endif
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
{
__annotate_delete();
__alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
_VSTD::swap(this->__begin_, __v.__begin_);
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
__invalidate_all_iterators();
}
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::pointer
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
{
__annotate_delete();
pointer __r = __v.__begin_;
__alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_);
__alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_);
_VSTD::swap(this->__begin_, __v.__begin_);
_VSTD::swap(this->__end_, __v.__end_);
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
__invalidate_all_iterators();
return __r;
}
// Allocate space for __n objects
// throws length_error if __n > max_size()
// throws (probably bad_alloc) if memory run out
// Precondition: __begin_ == __end_ == __end_cap() == 0
// Precondition: __n > 0
// Postcondition: capacity() == __n
// Postcondition: size() == 0
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__vallocate(size_type __n)
{
if (__n > max_size())
this->__throw_length_error();
this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n);
this->__end_cap() = this->__begin_ + __n;
__annotate_new(0);
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
{
if (this->__begin_ != nullptr)
{
clear();
__alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity());
this->__begin_ = this->__end_ = this->__end_cap() = nullptr;
}
}
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
{
return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()),
numeric_limits<difference_type>::max());
}
// Precondition: __new_size > capacity()
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
{
const size_type __ms = max_size();
if (__new_size > __ms)
this->__throw_length_error();
const size_type __cap = capacity();
if (__cap >= __ms / 2)
return __ms;
return _VSTD::max<size_type>(2*__cap, __new_size);
}
// Default constructs __n objects starting at __end_
// throws if construction throws
// Precondition: __n > 0
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
allocator_type& __a = this->__alloc();
do
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
++this->__end_;
--__n;
__annotator.__done();
} while (__n > 0);
}
// Copy constructs __n objects starting at __end_ from __x
// throws if construction throws
// Precondition: __n > 0
// Precondition: size() + __n <= capacity()
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
inline
void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
allocator_type& __a = this->__alloc();
do
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x);
++this->__end_;
--__n;
__annotator.__done();
} while (__n > 0);
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
{
allocator_type& __a = this->__alloc();
__RAII_IncreaseAnnotator __annotator(*this, __n);
__alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_);
__annotator.__done();
}
// Default constructs __n objects starting at __end_
// throws if construction throws
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__append(size_type __n)
{
if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
this->__construct_at_end(__n);
else
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
__v.__construct_at_end(__n);
__swap_out_circular_buffer(__v);
}
}
// Default constructs __n objects starting at __end_
// throws if construction throws
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
{
if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
this->__construct_at_end(__n, __x);
else
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
__v.__construct_at_end(__n, __x);
__swap_out_circular_buffer(__v);
}
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n);
}
}
#if _LIBCPP_STD_VER > 11
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n);
}
}
#endif
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, __x);
}
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, __x);
}
}
template <class _Tp, class _Allocator>
template <class _InputIterator>
vector<_Tp, _Allocator>::vector(_InputIterator __first,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
_InputIterator>::type __last)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
for (; __first != __last; ++__first)
__emplace_back(*__first);
}
template <class _Tp, class _Allocator>
template <class _InputIterator>
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value>::type*)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
for (; __first != __last; ++__first)
__emplace_back(*__first);
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value,
_ForwardIterator>::type __last)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last, __n);
}
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last, __n);
}
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(const vector& __x)
: __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc()))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
size_type __n = __x.size();
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
}
template <class _Tp, class _Allocator>
vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
size_type __n = __x.size();
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#endif
: __base(_VSTD::move(__x.__alloc()))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
__get_db()->swap(this, &__x);
#endif
this->__begin_ = __x.__begin_;
this->__end_ = __x.__end_;
this->__end_cap() = __x.__end_cap();
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
if (__a == __x.__alloc())
{
this->__begin_ = __x.__begin_;
this->__end_ = __x.__end_;
this->__end_cap() = __x.__end_cap();
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->swap(this, &__x);
#endif
}
else
{
typedef move_iterator<iterator> _Ip;
assign(_Ip(__x.begin()), _Ip(__x.end()));
}
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
if (__il.size() > 0)
{
__vallocate(__il.size());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
if (__il.size() > 0)
{
__vallocate(__il.size());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
{
__move_assign(__x, integral_constant<bool,
__alloc_traits::propagate_on_container_move_assignment::value>());
return *this;
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value)
{
if (__base::__alloc() != __c.__alloc())
{
typedef move_iterator<iterator> _Ip;
assign(_Ip(__c.begin()), _Ip(__c.end()));
}
else
__move_assign(__c, true_type());
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__vdeallocate();
__base::__move_assign_alloc(__c); // this can throw
this->__begin_ = __c.__begin_;
this->__end_ = __c.__end_;
this->__end_cap() = __c.__end_cap();
__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->swap(this, &__c);
#endif
}
#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(const vector& __x)
{
if (this != &__x)
{
__base::__copy_assign_alloc(__x);
assign(__x.__begin_, __x.__end_);
}
return *this;
}
template <class _Tp, class _Allocator>
template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
void
>::type
vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
{
clear();
for (; __first != __last; ++__first)
__emplace_back(*__first);
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_ForwardIterator>::reference>::value,
void
>::type
vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__new_size <= capacity())
{
_ForwardIterator __mid = __last;
bool __growing = false;
if (__new_size > size())
{
__growing = true;
__mid = __first;
_VSTD::advance(__mid, size());
}
pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
if (__growing)
__construct_at_end(__mid, __last, __new_size - size());
else
this->__destruct_at_end(__m);
}
else
{
__vdeallocate();
__vallocate(__recommend(__new_size));
__construct_at_end(__first, __last, __new_size);
}
__invalidate_all_iterators();
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
{
if (__n <= capacity())
{
size_type __s = size();
_VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u);
if (__n > __s)
__construct_at_end(__n - __s, __u);
else
this->__destruct_at_end(this->__begin_ + __n);
}
else
{
__vdeallocate();
__vallocate(__recommend(static_cast<size_type>(__n)));
__construct_at_end(__n, __u);
}
__invalidate_all_iterators();
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
return iterator(this, __p);
#else
return iterator(__p);
#endif
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
return const_iterator(this, __p);
#else
return const_iterator(__p);
#endif
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::begin() _NOEXCEPT
{
return __make_iter(this->__begin_);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::begin() const _NOEXCEPT
{
return __make_iter(this->__begin_);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::end() _NOEXCEPT
{
return __make_iter(this->__end_);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::end() const _NOEXCEPT
{
return __make_iter(this->__end_);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::operator[](size_type __n)
{
_LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
return this->__begin_[__n];
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::operator[](size_type __n) const
{
_LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
return this->__begin_[__n];
}
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::at(size_type __n)
{
if (__n >= size())
this->__throw_out_of_range();
return this->__begin_[__n];
}
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::at(size_type __n) const
{
if (__n >= size())
this->__throw_out_of_range();
return this->__begin_[__n];
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::reserve(size_type __n)
{
if (__n > capacity())
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__n, size(), __a);
__swap_out_circular_buffer(__v);
}
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
if (capacity() > size())
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(size(), size(), __a);
__swap_out_circular_buffer(__v);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
}
template <class _Tp, class _Allocator>
template <class _Up>
void
#ifndef _LIBCPP_CXX03_LANG
vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
#else
vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
#endif
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
// __v.push_back(_VSTD::forward<_Up>(__x));
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Up>(__x));
__v.__end_++;
__swap_out_circular_buffer(__v);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::push_back(const_reference __x)
{
if (this->__end_ != this->__end_cap())
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_), __x);
__annotator.__done();
++this->__end_;
}
else
__push_back_slow_path(__x);
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::push_back(value_type&& __x)
{
if (this->__end_ < this->__end_cap())
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_),
_VSTD::move(__x));
__annotator.__done();
++this->__end_;
}
else
__push_back_slow_path(_VSTD::move(__x));
}
template <class _Tp, class _Allocator>
template <class... _Args>
void
vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
// __v.emplace_back(_VSTD::forward<_Args>(__args)...);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Args>(__args)...);
__v.__end_++;
__swap_out_circular_buffer(__v);
}
template <class _Tp, class _Allocator>
template <class... _Args>
inline
#if _LIBCPP_STD_VER > 14
typename vector<_Tp, _Allocator>::reference
#else
void
#endif
vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
if (this->__end_ < this->__end_cap())
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_),
_VSTD::forward<_Args>(__args)...);
__annotator.__done();
++this->__end_;
}
else
__emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
#if _LIBCPP_STD_VER > 14
return this->back();
#endif
}
#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline
void
vector<_Tp, _Allocator>::pop_back()
{
_LIBCPP_ASSERT(!empty(), "vector::pop_back called for empty vector");
this->__destruct_at_end(this->__end_ - 1);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __position)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::erase(iterator) called with an iterator not"
" referring to this vector");
#endif
_LIBCPP_ASSERT(__position != end(),
"vector::erase(iterator) called with a non-dereferenceable iterator");
difference_type __ps = __position - cbegin();
pointer __p = this->__begin_ + __ps;
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
this->__invalidate_iterators_past(__p-1);
iterator __r = __make_iter(__p);
return __r;
}
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
"vector::erase(iterator, iterator) called with an iterator not"
" referring to this vector");
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
"vector::erase(iterator, iterator) called with an iterator not"
" referring to this vector");
#endif
_LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
pointer __p = this->__begin_ + (__first - begin());
if (__first != __last) {
this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
this->__invalidate_iterators_past(__p - 1);
}
iterator __r = __make_iter(__p);
return __r;
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
{
pointer __old_last = this->__end_;
difference_type __n = __old_last - __to;
for (pointer __i = __from_s + __n; __i < __from_e; ++__i, ++this->__end_)
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_),
_VSTD::move(*__i));
_VSTD::move_backward(__from_s, __from_s + __n, __old_last);
}
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, x) called with an iterator not"
" referring to this vector");
#endif
pointer __p = this->__begin_ + (__position - begin());
if (this->__end_ < this->__end_cap())
{
__RAII_IncreaseAnnotator __annotator(*this);
if (__p == this->__end_)
{
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_), __x);
++this->__end_;
}
else
{
__move_range(__p, this->__end_, __p + 1);
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
if (__p <= __xr && __xr < this->__end_)
++__xr;
*__p = *__xr;
}
__annotator.__done();
}
else
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
__v.push_back(__x);
__p = __swap_out_circular_buffer(__v, __p);
}
return __make_iter(__p);
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, x) called with an iterator not"
" referring to this vector");
#endif
pointer __p = this->__begin_ + (__position - begin());
if (this->__end_ < this->__end_cap())
{
__RAII_IncreaseAnnotator __annotator(*this);
if (__p == this->__end_)
{
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_),
_VSTD::move(__x));
++this->__end_;
}
else
{
__move_range(__p, this->__end_, __p + 1);
*__p = _VSTD::move(__x);
}
__annotator.__done();
}
else
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
__v.push_back(_VSTD::move(__x));
__p = __swap_out_circular_buffer(__v, __p);
}
return __make_iter(__p);
}
template <class _Tp, class _Allocator>
template <class... _Args>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::emplace(iterator, x) called with an iterator not"
" referring to this vector");
#endif
pointer __p = this->__begin_ + (__position - begin());
if (this->__end_ < this->__end_cap())
{
__RAII_IncreaseAnnotator __annotator(*this);
if (__p == this->__end_)
{
__alloc_traits::construct(this->__alloc(),
_VSTD::__to_raw_pointer(this->__end_),
_VSTD::forward<_Args>(__args)...);
++this->__end_;
}
else
{
__temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
__move_range(__p, this->__end_, __p + 1);
*__p = _VSTD::move(__tmp.get());
}
__annotator.__done();
}
else
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
__v.emplace_back(_VSTD::forward<_Args>(__args)...);
__p = __swap_out_circular_buffer(__v, __p);
}
return __make_iter(__p);
}
#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, n, x) called with an iterator not"
" referring to this vector");
#endif
pointer __p = this->__begin_ + (__position - begin());
if (__n > 0)
{
if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))
{
size_type __old_n = __n;
pointer __old_last = this->__end_;
if (__n > static_cast<size_type>(this->__end_ - __p))
{
size_type __cx = __n - (this->__end_ - __p);
__construct_at_end(__cx, __x);
__n -= __cx;
}
if (__n > 0)
{
__RAII_IncreaseAnnotator __annotator(*this, __n);
__move_range(__p, __old_last, __p + __old_n);
__annotator.__done();
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
if (__p <= __xr && __xr < this->__end_)
__xr += __old_n;
_VSTD::fill_n(__p, __n, *__xr);
}
}
else
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
__v.__construct_at_end(__n, __x);
__p = __swap_out_circular_buffer(__v, __p);
}
}
return __make_iter(__p);
}
template <class _Tp, class _Allocator>
template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
typename vector<_Tp, _Allocator>::iterator
>::type
vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, range) called with an iterator not"
" referring to this vector");
#endif
difference_type __off = __position - begin();
pointer __p = this->__begin_ + __off;
allocator_type& __a = this->__alloc();
pointer __old_last = this->__end_;
for (; this->__end_ != this->__end_cap() && __first != __last; ++__first)
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_),
*__first);
++this->__end_;
__annotator.__done();
}
__split_buffer<value_type, allocator_type&> __v(__a);
if (__first != __last)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
__v.__construct_at_end(__first, __last);
difference_type __old_size = __old_last - this->__begin_;
difference_type __old_p = __p - this->__begin_;
reserve(__recommend(size() + __v.size()));
__p = this->__begin_ + __old_p;
__old_last = this->__begin_ + __old_size;
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
erase(__make_iter(__old_last), end());
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
__p = _VSTD::rotate(__p, __old_last, this->__end_);
insert(__make_iter(__p), make_move_iterator(__v.begin()),
make_move_iterator(__v.end()));
return begin() + __off;
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_ForwardIterator>::reference>::value,
typename vector<_Tp, _Allocator>::iterator
>::type
vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
"vector::insert(iterator, range) called with an iterator not"
" referring to this vector");
#endif
pointer __p = this->__begin_ + (__position - begin());
difference_type __n = _VSTD::distance(__first, __last);
if (__n > 0)
{
if (__n <= this->__end_cap() - this->__end_)
{
size_type __old_n = __n;
pointer __old_last = this->__end_;
_ForwardIterator __m = __last;
difference_type __dx = this->__end_ - __p;
if (__n > __dx)
{
__m = __first;
difference_type __diff = this->__end_ - __p;
_VSTD::advance(__m, __diff);
__construct_at_end(__m, __last, __n - __diff);
__n = __dx;
}
if (__n > 0)
{
__RAII_IncreaseAnnotator __annotator(*this, __n);
__move_range(__p, __old_last, __p + __old_n);
__annotator.__done();
_VSTD::copy(__first, __m, __p);
}
}
else
{
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
__v.__construct_at_end(__first, __last);
__p = __swap_out_circular_buffer(__v, __p);
}
}
return __make_iter(__p);
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::resize(size_type __sz)
{
size_type __cs = size();
if (__cs < __sz)
this->__append(__sz - __cs);
else if (__cs > __sz)
this->__destruct_at_end(this->__begin_ + __sz);
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
{
size_type __cs = size();
if (__cs < __sz)
this->__append(__sz - __cs, __x);
else if (__cs > __sz)
this->__destruct_at_end(this->__begin_ + __sz);
}
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT_DEBUG
#else
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
_LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
this->__alloc() == __x.__alloc(),
"vector::swap: Either propagate_on_container_swap must be true"
" or the allocators must compare equal");
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__end_, __x.__end_);
_VSTD::swap(this->__end_cap(), __x.__end_cap());
__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->swap(this, &__x);
#endif // _LIBCPP_DEBUG_LEVEL >= 2
}
template <class _Tp, class _Allocator>
bool
vector<_Tp, _Allocator>::__invariants() const
{
if (this->__begin_ == nullptr)
{
if (this->__end_ != nullptr || this->__end_cap() != nullptr)
return false;
}
else
{
if (this->__begin_ > this->__end_)
return false;
if (this->__begin_ == this->__end_cap())
return false;
if (this->__end_ > this->__end_cap())
return false;
}
return true;
}
#if _LIBCPP_DEBUG_LEVEL >= 2
template <class _Tp, class _Allocator>
bool
vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const
{
return this->__begin_ <= __i->base() && __i->base() < this->__end_;
}
template <class _Tp, class _Allocator>
bool
vector<_Tp, _Allocator>::__decrementable(const const_iterator* __i) const
{
return this->__begin_ < __i->base() && __i->base() <= this->__end_;
}
template <class _Tp, class _Allocator>
bool
vector<_Tp, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
{
const_pointer __p = __i->base() + __n;
return this->__begin_ <= __p && __p <= this->__end_;
}
template <class _Tp, class _Allocator>
bool
vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{
const_pointer __p = __i->base() + __n;
return this->__begin_ <= __p && __p < this->__end_;
}
#endif // _LIBCPP_DEBUG_LEVEL >= 2
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_all_iterators()
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__invalidate_all(this);
#endif // _LIBCPP_DEBUG_LEVEL >= 2
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
#if _LIBCPP_DEBUG_LEVEL >= 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
--__p;
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
if (__i->base() > __new_last) {
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
#else
((void)__new_last);
#endif
}
// vector<bool>
template <class _Allocator> class vector<bool, _Allocator>;
template <class _Allocator> struct hash<vector<bool, _Allocator> >;
template <class _Allocator>
struct __has_storage_type<vector<bool, _Allocator> >
{
static const bool value = true;
};
template <class _Allocator>
class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator>
: private __vector_base_common<true>
{
public:
typedef vector __self;
typedef bool value_type;
typedef _Allocator allocator_type;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __alloc_traits::size_type size_type;
typedef typename __alloc_traits::difference_type difference_type;
typedef size_type __storage_type;
typedef __bit_iterator<vector, false> pointer;
typedef __bit_iterator<vector, true> const_pointer;
typedef pointer iterator;
typedef const_pointer const_iterator;
typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
private:
typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
typedef allocator_traits<__storage_allocator> __storage_traits;
typedef typename __storage_traits::pointer __storage_pointer;
typedef typename __storage_traits::const_pointer __const_storage_pointer;
__storage_pointer __begin_;
size_type __size_;
__compressed_pair<size_type, __storage_allocator> __cap_alloc_;
public:
typedef __bit_reference<vector> reference;
typedef __bit_const_reference<vector> const_reference;
private:
_LIBCPP_INLINE_VISIBILITY
size_type& __cap() _NOEXCEPT
{return __cap_alloc_.first();}
_LIBCPP_INLINE_VISIBILITY
const size_type& __cap() const _NOEXCEPT
{return __cap_alloc_.first();}
_LIBCPP_INLINE_VISIBILITY
__storage_allocator& __alloc() _NOEXCEPT
{return __cap_alloc_.second();}
_LIBCPP_INLINE_VISIBILITY
const __storage_allocator& __alloc() const _NOEXCEPT
{return __cap_alloc_.second();}
static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
_LIBCPP_INLINE_VISIBILITY
static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
{return __n * __bits_per_word;}
_LIBCPP_INLINE_VISIBILITY
static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
{return (__n - 1) / __bits_per_word + 1;}
public:
_LIBCPP_INLINE_VISIBILITY
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
#else
_NOEXCEPT;
#endif
~vector();
explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
explicit vector(size_type __n, const allocator_type& __a);
#endif
vector(size_type __n, const value_type& __v);
vector(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value>::type* = 0);
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
vector(const vector& __v);
vector(const vector& __v, const allocator_type& __a);
vector& operator=(const vector& __v);
#ifndef _LIBCPP_CXX03_LANG
vector(initializer_list<value_type> __il);
vector(initializer_list<value_type> __il, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
vector(vector&& __v, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
_LIBCPP_INLINE_VISIBILITY
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // !_LIBCPP_CXX03_LANG
template <class _InputIterator>
typename enable_if
<
__is_input_iterator<_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value,
void
>::type
assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
assign(_ForwardIterator __first, _ForwardIterator __last);
void assign(size_type __n, const value_type& __x);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
_LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(this->__alloc());}
size_type max_size() const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type capacity() const _NOEXCEPT
{return __internal_cap_to_external(__cap());}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT
{return __size_;}
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return __size_ == 0;}
void reserve(size_type __n);
void shrink_to_fit() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT
{return __make_iter(0);}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT
{return __make_iter(0);}
_LIBCPP_INLINE_VISIBILITY
iterator end() _NOEXCEPT
{return __make_iter(__size_);}
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT
{return __make_iter(__size_);}
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const _NOEXCEPT
{return __make_iter(0);}
_LIBCPP_INLINE_VISIBILITY
const_iterator cend() const _NOEXCEPT
{return __make_iter(__size_);}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
_LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);}
_LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);}
reference at(size_type __n);
const_reference at(size_type __n) const;
_LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);}
_LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);}
_LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);}
_LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);}
void push_back(const value_type& __x);
#if _LIBCPP_STD_VER > 11
template <class... _Args>
#if _LIBCPP_STD_VER > 14
_LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args)
#else
_LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
#endif
{
push_back ( value_type ( _VSTD::forward<_Args>(__args)... ));
#if _LIBCPP_STD_VER > 14
return this->back();
#endif
}
#endif
_LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
#if _LIBCPP_STD_VER > 11
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args)
{ return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); }
#endif
iterator insert(const_iterator __position, const value_type& __x);
iterator insert(const_iterator __position, size_type __n, const value_type& __x);
iterator insert(const_iterator __position, size_type __n, const_reference __x);
template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value,
iterator
>::type
insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
iterator
>::type
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif
_LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
iterator erase(const_iterator __first, const_iterator __last);
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT {__size_ = 0;}
void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
void resize(size_type __sz, value_type __x = false);
void flip() _NOEXCEPT;
bool __invariants() const;
private:
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
void __vallocate(size_type __n);
void __vdeallocate() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static size_type __align_it(size_type __new_size) _NOEXCEPT
{return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);}
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
_LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
void __append(size_type __n, const_reference __x);
_LIBCPP_INLINE_VISIBILITY
reference __make_ref(size_type __pos) _NOEXCEPT
{return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
_LIBCPP_INLINE_VISIBILITY
const_reference __make_ref(size_type __pos) const _NOEXCEPT
{return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
_LIBCPP_INLINE_VISIBILITY
iterator __make_iter(size_type __pos) _NOEXCEPT
{return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
_LIBCPP_INLINE_VISIBILITY
const_iterator __make_iter(size_type __pos) const _NOEXCEPT
{return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
_LIBCPP_INLINE_VISIBILITY
iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
{return begin() + (__p - cbegin());}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector& __v)
{__copy_assign_alloc(__v, integral_constant<bool,
__storage_traits::propagate_on_container_copy_assignment::value>());}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector& __c, true_type)
{
if (__alloc() != __c.__alloc())
__vdeallocate();
__alloc() = __c.__alloc();
}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector&, false_type)
{}
void __move_assign(vector& __c, false_type);
void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector& __c)
_NOEXCEPT_(
!__storage_traits::propagate_on_container_move_assignment::value ||
is_nothrow_move_assignable<allocator_type>::value)
{__move_assign_alloc(__c, integral_constant<bool,
__storage_traits::propagate_on_container_move_assignment::value>());}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector&, false_type)
_NOEXCEPT
{}
size_t __hash_code() const _NOEXCEPT;
friend class __bit_reference<vector>;
friend class __bit_const_reference<vector>;
friend class __bit_iterator<vector, false>;
friend class __bit_iterator<vector, true>;
friend struct __bit_array<vector>;
friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;
};
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<bool, _Allocator>::__invalidate_all_iterators()
{
}
// Allocate space for __n objects
// throws length_error if __n > max_size()
// throws (probably bad_alloc) if memory run out
// Precondition: __begin_ == __end_ == __cap() == 0
// Precondition: __n > 0
// Postcondition: capacity() == __n
// Postcondition: size() == 0
template <class _Allocator>
void
vector<bool, _Allocator>::__vallocate(size_type __n)
{
if (__n > max_size())
this->__throw_length_error();
__n = __external_cap_to_internal(__n);
this->__begin_ = __storage_traits::allocate(this->__alloc(), __n);
this->__size_ = 0;
this->__cap() = __n;
}
template <class _Allocator>
void
vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
{
if (this->__begin_ != nullptr)
{
__storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
__invalidate_all_iterators();
this->__begin_ = nullptr;
this->__size_ = this->__cap() = 0;
}
}
template <class _Allocator>
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::max_size() const _NOEXCEPT
{
size_type __amax = __storage_traits::max_size(__alloc());
size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always
if (__nmax / __bits_per_word <= __amax)
return __nmax;
return __internal_cap_to_external(__amax);
}
// Precondition: __new_size > capacity()
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::__recommend(size_type __new_size) const
{
const size_type __ms = max_size();
if (__new_size > __ms)
this->__throw_length_error();
const size_type __cap = capacity();
if (__cap >= __ms / 2)
return __ms;
return _VSTD::max(2*__cap, __align_it(__new_size));
}
// Default constructs __n objects starting at __end_
// Precondition: __n > 0
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
{
size_type __old_size = this->__size_;
this->__size_ += __n;
_VSTD::fill_n(__make_iter(__old_size), __n, __x);
}
template <class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
size_type __old_size = this->__size_;
this->__size_ += _VSTD::distance(__first, __last);
_VSTD::copy(__first, __last, __make_iter(__old_size));
}
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
{
}
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
{
}
template <class _Allocator>
vector<bool, _Allocator>::vector(size_type __n)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
{
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, false);
}
}
#if _LIBCPP_STD_VER > 11
template <class _Allocator>
vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
{
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, false);
}
}
#endif
template <class _Allocator>
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
{
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, __x);
}
}
template <class _Allocator>
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
{
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__n, __x);
}
}
template <class _Allocator>
template <class _InputIterator>
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (; __first != __last; ++__first)
push_back(*__first);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
__invalidate_all_iterators();
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Allocator>
template <class _InputIterator>
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (; __first != __last; ++__first)
push_back(*__first);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
__invalidate_all_iterators();
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Allocator>
template <class _ForwardIterator>
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
{
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last);
}
}
template <class _Allocator>
template <class _ForwardIterator>
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
{
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__first, __last);
}
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Allocator>
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
{
size_type __n = static_cast<size_type>(__il.size());
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__il.begin(), __il.end());
}
}
template <class _Allocator>
vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
{
size_type __n = static_cast<size_type>(__il.size());
if (__n > 0)
{
__vallocate(__n);
__construct_at_end(__il.begin(), __il.end());
}
}
#endif // _LIBCPP_CXX03_LANG
template <class _Allocator>
vector<bool, _Allocator>::~vector()
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
__invalidate_all_iterators();
}
template <class _Allocator>
vector<bool, _Allocator>::vector(const vector& __v)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc()))
{
if (__v.size() > 0)
{
__vallocate(__v.size());
__construct_at_end(__v.begin(), __v.end());
}
}
template <class _Allocator>
vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, __a)
{
if (__v.size() > 0)
{
__vallocate(__v.size());
__construct_at_end(__v.begin(), __v.end());
}
}
template <class _Allocator>
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(const vector& __v)
{
if (this != &__v)
{
__copy_assign_alloc(__v);
if (__v.__size_)
{
if (__v.__size_ > capacity())
{
__vdeallocate();
__vallocate(__v.__size_);
}
_VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
}
__size_ = __v.__size_;
}
return *this;
}
#ifndef _LIBCPP_CXX03_LANG
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#endif
: __begin_(__v.__begin_),
__size_(__v.__size_),
__cap_alloc_(std::move(__v.__cap_alloc_)) {
__v.__begin_ = nullptr;
__v.__size_ = 0;
__v.__cap() = 0;
}
template <class _Allocator>
vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, __a)
{
if (__a == allocator_type(__v.__alloc()))
{
this->__begin_ = __v.__begin_;
this->__size_ = __v.__size_;
this->__cap() = __v.__cap();
__v.__begin_ = nullptr;
__v.__cap() = __v.__size_ = 0;
}
else if (__v.size() > 0)
{
__vallocate(__v.size());
__construct_at_end(__v.begin(), __v.end());
}
}
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
{
__move_assign(__v, integral_constant<bool,
__storage_traits::propagate_on_container_move_assignment::value>());
return *this;
}
template <class _Allocator>
void
vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
{
if (__alloc() != __c.__alloc())
assign(__c.begin(), __c.end());
else
__move_assign(__c, true_type());
}
template <class _Allocator>
void
vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__vdeallocate();
__move_assign_alloc(__c);
this->__begin_ = __c.__begin_;
this->__size_ = __c.__size_;
this->__cap() = __c.__cap();
__c.__begin_ = nullptr;
__c.__cap() = __c.__size_ = 0;
}
#endif // !_LIBCPP_CXX03_LANG
template <class _Allocator>
void
vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
{
__size_ = 0;
if (__n > 0)
{
size_type __c = capacity();
if (__n <= __c)
__size_ = __n;
else
{
vector __v(__alloc());
__v.reserve(__recommend(__n));
__v.__size_ = __n;
swap(__v);
}
_VSTD::fill_n(begin(), __n, __x);
}
__invalidate_all_iterators();
}
template <class _Allocator>
template <class _InputIterator>
typename enable_if
<
__is_input_iterator<_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value,
void
>::type
vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
{
clear();
for (; __first != __last; ++__first)
push_back(*__first);
}
template <class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
clear();
difference_type __ns = _VSTD::distance(__first, __last);
_LIBCPP_ASSERT(__ns >= 0, "invalid range specified");
const size_t __n = static_cast<size_type>(__ns);
if (__n)
{
if (__n > capacity())
{
__vdeallocate();
__vallocate(__n);
}
__construct_at_end(__first, __last);
}
}
template <class _Allocator>
void
vector<bool, _Allocator>::reserve(size_type __n)
{
if (__n > capacity())
{
vector __v(this->__alloc());
__v.__vallocate(__n);
__v.__construct_at_end(this->begin(), this->end());
swap(__v);
__invalidate_all_iterators();
}
}
template <class _Allocator>
void
vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
{
if (__external_cap_to_internal(size()) > __cap())
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
vector(*this, allocator_type(__alloc())).swap(*this);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
}
template <class _Allocator>
typename vector<bool, _Allocator>::reference
vector<bool, _Allocator>::at(size_type __n)
{
if (__n >= size())
this->__throw_out_of_range();
return (*this)[__n];
}
template <class _Allocator>
typename vector<bool, _Allocator>::const_reference
vector<bool, _Allocator>::at(size_type __n) const
{
if (__n >= size())
this->__throw_out_of_range();
return (*this)[__n];
}
template <class _Allocator>
void
vector<bool, _Allocator>::push_back(const value_type& __x)
{
if (this->__size_ == this->capacity())
reserve(__recommend(this->__size_ + 1));
++this->__size_;
back() = __x;
}
template <class _Allocator>
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
{
iterator __r;
if (size() < capacity())
{
const_iterator __old_end = end();
++__size_;
_VSTD::copy_backward(__position, __old_end, end());
__r = __const_iterator_cast(__position);
}
else
{
vector __v(__alloc());
__v.reserve(__recommend(__size_ + 1));
__v.__size_ = __size_ + 1;
__r = _VSTD::copy(cbegin(), __position, __v.begin());
_VSTD::copy_backward(__position, cend(), __v.end());
swap(__v);
}
*__r = __x;
return __r;
}
template <class _Allocator>
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
{
iterator __r;
size_type __c = capacity();
if (__n <= __c && size() <= __c - __n)
{
const_iterator __old_end = end();
__size_ += __n;
_VSTD::copy_backward(__position, __old_end, end());
__r = __const_iterator_cast(__position);
}
else
{
vector __v(__alloc());
__v.reserve(__recommend(__size_ + __n));
__v.__size_ = __size_ + __n;
__r = _VSTD::copy(cbegin(), __position, __v.begin());
_VSTD::copy_backward(__position, cend(), __v.end());
swap(__v);
}
_VSTD::fill_n(__r, __n, __x);
return __r;
}
template <class _Allocator>
template <class _InputIterator>
typename enable_if
<
__is_input_iterator <_InputIterator>::value &&
!__is_forward_iterator<_InputIterator>::value,
typename vector<bool, _Allocator>::iterator
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
{
difference_type __off = __position - begin();
iterator __p = __const_iterator_cast(__position);
iterator __old_end = end();
for (; size() != capacity() && __first != __last; ++__first)
{
++this->__size_;
back() = *__first;
}
vector __v(__alloc());
if (__first != __last)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
__v.assign(__first, __last);
difference_type __old_size = static_cast<difference_type>(__old_end - begin());
difference_type __old_p = __p - begin();
reserve(__recommend(size() + __v.size()));
__p = begin() + __old_p;
__old_end = begin() + __old_size;
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
erase(__old_end, end());
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
}
__p = _VSTD::rotate(__p, __old_end, end());
insert(__p, __v.begin(), __v.end());
return begin() + __off;
}
template <class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
typename vector<bool, _Allocator>::iterator
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
{
const difference_type __n_signed = _VSTD::distance(__first, __last);
_LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified");
const size_type __n = static_cast<size_type>(__n_signed);
iterator __r;
size_type __c = capacity();
if (__n <= __c && size() <= __c - __n)
{
const_iterator __old_end = end();
__size_ += __n;
_VSTD::copy_backward(__position, __old_end, end());
__r = __const_iterator_cast(__position);
}
else
{
vector __v(__alloc());
__v.reserve(__recommend(__size_ + __n));
__v.__size_ = __size_ + __n;
__r = _VSTD::copy(cbegin(), __position, __v.begin());
_VSTD::copy_backward(__position, cend(), __v.end());
swap(__v);
}
_VSTD::copy(__first, __last, __r);
return __r;
}
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::erase(const_iterator __position)
{
iterator __r = __const_iterator_cast(__position);
_VSTD::copy(__position + 1, this->cend(), __r);
--__size_;
return __r;
}
template <class _Allocator>
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
iterator __r = __const_iterator_cast(__first);
difference_type __d = __last - __first;
_VSTD::copy(__last, this->cend(), __r);
__size_ -= __d;
return __r;
}
template <class _Allocator>
void
vector<bool, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__size_, __x.__size_);
_VSTD::swap(this->__cap(), __x.__cap());
__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
}
template <class _Allocator>
void
vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
{
size_type __cs = size();
if (__cs < __sz)
{
iterator __r;
size_type __c = capacity();
size_type __n = __sz - __cs;
if (__n <= __c && __cs <= __c - __n)
{
__r = end();
__size_ += __n;
}
else
{
vector __v(__alloc());
__v.reserve(__recommend(__size_ + __n));
__v.__size_ = __size_ + __n;
__r = _VSTD::copy(cbegin(), cend(), __v.begin());
swap(__v);
}
_VSTD::fill_n(__r, __n, __x);
}
else
__size_ = __sz;
}
template <class _Allocator>
void
vector<bool, _Allocator>::flip() _NOEXCEPT
{
// do middle whole words
size_type __n = __size_;
__storage_pointer __p = __begin_;
for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
*__p = ~*__p;
// do last partial word
if (__n > 0)
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
__storage_type __b = *__p & __m;
*__p &= ~__m;
*__p |= ~__b & __m;
}
}
template <class _Allocator>
bool
vector<bool, _Allocator>::__invariants() const
{
if (this->__begin_ == nullptr)
{
if (this->__size_ != 0 || this->__cap() != 0)
return false;
}
else
{
if (this->__cap() == 0)
return false;
if (this->__size_ > this->capacity())
return false;
}
return true;
}
template <class _Allocator>
size_t
vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
{
size_t __h = 0;
// do middle whole words
size_type __n = __size_;
__storage_pointer __p = __begin_;
for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
__h ^= *__p;
// do last partial word
if (__n > 0)
{
const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
__h ^= *__p & __m;
}
return __h;
}
template <class _Allocator>
struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
: public unary_function<vector<bool, _Allocator>, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
{return __vec.__hash_code();}
};
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
return !(__x == __y);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
return __y < __x;
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
return !(__x < __y);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
{
return !(__y < __x);
}
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#endif // _LIBCPP_VECTOR
| [
"dr.revanthstrakz@gmail.com"
] | dr.revanthstrakz@gmail.com | |
e9658693b820fcb65bbfc5df8a3ced8390eb472e | 3f33fa904475034c9e3decfbaebc195bdaf4306d | /source/renderer/RenderShape.cpp | 7d8b7139cf7e8543c7cf57c8064869e3b9dc4544 | [] | no_license | jordan-reid/lightningengine | 739379c116cfb9bc22f682a5d06ffddd87704bfa | a29be0a99aebaace305a6c51477e1332c1d2ce9f | refs/heads/master | 2016-09-06T06:08:53.504146 | 2015-05-25T02:04:38 | 2015-05-25T02:04:38 | 35,685,800 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 104 | cpp | #include "RenderShape.h"
CRenderShape::CRenderShape(void)
{
}
CRenderShape::~CRenderShape(void)
{
}
| [
"jreid2712@gmail.com"
] | jreid2712@gmail.com |
ebb890294546a50ba28da6f06bac1ba49678a255 | 1e255e86d05f156cff52b892e50871f256aaae37 | /src/qt/paymentserver.h | 64ab4b3e894f0de8b113b38a0b19bd6c408e7bde | [
"MIT"
] | permissive | Mart1250/biblepay | 34aa220e1bde90f841d05886de0128dce3fe7629 | d53d04f74242596b104d360187268a50b845b82e | refs/heads/master | 2020-04-19T23:48:36.958722 | 2019-01-27T18:40:58 | 2019-01-27T18:40:58 | 168,506,069 | 0 | 0 | MIT | 2019-01-31T10:23:35 | 2019-01-31T10:23:35 | null | UTF-8 | C++ | false | false | 5,180 | h | // Copyright (c) 2011-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_PAYMENTSERVER_H
#define BITCOIN_QT_PAYMENTSERVER_H
// This class handles payment requests from clicking on
// biblepay: URIs
//
// This is somewhat tricky, because we have to deal with
// the situation where the user clicks on a link during
// startup/initialization, when the splash-screen is up
// but the main window (and the Send Coins tab) is not.
//
// So, the strategy is:
//
// Create the server, and register the event handler,
// when the application is created. Save any URIs
// received at or during startup in a list.
//
// When startup is finished and the main window is
// shown, a signal is sent to slot uiReady(), which
// emits a receivedURL() signal for any payment
// requests that happened during startup.
//
// After startup, receivedURL() happens as usual.
//
// This class has one more feature: a static
// method that finds URIs passed in the command line
// and, if a server is running in another process,
// sends them to the server.
//
#include "paymentrequestplus.h"
#include "walletmodel.h"
#include <QObject>
#include <QString>
class OptionsModel;
class CWallet;
QT_BEGIN_NAMESPACE
class QApplication;
class QByteArray;
class QLocalServer;
class QNetworkAccessManager;
class QNetworkReply;
class QSslError;
class QUrl;
QT_END_NAMESPACE
// BIP70 max payment request size in bytes (DoS protection)
extern const qint64 BIP70_MAX_PAYMENTREQUEST_SIZE;
class PaymentServer : public QObject
{
Q_OBJECT
public:
// Parse URIs on command line
// Returns false on error
static void ipcParseCommandLine(int argc, char *argv[]);
// Returns true if there were URIs on the command line
// which were successfully sent to an already-running
// process.
// Note: if a payment request is given, SelectParams(MAIN/TESTNET)
// will be called so we startup in the right mode.
static bool ipcSendCommandLine();
// parent should be QApplication object
PaymentServer(QObject* parent, bool startLocalServer = true);
~PaymentServer();
// Load root certificate authorities. Pass NULL (default)
// to read from the file specified in the -rootcertificates setting,
// or, if that's not set, to use the system default root certificates.
// If you pass in a store, you should not X509_STORE_free it: it will be
// freed either at exit or when another set of CAs are loaded.
static void LoadRootCAs(X509_STORE* store = NULL);
// Return certificate store
static X509_STORE* getCertStore() { return certStore; }
// OptionsModel is used for getting proxy settings and display unit
void setOptionsModel(OptionsModel *optionsModel);
// Verify that the payment request network matches the client network
static bool verifyNetwork(const payments::PaymentDetails& requestDetails);
// Verify if the payment request is expired
static bool verifyExpired(const payments::PaymentDetails& requestDetails);
// Verify the payment request size is valid as per BIP70
static bool verifySize(qint64 requestSize);
// Verify the payment request amount is valid
static bool verifyAmount(const CAmount& requestAmount);
Q_SIGNALS:
// Fired when a valid payment request is received
void receivedPaymentRequest(SendCoinsRecipient);
// Fired when a valid PaymentACK is received
void receivedPaymentACK(const QString &paymentACKMsg);
// Fired when a message should be reported to the user
void message(const QString &title, const QString &message, unsigned int style);
public Q_SLOTS:
// Signal this when the main window's UI is ready
// to display payment requests to the user
void uiReady();
// Submit Payment message to a merchant, get back PaymentACK:
void fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QByteArray transaction);
// Handle an incoming URI, URI with local file scheme or file
void handleURIOrFile(const QString& s);
private Q_SLOTS:
void handleURIConnection();
void netRequestFinished(QNetworkReply*);
void reportSslErrors(QNetworkReply*, const QList<QSslError> &);
void handlePaymentACK(const QString& paymentACKMsg);
protected:
// Constructor registers this on the parent QApplication to
// receive QEvent::FileOpen and QEvent:Drop events
bool eventFilter(QObject *object, QEvent *event);
private:
static bool readPaymentRequestFromFile(const QString& filename, PaymentRequestPlus& request);
bool processPaymentRequest(const PaymentRequestPlus& request, SendCoinsRecipient& recipient);
void fetchRequest(const QUrl& url);
// Setup networking
void initNetManager();
bool saveURIs; // true during startup
QLocalServer* uriServer;
static X509_STORE* certStore; // Trusted root certificates
static void freeCertStore();
QNetworkAccessManager* netManager; // Used to fetch payment requests
OptionsModel *optionsModel;
};
#endif // BITCOIN_QT_PAYMENTSERVER_H
| [
"contact@biblepay.us"
] | contact@biblepay.us |
b5a65a4006a30f32b3f873dd02dd7de5122204b4 | 8a7afe26f7733bcecf1bce34a081dd3d1b96787a | /libvpvl2/include/vpvl2/IBoneKeyframe.h | 25047b04520db5fde18bf795b1dbf027ff1042a4 | [
"BSD-3-Clause"
] | permissive | sun16/MMDAI | 707cb91cb293ef4b07f90e5e8e2ac5d249a39600 | e7f811cdfd361794790e15dd57756c9a758c2a91 | refs/heads/master | 2021-01-15T19:39:13.982345 | 2012-12-04T05:11:23 | 2012-12-04T05:11:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,194 | h | /* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2010-2012 hkrn */
/* */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* - Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* - Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials provided */
/* with the distribution. */
/* - Neither the name of the MMDAI project team 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 OWNER 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 VPVL2_IBONEKEYFRAME_H_
#define VPVL2_IBONEKEYFRAME_H_
#include "vpvl2/IKeyframe.h"
namespace vpvl2
{
/**
* ボーンのキーフレームをあらわすインターフェースです。
*
*/
class VPVL2_API IBoneKeyframe : public virtual IKeyframe
{
public:
struct InterpolationParameter
{
QuadWord x;
QuadWord y;
QuadWord z;
QuadWord rotation;
};
enum InterpolationType
{
kX = 0,
kY,
kZ,
kRotation,
kMaxInterpolationType
};
virtual ~IBoneKeyframe() {}
/**
* IBoneKeyframe のインスタンスの完全なコピーを返します.
*
* @return IBoneKeyframe
*/
virtual IBoneKeyframe *clone() const = 0;
/**
* 補間パラメータを初期状態に設定します.
*
* @sa setInterpolationParameter
* @sa getInterpolationParameter
*/
virtual void setDefaultInterpolationParameter() = 0;
/**
* 指定された型の補間パラメータを設定します.
*
* 第2引数は以下で解釈されます。第2引数の値はそれぞれ 0 以上かつ 128 未満でなければなりません。
*
* - x = x1
* - y = y1
* - z = x2
* - w = y2
*
* @param InterpolationType
* @param QuadWord
* @sa setDefaultInterpolationParameter
* @sa getInterpolationParameter
*/
virtual void setInterpolationParameter(InterpolationType type, const QuadWord &value) = 0;
/**
* 指定された型の補間パラメータを第二引数にコピーします.
*
* 第2引数にコピーされる値の設定順は setInterpolationParameter と同じです。
*
* @param InterpolationType
* @param QuadWord
* @sa setDefaultInterpolationParameter
* @sa setInterpolationParameter
*/
virtual void getInterpolationParameter(InterpolationType type, QuadWord &value) const = 0;
/**
* 移動量を返します.
*
* @return Vector3
* @sa setLocalPosition
*/
virtual const Vector3 &localPosition() const = 0;
/**
* 回転量を返します.
*
* @return Quaternion
* @sa setLocalRotation
*/
virtual const Quaternion &localRotation() const = 0;
/**
* 移動量を設定します.
*
* @param Vector3
* @sa localPosition
*/
virtual void setLocalPosition(const Vector3 &value) = 0;
/**
* 回転量を設定します.
*
* @param Quaternion
* @sa localRotation
*/
virtual void setLocalRotation(const Quaternion &value) = 0;
};
} /* namespace vpvl2 */
#endif
| [
"hikarin.jp@gmail.com"
] | hikarin.jp@gmail.com |
49be1040acef4524b0102ea2eab9639edfecc2e5 | 15bd7227959f8fd37d4293f44a3d99d5b5172510 | /LeetCode/1026/Solution.cpp | ec6ba5b11d3f83d059ae2a91009a0a24d6b0d0a9 | [] | no_license | dskym/Algorithm | a9d589ec47a472a157fb4843010c77a09315e262 | 6b215fdf88ba02370b75c8565867cdc401c40fa1 | refs/heads/master | 2023-05-10T22:04:44.567097 | 2023-05-09T13:12:41 | 2023-05-09T13:12:41 | 148,602,397 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 823 | cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int solve(TreeNode* root, int maxValue, int minValue) {
if(root == NULL)
return 0;
int result = 0;
result = max(result, abs(minValue - root->val));
result = max(result, abs(maxValue - root->val));
result = max(result, solve(root->left, max(maxValue, root->val), min(minValue, root->val)));
result = max(result, solve(root->right, max(maxValue, root->val), min(minValue, root->val)));
return result;
}
int maxAncestorDiff(TreeNode* root) {
return solve(root, root->val, root->val);
}
};
| [
"dskym@naver.com"
] | dskym@naver.com |
e7b51e73ccb5aad93b39d54b795f0d0e16d6d63c | 13c756aabf546fb46bb6a9dbbdb3ea5d0d8b5356 | /ACM/图论/生成树/hdu4081.cpp | 18fadc62407c1a24e5761071926569cc4bf43097 | [] | no_license | JosephZ7/ACM | def2fa0030989464bbaebeab400d88815df1c410 | 63c9d696dad4d010468750e783a151e68a0395ae | refs/heads/master | 2021-01-19T18:41:53.788146 | 2018-07-23T08:12:04 | 2018-07-23T08:12:04 | 101,154,332 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,454 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string.h>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <iostream>
#define PI 3.1415926535898
#define LL long long
#define MAX 0x3fffffff
#define INF 0x3f3f3f3f
#define mem(a,v) memset(a,v,sizeof(a))
const int MAX_N = 1e5+10;
const double eps = 1e-7;
const int mod = 10007;
const LL inf = 1LL<<60;
using namespace std;
struct Point
{
double x,y,p;
}a[MAX_N];
double cost[1005][1005];
double getdist(Point e1,Point e2)
{
return sqrt((e1.x-e2.x)*(e1.x-e2.x)+(e1.y-e2.y)*(e1.y-e2.y));
}
int n;
double d[1005];
bool vis[1005];
bool used[1005][1005];
double Ma[1005][1005];
int pre[1005];
double prim()
{
memset(vis,false,sizeof(vis));
memset(used,false,sizeof(used));
memset(Ma,0,sizeof(Ma));
for(int i = 1;i <= n;i++)
{
d[i] = cost[1][i];
pre[i] = 1;
}
vis[1] = true;
double sum = 0;
for(int i = 1;i < n;i++)
{
double Mi = INF;
int p = -1;
for(int j = 1;j <= n;j++)
{
if(!vis[j]&&d[j] < Mi)
{
Mi = d[j];
p = j;
}
}
if(Mi == INF) return 0;
sum+=Mi;
vis[p] = true;
used[p][pre[p]] = used[pre[p]][p] = true;
for(int j = 1;j <= n;j++)
{
if(vis[j]&&j!=p)
Ma[p][j] = Ma[j][p] = max(Ma[j][pre[p]],d[p]);
if(!vis[j]&&d[j] > cost[p][j])
{
d[j] = cost[p][j];
pre[j] = p;
}
}
}
return sum;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
memset(cost,0,sizeof(cost));
for(int i = 1;i <= n;i++)
{
scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].p);
}
for(int i = 1;i <= n;i++)
{
for(int j = i+1;j <= n;j++)
{
cost[j][i] = cost[i][j] = getdist(a[i],a[j]);
}
}
double ans = prim();
double Mans = -1;
for(int i = 1;i <= n;i++)
{
for(int j = i+1;j <= n;j++)
{
if(used[i][j])
Mans = max(Mans,(a[i].p+a[j].p)/(ans-cost[i][j]));
else
Mans = max(Mans,(a[i].p+a[j].p)/(ans-Ma[i][j]));
}
}
printf("%.2f\n",Mans);
}
return 0;
}
| [
"1072920311@qq.com"
] | 1072920311@qq.com |
9c10bfcccd94eefb614cf2454b4aeaa26ef86a16 | 3c3a77937d43706dfa4cc14ee82c83378968a57c | /Visual Studio 2013/Projects/Data Structures/Data Structures/polynomial.cpp | 44b222952b8cadddd88bae3cc2e718afc1801c20 | [] | no_license | KimBoWoon/HomeWork | 221225411e08e184805af2f1742334639bb0db89 | c5d9fc2e9b14812b85afbf8319395518f7ca0b0a | refs/heads/master | 2021-07-21T10:24:30.769743 | 2016-10-04T06:58:05 | 2016-10-04T06:58:05 | 41,595,238 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 592 | cpp | #include <iostream>
using namespace std;
void merge(int *X, int *Y, int *Z, int m, int n)
{
int i = 0, j = 0, k = 0;
while ((i < m) && (j < n)) {
if (X[i] == Y[j]) {
Z[k++] = X[i++];
Z[k++] = Y[j++];
}
else if (X[i] > Y[j]) {
Z[k++] = Y[j++];
}
else {
Z[k++] = X[i++];
}
}
for (; i < m; i++, k++)
Z[k] = X[i];
for (; j < n; j++, k++)
Z[k] = Y[j];
}
int main()
{
int a[10] = { 1, 2, 4, 5, 7, 8, 9, 10, 12, 14 };
int b[5] = { 2, 3, 4, 5, 6 };
int c[15] = { 0 };
merge(a, b, c, 10, 5);
for (int i = 0; i < 15; i++)
cout << c[i] << " ";
cout << endl;
} | [
"haioer@naver.com"
] | haioer@naver.com |
b469c2b13b87026541c0d25d1639936645f06bd7 | 179c0ea4275387bb530d224f50c806cd60ca3f32 | /src/server/scripts/World/npc_innkeeper.cpp | 50b6c3fbe9cf1ef495c943fc5bd18cde3b710d61 | [] | no_license | freadblangks/Hellhunter15595 | 40a707ca61d7163d21051a29ca0db7bcb9c9845d | e39720d0eaa49a730a77c6e339dfb6ead735ca3f | refs/heads/master | 2021-06-09T11:24:57.485838 | 2016-12-17T07:43:35 | 2016-12-17T07:43:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,044 | cpp | /*
Hellhunter
*/
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "GameEventMgr.h"
#include "Player.h"
#include "WorldSession.h"
#define HALLOWEEN_EVENTID 12
#define SPELL_TRICK_OR_TREATED 24755
#define SPELL_TREAT 24715
#define LOCALE_TRICK_OR_TREAT_0 "Trick or Treat!"
#define LOCALE_TRICK_OR_TREAT_2 "Des bonbons ou des blagues!"
#define LOCALE_TRICK_OR_TREAT_3 "Süßes oder Saures!"
#define LOCALE_TRICK_OR_TREAT_6 "¡Truco o trato!"
#define LOCALE_TRICK_OR_TREAT_8 "Конфета или Жизнь!"
#define LOCALE_INNKEEPER_0 "Make this inn my home."
#define LOCALE_INNKEEPER_3 "Ich möchte dieses Gasthaus zu meinem Heimatort machen."
#define LOCALE_INNKEEPER_8 "Я хочу остановиться в этой таверне."
class npc_innkeeper : public CreatureScript
{
public:
npc_innkeeper() : CreatureScript("npc_innkeeper") { }
bool OnGossipHello(Player* player, Creature* creature)
{
if (IsEventActive(HALLOWEEN_EVENTID) && !player->HasAura(SPELL_TRICK_OR_TREATED))
{
const char* localizedEntry;
switch (player->GetSession()->GetSessionDbcLocale())
{
case LOCALE_frFR: localizedEntry = LOCALE_TRICK_OR_TREAT_2; break;
case LOCALE_deDE: localizedEntry = LOCALE_TRICK_OR_TREAT_3; break;
case LOCALE_esES: localizedEntry = LOCALE_TRICK_OR_TREAT_6; break;
case LOCALE_ruRU: localizedEntry = LOCALE_TRICK_OR_TREAT_8; break;
case LOCALE_enUS: default: localizedEntry = LOCALE_TRICK_OR_TREAT_0;
}
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID);
}
if (creature->IsQuestGiver())
player->PrepareQuestMenu(creature->GetGUID());
if (creature->IsVendor())
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
if (creature->IsInnkeeper())
{
const char* localizedEntry;
switch (player->GetSession()->GetSessionDbcLocale())
{
case LOCALE_deDE: localizedEntry = LOCALE_INNKEEPER_3; break;
case LOCALE_ruRU: localizedEntry = LOCALE_INNKEEPER_8; break;
case LOCALE_enUS: default: localizedEntry = LOCALE_INNKEEPER_0;
}
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INN);
}
player->TalkedToCreature(creature->GetEntry(), creature->GetGUID());
player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
if (action == GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID && IsEventActive(HALLOWEEN_EVENTID) && !player->HasAura(SPELL_TRICK_OR_TREATED))
{
player->CastSpell(player, SPELL_TRICK_OR_TREATED, true);
if (urand(0, 1))
player->CastSpell(player, SPELL_TREAT, true);
else
{
uint32 trickspell = 0;
switch (urand(0, 13))
{
// Hellhunter на Эвент Хэлуин костюмы от хояев таверны
case 0: trickspell = 24753; break; // cannot cast, random 30sec
case 1: trickspell = 24713; break; // lepper gnome costume
case 2: trickspell = 24735; break; // male ghost costume
case 3: trickspell = 24736; break; // female ghostcostume
case 4: trickspell = 24710; break; // male ninja costume
case 5: trickspell = 24711; break; // female ninja costume
case 6: trickspell = 24708; break; // male pirate costume
case 7: trickspell = 24709; break; // female pirate costume
case 8: trickspell = 24723; break; // skeleton costume
case 9: trickspell = 24753; break; // Trick
case 10: trickspell = 24924; break; // Hallow's End Candy
case 11: trickspell = 24925; break; // Hallow's End Candy
case 12: trickspell = 24926; break; // Hallow's End Candy
case 13: trickspell = 24927; break; // Hallow's End Candy
}
player->CastSpell(player, trickspell, true);
}
player->CLOSE_GOSSIP_MENU();
return true;
}
player->CLOSE_GOSSIP_MENU();
switch (action)
{
case GOSSIP_ACTION_TRADE: player->GetSession()->SendListInventory(creature->GetGUID()); break;
case GOSSIP_ACTION_INN: player->SetBindPoint(creature->GetGUID()); break;
}
return true;
}
};
void AddSC_npc_innkeeper()
{
new npc_innkeeper;
}
| [
"game.techbang01@gmail.com"
] | game.techbang01@gmail.com |
00cffb37793ddfcdb3d6334ff87a1a943c3e2ffa | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /content/browser/devtools/forwarding_agent_host.cc | 1682f1cc880a1d96c1a3bf65711199aedc3996ff | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 3,176 | cc | // Copyright 2014 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 "content/browser/devtools/forwarding_agent_host.h"
#include "base/bind.h"
#include "content/browser/devtools/devtools_session.h"
#include "content/browser/devtools/protocol/inspector_handler.h"
#include "content/public/browser/devtools_external_agent_proxy.h"
#include "content/public/browser/devtools_external_agent_proxy_delegate.h"
namespace content {
class ForwardingAgentHost::SessionProxy : public DevToolsExternalAgentProxy {
public:
SessionProxy(ForwardingAgentHost* agent_host, DevToolsAgentHostClient* client)
: agent_host_(agent_host), client_(client) {
agent_host_->delegate_->Attach(this);
}
~SessionProxy() override { agent_host_->delegate_->Detach(this); }
void ConnectionClosed() override {
DevToolsAgentHostClient* client = client_;
ForwardingAgentHost* agent_host = agent_host_;
agent_host_->session_proxies_.erase(client_);
// |this| is delete here, do not use any fields below.
client->AgentHostClosed(agent_host);
}
private:
void DispatchOnClientHost(const std::string& message) override {
client_->DispatchProtocolMessage(agent_host_, message);
}
ForwardingAgentHost* agent_host_;
DevToolsAgentHostClient* client_;
DISALLOW_COPY_AND_ASSIGN(SessionProxy);
};
ForwardingAgentHost::ForwardingAgentHost(
const std::string& id,
std::unique_ptr<DevToolsExternalAgentProxyDelegate> delegate)
: DevToolsAgentHostImpl(id),
delegate_(std::move(delegate)) {
NotifyCreated();
}
ForwardingAgentHost::~ForwardingAgentHost() {
}
void ForwardingAgentHost::AttachClient(DevToolsAgentHostClient* client) {
session_proxies_[client].reset(new SessionProxy(this, client));
}
bool ForwardingAgentHost::DetachClient(DevToolsAgentHostClient* client) {
auto it = session_proxies_.find(client);
if (it == session_proxies_.end())
return false;
session_proxies_.erase(it);
return true;
}
bool ForwardingAgentHost::DispatchProtocolMessage(
DevToolsAgentHostClient* client,
const std::string& message) {
auto it = session_proxies_.find(client);
if (it == session_proxies_.end())
return false;
delegate_->SendMessageToBackend(it->second.get(), message);
return true;
}
bool ForwardingAgentHost::IsAttached() {
return !session_proxies_.empty();
}
std::string ForwardingAgentHost::GetType() {
return delegate_->GetType();
}
std::string ForwardingAgentHost::GetTitle() {
return delegate_->GetTitle();
}
GURL ForwardingAgentHost::GetURL() {
return delegate_->GetURL();
}
GURL ForwardingAgentHost::GetFaviconURL() {
return delegate_->GetFaviconURL();
}
std::string ForwardingAgentHost::GetFrontendURL() {
return delegate_->GetFrontendURL();
}
bool ForwardingAgentHost::Activate() {
return delegate_->Activate();
}
void ForwardingAgentHost::Reload() {
delegate_->Reload();
}
bool ForwardingAgentHost::Close() {
return delegate_->Close();
}
base::TimeTicks ForwardingAgentHost::GetLastActivityTime() {
return delegate_->GetLastActivityTime();
}
} // content
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
ec924f5ba6e4b60940e3129841cf16b8c436b70c | 0af33c10d3c6cb817f5067743f06c71ad99bca0b | /done/dmopc15c5p5.cpp | 0a406a4299aa0accd4fc69616541cfcce96d768b | [] | no_license | nathanlo99/dmoj_archive | 6d4f84b58d963109c73a52281a4aa06dd79bc1da | b137f8fa5894542a39e168c1f6485d622a119f42 | refs/heads/master | 2020-04-15T12:47:18.181614 | 2019-07-21T03:03:21 | 2019-07-21T03:03:21 | 62,849,549 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 905 | cpp | #include <cstdio>
#include <vector>
#define MOD (1000000007)
long long bit[200005];
int ans[200005], order[200005], n, a, rt;
std::vector<int> adj[200005];
long long query(int i) {
long long ans = 0LL;
for (int j = i; j > 0; j -= j & -j) ans += bit[j];
return ans;
}
void update(int i, long long v) {
for (int j = i; j <= 200001; j += j & -j) bit[j] += v;
}
static void dfs(int node) {
long long old_ans = query(order[node]);
for (int child: adj[node]) dfs(child);
long long new_ans = query(order[node]);
ans[node] = (new_ans - old_ans + 1) % MOD;
update(order[node], ans[node]);
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a), adj[a].push_back(i);
for (int i = 1; i <= n; i++) scanf("%d", &a), order[a] = i;
dfs(adj[0][0]);
for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
} | [
"nathanlo99@hotmail.ca"
] | nathanlo99@hotmail.ca |
97afa2a6ae284c2353efa52c8b6f7991ed9f089c | 6a42841765f2356da99d9844cab8f3f3353eaebf | /WHAndroidClient/客户端组件/游戏框架/UserInfoDlg.h | 376eef1ae8744d9c69e0bd8a1a0680bf9f5e45ac | [] | no_license | Ivanhan2018/wh6602_zhuque | d904e1d7136ed7db6cd9b46d65ab33797f400a74 | b0e7e574786eac927d109967618ba2a3af5bbee3 | refs/heads/master | 2020-04-05T17:28:14.739789 | 2018-12-24T07:36:47 | 2018-12-24T07:36:47 | 157,062,380 | 2 | 8 | null | null | null | null | GB18030 | C++ | false | false | 2,737 | h | #pragma once
#include "Resource.h"
#include "GameAffiche.h"
#include "ShowDJInfo.h"
#include "UserDaoJu.h"
#include "LanguageList.h"
#include <string>
#include "ImageNums.h"
class CGameFrameDlg;
class CGameFrameControl;
using namespace std;
// CUserInfoDlg 对话框
class CUserInfoDlg : public CDialog
{
DECLARE_DYNAMIC(CUserInfoDlg)
public:
CUserInfoDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~CUserInfoDlg();
// 对话框数据
enum { IDD = IDD_USERINFODLG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
private:
CPngImage m_ImageBack; //背景
CPngImage m_InfoBack; //信息背景
CPngImage m_GoldBack; //金币背景
CPngImage m_GemsBack; //宝石背景
CPngImage m_NumImage; //数字图片
CPngImage m_ClassNumImage; //等级数字
//CPngImage m_GameInfoBack; //游戏公告背景
CSkinButton m_btSound; //声音
CSkinButton m_btBB; //背包
private:
CImageNums m_ClassNum; //等级
CImageNums m_GoldNum; //金币
CImageNums m_GemsNum; //宝石
CToolTipCtrl m_ToolTipCtrl; //提示控件
CPoint m_ptWnd; //窗口坐标
private:
//用户数据
tagUserData* m_pUserData; //用户数据
//走马灯子窗口
CGameAffiche m_Affiche; //
//游戏用户道具
CUserDaoJu * m_pGameUserDaoJu;
//框架指针
CGameFrameDlg * m_pGameFrameDlg;
//语音列表
CLanguageList * m_pLanguageListPtr;
private:
std::string m_strGradeName;
public:
CGameFrameControl * m_pGameFrameControl; //控制视图
public:
afx_msg void OnPaint();
virtual BOOL OnInitDialog();
public:
//BOOL SetImageRgn(CPngImage * pImage);
//设置用户信息
void SetUserData(tagUserData* pUserData);
//设置道具信息
void SetShowDJInfo(CShowDJInfo* pShowDJInfoPtr);
//设置语音列表
void SetLLInfoPtr(CLanguageList* pLLPtr);
//获得道具列表信息
CUserDaoJu* GetUserDaoJuListPtr();
//设置框架指针
void SetGameFrameDlgPtr(CGameFrameDlg* pFrameDlg);
virtual BOOL PreTranslateMessage(MSG* pMsg);
//激活按钮
void EnableBTWindow();
//更新用户数据
void UpdateUserData(CMD_GF_NEW_GIFT* pNewData);
//艺术字体
void DrawTextString(CDC * pDC, LPCTSTR pszString, COLORREF crText, COLORREF crFrame, int nXPos, int nYPos);
public:
//语音
afx_msg void OnLanguageList();
//背包
afx_msg void OnOpenBB();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
int cx, int cy, UINT nFlags);
// 绘画背景 -处理非矩形边框
void DrawBackground(CDC *pDC, int nWidth, int nHeight, int iExcursionY=0);
};
| [
"hanshouqing85@163.com"
] | hanshouqing85@163.com |
52ea70f93fdb6754ec9251d4d63ca9934afe91cd | 7d276a2575c9d7097c3d007b88b593f7c1e4a300 | /src/qt/signverifymessagedialog.cpp | 930ce7063c3a32d59f3e3c5d3124d1895dd7f88a | [
"MIT"
] | permissive | supervortex/vortex | ebc9b32bcbc5ceb14c513dbb17b56581949f9224 | 03bd27e2ba140ac9d5e5d8fb296152c7afc32713 | refs/heads/master | 2020-03-25T18:38:14.427641 | 2018-08-14T12:05:12 | 2018-08-14T12:05:12 | 144,041,492 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,725 | cpp | #include "signverifymessagedialog.h"
#include "ui_signverifymessagedialog.h"
#include "addressbookpage.h"
#include "base58.h"
#include "guiutil.h"
#include "init.h"
#include "main.h"
#include "optionsmodel.h"
#include "walletmodel.h"
#include "wallet.h"
#include <QClipboard>
#include <string>
#include <vector>
SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SignVerifyMessageDialog),
model(0)
{
ui->setupUi(this);
#if (QT_VERSION >= 0x040700)
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
ui->addressIn_SM->setPlaceholderText(tr("Enter Vortex address"));
ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signature"));
ui->addressIn_VM->setPlaceholderText(tr("Enter Vortex address"));
ui->signatureIn_VM->setPlaceholderText(tr("Enter Vortex signature"));
#endif
GUIUtil::setupAddressWidget(ui->addressIn_SM, this);
GUIUtil::setupAddressWidget(ui->addressIn_VM, this);
ui->addressIn_SM->installEventFilter(this);
ui->messageIn_SM->installEventFilter(this);
ui->signatureOut_SM->installEventFilter(this);
ui->addressIn_VM->installEventFilter(this);
ui->messageIn_VM->installEventFilter(this);
ui->signatureIn_VM->installEventFilter(this);
ui->signatureOut_SM->setFont(GUIUtil::bitcoinAddressFont());
ui->signatureIn_VM->setFont(GUIUtil::bitcoinAddressFont());
}
SignVerifyMessageDialog::~SignVerifyMessageDialog()
{
delete ui;
}
void SignVerifyMessageDialog::setModel(WalletModel *model)
{
this->model = model;
}
void SignVerifyMessageDialog::setAddress_SM(QString address)
{
ui->addressIn_SM->setText(address);
ui->messageIn_SM->setFocus();
}
void SignVerifyMessageDialog::setAddress_VM(QString address)
{
ui->addressIn_VM->setText(address);
ui->messageIn_VM->setFocus();
}
void SignVerifyMessageDialog::showTab_SM(bool fShow)
{
ui->tabWidget->setCurrentIndex(0);
if (fShow)
this->show();
}
void SignVerifyMessageDialog::showTab_VM(bool fShow)
{
ui->tabWidget->setCurrentIndex(1);
if (fShow)
this->show();
}
void SignVerifyMessageDialog::on_addressBookButton_SM_clicked()
{
if (model && model->getAddressTableModel())
{
AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this);
dlg.setModel(model->getAddressTableModel());
if (dlg.exec())
{
setAddress_SM(dlg.getReturnValue());
}
}
}
void SignVerifyMessageDialog::on_pasteButton_SM_clicked()
{
setAddress_SM(QApplication::clipboard()->text());
}
void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
{
if (!model)
return;
/* Clear old signature to ensure users don't get confused on error with an old signature displayed */
ui->signatureOut_SM->clear();
CVortexcoinAddress addr(ui->addressIn_SM->text().toStdString());
if (!addr.IsValid())
{
ui->addressIn_SM->setValid(false);
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again."));
return;
}
CKeyID keyID;
if (!addr.GetKeyID(keyID))
{
ui->addressIn_SM->setValid(false);
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again."));
return;
}
WalletModel::UnlockContext ctx(model->requestUnlock());
if (!ctx.isValid())
{
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(tr("Wallet unlock was cancelled."));
return;
}
CKey key;
if (!pwalletMain->GetKey(keyID, key))
{
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(tr("Private key for the entered address is not available."));
return;
}
CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << ui->messageIn_SM->document()->toPlainText().toStdString();
std::vector<unsigned char> vchSig;
if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig))
{
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signing failed.") + QString("</nobr>"));
return;
}
ui->statusLabel_SM->setStyleSheet("QLabel { color: green; }");
ui->statusLabel_SM->setText(QString("<nobr>") + tr("Message signed.") + QString("</nobr>"));
ui->signatureOut_SM->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size())));
}
void SignVerifyMessageDialog::on_copySignatureButton_SM_clicked()
{
QApplication::clipboard()->setText(ui->signatureOut_SM->text());
}
void SignVerifyMessageDialog::on_clearButton_SM_clicked()
{
ui->addressIn_SM->clear();
ui->messageIn_SM->clear();
ui->signatureOut_SM->clear();
ui->statusLabel_SM->clear();
ui->addressIn_SM->setFocus();
}
void SignVerifyMessageDialog::on_addressBookButton_VM_clicked()
{
if (model && model->getAddressTableModel())
{
AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this);
dlg.setModel(model->getAddressTableModel());
if (dlg.exec())
{
setAddress_VM(dlg.getReturnValue());
}
}
}
void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked()
{
CVortexcoinAddress addr(ui->addressIn_VM->text().toStdString());
if (!addr.IsValid())
{
ui->addressIn_VM->setValid(false);
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_VM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again."));
return;
}
CKeyID keyID;
if (!addr.GetKeyID(keyID))
{
ui->addressIn_VM->setValid(false);
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_VM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again."));
return;
}
bool fInvalid = false;
std::vector<unsigned char> vchSig = DecodeBase64(ui->signatureIn_VM->text().toStdString().c_str(), &fInvalid);
if (fInvalid)
{
ui->signatureIn_VM->setValid(false);
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_VM->setText(tr("The signature could not be decoded.") + QString(" ") + tr("Please check the signature and try again."));
return;
}
CDataStream ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << ui->messageIn_VM->document()->toPlainText().toStdString();
CPubKey pubkey;
if (!pubkey.RecoverCompact(Hash(ss.begin(), ss.end()), vchSig))
{
ui->signatureIn_VM->setValid(false);
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_VM->setText(tr("The signature did not match the message digest.") + QString(" ") + tr("Please check the signature and try again."));
return;
}
if (!(CVortexcoinAddress(pubkey.GetID()) == addr))
{
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_VM->setText(QString("<nobr>") + tr("Message verification failed.") + QString("</nobr>"));
return;
}
ui->statusLabel_VM->setStyleSheet("QLabel { color: green; }");
ui->statusLabel_VM->setText(QString("<nobr>") + tr("Message verified.") + QString("</nobr>"));
}
void SignVerifyMessageDialog::on_clearButton_VM_clicked()
{
ui->addressIn_VM->clear();
ui->signatureIn_VM->clear();
ui->messageIn_VM->clear();
ui->statusLabel_VM->clear();
ui->addressIn_VM->setFocus();
}
bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::FocusIn)
{
if (ui->tabWidget->currentIndex() == 0)
{
/* Clear status message on focus change */
ui->statusLabel_SM->clear();
/* Select generated signature */
if (object == ui->signatureOut_SM)
{
ui->signatureOut_SM->selectAll();
return true;
}
}
else if (ui->tabWidget->currentIndex() == 1)
{
/* Clear status message on focus change */
ui->statusLabel_VM->clear();
}
}
return QDialog::eventFilter(object, event);
}
| [
"you@example.com"
] | you@example.com |
197ef1ffa031ca79de0dc39033e1f124580de6b3 | 43083741d5eb9bc75e5bcafe5696bbfc0d79ef92 | /CR673/A.cpp | f3de090938830c1aa5365b85245ae69497e50920 | [] | no_license | shubhamamsa/Code-Forces | bf6bdb57ef801bfe48aa218e60dd2beaa0997aa7 | e45dbf4c70ae10abfd6960cffccd2d4242b695ac | refs/heads/master | 2021-12-23T22:25:07.588221 | 2021-09-28T14:14:44 | 2021-09-28T14:14:44 | 187,487,958 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 417 | cpp | #include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
void subMain() {
int n, k;
cin >> n >> k;
int a[n];
for(int i=0;i<n;i++)
cin >> a[i];
sort(a, a+n);
int count = 0;
for(int i=1;i<n;i++)
count+=max(0, ((k-a[i])/a[0]));
cout << count;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin >> t;
while(t--) {
subMain();
cout << "\n";
}
return 0;
} | [
"shubhamyadav2002@gmail.com"
] | shubhamyadav2002@gmail.com |
36aaf186823f1ccacf17211a0677396a9995a93c | 34b3623dbd185b9d8e6bc5af787ff656ebb8f837 | /finalProject/results/test/test_movingboundary/wedge05/35/p | a21a8ed4b262c3c5baa1836e2ea7bd4a2cbc8589 | [] | no_license | kenneth-meyer/COE347 | 6426252133cdb94582b49337d44bdc5759d96cda | a4f1e5f3322031690a180d0815cc8272b6f89726 | refs/heads/master | 2023-04-25T04:03:37.617189 | 2021-05-16T02:40:23 | 2021-05-16T02:40:23 | 339,565,109 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 82,357 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "35";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
7807
(
0.216205
-0.0235348
0.328764
0.202255
-0.000665087
-4.47056e-06
0.32375
-0.00352197
-7.69247e-05
0.076322
-4.27992e-06
0.00115995
-0.00538401
0.034072
0.0799426
-0.0126333
0.228144
-0.00727113
-0.00184364
-0.0834749
0.046077
0.000682919
0.0235386
0.156605
-0.0095029
0.224787
-0.000622727
0.0436438
0.129949
-0.000984106
-0.0150737
0.450063
0.0229064
-0.000280049
-1.86321e-05
0.0609577
-0.000876411
0.313505
-0.00524738
-0.000112517
-0.00511795
-0.0118097
-0.0965921
-0.0853815
-4.75979e-05
-1.39219e-05
0.00066051
-0.0052854
-1.62983e-05
-0.0835464
0.00198608
0.0410441
-0.0119426
-0.0145204
0.060153
-0.00345583
-0.00167694
-0.00335663
-0.0219967
-0.000269373
7.63896e-09
0.00271938
0.0344183
0.00133575
-0.000385212
-0.0152938
-6.60488e-05
-8.92542e-07
0.0463772
-0.00499137
-1.25484e-05
-0.0548443
-0.00924498
-0.0158456
-0.00708345
-0.0314483
0.324909
0.0451479
0.0279645
-0.0497753
-0.0052206
0.276489
0.0711127
-0.0183843
-0.00141613
-0.0011811
-0.0040018
-0.0116902
-0.00059405
-0.00241159
0.132985
-0.0972497
-3.81365e-05
-0.00110125
-0.00217699
-0.0143226
-0.0521725
-0.0121244
-0.0014697
-0.000497497
-0.0289404
0.0355123
-0.00209278
-9.96991e-07
-0.0875853
0.136598
0.379803
-0.00360645
3.7462e-08
0.0178062
0.189322
-0.0684495
-4.19726e-07
0.0191705
0.136915
8.94357e-05
-0.0934996
0.106985
-0.0400761
-0.0172317
-0.0275011
0.26287
-0.0920179
0.00611631
-0.0266183
-0.000817338
-0.0130147
-0.000786739
-0.000408999
-0.0151686
-0.15296
0.0294168
-0.00038003
-0.000662207
-0.0188652
0.182335
0.31851
-6.32249e-07
0.0053525
-0.0378585
-0.0145206
-0.0545597
-0.03304
-0.0152302
0.378803
-0.032029
0.130727
-0.0237447
-0.0186143
0.262527
0.0578223
-0.0850047
-0.00135553
0.0258418
0.0708538
0.29163
-0.0376596
-0.00510991
0.389639
-1.40772e-05
-0.00172783
0.162435
-5.51855e-06
-0.00267527
-0.00242828
0.203953
0.204483
0.406446
-0.00277089
-0.00172919
-9.33189e-07
-0.0229554
8.94781e-05
-0.0170786
0.00593259
-0.0184921
-0.064829
0.108116
-4.42233e-05
-0.000363342
0.207319
-9.92963e-06
-1.97419e-05
0.328254
-0.0287697
-0.0541548
-0.0382838
-0.0160783
-0.0344695
-0.0388657
-5.22545e-06
-0.0499131
0.113757
-0.00222599
5.42192e-06
0.153329
-0.000649606
-0.0143026
-0.0317374
-4.73755e-07
0.000124074
0.187361
0.142764
0.289532
-0.0869545
-0.0640411
-0.153235
0.0481735
0.18457
-5.22676e-05
-2.32801e-08
0.355074
-0.0107453
-0.000369721
-0.0482554
-0.0136929
0.264701
0.269544
-0.0592138
0.437733
-0.000608025
-0.00692068
-0.0292445
0.0585813
-0.120408
0.18581
0.384806
-5.54069e-06
0.00673007
0.114996
-0.00446484
0.104279
-0.000569776
0.439458
0.28399
-0.00378974
-7.09829e-05
-0.000103205
0.104238
-1.48138e-05
-0.00810272
-0.0410634
-1.67834e-05
-0.00151492
-0.000497081
0.119627
-7.18271e-06
-0.00249119
-0.0491473
0.445576
0.0218643
0.411509
-5.01037e-06
-0.0335583
-0.000135396
0.305709
0.00255913
0.319478
-0.00176093
-1.41101e-06
-0.0122799
0.0507968
0.000194232
-7.09668e-05
0.000146383
-0.00475148
-0.0571402
-4.94883e-06
-0.036287
-0.00232232
-4.21327e-05
-0.000411324
0.312983
-0.00467929
-0.000297433
0.402462
-0.00154803
0.206194
-0.000137096
-0.00812115
-6.08187e-07
-0.0337369
0.0558716
-0.0563678
-0.0230157
-0.000319378
-0.0698783
-0.00965848
-3.77058e-05
0.000139544
-0.00235545
-0.00490794
0.00174963
-0.00119927
-0.0177044
-0.0522174
-0.0165016
-0.0719727
-0.0207334
0.287357
0.299843
-0.000936287
-0.0903732
-2.39342e-07
-0.00280007
-0.0140321
0.152245
0.0812346
1.0314e-05
-0.00260334
-0.0202206
0.128135
-0.000819393
0.00224531
0.000509127
0.0138643
-0.167656
0.280254
-0.000835517
-0.0278291
-4.2085e-05
0.00148484
-1.04995e-05
-0.0207818
-0.000122737
-0.0045007
-0.122508
-0.0311153
-0.00660736
0.00600617
-0.000284322
0.0124879
-0.0129292
0.0483589
0.122773
-0.196781
-0.0920242
-0.00984513
0.00318413
-0.0410517
0.413425
-0.0804578
0.0264532
0.42977
-0.000814213
-0.00116041
-0.0945333
-0.00116149
-0.0287296
0.00452911
-0.00156264
-0.00109426
0.12221
-5.31051e-05
0.00018153
5.33529e-06
-0.00192413
-0.0080762
-5.24122e-07
-0.000529186
-0.0210886
0.361267
-0.0066546
-0.0102745
0.35965
0.2335
0.0386041
-0.0774231
-0.0229527
0.00294218
0.197605
-0.00714733
0.239163
-0.0389136
-0.11232
0.145401
0.242087
-0.0323288
0.0749829
0.183934
0.216784
0.0464636
-0.00213513
-0.00319683
-2.28587e-05
-0.0092807
-0.00723355
0.00010535
-2.7538e-05
-0.0010075
-0.0678265
0.0497677
-0.0126878
-0.0062416
-0.00234572
-0.0289182
-0.0047188
-0.000634427
0.156366
-0.000993326
-1.37184e-05
-5.70796e-05
-9.56936e-06
-0.0157003
0.11823
-0.00250956
0.0246838
-0.133556
0.305006
0.000679585
0.00452446
-0.00386587
0.302119
-0.000480288
0.277245
0.133862
-2.91453e-05
-0.0408133
-0.00191376
-0.0536497
0.000194586
0.0468534
-0.00261032
0.00411349
-0.000398218
0.106549
0.131106
-0.0606653
-0.0227177
-0.00252583
-0.0314107
0.0241077
0.441321
-0.0877991
0.00166324
-2.53941e-07
-0.00993253
-0.00126713
0.0107419
-0.104275
-0.102063
0.323337
0.117052
-0.140853
0.162568
0.292906
0.0264859
0.000275495
0.208745
-0.00103639
-9.71122e-05
-0.00974349
9.7631e-06
-0.168415
-0.00663974
-0.0309727
0.000886589
0.157856
-0.000995164
-1.1702e-05
-0.117658
0.000798518
-0.00184405
-0.02858
-0.0329502
-0.0529696
0.116348
0.0936438
0.0965901
-6.78679e-05
0.0409209
0.0550865
-0.000395171
-0.0124099
0.000218864
-0.00252152
-0.0137912
0.00313235
-0.000728225
0.0980401
-6.65377e-06
3.96944e-05
0.001021
-0.0142525
0.0161806
-0.0274756
-0.0174288
-0.0515906
-0.139805
-0.00808119
0.201998
-0.106988
-0.00478436
0.439593
-0.0526012
-0.00848036
-0.0173901
-0.0113183
-0.0126848
-0.00760055
0.0225504
-0.0877273
-1.36641e-05
0.0192451
-2.42313e-05
0.285622
0.0559122
-0.00343336
-0.00822922
-6.10686e-05
0.276812
0.262735
0.0231671
0.106967
-0.0578995
0.324109
-4.69991e-05
0.00102849
-0.010359
0.114181
0.395803
0.010686
0.111896
-0.00540278
-7.53008e-05
0.0929136
-0.130879
0.290275
0.000999883
0.173433
-0.00501024
0.307896
0.248712
-0.0065359
-0.00560498
0.0695477
-0.0338212
-5.92581e-05
-0.00966367
-0.0376636
-0.0685149
0.00879664
0.00635675
-8.38696e-05
0.266619
-0.00421285
-3.6917e-05
-0.0479979
-0.000308509
-8.08383e-05
-0.000885609
0.174073
-0.10305
0.372362
4.55051e-06
0.172621
-0.0382474
-6.50131e-05
-7.00955e-07
0.127894
0.166712
-0.00306644
0.148735
-1.01439e-06
0.158119
-0.187778
-0.00677806
0.304519
-0.0454155
0.0987413
-0.0159661
0.156361
0.164096
-0.0128891
-0.0163557
-0.00737566
-0.00173291
-0.000107837
-0.00405848
0.224329
-1.14217e-05
0.151287
-0.104103
0.255346
0.142585
-0.0371558
0.37176
-0.00112579
-0.00667827
-0.0731304
-0.0129781
-0.00487127
-0.0409376
0.012557
0.416556
9.45243e-07
-0.00131505
-0.0641496
-8.30024e-07
0.293366
0.000831246
-1.37475e-06
3.46054e-05
0.000113775
-0.019274
0.0102763
-0.000993594
-1.60171e-05
-0.00506133
-0.00209767
-0.110189
-0.0303169
0.0170054
-1.20594e-06
-0.179715
-0.00893556
0.0762662
0.247264
-9.48674e-05
0.083955
2.22273e-05
-0.00863376
0.0681498
-0.00511016
0.189386
-0.00994502
0.00375092
0.0709693
0.114243
-0.0012241
-0.0073435
0.138484
-0.080306
0.312982
-0.00703957
0.217541
-0.00670045
-0.00064544
0.105555
-0.0119086
0.0642387
0.000879749
-1.17744e-06
-0.126595
0.150372
0.000181923
0.0722946
-0.00941336
-0.178588
-0.0211948
-0.0287955
-0.00109886
-0.00498191
-0.0645509
-0.0191767
-0.0069305
-0.000155084
0.332832
0.0794584
0.0239594
-9.28358e-05
0.245954
-4.55399e-06
-8.31842e-05
0.0896308
-0.00866773
0.125244
0.0425942
0.0112421
-0.0755836
-0.14304
-0.0549476
0.000539111
-0.0284075
-1.57763e-05
-0.000191951
0.182261
-0.0123176
-0.00188619
-0.0255504
-0.00126952
-0.000448246
0.39969
-0.00747603
-0.000404057
3.64962e-07
0.104782
-0.0286255
-0.000259055
-0.00163483
0.123095
0.0560699
-0.0304983
-2.96633e-06
0.137445
-0.0165497
0.148439
0.0134307
0.0172316
-0.0211473
-3.42581e-05
0.0690798
0.0480638
-0.0191121
-0.098093
0.223454
0.00400399
0.133936
-0.00674938
-0.0448873
-0.00016912
-0.0081249
-0.000132775
0.122665
0.201104
-0.00104918
0.0130047
-0.0117197
-0.0836552
-0.0902947
-0.00111106
-0.000247011
0.387965
-0.0362593
-5.16528e-05
0.0559683
-0.00536875
0.333094
-0.00893621
-0.0190295
-0.018835
-0.0210785
-0.0130972
-0.00540688
-0.00729603
-0.000533416
0.00568661
1.15909e-05
-0.181359
-0.0576336
0.282737
-0.029457
0.131119
0.000998675
-0.0753774
-0.026426
0.161362
-0.00546616
-2.622e-06
-0.0167755
-0.00668302
0.00302404
-0.0174966
-0.0168391
-0.0575076
-0.00912938
-0.0221628
-0.0755309
-1.08937e-06
0.018821
-0.0652666
0.10718
-0.0857071
0.0640451
-0.0972613
0.2566
-0.0145306
-0.0215562
-0.0340451
0.347968
-0.152141
-0.00918168
-0.127033
-0.0560067
-0.120399
-0.0763816
0.129891
-0.00197088
0.192493
0.00622544
-0.000289801
-0.00129128
0.047164
0.436352
-0.00101124
-0.0405408
0.129602
-5.57115e-07
-0.0157262
0.0219958
-0.0309894
0.00635076
-0.00146419
-0.0358875
-0.004734
-7.66307e-07
-0.043775
0.20002
-0.0124318
-0.0112647
0.000920108
0.129344
-0.000319668
-0.000744656
-0.000159126
-0.000983186
-0.00173575
-0.0166257
-0.00423095
-0.0131737
-2.59886e-06
-0.137678
-0.119521
-0.156377
-0.0252477
0.0101903
-8.25112e-05
-0.0122203
-0.0494907
-0.0187658
0.256145
-0.00161833
-0.0422531
-0.00361429
-0.0109177
0.107983
0.000131882
-9.95326e-05
0.0777064
-0.0311467
0.00774403
-0.00212914
-0.00109611
-0.0482574
-0.00014586
-0.0156426
-0.00750511
0.219027
0.199338
-0.0675209
-0.0647777
0.00486592
-0.00680013
-0.0422567
-0.0748049
-0.0308694
-1.34269e-06
-0.0441908
-0.014958
-0.0818368
-0.00943638
-0.0283612
-0.000214439
-0.00198202
0.144377
-0.0204829
-4.45789e-07
-0.00156092
-0.140412
-5.03062e-05
-0.0369642
-4.13457e-05
-0.00128219
-0.10696
-0.0653767
-3.39824e-05
-2.35785e-07
0.0894151
-0.0584211
0.277082
0.208257
-0.045396
-0.000846641
-0.0266456
4.4298e-05
-0.149361
-0.112601
-0.0582939
-0.0116666
0.200684
-0.00171412
1.02802e-05
-0.0045278
-0.149934
0.000955692
-0.0440057
-0.0485571
-0.00945129
0.0108935
0.0460359
-0.0035713
-0.0194569
-0.0985781
0.136168
-0.051623
-8.93407e-08
-0.129434
-0.0405735
-0.0606953
-0.00272548
0.000270158
-0.00585679
-0.113235
0.0172105
-0.0166457
0.0843024
-0.0702466
-0.000996429
0.00863871
-0.00586481
-0.0179911
-0.158971
-0.000120181
0.103686
0.150702
0.00365615
0.154746
-0.0902339
0.0271833
-0.0594015
0.144153
0.0678607
0.417485
-9.31441e-07
0.0634678
0.125534
0.0079325
-0.000697899
-0.00810398
-0.0586132
-4.03758e-06
-0.0102095
-0.0574606
-0.00865073
-0.0120314
1.73644e-05
-0.131996
-0.000253668
-0.000269448
0.1736
-9.08598e-05
0.0192745
0.00844576
0.148995
-4.47359e-05
-0.000384203
-0.142596
0.000278021
0.266074
0.000375327
-0.0584128
-0.000205447
-0.000203806
-0.00251959
-0.080419
-1.5776e-05
-0.00441608
0.0129161
-0.000613843
-1.18512e-06
-3.97174e-05
0.106901
-0.0710142
0.00131077
-0.000369656
0.00206183
0.00828621
0.00136109
-0.000219326
0.275145
-0.12961
0.159119
0.233594
-4.92044e-05
0.00984722
0.0685851
-0.000338012
-0.000149735
-0.000457868
-0.0444486
-0.00363362
-0.0236026
-0.0286245
-0.0647991
0.120306
-0.129195
-7.7699e-07
-0.011351
-0.0160407
-0.0175891
-0.0018109
0.00106007
0.000353711
0.015054
-0.000154133
-0.000225554
-0.0115817
-0.00224492
-0.0146314
-9.27061e-07
-0.0085875
0.018349
-0.0556965
-0.0593193
-0.00454463
-0.00630864
-0.00451376
-0.00250444
-0.00861231
-0.00434977
-3.43165e-05
-0.000279761
0.00982476
-0.00618054
-0.00253707
0.00242855
-0.00402778
-0.151363
-0.00634377
0.109666
-0.0059916
-0.041446
-0.0235904
-0.0135811
-0.0084745
-0.00174624
0.000150065
-0.00175008
-0.00655423
-0.00823248
0.137456
0.100808
0.0220323
0.247687
-1.34081e-05
-0.00341218
-0.00785735
-0.00456468
0.047951
-0.0111555
0.0170355
-0.00417922
0.151517
-0.00107746
-0.00099637
-0.00785887
-0.0287757
-0.000108457
-0.0257359
-0.00277037
-0.010889
-5.16383e-06
-0.00304985
0.000590102
-0.0104149
0.00973872
0.0219057
0.0105679
-0.00772413
-0.0184724
0.0793423
-0.000887969
-0.000862596
-0.000860511
0.361452
-0.000101845
0.0390956
-0.0104784
-0.0119545
-0.0126625
-0.0393357
-0.014704
-0.0196471
-0.0122093
-0.00252373
-3.02471e-05
-0.0019565
-0.0105545
0.0663664
0.000532364
0.101229
-0.0191641
-0.00780172
-0.000294086
-0.0172649
-2.80106e-05
0.103032
-0.0180165
-0.0153299
-0.0142725
-0.00435389
-0.0251001
-0.000597658
-0.0231679
0.0688769
-0.0142899
-0.081699
-0.000548348
-0.0148005
-0.0110127
0.008171
-0.00171742
0.0988726
-0.000969388
-0.00876261
-0.000400557
0.112303
-0.0224544
-0.0138328
-0.00134483
-0.00569118
-0.00148018
0.134548
-0.02369
0.147692
-0.00430741
-0.00052889
-0.000475032
-0.00126725
0.123023
-0.0400862
-0.00403931
5.62189e-05
-0.011596
-0.0270006
-0.000752844
-0.0241175
-0.00910317
0.0368194
-0.00240074
-0.00460336
0.332331
-0.0379804
-0.0128161
-0.0363848
-1.026e-06
0.049888
-0.0016651
-0.0132241
-0.0032004
-0.020194
-0.000205927
-0.000257855
-0.0012296
0.00123736
0.142361
-0.00256933
-0.000850997
-0.00242177
-0.0459308
-0.00431755
-0.0105838
0.000596827
-0.00421187
-0.00389809
-0.0016536
0.145162
-0.0265604
0.00113565
-0.00178371
-0.0141514
-0.00633551
-0.0276447
-0.000894099
0.0606218
0.0116287
-0.00437239
-0.000987799
-0.00828239
0.38045
0.143508
-0.00598547
-0.00018437
-0.00122984
-0.013127
-0.00220691
0.0106847
-0.000232726
-0.0242
-0.000813003
-0.00809668
-0.131922
-0.000786039
-0.0136741
-0.000553887
0.233351
-0.0043198
-0.00578735
-0.0661282
-0.000671617
-0.0147844
0.0122013
0.3336
-0.00606887
-0.00676093
-0.000789076
-0.00033748
-4.79946e-06
-7.51973e-07
-0.00568083
-0.000315471
0.0645344
-0.000468643
-0.000815086
0.00269722
-7.67141e-05
-0.0258806
-0.0704941
0.00938501
0.0244874
0.0153341
-0.00249665
-0.0655805
0.0598078
0.0459227
0.064796
0.084358
-0.00629054
-0.000408739
-0.00557195
-0.0788263
-0.00153073
-0.00800804
-0.0175952
0.255993
-0.0613189
-0.000171182
-3.05495e-05
-0.000505734
-2.99217e-06
-0.000909699
-0.00035551
-0.00458795
-0.027027
0.000113082
0.000749617
-7.55374e-05
0.0307358
-0.00764701
-0.0744416
-0.000948146
0.234258
0.214591
-0.00607491
-0.103618
-0.015218
-0.0116756
-0.00819353
-0.000957458
-0.0918088
-0.0466815
-0.0318105
-0.116517
-5.28133e-05
0.134738
-0.0325879
-0.00450444
-0.044535
0.00932284
-0.000229536
-0.00488497
-0.000520791
0.000317487
-0.00135956
0.114497
5.91412e-05
0.00487144
-0.000119481
-0.137652
0.00395867
-0.000773176
-0.013593
2.76208e-05
-0.0267557
0.0757778
-0.00549795
-0.000638101
-3.73343e-05
-0.000256004
-0.000197487
-0.0349224
0.0860408
-0.0331882
-6.83611e-05
0.000430998
-0.000232196
0.163714
-0.0369774
0.186639
-0.0254702
-0.000143017
-0.000198839
-0.0043378
-0.00267911
-0.000430048
-1.37066e-06
0.0123397
0.015703
-6.82987e-05
-0.000262867
-0.0105191
-1.26695e-06
0.118534
-0.000501902
-0.0302181
-0.0108044
-0.00293887
-0.033067
-0.0419619
0.106198
-0.0391465
-0.0101069
-9.35483e-05
-0.0312545
-0.0099423
-0.0356798
0.0521023
0.262266
-0.000409258
-0.0344625
-0.00124101
0.233261
0.022594
-3.00311e-05
-0.00344437
-0.00186771
-0.00271684
-0.0191376
0.0541673
-2.7743e-05
-0.00241195
-4.17991e-05
0.0392532
-0.00018944
-8.9027e-05
-0.127176
0.210703
-0.0308294
0.0995491
-0.00127731
-6.73637e-05
-2.23957e-07
-0.119806
-0.0166722
-0.000205166
0.0633282
0.00554857
-0.00286325
0.293202
-0.000349995
-0.0023364
-0.0387216
-0.0463975
-0.000930203
0.0938695
-0.0846813
-3.44259e-05
-0.00323382
-0.000114274
-3.60845e-05
0.0948668
-0.0165484
-0.000130603
-0.0251246
-0.0138756
-0.0013969
-0.0539939
0.000799645
-0.0107841
0.000322156
-0.00185786
-0.0388155
-0.0221117
-0.00440818
-0.000519839
0.108544
0.148872
-0.134144
0.00155284
0.00976088
-0.00238107
0.117808
0.0668407
-0.0133303
-5.50638e-05
0.00237514
-0.0235023
-0.00556054
-0.0197702
-0.00117366
0.0153723
-0.0168725
-2.86148e-05
-3.31239e-05
-0.063293
-0.0250216
-0.0128005
0.00288273
-0.0367059
-0.0287248
-9.16686e-05
-0.000977642
-0.000117268
-0.0342387
-4.26164e-06
-0.000928057
-0.0637442
-0.130589
0.063449
-0.0016054
0.00163316
-0.0145172
-0.0134256
-4.46225e-05
-0.0188554
0.0569983
0.110878
-9.74428e-07
-2.3158e-05
0.113212
-0.00137788
-0.11079
-0.0162226
0.00127525
-6.32391e-05
-0.0299977
-0.0585991
0.116332
-0.0236112
-0.000609104
-0.0138366
-0.0427112
-0.000284025
-6.22119e-05
-0.00047159
-0.0517428
-0.0262776
0.092391
-6.32328e-05
0.351339
-0.0676375
-1.17293e-05
-0.000823618
-5.72899e-06
-2.1726e-06
-5.00279e-06
-9.41272e-09
-0.0258627
-0.000439508
7.97419e-05
-5.15071e-05
0.098366
-0.00285624
-5.58814e-05
-2.88384e-05
0.281575
-0.0132012
-0.0790997
0.000104321
-0.000348297
0.0278099
-4.17502e-05
-0.0161231
-0.177174
0.000729592
-0.00647226
-2.45113e-05
-7.82919e-05
-0.0202978
-0.08377
0.00326452
-0.16004
-0.0945347
-3.46822e-06
0.0119961
0.0196051
0.0743785
-0.000706964
-4.55561e-05
-0.035283
-0.00304296
-0.000371037
-0.0257149
-4.22865e-05
0.0135603
-9.22878e-05
-0.000439858
-0.0505441
-0.00210839
-0.0316165
0.338639
-0.00109151
3.75101e-05
-0.0448968
-0.0614762
0.00307291
0.00193065
-3.27437e-05
-0.0173641
-3.25617e-05
0.14067
0.402356
0.0341019
0.00111044
0.00126945
-5.58932e-06
-0.0188961
-2.93231e-05
-0.0105564
-0.000883746
2.46917e-05
-0.0014631
-0.00896204
-2.66751e-05
0.000181411
-0.0104559
-0.000100596
-0.00878423
-0.0100708
-0.0234349
-0.00108148
0.364181
-0.000645466
0.000838466
2.98766e-05
0.00720599
-0.0239069
0.00432288
-6.19969e-05
-2.20185e-05
0.000407564
-4.05723e-05
-2.23324e-05
-0.0106175
0.000158332
-3.24928e-06
-0.0295919
-0.00233499
-0.024988
-0.000792877
-1.17402e-05
-0.00127786
-0.0208747
-0.0118472
-0.0289606
0.000790951
6.93761e-05
-0.000208224
-0.000661753
-3.71666e-05
0.205023
0.000472898
-3.62275e-06
-6.08991e-06
-0.00119171
-0.00028955
-0.0275304
-0.0259984
-9.89815e-05
-0.00388592
-3.13744e-06
-0.00295181
-1.55214e-05
0.0214657
-5.01568e-05
-0.000126857
-0.00368008
-1.22871e-05
0.00691093
-8.6291e-05
-0.000521982
0.0103805
-3.59215e-06
0.281905
-0.0322216
-0.0246156
-9.00572e-06
-2.72676e-06
0.000372294
-0.000449317
-0.0396833
-3.04296e-06
-2.31865e-06
0.000127295
-1.47042e-07
6.20185e-05
8.54709e-05
-0.000183619
0.0001861
-0.0268724
0.3616
-0.0361013
0.25676
0.00428147
-0.0151224
-4.08493e-06
-0.000281669
-0.00748217
2.78125e-06
4.05241e-05
1.38408e-05
0.0223612
-0.00140056
-0.000170922
0.330956
-0.000134968
2.83488e-05
9.95018e-05
-5.2331e-07
-0.0160566
-0.00129835
0.00030575
8.97091e-07
-0.000648427
-9.58501e-06
-0.00108956
-0.0270316
-0.000133769
-0.00181171
3.42007e-07
-0.00325252
-6.12981e-05
0.137639
-0.000158592
-0.000293901
-0.0268704
0.00144358
-7.5969e-05
-0.0005964
-8.41424e-06
0.124575
-0.0421486
-0.000382247
-0.000111296
-0.00234247
-0.000172597
0.0334089
0.0740061
-0.00722661
-1.50822e-05
-8.16315e-07
4.8837e-08
0.025281
3.27952e-05
-0.0229286
-0.0326295
-0.0114922
-0.0759112
0.376494
0.000627333
0.142028
-0.010879
-0.0185118
0.126889
-8.9027e-05
-0.0368348
-3.16764e-06
-0.00542427
-0.0197022
7.79192e-07
-0.0486375
-0.000331805
-0.0245608
-0.00578579
-0.0170589
-0.0235179
-0.00381395
-0.0454722
-0.0179086
-2.36737e-05
-0.00520867
-4.42321e-05
-0.0159669
-2.48505e-06
-3.13448e-05
-0.00671372
0.119933
-8.17672e-08
-0.0278441
0.00119617
3.26409e-07
-0.0181516
-2.51651e-06
-0.00568185
-0.000161865
-0.0160269
8.2745e-06
-2.76596e-05
-0.00167989
-7.7029e-05
0.116649
-0.0188908
0.0339878
-2.49642e-05
0.00013594
-0.0134356
-5.66626e-07
-0.0335872
-0.0347495
-0.0263218
0.356856
-0.00382751
-2.47368e-06
0.013903
-0.0180456
-0.00271986
-4.44392e-05
-2.27018e-05
-0.0251819
2.19024e-06
0.000211698
-2.734e-07
1.69795e-06
-0.0121054
0.0649383
-0.0960449
0.0626822
-0.00302375
1.41822e-07
0.00051888
-0.05131
-8.64745e-07
-2.77319e-06
4.9645e-05
1.74597e-06
7.27541e-05
0.174941
0.0201219
9.72347e-07
-2.73108e-06
-0.031397
0.149052
0.129537
-1.3606e-06
-0.0213745
-0.0171889
-0.0098642
-0.0237556
-0.00827795
-0.00143129
0.102316
-2.30333e-05
-0.0160984
0.123538
-0.0291538
-1.92676e-05
-0.0279458
-5.19895e-05
0.230416
0.0127008
-2.59087e-05
-1.05242e-05
0.136521
-9.21618e-07
-7.23097e-05
-0.00529256
-6.08782e-06
0.189546
-6.21128e-05
-0.00330844
-0.0276465
-0.00207066
-0.0845506
0.13559
-0.0220676
-0.0653076
0.000259657
-8.10818e-06
-0.000713111
-1.49074e-05
-9.5609e-06
0.00135702
0.133623
0.109374
-0.00021012
0.184636
-0.0154575
-3.01438e-06
-0.0192227
-1.72191e-05
-0.0176804
0.0137941
-0.0131736
0.001306
0.000571311
-0.00431394
-1.97526e-05
-0.000902371
0.00710994
-0.00104904
-3.22881e-05
-1.0843e-06
-1.11284e-05
0.0186425
-2.69005e-06
-0.0221848
0.194304
-0.00402722
7.03437e-07
-0.00155099
-1.0769e-05
0.0301038
-7.58147e-05
-1.45744e-05
-6.19457e-06
-4.1381e-06
0.156829
-8.3864e-05
0.180671
-0.0456437
9.12434e-07
-0.0394827
-0.000500779
0.114834
0.336214
-0.000465163
-2.78194e-07
-5.22698e-06
-6.57324e-06
0.0958862
-3.54093e-07
0.000197823
-0.0101101
0.168657
-2.09639e-06
-4.06665e-06
-2.45033e-07
-1.11642e-06
-0.0125323
-4.25496e-07
0.212064
-0.0140762
-1.31762e-05
-3.65732e-07
-0.000746806
-0.0132684
-2.45774e-07
-8.03827e-06
0.122045
-3.45928e-07
-0.0196984
-0.0779349
7.86316e-06
-3.68941e-07
-0.18306
-2.62785e-07
0.119402
-5.46779e-07
-0.000189655
-2.40051e-06
-2.06793e-05
0.0639329
-1.71395e-06
-0.000813107
-3.96576e-06
0.00153717
-0.00215199
-0.00267213
-0.00190142
0.112444
-0.000268317
-2.88653e-05
-0.00396349
-0.00405731
-3.77764e-05
-5.88412e-05
-0.000498574
-3.76436e-06
0.125607
-0.00885355
0.372866
-2.39309e-06
-0.00405608
-0.000157657
0.0928742
-1.93855e-06
-0.0190683
-1.13655e-06
-0.000724666
-0.0201333
-5.45532e-05
-0.00949867
-0.0309198
0.00107745
-1.3289e-05
-0.0589252
-5.43312e-05
-0.000348783
-0.00273024
-0.022492
0.000185184
-6.98002e-05
-0.000165185
-0.000998624
-0.000545665
-4.67311e-06
-0.000475713
0.332911
3.8436e-06
-0.00137893
-0.0208933
-0.0272142
-0.0358209
-0.0209705
-0.0137441
-0.000594182
-0.0222334
7.75792e-07
-2.43409e-05
0.350574
-1.89986e-05
0.129807
-8.42893e-05
3.62506e-05
-0.000410585
-0.102136
-0.000142702
-0.00144908
-8.31201e-06
-0.00011981
-2.32916e-05
-1.98047e-05
-0.00655996
-4.68378e-05
-4.01922e-05
-1.78926e-05
-4.40914e-05
-9.4451e-06
-0.0299693
0.180875
-2.7283e-06
-0.000125931
-8.25819e-05
-1.17018e-06
-0.000259301
-2.00204e-06
-0.000303832
6.96452e-06
-0.000100523
-0.0336547
-0.000254822
-0.0010796
-1.69995e-06
-0.00166801
4.94434e-05
-1.50418e-06
-3.69537e-06
-1.18742e-06
-0.00018341
7.53695e-05
-0.0301264
-0.021826
-0.0313935
-0.0005644
-0.00216076
-0.06098
-0.0290908
-9.98783e-06
0.00457637
0.00199148
-0.000251915
-0.00702997
-0.0216868
0.332286
-9.86317e-05
-3.81893e-06
4.37016e-05
-2.12061e-06
-1.45303e-06
0.050301
0.000391249
0.0593453
-0.0380833
0.312648
-0.000105556
-1.16117e-06
8.10143e-06
-6.94006e-06
-0.000361863
0.109562
0.163621
-4.75004e-06
-6.4754e-05
-1.22308e-05
0.15437
-0.000696814
-0.00932116
-1.0313e-06
-1.01057e-06
0.00294889
-0.000154049
-0.0481577
-0.0104859
-7.449e-06
0.001019
-0.0251754
-1.26493e-05
0.000392919
-3.69814e-05
-0.0248022
-0.000495226
0.103488
-1.37938e-06
0.000470286
-0.00195644
-2.02683e-06
9.81186e-06
-0.0144741
-1.78058e-06
-0.000221325
-4.37106e-06
-0.00800367
-0.0219716
-0.00350229
-0.00943073
-0.00382004
0.00399851
-0.00506854
-0.000771308
2.27338e-07
-4.76094e-06
-3.40221e-06
-2.62375e-06
-9.54655e-06
0.00319528
-0.0494007
8.26696e-05
-0.0514449
-0.000979793
-0.0521532
2.82019e-06
-1.02293e-05
0.00032515
-0.114464
-2.32193e-06
-0.0484982
-0.0111476
-0.0392173
-0.0545599
-2.13274e-06
-0.00113348
1.06732e-05
-0.186413
0.0952458
-7.981e-06
-0.0417699
-0.0180962
-0.00146817
-4.61714e-06
-3.02938e-06
0.00459464
-0.00659844
-5.66137e-06
-0.00317808
-1.7874e-05
1.09929e-05
0.0858837
-2.15117e-06
-1.36953e-05
-6.90256e-05
-3.54907e-06
0.000191859
3.27495e-06
-0.00186396
8.53659e-06
-0.00774732
0.000227725
-0.000105866
-0.0314636
-0.0279112
-0.00356006
-1.98292e-06
-2.92223e-06
-0.0675123
0.00213405
-0.0283057
-8.16173e-06
-0.00281153
-1.16733e-06
-3.73424e-06
0.0407656
-0.00248803
-0.000892883
-1.14968e-05
-0.0130522
-1.75947e-06
-0.039948
-4.7773e-06
-0.0462798
-1.32473e-05
-1.76832e-06
2.72747e-06
0.00024291
-0.125659
-0.00739122
-0.0514689
-6.79143e-06
-3.68596e-06
-0.0427062
-0.0308793
-0.00317443
-3.39449e-06
-0.0584808
-0.0413903
-0.0398642
-8.83966e-06
-3.90864e-06
-2.30432e-05
-0.11763
-0.0525266
0.000105265
-0.00410136
-2.61319e-05
0.171203
5.01356e-06
-8.86393e-06
8.53659e-06
-3.0605e-05
-4.68971e-06
-0.00191635
-7.36929e-06
-0.00140354
-0.0530727
-0.00509499
-0.0204208
-8.7535e-06
-6.81568e-06
0.0242288
-0.0737127
-0.00166122
0.0766012
-3.88935e-05
-6.19365e-06
-5.28127e-06
0.068121
1.07817e-05
-6.70031e-05
-8.29172e-06
-0.0617653
-0.00618983
-1.51985e-05
-6.31639e-05
-0.00558749
-0.0023134
2.1758e-05
0.165566
-0.052985
-0.000828546
0.440024
-5.2429e-05
-0.000589925
-0.00778499
-0.0353483
-6.78053e-06
-1.97983e-05
-1.61532e-06
0.00151985
-0.0337516
-0.000186139
-0.0343471
-0.00285732
-1.0901e-05
-1.27058e-06
-0.00384866
-0.0197296
-0.0476614
-0.112722
-0.0230805
-0.0233327
-0.0358316
-0.0200971
-1.60166e-05
2.92917e-05
-0.0167747
9.74217e-05
-0.000152636
9.37303e-05
-2.1238e-05
-0.000120237
-0.00460297
-2.19628e-06
-1.7909e-05
0.0128019
-0.0515633
-0.000261469
-9.05161e-05
-5.58364e-06
0.18093
-0.00394321
6.87754e-05
-0.0208151
2.57883e-05
1.31508e-05
1.40767e-05
-1.56033e-05
6.41991e-05
-0.0265497
0.00208068
-1.84691e-06
-0.000203786
-0.0327753
-0.029225
0.0301787
-9.23073e-05
0.000545893
0.00883273
-7.8299e-06
-6.53068e-06
-0.0498963
-1.79408e-06
0.117925
-2.53977e-05
0.00151973
1.36455e-05
1.46496e-05
-0.0348427
-0.00463182
-0.0111159
-0.00083015
-1.93001e-06
8.94637e-05
0.0389793
-0.008095
-5.21634e-05
0.0634663
0.114799
-2.56608e-06
-0.0319687
-2.59637e-05
-7.3741e-06
-7.58067e-06
-0.00011517
0.0101934
-3.36545e-05
1.48103e-05
-0.0111815
-0.0156819
-0.00838376
0.227974
-1.921e-05
-1.83182e-05
0.121728
-0.0179292
-0.00212375
-0.000135451
0.119693
-1.69653e-05
-0.000448515
-3.51783e-05
-3.17144e-05
-2.25194e-06
-2.93783e-06
2.60938e-06
-0.00773691
-1.04532e-05
-0.00217759
-0.0242815
0.179761
-0.000331704
-8.95466e-06
0.00170681
0.0561877
-0.0508514
-0.000170045
-0.0280896
0.228414
-1.79245e-06
0.29909
-2.72915e-06
0.000871177
0.0126414
6.42324e-05
0.316109
-5.75407e-05
-2.60127e-06
0.000157179
-2.75959e-06
-0.00018878
2.63486e-05
-1.16045e-05
-0.000747867
-4.28041e-05
-5.81085e-05
-0.00146629
0.177713
0.0275527
0.011428
-0.0208009
-1.98067e-06
-1.3921e-05
0.000760482
-0.0573806
-6.33548e-06
-0.0237151
-1.47234e-05
0.0701806
0.0390136
-0.0257597
-0.000618062
-0.00977619
-0.000231864
-0.00582261
-0.00240826
-0.00630252
0.039122
-9.04638e-07
0.190376
-0.00170467
-0.000763879
0.15443
-0.00823605
-1.79577e-06
-1.44875e-05
2.8452e-07
-2.6903e-05
-7.39374e-05
0.179439
-0.000352922
0.184942
-0.00129587
0.118207
0.164103
0.0728585
-0.00422876
-7.25447e-06
-5.87841e-05
-0.00391146
-0.168153
-0.0384201
0.000401981
-2.89257e-05
-0.0193999
-0.00057271
-7.31617e-05
0.000241454
-0.000348608
-0.000983658
0.0183182
2.09266e-06
-0.0212483
0.0339177
-2.02631e-07
1.20035e-05
-0.0124111
-0.0553351
-0.000229884
-0.000137272
-1.74578e-05
3.16895e-06
0.0427337
-0.0126341
-0.0393582
0.000314316
0.0566104
-0.0275809
-1.57514e-05
-9.93155e-06
-0.0097424
-0.000131214
0.0431939
-0.00604137
-0.00536966
-0.000188747
0.000337478
-0.0284096
-9.897e-05
7.0341e-05
-0.0169744
-0.0423704
0.106859
-0.0308618
-0.0179867
-0.000222517
-6.44531e-06
0.00285215
-6.69823e-06
-0.0381701
-0.0502998
9.60165e-05
0.000589306
0.0013819
-0.134063
0.000110479
-1.47395e-05
-2.30562e-05
-0.0291676
-6.17998e-06
9.81008e-05
0.0847015
0.129342
-0.154136
0.0304037
0.0284178
-0.00843258
-0.000285372
0.0011275
7.0084e-06
-4.88491e-07
-0.000166155
-9.13446e-07
-0.000137716
-0.000111808
-0.00447988
-0.0872988
-0.00597099
-0.0262909
0.0314116
0.0257779
0.00131243
-0.0513039
-2.72829e-05
0.000954168
0.00429514
-0.000150739
0.0470778
-0.00166799
-0.00786252
0.00376807
0.00222759
-0.000836177
-0.00228953
0.0225586
0.000126414
-0.0121216
-0.011055
0.379741
-0.0189956
0.0520762
-0.00990321
-0.035239
0.000578285
-4.36453e-05
-0.000843131
-3.80427e-05
-0.000777023
-0.0180671
-2.22276e-05
-0.000209533
0.214452
-0.0010379
-0.026473
-0.00735619
-7.12988e-05
-0.00215691
-1.06977e-05
-5.22278e-06
0.0183887
-6.23967e-06
-0.000953518
0.0470966
0.00175677
0.000285982
0.00767896
-0.0033465
0.0015216
-0.160149
0.000113153
-0.0024505
-0.0382734
-0.000629339
-0.00480112
-3.69086e-05
-0.00267473
0.000194524
0.0166612
-0.000487876
0.00199933
-0.0242069
-0.0138833
-0.000132945
-0.0214252
-0.00914291
-0.00684029
-0.00010275
0.00261186
-0.0724441
-0.000286854
-0.00321517
-0.0205494
-0.00362958
-0.000503578
0.163788
-0.0222527
-7.88782e-07
0.00351798
-0.0444706
-0.000385896
0.141657
-0.00277591
0.000212344
0.0383136
-0.000661244
0.00288346
0.0899976
-0.000295516
0.000279636
-7.49609e-07
-5.31638e-05
-0.00155533
-0.007003
-0.000360493
-0.0148953
0.0650472
-0.018106
-0.0777445
0.000281491
-0.00152859
-0.000833579
-0.0722534
-4.88374e-05
0.00357429
-8.87543e-05
-0.00647441
-0.000698327
-0.00173645
-0.0853691
0.079118
-0.0869258
-1.77218e-05
0.144953
-0.00177374
-0.0035402
-0.0322751
-0.0942363
-0.0104376
-8.58319e-06
-0.00141153
0.00284006
-0.00136331
-0.00264107
-0.000133888
0.0569088
-0.0413547
-0.00671878
-0.00237361
0.00260503
-0.0066425
-0.0050363
0.000469276
-0.000520502
-0.00129712
0.0773399
2.85489e-05
-0.176189
-0.000192402
-0.00268447
-0.00446342
-0.106199
-0.00759841
-0.136399
-1.95447e-05
-2.30273e-05
-0.00850419
0.00419525
-0.000125958
-0.167374
0.054202
-0.0362079
-6.02389e-06
-0.190342
-0.000258887
-0.204827
-0.0163626
-0.236867
-0.240452
-0.235017
-0.199703
-0.118701
-0.0860331
-0.0550369
-0.0239421
0.00772987
0.0992839
0.129339
0.156865
0.203574
-0.00301232
-0.00545187
0.0310657
-0.0230798
8.89861e-05
-0.00163764
-0.0274307
-0.000266299
-0.00107356
-9.29086e-07
-0.0101784
0.0086535
-4.88258e-06
-0.000622449
-0.00381912
-0.0172899
-0.234468
-0.0188557
-0.0396928
-0.000121973
-5.96507e-05
-1.89211e-06
-0.0692559
-0.00637873
-0.0279017
-0.0156458
0.000398827
-0.000213086
0.00173772
-2.79429e-06
-0.0289461
-0.000112828
3.67976e-05
-0.0106508
-0.00434264
-0.000929294
2.95387e-05
0.030493
-0.00735854
0.0345132
-0.219992
-0.0129902
0.0698311
-0.011503
0.000972123
-0.014833
-0.00199595
-0.00486072
-0.0114284
0.248658
-0.00182464
-2.704e-05
-0.00375777
-0.00690957
-9.34728e-07
0.0534162
-0.00355906
0.234451
-0.153258
-0.0215826
-0.0172093
0.0197505
-0.00553483
-1.27829e-05
-6.66465e-07
-0.00251748
-0.0635799
-2.51751e-05
0.269184
-0.00151618
-0.00350688
-0.000453563
-0.000132052
-0.00674631
0.038568
-0.121377
0.0831791
0.000111701
-0.00859973
4.49339e-07
0.0143085
-0.00807001
0.0101184
-0.0415401
-0.00310921
-0.00208168
-0.000158891
0.00480102
-1.04716e-06
-0.00959634
-0.000532109
-0.00016994
8.32007e-05
-0.0569475
-0.000382659
0.102672
-0.00628229
0.000860223
-0.123494
-0.0232689
-0.112372
-0.0112841
0.010501
-0.0080894
0.12868
-0.049681
-0.00196706
-0.0337284
-0.00138165
-9.99294e-06
5.9793e-05
-1.32184e-06
-0.00301639
0.00134354
-4.08915e-05
-0.0130752
0.0114783
-0.00164276
-0.000148844
-0.00178514
-0.0305367
0.107643
-0.0304109
-0.0422674
0.0034198
0.0470798
-0.000667249
-0.0126396
-0.00738541
0.00205094
0.0205341
-0.0528594
0.0745134
-1.1715e-05
-0.0215177
0.000299265
-0.00124202
-0.000239476
-0.00368963
0.0687556
-0.000331248
0.174234
-0.0132701
-0.0412463
-0.0100628
-0.000709214
-0.00360463
0.0388647
-0.179172
0.173001
0.0100402
0.0129101
0.123379
-0.0334636
-0.00293889
-0.0327794
-0.00132488
-0.021527
0.111263
-0.00182774
0.236654
-0.00235045
0.0619873
-7.82012e-06
0.0684841
0.0859155
-0.0149196
-0.0125437
-6.14486e-05
-7.39265e-07
0.00187482
-0.000504247
-0.0262592
-0.0242054
-0.00342259
-0.0241984
0.117003
0.0258074
-0.0782372
-0.0150786
-0.000562644
0.00140202
0.165604
0.00148958
0.118471
-0.0515075
0.00194936
-9.66502e-05
-0.000245953
-0.0195427
-0.00044146
-0.00220359
-0.0507863
-0.000163894
0.000331931
-0.0537698
-0.0356267
0.155066
4.6604e-07
-0.0172182
-0.000199662
-0.0173587
-0.000117838
-0.052268
0.0868756
-0.0479242
-0.0220561
-0.00298162
-0.00947713
-0.00126452
-0.00347595
0.055331
-0.029988
-4.26658e-07
-0.0084466
-0.00580806
-0.000170848
-0.00388059
0.00412891
-0.00717064
-0.0238312
-7.06065e-06
0.108176
-0.0298067
0.00212802
-0.00015361
-0.00601712
-0.000136379
-0.0512403
-1.93353e-05
-0.0174243
-0.000418476
-0.0255104
0.000201636
-0.00164387
-0.0119335
3.26175e-05
-0.00680943
-0.00090513
0.12093
0.000231232
-0.00361942
-0.00330437
0.000676207
0.0874251
-0.00991868
-0.113837
-0.0159315
-0.000230532
0.0848779
0.0287114
0.000220473
4.76692e-06
0.0318114
-0.0381957
-0.000115581
-0.0226585
-0.00779545
-7.57097e-05
-0.0174901
-0.0120362
-0.00963373
-0.00693339
0.250035
0.0147476
-0.100739
0.0185133
-7.33547e-05
-6.66823e-07
-0.00279688
-0.00206603
0.0877702
-0.00479804
0.00446539
-2.7427e-05
0.355549
0.334798
-0.000393428
0.143968
0.434553
-0.0254015
-5.09976e-07
0.0584189
0.0924298
-0.00123797
-0.0179345
-0.000359007
-3.40589e-06
0.101589
-0.0250768
-4.14303e-06
-0.0514773
-0.000317827
0.0279878
0.00882316
-0.0279912
-0.0149083
-0.020844
-0.000726262
0.000186951
-0.00555349
0.0519509
-0.0362104
0.126042
-0.0037649
0.0182838
-0.00578727
-3.29875e-05
-0.00397117
-0.00196351
0.0929963
-0.00604087
0.0926451
-0.000790368
-0.100108
-0.0219338
0.0928472
-0.00722356
-0.00114451
-0.0305881
5.45758e-05
0.00481475
0.0779567
-0.00876315
0.104914
-0.0103243
-0.00735481
-0.116545
-0.00473968
-0.0255742
-0.0136246
-0.000258535
-0.0263375
0.000401453
-0.0073393
-0.000473447
-0.0358693
-0.0121131
0.0258726
-0.00131355
-0.028147
-0.0334595
0.0164634
-0.00490632
0.0794555
0.00150912
-5.46226e-07
-0.00440571
0.139428
-6.33325e-06
-0.00223594
-0.00278942
-9.86119e-05
-0.0164206
-0.00547665
0.000982097
-0.000453681
-0.000416828
3.46138e-05
-0.0228244
-0.00719946
-0.0200189
-0.019576
-0.00182094
0.274861
0.0319618
-0.0273423
-0.0202966
0.000345199
-2.90475e-05
0.00468693
-0.000405694
0.00323853
0.289892
0.0695841
0.0551408
-0.00100645
-0.00694011
-0.000758903
0.00536811
0.042824
0.0760543
0.104802
0.112583
-0.0140069
-0.000326254
-0.00071816
0.016068
-0.00922682
0.118928
-5.47052e-06
-0.00274589
8.19606e-07
-0.0127847
-0.0403333
-0.000590775
-0.0182974
-0.0279752
-0.0458161
0.11141
0.0957882
-0.0188256
0.0963527
0.0419782
0.0357184
-6.33217e-06
-0.0138966
-0.0168897
-0.219718
-0.0114528
-0.0254822
0.0303567
-0.192143
-0.000344082
-0.0299782
0.0648363
0.0830301
0.0352698
0.0159224
-0.0140804
-0.0161289
0.00371925
-0.00318636
0.268065
-1.02251e-06
-0.0763355
0.0391872
0.00888985
-0.00162988
-0.0376825
0.352334
-0.0184033
0.0347918
-0.00177281
-0.0373584
2.95915e-05
0.174413
-0.0363612
-0.0208187
0.0318601
0.00272189
0.0352251
0.328532
0.197302
0.00041753
8.46807e-05
-0.0018229
-1.5244e-05
-0.0128874
-0.00199502
0.0305933
-5.98214e-06
-0.000666198
0.0475807
0.284957
-0.0217435
-4.73909e-07
0.347858
-0.0793768
-0.157077
-0.00126742
0.035954
-0.0323287
0.0219806
0.0964819
-2.03408e-06
0.0851953
-0.0241446
1.78499e-05
0.0125032
0.0124049
0.0297703
0.26818
0.330687
0.0013162
0.0345592
5.50187e-05
-0.0219659
-0.0268956
-1.09634e-05
0.0964142
-0.0925176
-0.0218637
-0.155367
-0.00226428
-3.40863e-07
0.00146653
0.00609226
0.227467
-0.0295734
-0.00109206
1.08329e-05
-0.00234601
3.10101e-06
-0.0209971
-0.0321693
-0.00527945
-0.0319566
-0.0252688
-0.0351673
-1.72295e-06
-0.0424067
-0.0020732
-0.0999613
0.0253576
-2.048e-05
-4.52773e-07
0.449749
0.303769
0.323923
0.193195
0.000215165
-0.000651598
0.00560376
-0.0374467
-7.29434e-06
0.239112
-0.0381622
-0.000228974
0.0329489
0.0532772
0.00335464
-0.170435
-0.0488809
0.153644
-0.186685
0.0174661
0.00266419
-0.222609
-0.224953
-0.0964057
-0.0698799
-0.037512
-0.0074837
0.110544
0.143368
0.0297946
-0.0443535
0.386572
-0.00374355
-0.0186598
-0.0340896
0.00232238
0.0724988
-0.0446252
-0.00627795
-0.0509406
-0.21837
0.0232075
7.15788e-06
-0.0353825
0.321257
-0.0338726
0.26586
0.193308
0.387036
0.0241588
-0.196772
0.318889
0.00818716
0.0859476
-0.000259875
-0.00185767
-3.46702e-05
-0.0472079
0.0586021
-0.102209
-0.0558506
-0.0390204
-0.0450614
-0.018194
-0.0106368
0.0587307
-0.0452406
0.000326521
-0.00619157
-0.21525
0.00117565
-0.0350432
-0.015074
0.352698
-1.44103e-06
-0.129588
-0.000121261
-0.00835228
0.00232465
-0.00872714
1.90835e-05
-0.0443819
-6.24971e-06
-0.00326337
0.0532368
-0.0167247
-0.0121178
-0.00871382
2.36102e-07
-0.0243035
0.0241812
-0.0352548
-0.0279571
-0.00388724
-0.00286976
-0.00064264
0.096732
-4.10172e-06
0.0193632
0.0165382
-0.065292
-1.61114e-06
-0.000384563
-2.72018e-06
-0.0486851
0.108103
-1.70265e-06
-0.00491764
3.48006e-06
-0.0316849
-0.0194118
2.15909e-05
-0.0249855
-0.0644035
0.486954
-2.04834e-05
0.0433701
0.000394139
-0.000210315
0.000150309
0.0535784
-0.0486476
-0.0467854
-0.0226366
0.198783
-0.0111298
0.0624078
-7.3119e-07
0.189934
-0.0206457
-1.87725e-06
-0.0971827
0.0561719
-6.76138e-05
-1.81308e-05
-0.0206719
-0.0300877
0.488125
-9.4319e-06
-0.0321113
-0.0222666
-4.82799e-06
0.000944041
-0.000137156
-0.0206578
0.137868
-0.0223638
0.017012
0.00191432
-0.00151487
0.240915
0.314925
0.000389257
-0.0304508
-0.0212122
0.212482
-0.0429952
-8.53292e-05
0.0412284
-0.111965
-0.0889179
-0.000382797
-0.0133496
0.00413555
0.00737118
-0.0985578
-0.0372026
-0.0467463
-0.0380433
0.0286374
-2.80575e-07
-0.00906833
0.485691
-0.000288443
-0.00387816
-0.00293163
0.345272
0.0774124
-2.72226e-07
-3.9157e-07
0.119684
0.119009
-0.0105218
-0.0604426
-0.0473659
-5.12281e-06
0.0129099
0.00416486
0.089379
-0.00135409
0.158666
-0.0159026
0.0101075
0.303075
2.2613e-05
-0.013686
-0.214537
-0.193164
-0.0150007
-0.00216578
0.249217
0.0419744
-0.0147652
-0.0349946
-0.069643
-6.83993e-06
0.128801
-0.000274716
-1.83109e-05
-0.0424737
0.04151
0.000339429
-0.00461917
-0.0572535
0.0863032
-0.00193412
-0.031385
-0.000137937
-0.0133421
5.42791e-05
-0.0365658
-0.000429385
-0.0155415
-0.0282407
0.123822
-0.00585343
-4.1056e-06
-7.57376e-05
0.449299
-2.18035e-06
-0.0429707
-0.0410348
0.212421
0.0205575
-0.000180812
-0.0104953
-0.026269
-0.0214603
0.0431501
-0.0436881
0.0676551
-0.00851503
-0.00559427
-0.0217805
-0.00909006
0.215243
0.000389487
-0.0127846
0.108198
0.0925064
0.3382
-0.0450194
-0.0225926
-0.00030117
-0.0449626
-0.0895556
0.0601012
-0.00370603
0.0180761
-7.16009e-05
0.00558639
-0.0015288
-0.0220545
-0.0233968
-0.0502256
-0.000754343
-0.0231618
-6.8126e-05
-0.00830805
-0.019622
-0.000305233
1.33912e-06
-0.0556419
0.426546
-0.0324771
-0.0170378
-0.00495211
-0.00130008
0.272743
0.020877
-9.77033e-07
-0.019014
-0.040089
-1.0205e-06
-0.00296631
-0.0238669
-0.00613326
-0.00191608
0.0837536
0.23157
0.233123
-0.0340053
-0.000470926
-0.038843
-1.7963e-05
0.131004
0.395884
6.19861e-06
-0.00269087
-0.0246638
0.413874
-3.57787e-06
0.208293
0.432525
-0.0195877
-0.00355212
-0.0044375
0.208881
-0.00410036
-0.0459644
0.348513
-0.00291153
0.229455
-0.00965528
-0.0107884
0.377934
0.0560302
0.215277
0.191832
0.000639695
6.04911e-08
0.133367
0.0469094
-0.00584742
-0.0336636
-0.0337636
-0.0284682
-0.0146867
0.21016
-0.00091682
-0.00208353
-0.104745
-0.109293
-0.0120903
-0.0589954
-0.110487
0.242472
0.0354387
0.0128896
0.361493
-2.83109e-05
-9.04418e-06
0.0354124
0.0267013
0.0391267
-3.89903e-05
0.00224697
-3.43498e-06
-0.118748
0.00461439
-3.95705e-06
-0.000541117
-0.000131105
-1.89783e-05
0.0550215
-0.00642723
-0.00105701
-0.0100621
-0.0281093
-0.00576491
-0.00170111
0.236727
-0.0196455
-0.0176513
0.00033344
-0.00607613
-9.22922e-06
-0.0455787
0.0878101
-0.0424036
0.0939468
0.00347296
0.0596419
0.112799
0.154164
-0.0102952
0.285554
-0.0137905
0.257264
-0.145287
-1.02633e-06
-0.0165607
-0.0195216
0.0145769
0.102938
-0.0350833
-0.000127584
0.470643
0.0031022
0.08423
-0.0260892
0.0156614
0.0514015
-0.000304133
-0.0237095
-0.0388127
0.000704793
-0.00018436
-0.00671866
-0.0326147
-0.00270719
-0.00280101
-0.0448644
0.126771
-0.00376927
-0.020748
4.93678e-08
0.373784
0.423157
0.00201854
-0.000168847
-0.0211512
-0.00823435
-0.0401132
-1.18464e-05
0.00886779
-0.0317166
-4.57397e-05
-0.000147126
-0.0666815
-0.000248016
-0.0183091
-0.033962
0.275172
-0.0351944
0.245129
-0.000234983
-0.00656021
-0.00904843
0.00964859
0.012037
-0.0712622
0.000305146
-0.00931512
0.199118
-0.0269928
-7.49953e-05
1.05505e-07
-0.00171167
-1.60712e-06
-0.043829
-0.00508216
0.00301263
-0.00200194
0.0794298
-1.29079e-05
-0.000155336
0.165934
0.19065
-0.015896
-0.000600058
0.137083
3.17514e-05
-4.26308e-05
0.00517217
-0.000320956
0.355257
-0.0233214
0.224354
-0.169479
-9.62945e-06
-0.00327508
0.322786
0.214046
0.00793535
-0.00237061
-0.00119584
0.085348
0.0168448
0.00660866
-0.000559158
-0.0658939
-0.0223291
-2.02432e-06
-0.0274874
-0.0416247
-0.0426214
-0.00296296
0.363081
-0.00616622
-0.0164797
-0.0405363
4.58269e-05
-5.82812e-07
0.000363083
-0.00867626
0.290535
-0.0173264
1.94805e-06
0.000173497
-0.07998
0.345595
1.68856e-05
0.000126152
0.00286663
-0.04487
0.325091
-0.0205371
0.24822
0.224981
1.67085e-05
0.211001
0.236658
-0.0245883
0.00764717
-3.62084e-05
0.246435
4.60041e-05
-7.61277e-06
-0.00329568
0.154762
-0.00541126
0.150088
0.000614509
0.360856
0.000567597
-1.44714e-06
0.477942
0.0229774
0.428343
0.0924277
-0.204614
0.0084958
-0.0454028
0.319463
-4.51197e-05
-2.01466e-05
0.0124751
-0.000191708
0.339947
-0.141452
-0.157319
0.000550004
0.0484414
0.080156
-0.0373414
0.0024898
-0.0293563
-0.00687682
0.0120168
-3.25536e-05
-0.00235307
-0.0475265
-0.0334241
-0.0597923
0.0117756
-0.0379308
0.0511976
0.0425292
0.39058
-0.0608531
0.0191745
6.67002e-05
-0.0301927
0.251949
-0.0375548
0.0749755
0.177931
-0.0430668
0.00680064
-0.0434251
-3.43842e-06
-0.00255762
-0.00202864
0.00288039
-0.00402578
-0.188884
3.61042e-06
0.103983
0.0645085
0.146188
0.0730116
0.188216
0.00559922
0.0231833
0.00760546
0.00925733
-0.0148885
-0.134009
0.0488088
0.242456
0.0249747
-0.00402229
-0.159161
0.06241
-0.0185161
-0.146936
0.146407
-0.00731909
-0.0345065
0.0952383
0.0206282
0.332456
-4.6267e-06
-6.63167e-07
-0.056584
0.254623
0.304114
0.207759
0.279132
0.0317815
-0.00753769
-0.018851
0.0252984
-0.0223497
-0.00875413
0.00597497
0.396739
0.00249177
0.248796
0.080481
0.00638307
2.61162e-06
-0.0142531
0.311855
-0.000683506
-0.00604478
0.0880306
-0.155894
2.78648e-05
-0.0137719
-0.100571
0.459441
-0.0425256
0.123665
0.0297657
-0.0168742
0.0552352
0.223204
0.305018
0.0894135
-0.0480091
0.0826184
0.071591
0.472506
0.000145878
-0.0103569
0.277314
-0.043703
0.217225
0.301366
0.000893725
-0.0249751
0.0995492
-1.76548e-05
0.320238
-0.00883539
0.285065
0.00504104
-0.00488294
-0.0440261
-0.000345752
0.475489
-1.27653e-05
-0.11865
0.241302
-8.70039e-05
0.0112765
-0.0160053
-0.0167448
0.11005
-0.00875588
-0.000727359
0.101045
-0.0270661
-0.000686467
-4.13267e-06
0.0722398
-0.000910662
0.168997
-0.0491116
-0.0378966
0.0479631
-0.000670095
-0.0931833
0.0369067
-0.0455299
0.180115
-0.00851933
-0.0127161
0.130786
-0.000122456
0.000506995
0.0689493
-0.00958453
0.00223932
0.0991066
0.343306
0.0447196
0.00377698
0.19347
0.308754
-0.00903381
-1.40827e-06
0.182919
-0.100231
0.00625977
-0.000208025
-0.044629
-0.000110728
-0.000171612
0.0274911
-0.00273297
-0.00346061
-0.0374382
-1.09026e-06
0.165717
-0.000153712
0.0104652
-0.166169
-1.23876e-05
-0.0861759
-0.0105197
-0.0636825
1.99248e-05
0.00658921
0.28962
0.330683
0.420315
-6.10154e-08
-0.0345722
3.23433e-06
2.01014e-08
-1.44704e-06
0.00014213
-0.000291777
-0.00145581
0.199884
0.0114835
-0.00107213
0.0237041
0.00442805
0.00105443
-0.0431019
-0.0327287
0.0810509
0.220805
-1.95703e-09
0.00333283
-0.113792
-7.8594e-07
-0.0167462
0.0292379
0.170515
-5.99748e-07
0.347263
-0.0126187
0.073256
0.0723796
5.98209e-05
0.121862
0.000656106
-0.0293113
0.436769
-0.000114805
-0.00177734
0.118976
-0.000124743
-0.0106204
-8.09288e-07
-0.000181386
0.000747177
-0.015128
-0.00101175
2.61494e-05
-3.36553e-07
-0.0203751
-0.0231371
-0.0603025
0.107895
0.0423829
-0.00538631
0.402625
0.00743363
0.341861
-0.0218706
0.420729
0.366477
0.386979
0.00554421
-0.00402203
0.00456515
-0.0109967
2.29454e-05
0.172151
-0.0503815
-0.000129399
0.167721
0.405151
0.118756
0.066862
-0.0915124
-0.0133222
-0.0314194
-0.0319392
-0.0152254
-0.00342258
0.369804
-9.30379e-05
0.462003
0.2168
-0.000236687
0.152335
-0.0480173
-0.0497536
0.123322
0.0366304
-0.0027503
0.116907
-0.00686927
0.248988
0.0497609
-0.000152248
-1.20265e-05
-0.0149729
-0.0771687
-9.04117e-07
-0.00377541
-0.185172
-0.000194396
-0.0133147
-1.11099e-06
-1.6286e-07
-0.0289028
2.85789e-08
-0.00233686
-0.00457407
-0.0105546
0.0328806
-0.0244836
0.00321171
-0.0486314
-0.0198664
-0.163554
0.0922393
0.0078481
0.00493102
0.262406
0.224139
-3.4434e-06
0.16907
-0.0255652
0.360029
0.180282
0.000647914
0.2548
0.376443
-3.89276e-07
0.163748
-0.0112699
0.00230219
-0.0367423
-2.13676e-06
-0.043606
-0.0407397
-0.00334313
-3.9051e-05
1.41481e-06
0.00551174
-0.000168082
-0.0421531
0.0462356
-1.20097e-06
-0.120894
-0.000239752
-0.00285734
-0.000449175
-0.00681385
-0.000234419
-7.77422e-06
0.387622
0.353618
0.0378109
-0.0218582
-0.0155123
-0.000568353
-0.000123916
5.79291e-06
-0.0012343
0.00438321
-0.0342403
-0.0182004
-0.177849
0.26553
-0.0380975
0.474442
8.91751e-05
-0.0242465
0.291471
4.93216e-05
-0.0832418
-3.6134e-06
-0.00395069
-9.47749e-08
-0.00238411
0.12036
1.0954e-05
3.44052e-05
0.123282
-0.011355
-0.00369003
-0.00563035
-0.00371965
-2.4561e-06
0.450426
-0.0375
0.194041
0.0897473
-0.00141477
0.248141
-1.09369e-06
0.0343206
-5.70405e-07
0.000882547
0.00407646
0.366497
-0.000260988
0.220324
0.00174218
-8.4473e-05
7.27819e-07
-0.0384227
0.274133
-5.29991e-07
0.00209771
-0.00405683
-0.0438751
-0.0367843
-0.209685
-0.015763
-0.0266109
-0.00633084
0.000637279
-0.134318
-0.188189
-0.00198108
-0.00318694
-3.1062e-06
4.47871e-05
-0.000272458
-4.35049e-07
0.0189083
0.000458915
0.000328223
0.265913
-0.000471574
-0.0189814
0.162683
-1.0876e-06
-0.00358841
-0.114999
0.436812
-0.0325258
0.169584
-0.0723792
0.227581
-0.00986036
0.319752
-0.0408298
-0.0603252
-0.00566918
0.381063
-0.0137557
-1.47751e-06
-4.79321e-06
0.120604
0.0221326
0.0999407
0.469561
-0.0405053
-0.0376071
0.297851
-0.000369651
0.0163621
-0.0188939
-0.00316909
-0.00319745
-0.0266722
-8.54056e-05
-0.0451466
0.115261
0.0955031
-0.00847936
-5.91343e-06
-5.52519e-06
-3.8634e-07
-0.0267992
1.24187e-05
-0.0227879
0.300808
-0.0319932
0.454253
-0.172291
-0.000558076
0.485695
-0.0225725
-0.00473493
-5.12228e-06
-0.000307443
-0.00330038
0.437807
0.449243
-0.0220423
-0.00569819
2.19589e-05
0.255652
0.14376
-0.0262487
0.0779101
-0.0168538
-0.00715804
-0.0275738
0.337854
0.326468
0.095556
-0.00337211
-0.000450299
-0.0180293
0.0157409
-0.000206025
0.264658
-0.00050704
-0.0218223
-0.0135967
-0.04766
0.0426264
-0.0581372
-0.003501
0.426409
0.121818
0.0944689
-0.0500098
-0.0557467
-0.0027876
-6.38231e-06
0.307454
-0.0111395
-0.00141279
-0.0217005
0.00153749
2.41333e-06
0.195605
0.0140237
-0.0388814
-0.0257912
0.124614
-0.0515396
-0.0050701
-0.00417907
0.452695
0.0752198
0.343156
-0.00022109
0.0687368
0.00590214
-0.0230822
0.231479
0.000457196
0.00782704
-0.0270012
0.0946226
-0.0184935
-0.0397972
-0.0700385
-0.0990852
-0.00964531
-0.0250005
0.339624
-0.0106557
-0.0419965
-0.0157075
-0.00675184
-0.150007
0.468468
-0.0037284
-0.00503433
-0.209541
-0.00205939
-0.0143423
0.0127099
-0.0229496
0.477387
0.329525
0.00528713
0.311095
0.328766
-0.00300929
0.00690612
0.0159956
0.0519916
-0.000206473
-0.00772143
-4.25052e-05
-0.0383248
-0.0480193
-0.033875
-0.00115281
-0.183315
0.25766
0.00662064
0.303093
0.340434
0.341402
6.34197e-06
-0.00317557
0.335472
-0.0074459
0.409224
0.291462
0.000532208
0.404937
-7.44019e-07
-0.0100129
-0.0126737
0.0144096
0.317347
0.000663294
-0.0228306
0.000579991
0.269049
-0.0244467
0.00663769
0.36649
-0.0179419
0.364717
-0.00939109
-0.0722857
0.296506
0.336998
0.173849
0.177505
-0.0637626
-0.00286119
-0.185019
2.10294e-05
0.375388
0.184447
0.250102
0.184873
0.418021
0.00733396
-0.161753
0.4
-4.59005e-06
0.414568
0.0776537
0.457899
0.39546
-4.09268e-06
-0.017917
0.351243
0.000382915
-0.00107874
-7.139e-07
-0.0709738
0.00515907
0.311882
-0.00448571
0.00571123
0.0843821
-0.0797602
-0.000251542
-0.0254061
0.356917
-0.0405327
0.330058
0.399955
0.304156
-0.147797
-0.0256205
-0.495699
0.187007
0.445787
0.73202
0.0932698
-1.09273
-0.181145
0.450835
-0.63448
-0.173593
0.213886
-0.736406
0.556765
-1.23343
-0.0627874
0.840154
-0.263654
0.313564
-0.102358
-1.50972
0.170837
0.747267
-0.0471067
0.396354
-0.123671
0.552134
-1.64482
-0.846496
0.705381
1.25477
1.80332
-0.454545
2.27441
-1.38417
0.546175
0.0276136
-0.253371
-0.0625975
-0.0511388
-1.69524
-0.0168918
-0.112619
-1.02644
-0.0448335
0.456752
-0.0510528
0.354733
-0.224608
-0.140438
-0.555386
-0.731624
0.129262
0.0496569
-0.187292
0.0350246
0.0999398
-1.28872
-0.240524
-1.19025
2.045
-0.057425
0.391092
0.199479
0.304184
-2.71934
-0.0079859
2.19485
3.14845
-0.30853
0.543918
0.173733
-0.166101
0.375307
-2.24708
-1.31755
1.47169
0.924141
-0.0261048
0.177138
0.226382
0.00596223
-0.763792
0.188389
0.249942
0.203948
-0.120471
-0.0578225
0.815164
-2.35702
-0.214512
0.198404
-0.0590524
0.439474
-0.208776
0.0626945
-0.186071
-0.523257
3.35715
0.580953
2.36373
1.13041
1.67758
-0.536724
-1.46662
0.576232
-0.519365
-0.417306
-0.0937818
-0.0771807
-1.62455
-0.192388
0.143237
0.902276
0.399293
-0.287646
0.778619
-0.0598062
-0.0939574
0.972188
0.308262
3.3628
-0.226395
2.48457
-0.125001
-2.78537
-1.68123
-0.170037
-0.144511
-0.287798
0.34169
-0.0945847
-0.0737548
0.348386
-0.24351
-0.192029
-0.492005
-0.0896075
-0.0832265
-0.538961
0.574759
-0.666483
0.812762
2.35849
0.936288
0.359654
1.48509
2.02841
-0.790976
-1.7206
0.0132724
0.209601
0.412004
0.311539
-1.42479
0.244262
0.214085
-0.235874
-0.0553497
-0.382877
-0.40215
0.0141187
-0.0921896
-0.311438
-0.0628188
-0.0573599
-0.38474
0.430784
0.284217
-0.00198827
-0.0510039
0.0971914
-1.73239
-0.303424
0.272297
0.221963
-3.10663
-0.0506697
0.295948
-0.0263545
0.0529614
2.60669
-0.0531875
-1.61468
-0.477367
-0.834512
-0.225427
-0.185794
0.163117
-0.0659688
-0.125538
-0.273038
-0.0827435
0.0213451
-0.248977
-0.448702
-0.434994
-0.0653672
0.0697673
0.949191
0.0371958
-0.149821
0.1165
-0.163185
0.0863801
0.114693
0.455679
-0.339088
-0.0581046
0.718396
0.50119
0.421295
0.645818
-0.115842
-0.0700587
-0.0132775
-0.0456685
0.773194
-0.500555
-0.348633
0.546459
-0.147373
-0.00560478
0.0429419
-3.09776
-0.757664
0.131069
0.139963
0.0489337
-0.124495
-0.128775
0.246288
0.261491
0.0252809
0.335538
0.0945467
0.684397
-0.521426
0.0907898
0.00779499
-0.00967133
0.350429
-2.48356
-0.197676
-0.407539
-0.097903
-1.57923
0.441266
-1.7429
0.777628
-0.27743
0.109041
-0.205065
0.393802
-0.357089
-0.106457
-0.410041
-0.27893
3.35198
-1.2387
-0.0589827
0.592765
1.14178
-0.141778
2.11693
-0.496812
-0.241887
1.69477
-0.274254
-1.29042
-1.20356
-1.42652
-2.3963
-2.22032
0.44607
0.02766
3.14698
0.382166
0.0397771
-0.416955
0.510605
-0.380994
2.84408
-0.23253
0.535822
0.0155254
-0.131867
0.0631919
-0.0595265
-0.135169
-0.668061
-0.325356
-0.0241254
0.127409
0.243002
0.228898
0.155647
0.478777
0.24825
-1.32805
0.30894
0.932392
-0.04891
0.306056
-0.240246
-0.0528066
0.109574
-0.284659
-0.319139
-0.10769
-2.97067
0.259536
-0.105806
-0.032224
-0.411117
0.329502
0.327172
0.192206
3.31023
-0.193416
0.401552
-0.238087
-0.162102
-0.0450676
0.202924
-0.605981
-1.7968
-0.0335592
0.126418
-0.068967
-0.122056
-0.202367
-0.196565
-0.104084
-0.541148
0.145823
0.586923
-0.119687
0.00986404
-1.47514
-1.28365
-1.70196
-0.442827
-2.51182
-0.254652
-0.0610668
-0.220032
0.479996
-0.265823
-0.291488
0.22837
-0.452068
0.175482
0.145143
1.20522
0.0137172
0.101531
0.994044
0.734641
-0.0125374
0.3668
-0.514257
0.235235
0.785671
2.714
1.33522
1.86939
-0.890791
-1.82023
0.0917487
-0.046509
-0.925281
0.812719
-0.0643285
-0.192923
0.167602
-2.69578
-0.0651828
0.148594
0.36455
-0.437691
0.488566
0.30863
-0.106561
0.169861
-0.0112848
-0.283487
-2.28178
0.094238
-0.0130745
-1.28274
0.393704
3.07623
-0.0743009
-0.97493
-0.901962
-0.481234
-0.207286
0.306014
-0.870564
0.225372
-0.124548
0.426877
0.975828
-1.26792
1.54477
-2.19744
0.13785
0.0134445
0.389248
0.564881
1.23328
-0.477226
-0.0463621
-0.243354
-0.355055
0.117922
0.312439
0.63997
0.0707397
0.0845838
0.836997
-0.174232
-0.164664
0.073433
-0.305312
-0.571368
0.139686
0.562297
1.98056
-0.666515
-0.487693
-0.353994
0.366351
0.0556081
0.278936
-0.198775
1.01043
0.137444
0.268394
-0.118104
0.404475
0.297935
0.1369
-0.186364
0.240526
-0.212634
0.0141636
0.0891408
0.627546
-0.441
0.224492
0.0481561
-0.813132
-2.50451
-1.77823
-0.147771
-0.0873285
-0.263271
-0.768788
-1.71709
-1.60833
0.123781
-0.16409
2.10026
-1.56931
-0.0287015
0.0839955
0.0611284
-0.783835
0.0344205
-0.0476717
-0.111944
-0.158147
-0.00621853
-0.0337282
0.127817
0.962924
1.09621
-0.201669
-0.221104
-0.107834
-0.260666
1.04057
-0.419944
0.318131
0.158616
-0.330278
-0.313253
-0.364786
-0.263985
-0.649048
0.455319
-0.179825
-0.0105559
0.327826
-3.07065
-2.60984
-0.166986
-0.0639352
0.375222
-2.46
0.0137003
-0.160297
0.196823
-0.381005
2.6117
0.0521829
-0.100137
0.0959562
2.73146
-1.83407
1.32159
-0.904609
0.772039
0.223854
0.279361
-0.216455
-0.0502238
0.0857885
-0.00478658
0.0279884
0.534391
0.119831
-0.00786023
0.448193
0.0977991
0.290082
-1.12689
-3.09403
-0.100083
-0.0706936
0.212388
-2.05236
0.0284206
-0.605904
0.220482
-0.117661
-0.214312
-0.0982279
-0.159736
0.240305
-1.77017
-0.160026
0.621584
-0.474364
-1.86205
-0.138087
0.0516752
1.16705
-1.67479
-0.15886
0.525573
-0.14005
0.911572
0.340179
1.46061
2.03529
-0.808719
-1.73844
-0.292497
0.42187
3.27359
-0.0765004
-1.57543
-0.270757
0.0578826
-0.209821
-0.072277
-1.76482
0.241573
-0.982759
-0.0831364
-0.0394538
-1.66326
-0.0628804
0.200302
-0.227285
2.63073
-2.47955
-0.244261
-0.0383999
-0.492981
-0.0394941
-0.201296
-0.262934
-0.394639
0.216511
-0.26513
2.62154
-0.288239
-0.182196
0.215836
0.367731
-0.211765
-0.0944856
-1.1547
0.235713
0.0809813
0.478157
0.1875
-0.164048
0.177296
0.371531
-0.0686152
0.424636
-1.45311
-1.68848
0.662068
0.714662
-0.307591
0.233059
-0.107944
0.262377
0.0496994
0.478099
-0.0408081
-0.367474
0.0763069
0.0810337
-0.158205
0.00805785
-0.821036
-0.0412985
1.14619
0.597236
1.71276
-1.99662
-1.06556
0.0847653
0.235363
-0.0506245
0.206
0.164097
-0.788041
-0.25044
-0.101442
0.434568
0.540774
0.0319565
-1.61776
-1.75356
0.989116
-0.0474491
0.746867
0.508092
-1.55104
0.429644
-0.429884
0.874074
0.209852
-0.233448
0.0767338
0.369008
-0.382756
0.509978
0.585054
0.427597
-0.129226
-1.70839
0.592319
-1.30683
0.130245
3.28335
-1.89948
-0.139119
-0.630466
0.647254
0.347421
-1.70264
0.0702021
-0.910708
-0.0974648
-0.340991
0.573241
-0.218307
0.577681
-0.00652385
-1.52332
-0.028456
0.22952
0.183249
-0.0958928
-0.0385595
0.0836934
-0.136883
-0.295181
-0.781417
-0.445111
-0.059198
-1.38243
-0.136917
1.87899
0.0227982
0.536767
0.262215
-0.202977
-0.0269628
0.2345
-1.01925
0.684819
-1.10421
0.87635
-0.233046
-0.310212
0.0377622
-0.141598
-0.197799
0.119409
-0.958246
-1.56353
0.330586
0.74604
0.394658
-0.307587
0.82691
0.358414
-1.55042
0.828057
-0.0358591
-0.0179907
0.157801
0.123528
-0.101885
0.142456
-0.267004
-0.00347714
-0.00969104
-1.63151
0.0774934
0.404802
-0.572076
-1.60423
0.55626
0.00271177
-0.0227306
-1.50939
-1.59731
-0.447123
0.618518
-0.237437
-0.449743
-0.356656
0.303321
0.205983
0.145253
0.195235
-0.332791
-0.383516
-0.556469
0.692353
-1.76065
0.205155
0.189634
-0.825364
0.110309
-2.01665
-0.274726
-0.113016
-0.49876
-0.0619239
0.4644
0.169512
-0.16426
-0.304685
-0.016454
0.289731
-0.381668
0.256434
0.216971
0.841254
-0.111612
-0.610506
-0.297284
0.0661046
0.411942
-2.91283
0.468988
-0.896033
-0.0536246
0.449058
-0.239952
-0.312187
-1.49014
-0.0947917
-0.3144
-0.0939381
-0.277431
0.552438
0.493778
-0.0230012
0.0624032
0.288633
0.841278
2.68068
1.39043
1.95254
-0.858073
-1.78768
-0.1517
0.797447
0.276462
-0.283255
0.419458
0.809389
-0.625615
-0.208045
-0.028828
0.320508
-2.42268
0.287307
0.707754
0.636978
-0.130279
-0.0975432
-0.473558
-0.00333019
-2.0403
1.65335
-1.11055
1.11003
0.561246
0.0385622
-0.244748
0.0974936
-0.144316
0.0794147
0.378449
0.389835
0.73488
-0.249056
0.267083
-0.0246255
-0.787206
-0.170942
0.301293
-0.0422357
0.048147
-0.840611
0.314222
-0.069086
-0.118458
-0.122156
0.602207
3.0052
0.0842227
0.0889811
1.1418
0.290183
-0.0882317
0.000462861
0.989556
0.238771
-0.0588612
-1.55575
0.207269
0.149607
0.298808
-0.0357032
-0.377767
-0.0815929
0.19839
-0.0664449
0.288268
0.735793
-0.701934
0.210428
-0.683753
-0.263227
-0.201222
0.0582847
0.158504
0.0702384
-0.341228
-0.108229
-0.91401
0.448865
-0.324062
0.207007
0.16234
0.671
-0.0168881
-1.55236
-0.118744
0.191104
-0.396379
-1.36885
-0.00453939
-0.0233419
0.00421757
0.198436
0.0896536
0.0622685
0.34595
0.151387
-1.58503
0.271465
0.134068
0.394362
0.113274
0.159405
0.0981004
0.329994
0.245344
-0.641942
0.224215
0.233011
0.439125
-0.228225
-0.487329
0.6473
0.134806
-1.18566
-0.774935
-1.44818
0.331887
0.504126
0.182244
0.0605575
-0.15524
0.17542
-1.97351
0.0407836
-0.0283622
0.277381
0.295822
0.327251
-0.0239188
3.34109
-1.36438
0.114656
0.759779
1.30372
1.85262
2.21792
-1.32056
-0.391034
2.20232
0.559629
-0.921121
-0.105173
0.38747
-1.07781
0.362914
0.085479
-0.241828
-0.0697396
-0.0549792
-0.117735
0.418057
0.110772
0.0218252
-0.332672
-1.01379
-0.0327284
-0.145715
-2.17685
0.144553
0.207621
0.162753
-0.295171
0.946742
-0.397422
-0.246917
-1.35999
-0.0773452
-0.175652
0.574419
0.257612
0.757537
0.208933
0.807667
0.408905
-0.281725
0.288124
-0.00749964
0.25259
-0.182439
-0.0804484
-0.44848
-0.20738
0.575049
0.305546
0.117604
0.109737
-0.362785
-0.134139
0.271858
-0.281383
-0.242097
-0.437501
-1.46773
0.338798
-0.095032
0.385809
0.00297513
0.468218
0.151437
0.0978308
0.620588
-0.333335
0.0790755
0.165584
-0.353328
0.103872
-0.321526
0.237501
0.25334
0.585472
0.217105
0.287904
-0.133485
0.143912
0.494369
-0.12059
-0.0857635
-0.252868
0.232458
1.22747
-0.412672
0.0848948
0.0772895
-3.06361
2.73386
1.02163
-1.65221
0.313332
-1.21843
0.680798
0.791879
-1.22908
0.414367
0.0683859
-0.560419
-1.15742
-0.750695
-0.0804449
0.238781
0.256917
-0.672125
0.417935
0.751034
0.0192106
-0.0147324
0.082146
0.671947
3.17702
0.436114
0.623428
-0.254961
-0.0548901
-0.856301
-0.313571
0.325153
0.276091
0.729304
0.315352
-0.223084
-0.435053
-0.133827
2.20963
1.83136
-1.33474
-0.40495
2.28675
1.28246
0.731245
-0.0281004
1.8775
2.01014
-0.0921449
0.539878
0.48253
-0.116434
-0.323662
0.138532
0.499974
-0.259767
-0.263066
0.0781357
0.138227
-1.81221
0.350595
-0.0127542
-1.72743
-0.400378
-1.43608
0.438292
0.710029
0.0242649
0.129061
1.92663
-0.196626
0.183875
0.012968
0.705502
0.0700653
-0.079402
-0.0909286
0.475827
-0.179761
-0.380375
0.489754
0.596542
-0.0641341
-0.702758
0.0744948
-0.133065
0.399683
0.620906
0.0695418
-0.0451392
-0.269899
-0.295946
0.206361
0.178123
-0.227434
0.224965
-0.470268
0.153182
0.293484
-0.232744
-0.0333416
0.260163
0.218159
0.293181
-1.52901
-0.127668
-0.0968726
-0.222084
0.0364424
-0.0289703
0.30056
-0.0405116
0.799213
-1.58276
0.256915
0.174607
-0.136357
0.248322
-0.122599
0.495046
0.666968
0.662733
-0.424764
-0.665099
0.230221
0.0385993
-0.074747
-0.0740657
0.485055
-0.447585
0.0683463
-0.818073
-0.0478627
-0.398353
-0.159416
-0.200893
-0.0895795
0.219696
-0.216513
0.268033
-2.68596
-0.0665847
0.153301
-0.320753
0.567474
0.199363
-0.876844
-0.0417929
0.547328
-1.60572
0.150529
-0.0330542
-0.275806
-1.07135
-0.995864
-0.312598
0.152092
-1.48248
-0.35627
-0.0711348
0.786113
0.158951
-0.329914
0.213701
0.473863
0.0955854
-0.233402
-0.0684639
0.0906205
0.328479
1.26167
-0.0378079
0.0767378
-0.127254
0.00155097
-0.323668
0.241112
-0.0265885
-0.108103
-0.557913
-0.0410802
-0.326295
0.0448177
-0.015712
0.00395974
3.49596
-0.0292249
0.382162
-0.565079
-0.146143
-0.0869605
0.270774
-0.00846632
-0.0907119
-0.310992
-0.129691
-0.097369
-1.60745
1.1168
-2.04344
-0.186449
0.297985
0.0135717
-0.277855
-0.140607
-0.0328211
-0.137004
-0.161786
-0.0762098
-0.104444
0.220098
-0.243155
-0.0680499
0.282632
-0.365384
0.144807
0.639354
-0.327158
0.334244
-0.25123
0.148435
-0.177466
0.278809
-0.245791
-1.20653
-0.264439
-0.854332
0.238004
-0.0432482
-0.160152
-0.486193
-0.096911
-0.364564
-0.163821
-1.56531
0.176887
0.154801
0.768835
0.171352
-0.310089
-0.422845
-0.931264
0.296759
0.101396
0.424607
0.378951
-0.0483303
-0.0703459
0.132436
-0.364027
-0.205692
-0.417074
0.557751
-0.359407
0.34095
0.261732
-0.0993334
-0.165572
-0.139145
0.57614
0.492214
0.634186
0.196325
-0.0398461
-0.348885
-0.274555
0.0818393
0.307834
-0.112782
-0.330958
-0.179331
-0.297037
0.599828
-0.176694
0.0047197
-2.80852
-0.306613
-0.456151
-0.745713
0.0420249
-0.13147
-0.121971
-0.100767
-0.161581
0.268116
-0.432428
-0.819453
2.80325
-1.30023
0.468794
-0.174261
-0.251829
-0.0679647
1.51568
-0.375277
-0.104912
-0.0867635
-1.10156
-0.960824
-2.00649
-0.261477
0.0536692
-0.154163
-0.185453
2.08497
-1.11504
-1.08894
2.49757
-2.02705
-1.71343
-0.774694
-1.42696
-0.27715
-0.43887
-2.35758
-0.18948
-0.317095
0.107029
-0.156545
-0.412987
0.195754
0.330703
-0.0934681
-0.129762
-0.428946
0.369546
0.177595
0.240679
0.155545
-0.27007
-0.150471
0.196648
-0.179357
0.128525
-0.145311
0.221529
-0.0980591
-0.0390691
-0.295141
0.191664
0.0177651
-0.401871
-0.197786
0.189511
-0.00844309
-0.0835762
0.00575016
-0.24882
0.0371005
0.150699
-0.0690872
-0.520218
-0.0751096
-0.20177
0.0562199
0.519739
-0.0208567
-0.0952057
0.299152
-0.0449355
0.0895395
-0.0644244
-0.026916
-0.110425
-0.060504
0.110883
0.0896616
-0.152748
-0.107195
-0.374459
0.0294171
-0.133649
-0.199192
-0.0684738
0.543735
0.0857689
-0.0934556
-0.218073
-0.10641
-0.283313
-1.16091
-1.2495
-0.0299734
-0.1916
-0.198404
0.338137
-0.124035
-0.0717392
0.0864724
-0.179443
-0.0835363
-0.0537029
2.97366
-0.0520374
0.041044
-0.113691
-1.81976
-0.15871
-0.351724
-0.0609386
0.662575
0.300099
-0.12054
0.358509
0.534758
0.0125106
-0.228795
-0.0198176
-0.162061
0.425485
0.430393
-0.0652562
-1.364
-0.263727
-0.083546
0.266621
0.205359
-0.0299518
-0.100715
0.235887
-0.072265
0.974172
0.217116
-0.387899
0.698875
0.271593
-0.0359823
0.173921
0.00997351
-0.0896391
-0.139598
-0.0796379
-0.237368
0.817236
-0.467806
-0.184829
0.44352
0.327882
-0.154242
0.0860655
-0.13347
0.114376
-0.802977
-0.141418
-0.0700922
0.144137
-0.0783954
0.543763
-0.0740254
-0.0671454
0.473763
-0.407985
-0.173768
-0.0364425
-0.265296
-0.0593198
-0.0849403
-0.0628666
-0.523097
-0.168166
-0.144646
-1.56804
-1.95685
-0.109645
-0.22216
0.206231
-0.487388
-0.0546798
-2.55176
-0.35952
-0.0621953
-0.145444
-0.528622
-0.1271
-0.120831
-0.0619658
0.548771
0.732423
-0.0870148
0.359826
-1.20843
-0.0562358
-0.344674
-0.847717
0.14693
0.181046
0.149894
0.408429
0.320607
-0.84643
-0.118767
0.0986848
-0.0708261
-0.0651433
-0.161696
-0.0500328
-0.0411384
-0.169567
-0.064169
-0.0727304
-0.46716
-0.165344
-0.576337
-0.756274
0.347659
-0.0403371
-0.10124
-0.524037
-0.0778416
0.314452
-0.0535074
-0.600991
-0.0674667
-0.175188
0.720305
0.342746
-0.268137
-0.0613227
-0.180016
-1.07985
-0.0369994
-0.583662
0.123547
-0.257197
-0.121439
-0.228225
-0.309604
-0.0551124
-0.622316
0.622178
-0.405788
-0.00374377
-0.0838896
-0.136336
-0.0609359
-0.134892
-0.0520645
2.65455
0.588496
-0.216346
-1.04398
-1.04139
-0.0684794
-0.492231
-0.191692
-0.108793
-0.0488756
-0.099186
0.628973
0.667252
0.471824
0.199144
-0.887153
0.175236
0.331597
0.302965
0.339415
-1.60822
0.429124
0.257111
-0.0850588
0.239625
0.34423
-0.0750627
-0.0544331
-0.26414
-0.0534122
0.295765
-0.0667976
0.590728
-0.343017
-0.0726918
-2.15245
-0.155911
-0.366143
0.508738
0.81311
0.261861
0.42209
-0.10708
-0.0518746
-0.966479
0.357874
-0.0764443
0.193961
-0.538899
-0.830091
0.145892
-0.0469598
0.219726
0.304203
-0.213448
-0.112148
0.570594
-0.40029
-0.0612495
0.415166
0.158126
0.149239
-0.0565478
-0.0823302
0.430659
0.189187
0.932023
-1.72432
0.653475
-0.528035
0.403053
-0.081273
-0.0544762
0.405831
0.0464894
-0.426326
-0.693244
-0.0682277
-0.177403
0.106971
0.0990876
-1.71915
0.388325
-0.0411711
0.147079
-0.0412636
-1.31379
-0.0441285
-0.0784738
0.0820456
0.581207
-0.701126
0.381908
-0.193487
-0.0823051
-0.0867722
1.01374
-0.0446089
-1.2351
-0.11664
-0.0853704
-0.534148
0.0767252
0.0787223
-0.162315
-0.541493
0.0617662
-0.114802
-0.178724
-0.0582331
0.315911
-0.122668
-0.198494
0.542875
-0.126963
-1.08873
0.338539
-0.15775
0.414501
0.404285
0.26364
-0.135898
0.00969002
-0.460798
-0.0895072
-0.451344
-0.0280334
1.3488
-0.0883264
-0.0279697
-0.00333576
-0.0626182
-0.0570211
0.0343272
-0.308723
0.216247
-0.00962015
-0.310637
0.355871
-0.0890417
-0.0710992
0.508297
-0.0916545
-1.13176
-0.0766276
0.722428
-0.444313
-0.748453
0.39381
0.484873
-1.36253
-0.0951818
-0.0649797
-0.106313
-0.0542631
-1.19564
-0.0327742
-0.0857141
-0.0551102
-0.489338
-0.0413032
-0.384915
0.402317
0.593169
-0.0825827
0.513502
0.476583
-0.293787
-0.101884
0.365119
-0.860493
-0.0923658
-0.0645129
-0.661772
0.390073
0.109867
-0.0563408
-0.14362
-0.0916663
0.512152
-0.303077
-0.16166
-0.107298
0.333058
0.451459
-0.331263
-0.275715
-1.32018
-0.119768
2.46967
0.339227
-0.83959
-0.0691121
-0.273323
-0.167509
0.081474
-0.0630554
0.292378
-0.0628749
-0.084271
-0.0833828
0.310338
0.0396141
-0.290309
-0.368028
-0.461322
-0.0643785
-0.191467
-0.245484
-0.0923173
0.401949
-0.120677
-0.127948
0.367498
-0.253558
-0.168714
-0.0491007
-0.0590191
-0.372005
-0.063677
-0.130185
-0.0913247
-0.766656
0.282627
-0.693635
0.128237
-0.104987
-0.0610642
-1.00972
0.318067
-0.0931658
-0.398816
-0.252719
-0.0759271
-0.0384418
-0.061878
-0.339385
-0.0848165
-0.081226
-0.080351
0.478596
0.209169
-0.19004
0.0559252
-0.151757
0.258049
-0.138201
0.660009
-0.0819966
-1.08491
-0.115873
-0.0827001
-0.14762
-1.77014
-0.175002
-0.38351
-0.69341
0.151733
-0.12862
-0.544054
-1.2777
-1.62143
-1.47657
-0.980336
1.91898
2.44003
-2.19139
-1.90121
-0.157344
-1.0731
-0.624407
-0.0454637
-0.107194
0.280622
-0.625775
-0.110949
-0.185077
-0.0777358
0.188857
0.3744
-0.340028
0.235847
0.172769
-0.0750338
-0.0767628
0.210709
-0.218027
-0.0696617
-0.0813714
0.143138
0.329594
-0.416017
-0.114745
-0.0424676
-0.28018
0.579859
-0.296087
0.249841
-0.111825
0.187324
0.21995
0.372624
-0.294977
0.739556
-0.0710283
-2.11263
-1.13439
0.562164
0.19562
-0.0534919
0.120356
0.190711
0.404084
-0.135998
0.744296
0.214454
-0.253179
-0.037672
0.0246997
0.00264541
0.0491977
0.0738087
-1.29622
-0.2498
0.559031
-0.0961927
-0.903375
-0.294692
-0.136264
-0.1535
0.105099
-0.215625
-0.29417
-0.404344
0.538305
0.056689
-0.179392
-0.105183
-0.0398651
0.229289
0.526122
-0.572289
0.161072
-0.0766534
-0.0834737
-0.0835915
-0.925562
-0.106095
-0.197886
-0.015443
-0.180776
-0.254925
0.19077
-0.0760838
-0.0435178
-0.148637
-0.0762213
-1.58354
-0.0845653
0.129284
0.102081
-0.0549796
-0.0362668
-0.0458821
-0.0528808
-0.120634
-0.552883
0.0281242
-0.0337265
-0.00274799
0.634422
0.0727694
-0.747503
-0.208552
-0.348144
-0.287668
-0.177274
-0.0368639
0.354396
-0.404688
0.332576
-0.299942
0.414915
-0.0668979
-1.00264
0.269247
0.491208
0.399887
1.48714
-0.0904094
-0.171189
-0.255805
-0.213516
-0.330563
-0.191832
-1.54467
-0.138402
-0.209335
-0.340353
-0.224126
-0.824617
-0.769142
-0.0998671
0.49008
-0.0702874
-0.396131
0.566099
0.512512
-0.769262
-0.205814
1.37172
-0.699236
-0.0691567
0.519309
0.495011
-0.448667
0.362395
1.88557
-0.0493498
-0.196656
0.69248
0.39138
-0.0940032
-0.471963
-0.288571
-0.12209
-0.0926437
-0.0612883
-0.242619
0.0873942
0.685118
0.41959
0.543404
-0.279156
-0.103698
-0.24438
0.595825
-0.235106
0.309466
0.151236
-1.00389
-0.338362
-0.12357
0.815977
-0.582309
-0.580598
-0.78013
0.336503
0.335322
-0.214651
-0.392604
-0.427933
0.729632
-0.132328
0.947547
-3.04586
-0.492629
0.291287
-0.270623
0.243122
-3.11598
0.26663
-0.807496
-0.107015
0.288058
1.05568
-0.0198323
0.0761728
0.248151
-0.49264
-0.0672449
0.416806
-0.217012
0.227831
0.354346
0.408146
0.0378545
0.460162
0.273188
0.296334
0.335431
0.213912
0.159461
0.196774
0.254925
0.266214
0.392704
0.65307
0.225276
-0.106035
-0.441125
0.472339
-0.36994
-0.0767557
0.53966
-0.257346
0.276854
0.191927
0.311803
-0.3118
0.356024
0.133656
-0.449409
-0.952915
-0.169822
0.189965
-0.489732
0.554248
-1.08101
-0.313921
0.332521
0.14787
0.167993
-0.0451224
-0.561314
0.100445
-0.0448402
2.83669
0.112387
0.143669
-0.1741
0.599859
0.0739641
0.12859
-0.5497
0.0520638
-0.315413
0.0824781
0.186653
0.0960117
0.292386
0.0746814
0.352003
1.10372
0.0260637
-0.584872
0.686482
-0.600004
0.0537962
0.399265
0.120772
-0.0507885
-1.48966
-0.10926
0.434536
0.405888
-0.662837
-0.276016
0.145012
0.400034
-0.0128674
-0.0120054
0.282423
-0.482527
-0.183665
-0.0229879
0.0246297
0.17926
-0.762884
-0.275575
0.375635
-0.634786
-2.36598
-0.86583
-0.223369
0.328203
-0.0207214
-0.576347
-0.0488187
-0.199917
-0.299118
-0.520095
-0.306899
-0.638901
0.378856
0.367024
-0.0533111
-0.134424
-0.37282
0.0941989
0.633264
-1.13066
0.598136
0.576889
0.519335
-0.0964684
-1.65141
0.385351
-0.082572
-0.27733
0.139452
0.336872
-0.124892
0.408734
-0.161444
-0.598263
-0.695113
-0.151356
-0.357744
0.482308
-0.158601
-0.0694328
0.393424
0.519272
0.660415
-0.170278
-0.795561
0.376247
0.499585
0.681664
0.0283765
-0.186686
-0.0517424
0.507716
-0.0603266
-1.60888
0.485032
0.37014
-0.163084
-0.242986
0.472834
0.540584
0.540332
3.26513
0.411447
-0.65393
-0.236217
0.374065
-0.218843
-0.754495
0.496579
0.185252
0.453325
-0.236463
-0.539055
-1.13975
-1.58393
-0.264141
0.490426
0.436941
0.0239648
3.19392
-0.408445
0.347574
-2.05579
-0.0374156
-0.212551
-2.85587
-0.866951
-1.86096
-0.0815226
0.431169
0.535504
-0.607564
-1.72517
-1.08491
0.379083
-0.926791
-0.0435851
-0.0236614
-0.713446
-0.169915
-0.743694
-1.20016
-0.144108
0.374633
-1.59224
-0.617242
-0.14028
-0.634194
0.637553
0.509855
-0.449492
-1.19955
0.332631
-0.0262064
0.602559
-0.0687258
-0.626065
-1.11462
0.38955
-0.690179
-0.184654
0.353426
-0.067129
0.472292
-0.113828
0.0368232
-0.18385
-0.220747
-1.69283
-0.590959
-1.22557
0.421137
0.779925
0.047969
-0.538713
0.536366
0.690578
-0.4102
-1.63747
-0.553465
0.885319
-0.234733
0.561176
0.166903
-0.347969
0.264736
0.383245
0.338167
0.628553
0.31071
0.3926
0.346313
0.00999562
0.276632
-0.223006
0.22693
-0.623693
-0.0639407
0.551867
0.201836
0.134092
0.584881
-0.461979
-0.501103
-0.214267
0.442548
-0.504797
-0.336027
-1.52967
0.438794
0.503332
0.324653
0.151938
-1.00775
-0.386012
0.340573
-0.933372
-0.0554291
0.407939
-0.18822
-0.0540854
0.163042
0.112583
-1.73554
0.344763
0.45516
0.371922
0.00137436
0.457939
0.499294
0.213512
0.148451
-0.113161
-0.723439
0.572697
-0.182552
0.623722
-1.4369
0.522344
-0.802857
-0.919145
-0.57573
-0.0291319
0.952539
0.112963
0.0438108
0.211872
-0.624404
-1.70809
2.62139
1.91686
-2.19299
-1.27629
-0.886679
-1.81783
-0.777074
1.17258
-0.329729
1.71814
-0.202393
0.263752
0.623674
0.542782
0.0770619
0.216304
0.22332
0.606659
-1.42555
-3.93665
0.498295
0.496986
0.0701874
-0.0455258
0.642389
0.513647
-0.473178
0.641679
0.230927
0.615752
0.667603
0.0275385
-0.545642
0.0830388
-0.0623332
0.313214
0.276865
0.130234
0.597823
1.09412
0.165172
-0.306762
-0.708764
0.185992
0.122718
0.012419
0.703492
-0.701452
0.310986
0.261209
0.247588
-0.0110618
-0.854087
-0.104894
-0.860394
0.174231
-0.660069
-1.40557
-0.231339
-0.021634
0.571665
0.703311
0.244865
0.18636
0.168271
-0.0230391
0.332333
-0.232962
-0.077257
-0.790384
0.119177
0.0450432
0.253502
-1.8534
0.316078
0.127217
0.338284
2.48457
-1.6062
2.2092
-0.676134
1.63188
1.08602
0.53698
0.359136
0.00315434
-1.49012
-0.338516
0.34306
0.00206628
-1.4449
0.547452
0.147746
-0.0865128
0.271091
0.340156
0.284129
0.155387
0.517948
0.345872
0.310573
0.251833
0.529273
-0.0673029
-2.13822
0.286837
1.02911
-1.84203
0.884403
0.213297
0.252499
0.35224
0.184772
0.229984
0.510804
-0.091359
0.00163102
-1.53005
-0.0564011
0.259125
-1.23496
0.252906
-0.272505
-0.111169
0.363753
0.285714
-0.737272
0.418986
0.200435
2.9976
-2.27372
-0.0260487
0.446142
-0.689754
-0.179435
-0.178797
0.37615
-0.664266
0.0131461
1.34221
-0.0590669
-0.108913
-0.0610582
0.487131
-0.138987
-0.0569724
-0.332951
0.396851
0.559081
0.388467
-0.148728
0.211204
-1.07871
-0.648273
-0.467822
0.152835
0.269858
-0.250217
0.159652
-2.60417
-0.0538614
0.274902
-0.658536
-0.129352
-0.530492
0.791495
0.174139
-0.368393
0.0916624
-0.0567833
-1.26089
-0.298403
0.148321
-0.482263
-2.93389
-0.0573187
0.0975924
0.127649
-0.0799791
-0.297734
0.131732
0.127353
-0.234096
0.367048
0.533042
0.0847531
-0.462087
0.127048
-2.05384
0.0434537
-0.0395816
0.00710537
-0.0498954
-0.24454
-0.295296
-0.225841
-0.293532
0.478209
-0.261586
0.305206
0.215184
-1.63401
-0.260477
0.444721
0.462887
-1.29152
-2.3699
-0.219278
0.337018
0.0112165
-0.257438
1.15986
-0.526291
-0.0126357
0.967885
0.265456
0.359498
-0.11344
-1.78866
0.177189
0.341357
0.00361862
0.480935
-0.59125
-0.689454
-0.0715102
0.14281
-1.40053
-0.0427142
-0.152918
-2.85918
-0.0434027
-0.37863
-0.378918
0.389664
0.00092343
-0.143268
-0.430031
0.488768
0.304677
-0.0579888
-1.15549
-0.556279
0.354456
0.350806
0.0385922
0.6115
0.33937
0.242381
-0.164658
0.188819
0.501327
2.16936
-0.112643
-0.710593
-0.104542
0.896893
-1.11806
0.585632
0.246199
-0.181966
-1.25535
-0.933909
-0.105162
-0.457563
0.603784
-0.26762
1.04436
0.288867
0.152744
-0.0850873
-1.91288
-1.61436
0.504286
-1.29961
-0.287783
-1.01515
-0.188717
-2.20541
-0.251621
0.107231
0.296374
0.47375
0.362702
-1.11487
0.26669
1.01892
0.225909
-0.957852
-0.134746
-0.275254
0.438897
0.252695
-1.55107
-0.760453
-0.335249
-1.6366
-1.6706
0.45423
-0.232647
0.183693
-0.474227
-0.482421
-0.249207
-0.263856
0.395781
-1.59032
0.480711
0.0756611
0.140887
-0.305006
-0.408042
0.313187
-0.0976575
0.463709
0.411702
-1.02378
-0.00448196
1.20002
0.480566
0.588097
0.934125
0.219531
0.691832
0.457532
-0.472743
0.515284
-0.723147
0.286637
0.461236
0.0292703
0.187439
-1.96183
0.0852589
-0.1888
0.0183326
0.483469
-0.22113
1.37199
-0.228016
-1.79041
-0.170573
-1.58052
-2.6906
-0.674825
0.607944
0.101431
0.517802
-0.272067
-0.185646
-0.751379
-0.424926
-1.00939
-0.054307
-0.0280637
-0.073577
0.32422
-1.47404
-0.0651573
0.288207
0.0445548
0.425263
-2.81188
-1.04287
-0.104377
1.59307
0.151812
-0.345689
0.340805
0.258839
-0.397709
0.134123
0.23554
-1.05822
-0.125414
-0.226086
0.460453
0.566511
-0.0122054
-0.399422
0.306107
0.499175
-0.315289
2.79042
-1.61202
-1.99527
1.21171
0.164151
-0.20166
-1.13038
-0.0296093
0.257774
0.196564
0.228337
0.0276806
0.565376
0.0286825
-0.173866
0.147007
-1.19725
0.543996
-0.426804
0.0494938
-0.679919
0.122307
0.20792
0.237625
-0.381668
0.157399
0.467389
0.491688
1.28197
0.423102
-0.237981
0.162256
0.0872402
0.263685
0.144243
0.308799
-0.0549704
0.108777
-1.0304
-0.025513
-1.11507
-1.34743
0.376862
0.0807024
0.0443219
-0.124838
-0.353396
-1.66315
0.0732343
-0.296479
-0.0513318
0.254721
0.202146
0.252166
-1.95188
0.106527
-1.06457
0.105411
0.272934
1.92402
-0.521766
0.408027
0.445147
-1.93199
-0.134374
0.245052
0.666106
-0.0648806
0.415797
0.349176
-0.258438
0.281491
-0.465204
1.723
0.63901
0.79347
-0.547818
-0.149729
-1.34056
0.58731
0.0118303
-0.024387
0.133478
0.648464
0.52777
-1.43606
-0.0638502
1.04634
0.545498
1.27515
-0.997043
-0.00171979
0.167483
0.214712
-0.582777
0.00484782
-0.255805
0.0335643
-0.099496
1.31753
1.39157
-0.962625
-1.17553
0.367522
-1.74073
-0.613448
0.0242271
-0.304518
0.200544
-0.923544
0.112103
-0.943378
0.85171
0.616575
-0.933684
0.681288
-1.5024
-1.60836
0.0242469
0.892751
0.328339
0.218172
-0.565778
0.634295
0.135437
-0.0477615
0.0149084
0.156675
-0.606234
0.0685742
0.70443
-1.78496
0.510494
0.431978
-0.111676
0.0920194
-0.339781
1.54126
4.81947
0.118613
0.0151655
-0.123853
0.012189
-0.156881
0.8798
-0.410338
-0.0136969
-0.200806
-0.0885176
-0.908428
-1.63701
3.57099
0.318457
3.55091
-0.0398897
-0.102415
-2.13438
-0.5722
3.26131
-0.251486
-0.417683
-0.450071
-0.119191
-0.0390699
0.350487
-1.59851
-1.35793
-1.96062
-2.2431
-0.519481
-1.30837
2.27271
0.00338666
-2.39182
0.277686
-1.11681
-1.44583
-0.381447
-0.210271
-0.46077
-0.135775
-1.15153
0.364233
-0.79168
-2.39496
-2.08051
2.27613
2.92402
-0.874631
2.47876
0.0328166
0.119796
-0.436768
-1.80412
2.8497
3.25123
3.03264
2.6137
-1.72124
-1.38905
0.624655
0.615982
-1.03151
0.647154
-2.04511
-2.92912
-2.65644
-0.669283
1.45834
1.19588
-2.26506
1.71493
1.74407
1.72117
2.70278
0.909498
1.36653
1.1642
1.03305
3.07629
1.96827
1.17337
0.817521
0.486346
2.99324
1.89686
1.58195
2.32916
-2.66085
0.580612
-2.13666
0.27872
-0.382771
0.869746
1.09942
0.511525
-0.244422
-2.5105
-0.254685
0.928731
0.119997
0.430256
-0.253015
1.82263
-0.504009
0.0672408
-0.295128
0.043557
0.779465
-0.520562
0.437115
-0.512223
-0.953865
-0.13794
0.159147
-0.177821
0.118883
1.16187
0.105188
-0.0583181
-0.165066
-0.371909
0.496036
0.0373764
0.382349
-0.542324
-0.0186355
0.257601
0.21385
0.163238
-0.0573606
0.256638
0.0126972
-2.32355
-0.754689
0.080664
0.310543
0.738056
0.870328
-0.908142
0.358042
0.0808136
-0.0682448
0.107964
1.54249
0.00403592
-0.220858
0.624191
1.3287
-0.430078
0.278138
-1.92783
0.304281
-0.530582
0.833632
-0.105256
-2.98866
-0.0560878
1.87024
-0.138324
0.762076
0.177448
-3.21394
0.0620281
-0.588355
-0.233657
-0.196665
-0.0221348
0.952836
3.00631
0.467969
3.1039
1.29835
0.463264
-0.297872
-2.81223
1.99573
-0.176738
-0.170669
-1.83174
0.634767
0.144516
0.916903
0.430411
-0.382559
3.12265
-0.00549991
0.162286
0.511789
-0.439226
-0.144889
-0.0448364
0.458959
-0.0348053
-0.399073
-0.292457
-1.46488
0.437132
-0.0638182
0.165678
-2.21136
-0.264876
-0.0604771
-0.0665152
-0.415006
0.248971
0.667073
-0.899135
-1.82913
1.77407
1.2159
-0.976015
-0.188058
-0.488616
0.501095
-0.291528
-0.766989
-1.58141
-0.0935291
0.133829
-0.112638
-0.170856
-2.56855
0.181029
0.0872804
0.602589
-0.0186866
-0.240301
0.296489
-3.5198
-0.267272
-0.029511
0.161782
-1.41529
0.163779
-0.133042
0.323226
-0.0457298
0.0509249
0.159415
-0.609823
0.889822
0.276993
0.340806
3.22115
-0.520702
-0.0942515
-0.515704
-0.356718
-0.22445
0.840101
0.210064
-0.0560557
-3.58664
-0.279946
0.274731
-0.276803
-0.532475
-2.92167
-0.0391096
0.173295
-0.112718
0.309243
0.325472
-0.0249714
-0.0842106
-2.70729
-1.81679
0.167517
-0.849572
-2.61514
-0.0403766
0.7986
0.445388
-0.124701
0.0266939
2.30783
0.508617
-0.0677309
-1.46562
1.07497
0.199997
3.7857
-0.0770016
-0.12636
-0.0126896
-2.35245
-0.0184502
-2.95685
0.655599
0.894309
0.297238
-0.223452
0.502808
-0.222935
0.1143
-0.915129
-0.146968
0.309665
-0.820248
-0.227001
0.232925
-1.61947
-0.166086
-1.61253
1.1591
0.365586
-0.128866
-0.226668
0.04419
-0.283182
0.165134
-0.0759146
-0.114036
-1.9752
0.153965
-1.86986
-0.32478
-0.288312
0.339508
-0.0759258
-0.259158
-0.920392
-0.0490277
-0.0443882
-0.0438996
-0.304711
0.793432
0.432352
-0.0680869
-0.261609
-0.638392
1.01462
-0.170741
-2.5064
0.163935
-3.03505
-0.0548207
-0.163214
-0.619372
-0.95729
0.149706
0.744789
0.0968784
-0.0765618
-0.0885741
-0.0720709
-0.00656955
-0.20434
-0.249855
-0.352769
0.311094
0.0453335
-1.43186
-0.201388
-0.543694
0.700003
-0.0777155
0.365861
-0.670218
-0.598516
-1.36942
-0.0306187
-2.57772
0.307125
0.00691962
2.19045
1.55159
0.0923242
-0.918297
0.373021
0.199327
-0.0297107
-0.268906
-0.0889409
-0.0571535
-0.284819
-1.63087
0.339841
-2.46244
0.162883
0.254933
0.605342
-0.0258439
-0.277543
0.433278
0.342899
0.257249
-0.057294
-0.49018
0.0444389
-0.00441545
-0.77527
-0.272126
-0.50208
0.182538
0.090313
-0.0359744
-0.601773
-1.64761
-0.036492
0.561615
-1.96281
1.18682
-0.084194
0.129013
0.17218
0.352764
-0.193944
-2.12039
1.41635
-0.147542
-2.96438
0.453799
-0.566436
0.102713
-0.0256654
-0.296064
-0.0302055
0.168359
-1.0171
-0.374206
0.221578
4.46962
0.296108
0.226628
-0.103064
0.138714
0.43507
-1.13729
0.430643
-1.44586
-1.42187
0.268114
-0.0575766
-0.536187
0.0627719
0.30355
0.38095
-0.0179511
0.395471
1.46117
-2.72289
-0.250382
0.0888854
-0.248478
-0.12027
-0.8508
0.985607
3.91909
-0.104858
-0.111126
0.597851
-0.0815503
-0.571446
-2.26522
-0.214395
-0.19896
3.4416
-0.230386
1.65623
-0.161883
-0.570419
-0.22972
3.2946
-1.48099
-0.556568
-1.14399
-1.52622
-1.39412
-1.6687
-2.07319
-0.065089
-0.233372
-1.76371
-2.07031
0.0108535
0.0138857
-0.222842
-2.32798
-0.363139
0.299251
-1.2909
2.71219
2.41301
-0.473537
-1.21463
0.556954
2.54909
-0.834624
-1.14098
-2.65254
-1.78512
-2.34365
-0.739763
0.315781
-0.596901
-0.855585
-2.37519
3.05352
2.16748
3.20101
2.68331
0.606433
2.9575
0.831768
-2.14251
2.93219
0.549557
1.65148
2.97901
1.10254
1.92714
1.09832
1.38035
1.70578
2.37142
1.38995
0.420845
0.968557
1.15498
1.64227
1.90213
0.841029
1.51736
-2.48695
0.282537
0.341516
0.870442
-0.550982
0.511333
0.165503
-0.0582314
-0.107336
0.600872
0.587266
3.52011
-0.646005
-0.295788
-0.319718
-0.273047
-0.638078
-1.89037
0.147151
0.583632
-0.0902244
1.39248
0.622231
0.125012
-0.290703
-0.201399
2.62612
0.319148
0.489197
0.199907
-0.448142
0.263711
-0.0827792
0.339416
-2.69696
-2.8859
-0.383591
-0.00750534
0.0376846
0.828205
-0.115634
1.12748
-1.30184
0.013484
0.228302
0.302755
-0.189632
1.87107
-1.52682
0.287131
0.451376
2.12469
0.0343624
-2.47444
0.505489
0.285739
-2.0163
0.502213
0.396472
-1.27747
0.362398
-0.168359
0.12144
-0.258324
-0.47053
-1.73794
-2.38525
0.199477
-0.309337
0.282553
-1.38007
-0.268985
-0.108469
-0.191815
-0.0253733
-2.12918
2.40593
-1.41567
-1.19527
-0.486673
-0.236703
-0.035241
0.291155
-0.588605
-0.0822972
0.334609
0.248139
-0.598025
-0.0118721
-0.297351
-1.09901
0.39263
0.4655
-0.0281601
-0.0123741
0.0909457
0.267525
0.240319
-1.9071
0.213624
-0.640426
0.26468
0.147551
2.34712
-0.301242
-0.276286
-1.69233
-1.06364
0.181357
0.283906
-0.0892861
-0.657366
-0.241958
-0.320892
-0.272455
0.432548
-0.344887
-1.40434
-0.126978
0.0712715
0.345432
-1.94253
0.8999
-0.471041
0.0068752
-0.911649
0.0982535
0.86207
-0.0542146
-2.83171
0.14503
-0.259176
1.41158
-0.0583876
0.214845
-0.375583
-0.0505408
-1.28571
0.262714
0.630356
-0.248947
-2.7937
-1.69499
-1.88433
-2.83497
0.183208
-0.242484
0.0583752
-2.26994
0.270873
3.0884
-1.66681
0.338654
2.92647
0.0283448
0.0830711
0.20853
-1.6304
0.116801
3.36494
0.327293
0.0811189
0.592503
0.0966288
3.48779
-0.0735531
-0.748323
-0.0386445
1.61591
0.18772
0.584729
0.0984091
0.19341
0.331878
-2.78147
0.110392
-2.59866
)
;
boundaryField
{
frontAndBack
{
type empty;
}
bottom
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
top
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
car
{
type zeroGradient;
}
}
// ************************************************************************* //
| [
"kmeyer299@gmail.com"
] | kmeyer299@gmail.com | |
14e028f93d31266955ea42f1862f4d817bcc5858 | 860df3974f39dbdf012b9af58e98d93f99f12252 | /OpenGLWrapper/Plane.cpp | 73d958d55a82b096f9a0ab3abc7c284ddeab3eb4 | [] | no_license | CoDevLearners/PlanB | 8036d1580fc10718cece3fe41f7f2d0903b09317 | 39bc874a0be51896e163f0497d7815658f075107 | refs/heads/master | 2023-02-21T04:29:31.941397 | 2021-01-14T12:47:22 | 2021-01-14T12:47:22 | 322,607,950 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,393 | cpp | #include "Plane.h"
namespace glwrapper
{
Plane::Plane(float width, float height)
{
glGenBuffers(1, &m_vbo);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
float hw = width * 0.5f;
float hh = height * 0.5f;
Vertex data[] = {
// xy nor tex coord
{ -hw, -hh, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f },
{ +hw, -hh, 0.f, 0.f, 0.f, 1.f, 1.f, 0.f },
{ -hw, +hh, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f },
{ +hw, +hh, 0.f, 0.f, 0.f, 1.f, 1.f, 1.f },
};
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Plane::~Plane()
{
glDeleteBuffers(1, &m_vbo);
}
void Plane::Bind() const
{
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
EnableAttributes();
}
void Plane::Unbind()
{
DisableAttributes();
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void Plane::Draw()
{
glDrawArrays(GL_TRIANGLE_STRIP, 0, VERTEX_COUNT);
}
void Plane::EnableAttributes()
{
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, STRIDE, (void*)POS_OFFSET);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, STRIDE, (void*)NOR_OFFSET);
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, STRIDE, (void*)UV_OFFSET);
}
void Plane::DisableAttributes()
{
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
}
}
| [
"pkk1113@naver.com"
] | pkk1113@naver.com |
7eca6b7a68e550fe7c77fda0e9e3d316e1b1c0af | 3cce14d478c47b4856f31d14b58c3914d434fb03 | /MSCL/source/mscl/Communication/OperatingSystemErrorCodes.h | 85878eda29db892c1dc4bd8046afa842775b55aa | [
"MIT",
"OpenSSL",
"BSL-1.0"
] | permissive | skconan/MSCL | 12ac5dc669b6cb2da6b6733f5ff225369d5e134b | 6eb6f352d58e8efacbdf734e2b58db89b033b152 | refs/heads/master | 2020-04-08T19:43:38.798242 | 2018-09-05T11:32:59 | 2018-09-05T11:32:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 547 | h | /*******************************************************************************
Copyright(c) 2015-2018 LORD Corporation. All rights reserved.
MIT Licensed. See the included LICENSE.txt for a copy of the full MIT License.
*******************************************************************************/
#pragma once
namespace osErrorCodes
{
#ifdef _WIN32
//Windows specific error codes
static const int FILE_NOT_FOUND = 2;
static const int ACCESS_DENIED = 5;
#else
//Linux specific error codes
static const int FILE_NOT_FOUND = 2;
#endif
} | [
"richard.stoneback@lord.com"
] | richard.stoneback@lord.com |
2410f8e59b76bcc61d0ab59bbc59280ac18aca04 | 443fd6ad57a3a998f916e707bd4b47c3193deb3d | /chilkat/include/CkSpiderW.h | 703d239dadef8103b2a35262ef8594b18e87a872 | [] | no_license | michrasulis/BitsensingApp | a68fb72e8c72ed1bb4a428b78c438e441a3a6fa5 | b60043b50fd65b7c65526de1941dc2e43fce92fb | refs/heads/main | 2023-08-22T08:59:07.289800 | 2021-11-02T14:28:43 | 2021-11-02T14:28:43 | 423,867,447 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,130 | h | // CkSpiderW.h: interface for the CkSpiderW class.
//
//////////////////////////////////////////////////////////////////////
// This header is generated for Chilkat 9.5.0.88
#ifndef _CkSpiderW_H
#define _CkSpiderW_H
#include "chilkatDefs.h"
#include "CkString.h"
#include "CkClassWithCallbacksW.h"
class CkTaskW;
class CkBaseProgressW;
#if !defined(__sun__) && !defined(__sun)
#pragma pack (push, 8)
#endif
// CLASS: CkSpiderW
class CK_VISIBLE_PUBLIC CkSpiderW : public CkClassWithCallbacksW
{
private:
bool m_cbOwned;
private:
// Don't allow assignment or copying these objects.
CkSpiderW(const CkSpiderW &);
CkSpiderW &operator=(const CkSpiderW &);
public:
CkSpiderW(void);
virtual ~CkSpiderW(void);
static CkSpiderW *createNew(void);
CkSpiderW(bool bCallbackOwned);
static CkSpiderW *createNew(bool bCallbackOwned);
void CK_VISIBLE_PRIVATE inject(void *impl);
// May be called when finished with the object to free/dispose of any
// internal resources held by the object.
void dispose(void);
CkBaseProgressW *get_EventCallbackObject(void) const;
void put_EventCallbackObject(CkBaseProgressW *progress);
// BEGIN PUBLIC INTERFACE
// ----------------------
// Properties
// ----------------------
// When set to true, causes the currently running method to abort. Methods that
// always finish quickly (i.e.have no length file operations or network
// communications) are not affected. If no method is running, then this property is
// automatically reset to false when the next method is called. When the abort
// occurs, this property is reset to false. Both synchronous and asynchronous
// method calls can be aborted. (A synchronous method call could be aborted by
// setting this property from a separate thread.)
bool get_AbortCurrent(void);
// When set to true, causes the currently running method to abort. Methods that
// always finish quickly (i.e.have no length file operations or network
// communications) are not affected. If no method is running, then this property is
// automatically reset to false when the next method is called. When the abort
// occurs, this property is reset to false. Both synchronous and asynchronous
// method calls can be aborted. (A synchronous method call could be aborted by
// setting this property from a separate thread.)
void put_AbortCurrent(bool newVal);
// If set the 1 (true) the spider will avoid all HTTPS URLs. The default is 0
// (false).
bool get_AvoidHttps(void);
// If set the 1 (true) the spider will avoid all HTTPS URLs. The default is 0
// (false).
void put_AvoidHttps(bool newVal);
// Specifies a cache directory to use for spidering. If either of the
// FetchFromCache or UpdateCache properties are true, this is the location of the
// cache to be used. Note: the Internet Explorer, Netscape, and FireFox caches are
// completely separate from the Chilkat Spider cache directory. You should specify
// a new and empty directory.
void get_CacheDir(CkString &str);
// Specifies a cache directory to use for spidering. If either of the
// FetchFromCache or UpdateCache properties are true, this is the location of the
// cache to be used. Note: the Internet Explorer, Netscape, and FireFox caches are
// completely separate from the Chilkat Spider cache directory. You should specify
// a new and empty directory.
const wchar_t *cacheDir(void);
// Specifies a cache directory to use for spidering. If either of the
// FetchFromCache or UpdateCache properties are true, this is the location of the
// cache to be used. Note: the Internet Explorer, Netscape, and FireFox caches are
// completely separate from the Chilkat Spider cache directory. You should specify
// a new and empty directory.
void put_CacheDir(const wchar_t *newVal);
// If equal to 1 (true), then the query portion of all URLs are automatically
// removed when adding to the unspidered list. The default value is 0 (false).
bool get_ChopAtQuery(void);
// If equal to 1 (true), then the query portion of all URLs are automatically
// removed when adding to the unspidered list. The default value is 0 (false).
void put_ChopAtQuery(bool newVal);
// The maximum number of seconds to wait while connecting to an HTTP server.
int get_ConnectTimeout(void);
// The maximum number of seconds to wait while connecting to an HTTP server.
void put_ConnectTimeout(int newVal);
// The domain name that is being spidered. This is the domain previously set in the
// Initialize method.
void get_Domain(CkString &str);
// The domain name that is being spidered. This is the domain previously set in the
// Initialize method.
const wchar_t *domain(void);
// If equal to 1 (true) then pages are fetched from cache when possible. If 0, the
// cache is ignored. The default value is 1. Regardless, if no CacheDir is set then
// the cache is not used.
bool get_FetchFromCache(void);
// If equal to 1 (true) then pages are fetched from cache when possible. If 0, the
// cache is ignored. The default value is 1. Regardless, if no CacheDir is set then
// the cache is not used.
void put_FetchFromCache(bool newVal);
// If the last URL crawled was redirected (as indicated by the WasRedirected
// property), this property will contain the final redirect URL.
void get_FinalRedirectUrl(CkString &str);
// If the last URL crawled was redirected (as indicated by the WasRedirected
// property), this property will contain the final redirect URL.
const wchar_t *finalRedirectUrl(void);
// The number of milliseconds between each AbortCheck event callback. The
// AbortCheck callback allows an application to abort any method call prior to
// completion. If HeartbeatMs is 0 (the default), no AbortCheck event callbacks
// will fire.
int get_HeartbeatMs(void);
// The number of milliseconds between each AbortCheck event callback. The
// AbortCheck callback allows an application to abort any method call prior to
// completion. If HeartbeatMs is 0 (the default), no AbortCheck event callbacks
// will fire.
void put_HeartbeatMs(int newVal);
// Equal to 1 if the last page spidered was fetched from the cache. Otherwise equal
// to 0.
bool get_LastFromCache(void);
// The HTML text of the last paged fetched by the spider.
void get_LastHtml(CkString &str);
// The HTML text of the last paged fetched by the spider.
const wchar_t *lastHtml(void);
// The HTML META description from the last page fetched by the spider.
void get_LastHtmlDescription(CkString &str);
// The HTML META description from the last page fetched by the spider.
const wchar_t *lastHtmlDescription(void);
// The HTML META keywords from the last page fetched by the spider.
void get_LastHtmlKeywords(CkString &str);
// The HTML META keywords from the last page fetched by the spider.
const wchar_t *lastHtmlKeywords(void);
// The HTML title from the last page fetched by the spider.
void get_LastHtmlTitle(CkString &str);
// The HTML title from the last page fetched by the spider.
const wchar_t *lastHtmlTitle(void);
// The last-modification date of the last URL spidered.
void get_LastModDate(SYSTEMTIME &outSysTime);
// The last modification date/time from the last page fetched by the spider.
void get_LastModDateStr(CkString &str);
// The last modification date/time from the last page fetched by the spider.
const wchar_t *lastModDateStr(void);
// The URL of the last page spidered.
void get_LastUrl(CkString &str);
// The URL of the last page spidered.
const wchar_t *lastUrl(void);
// The maximum HTTP response size allowed. The spider will automatically fail any
// pages larger than this size. The default value is 250,000 bytes.
int get_MaxResponseSize(void);
// The maximum HTTP response size allowed. The spider will automatically fail any
// pages larger than this size. The default value is 250,000 bytes.
void put_MaxResponseSize(int newVal);
// The maximum URL length allowed. URLs longer than this are not added to the
// unspidered list. The default value is 200.
int get_MaxUrlLen(void);
// The maximum URL length allowed. URLs longer than this are not added to the
// unspidered list. The default value is 200.
void put_MaxUrlLen(int newVal);
// The number of avoid patterns previously set by calling AddAvoidPattern.
int get_NumAvoidPatterns(void);
// The number of URLs in the component's failed URL list.
int get_NumFailed(void);
// The number of URLs in the component's outbound links URL list.
int get_NumOutboundLinks(void);
// The number of URLs in the component's already-spidered URL list.
int get_NumSpidered(void);
// The number of URLs in the component's unspidered URL list.
int get_NumUnspidered(void);
// If true, then use IPv6 over IPv4 when both are supported for a particular
// domain. The default value of this property is false, which will choose IPv4
// over IPv6.
bool get_PreferIpv6(void);
// If true, then use IPv6 over IPv4 when both are supported for a particular
// domain. The default value of this property is false, which will choose IPv4
// over IPv6.
void put_PreferIpv6(bool newVal);
// The domain name of a proxy host if an HTTP proxy is used.
void get_ProxyDomain(CkString &str);
// The domain name of a proxy host if an HTTP proxy is used.
const wchar_t *proxyDomain(void);
// The domain name of a proxy host if an HTTP proxy is used.
void put_ProxyDomain(const wchar_t *newVal);
// If an HTTP proxy is used and it requires authentication, this property specifies
// the HTTP proxy login.
void get_ProxyLogin(CkString &str);
// If an HTTP proxy is used and it requires authentication, this property specifies
// the HTTP proxy login.
const wchar_t *proxyLogin(void);
// If an HTTP proxy is used and it requires authentication, this property specifies
// the HTTP proxy login.
void put_ProxyLogin(const wchar_t *newVal);
// If an HTTP proxy is used and it requires authentication, this property specifies
// the HTTP proxy password.
void get_ProxyPassword(CkString &str);
// If an HTTP proxy is used and it requires authentication, this property specifies
// the HTTP proxy password.
const wchar_t *proxyPassword(void);
// If an HTTP proxy is used and it requires authentication, this property specifies
// the HTTP proxy password.
void put_ProxyPassword(const wchar_t *newVal);
// The port number of a proxy server if an HTTP proxy is used.
int get_ProxyPort(void);
// The port number of a proxy server if an HTTP proxy is used.
void put_ProxyPort(int newVal);
// The maximum number of seconds to wait when reading from an HTTP server.
int get_ReadTimeout(void);
// The maximum number of seconds to wait when reading from an HTTP server.
void put_ReadTimeout(int newVal);
// If equal to 1 (true) then pages saved to the cache. If 0, the cache is ignored.
// The default value is 1. Regardless, if no CacheDir is set then the cache is not
// used.
bool get_UpdateCache(void);
// If equal to 1 (true) then pages saved to the cache. If 0, the cache is ignored.
// The default value is 1. Regardless, if no CacheDir is set then the cache is not
// used.
void put_UpdateCache(bool newVal);
// The value of the HTTP user-agent header field to be sent with HTTP requests. The
// default value is "Chilkat/1.0.0 (+http://www.chilkatsoft.com/ChilkatHttpUA.asp)"
void get_UserAgent(CkString &str);
// The value of the HTTP user-agent header field to be sent with HTTP requests. The
// default value is "Chilkat/1.0.0 (+http://www.chilkatsoft.com/ChilkatHttpUA.asp)"
const wchar_t *userAgent(void);
// The value of the HTTP user-agent header field to be sent with HTTP requests. The
// default value is "Chilkat/1.0.0 (+http://www.chilkatsoft.com/ChilkatHttpUA.asp)"
void put_UserAgent(const wchar_t *newVal);
// Indicates whether the last URL crawled was redirected. (true = yes, false =
// no)
bool get_WasRedirected(void);
// The "wind-down" phase begins when this number of URLs has been spidered. When in
// the wind-down phase, no new URLs are added to the unspidered list. The default
// value is 0 which means that there is NO wind-down phase.
int get_WindDownCount(void);
// The "wind-down" phase begins when this number of URLs has been spidered. When in
// the wind-down phase, no new URLs are added to the unspidered list. The default
// value is 0 which means that there is NO wind-down phase.
void put_WindDownCount(int newVal);
// ----------------------
// Methods
// ----------------------
// Adds a wildcarded pattern to prevent collecting matching outbound link URLs. For
// example, if "*google*" is added, then any outbound links containing the word
// "google" will be ignored. The "*" character matches zero or more of any
// character.
void AddAvoidOutboundLinkPattern(const wchar_t *pattern);
// Adds a wildcarded pattern to prevent spidering matching URLs. For example, if
// "*register*" is added, then any url containing the word "register" is not
// spidered. The "*" character matches zero or more of any character.
void AddAvoidPattern(const wchar_t *pattern);
// Adds a wildcarded pattern to limit spidering to only URLs that match the
// pattern. For example, if "*/products/*" is added, then only URLs containing
// "/products/" are spidered. This is helpful for only spidering a portion of a
// website. The "*" character matches zero or more of any character.
void AddMustMatchPattern(const wchar_t *pattern);
// To begin spidering you must call this method one or more times to provide
// starting points. It adds a single URL to the component's internal queue of URLs
// to be spidered.
void AddUnspidered(const wchar_t *url);
// Canonicalizes a URL by doing the following:
// Drops username/password if present.
// Drops fragment if present.
// Converts domain to lowercase.
// Removes port 80 or 443
// Remove default.asp, index.html, index.htm, default.html, index.htm,
// default.htm, index.php, index.asp, default.php, .cfm, .aspx, ,php3, .pl, .cgi,
// .txt, .shtml, .phtml
// Remove www. from the domain if present.
bool CanonicalizeUrl(const wchar_t *url, CkString &outStr);
// Canonicalizes a URL by doing the following:
// Drops username/password if present.
// Drops fragment if present.
// Converts domain to lowercase.
// Removes port 80 or 443
// Remove default.asp, index.html, index.htm, default.html, index.htm,
// default.htm, index.php, index.asp, default.php, .cfm, .aspx, ,php3, .pl, .cgi,
// .txt, .shtml, .phtml
// Remove www. from the domain if present.
const wchar_t *canonicalizeUrl(const wchar_t *url);
// Clears the component's internal list of URLs that could not be downloaded.
void ClearFailedUrls(void);
// Clears the component's internal list of outbound URLs that will automatically
// accumulate while spidering.
void ClearOutboundLinks(void);
// Clears the component's internal list of already-spidered URLs that will
// automatically accumulate while spidering.
void ClearSpideredUrls(void);
// Crawls the next URL in the internal list of unspidered URLs. The URL is moved
// from the unspidered list to the spidered list. Any new links within the same
// domain and not yet spidered are added to the unspidered list. (providing that
// they do not match "avoid" patterns, etc.) Any new outbound links are added to
// the outbound URL list. If successful, the HTML of the downloaded page is
// available in the LastHtml property. If there are no more URLs left unspidered,
// the method returns false. Information about the URL crawled is available in
// the properties LastUrl, LastFromCache, and LastModDate.
bool CrawlNext(void);
// Creates an asynchronous task to call the CrawlNext method with the arguments
// provided. (Async methods are available starting in Chilkat v9.5.0.52.)
// The caller is responsible for deleting the object returned by this method.
CkTaskW *CrawlNextAsync(void);
// Returns the contents of the robots.txt file from the domain being crawled. This
// spider component will not crawl URLs excluded by robots.txt. If you believe the
// spider is not behaving correctly, please notify us at support@chilkatsoft.com
// and provide information detailing a case that allows us to reproduce the
// problem.
bool FetchRobotsText(CkString &outStr);
// Returns the contents of the robots.txt file from the domain being crawled. This
// spider component will not crawl URLs excluded by robots.txt. If you believe the
// spider is not behaving correctly, please notify us at support@chilkatsoft.com
// and provide information detailing a case that allows us to reproduce the
// problem.
const wchar_t *fetchRobotsText(void);
// Creates an asynchronous task to call the FetchRobotsText method with the
// arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
// The caller is responsible for deleting the object returned by this method.
CkTaskW *FetchRobotsTextAsync(void);
// Returns the Nth avoid pattern previously added by calling AddAvoidPattern.
// Indexing begins at 0.
bool GetAvoidPattern(int index, CkString &outStr);
// Returns the Nth avoid pattern previously added by calling AddAvoidPattern.
// Indexing begins at 0.
const wchar_t *getAvoidPattern(int index);
// Returns the Nth avoid pattern previously added by calling AddAvoidPattern.
// Indexing begins at 0.
const wchar_t *avoidPattern(int index);
// To be documented soon.
bool GetBaseDomain(const wchar_t *domain, CkString &outStr);
// To be documented soon.
const wchar_t *getBaseDomain(const wchar_t *domain);
// To be documented soon.
const wchar_t *baseDomain(const wchar_t *domain);
// Returns the Nth URL in the failed URL list. Indexing begins at 0.
bool GetFailedUrl(int index, CkString &outStr);
// Returns the Nth URL in the failed URL list. Indexing begins at 0.
const wchar_t *getFailedUrl(int index);
// Returns the Nth URL in the failed URL list. Indexing begins at 0.
const wchar_t *failedUrl(int index);
// Returns the Nth URL in the outbound link URL list. Indexing begins at 0.
bool GetOutboundLink(int index, CkString &outStr);
// Returns the Nth URL in the outbound link URL list. Indexing begins at 0.
const wchar_t *getOutboundLink(int index);
// Returns the Nth URL in the outbound link URL list. Indexing begins at 0.
const wchar_t *outboundLink(int index);
// Returns the Nth URL in the already-spidered URL list. Indexing begins at 0.
bool GetSpideredUrl(int index, CkString &outStr);
// Returns the Nth URL in the already-spidered URL list. Indexing begins at 0.
const wchar_t *getSpideredUrl(int index);
// Returns the Nth URL in the already-spidered URL list. Indexing begins at 0.
const wchar_t *spideredUrl(int index);
// Returns the Nth URL in the unspidered URL list. Indexing begins at 0.
bool GetUnspideredUrl(int index, CkString &outStr);
// Returns the Nth URL in the unspidered URL list. Indexing begins at 0.
const wchar_t *getUnspideredUrl(int index);
// Returns the Nth URL in the unspidered URL list. Indexing begins at 0.
const wchar_t *unspideredUrl(int index);
// Returns the domain name part of a URL. For example, if the URL is
// "http://www.chilkatsoft.com/test.asp", then "www.chilkatsoft.com" is returned.
bool GetUrlDomain(const wchar_t *url, CkString &outStr);
// Returns the domain name part of a URL. For example, if the URL is
// "http://www.chilkatsoft.com/test.asp", then "www.chilkatsoft.com" is returned.
const wchar_t *getUrlDomain(const wchar_t *url);
// Returns the domain name part of a URL. For example, if the URL is
// "http://www.chilkatsoft.com/test.asp", then "www.chilkatsoft.com" is returned.
const wchar_t *urlDomain(const wchar_t *url);
// Initializes the component to begin spidering a domain. Calling Initialize clears
// any patterns added via the AddAvoidOutboundLinkPattern, AddAvoidPattern, and
// AddMustMatchPattern methods. The domain name passed to this method is what is
// returned by the Domain property. The spider only crawls URLs within the same
// domain.
void Initialize(const wchar_t *domain);
// Loads the caller of the task's async method.
bool LoadTaskCaller(CkTaskW &task);
// Re-crawls the last URL spidered. This helpful when cookies set in a previous
// page load cause the page to be loaded differently the next time.
bool RecrawlLast(void);
// Creates an asynchronous task to call the RecrawlLast method with the arguments
// provided. (Async methods are available starting in Chilkat v9.5.0.52.)
// The caller is responsible for deleting the object returned by this method.
CkTaskW *RecrawlLastAsync(void);
// Moves a URL from the unspidered list to the spidered list. This allows an
// application to skip a specific URL.
void SkipUnspidered(int index);
// Suspends the execution of the current thread until the time-out interval
// elapses.
void SleepMs(int numMilliseconds);
// END PUBLIC INTERFACE
};
#if !defined(__sun__) && !defined(__sun)
#pragma pack (pop)
#endif
#endif
| [
"mich@umich.edu"
] | mich@umich.edu |
6172966ed39719f3f91bb573eae569f894ec6dbd | 9e3183cdcbf0a5a49d9b9c4b6e0aff98ce3b5f10 | /i-b/2_pointers/arr_3_p/cpp_soln.cpp | 9135877c7c78cd532dc5a8cad2e0d61a679ade0a | [] | no_license | rsubbu55/coding-prep | 612e04eb6b2f88b45180b52704ac63a8784b6faa | d3a4b23e3b8dbdfed2d282ef5bc3393e522c5171 | refs/heads/master | 2022-08-14T19:40:43.552177 | 2022-07-20T14:30:29 | 2022-07-20T14:30:29 | 84,912,107 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,569 | cpp | def binsearchidx(A, l, r, key):
#import pdb; pdb.set_trace()
mid = l + (r-l)/2
while l <= r:
mid = l + (r-l)/2
if A[mid] > key:
r = mid -1
#return binsearchidx(A, l, r, key)
elif A[mid] < key:
if mid +1 < r and A[mid+1] > key:
break
else:
l = mid + 1
else:
break
return mid
def _3waymax(a, b, c):
return max(abs(a-b), abs(a-c), abs(b-c))
class Solution:
# @param A : tuple of integers
# @param B : tuple of integers
# @param C : tuple of integers
# @return an integer
def minimize(self, A, B, C):
minsofar = _3waymax(A[0], B[0], C[0])
#minonA
i = 0
j = 0
k = 0
for i in range(0, len(A)):
j = binsearchidx(B, 0, len(B)-1, A[i])
k = binsearchidx(C, 0, len(C)-1, A[i])
if _3waymax(A[i], B[j], C[k]) < minsofar:
minsofar = _3waymax(A[i], B[j], C[k])
#minonB
i = 0
j = 0
k = 0
for j in range(0, len(B)):
i = binsearchidx(A, 0, len(A)-1, B[j])
k = binsearchidx(C, 0, len(C)-1, B[j])
if _3waymax(A[i], B[j], C[k]) < minsofar:
minsofar = _3waymax(A[i], B[j], C[k])
#minonC
i = 0
j = 0
k = 0
for k in range(0, len(C)):
i = binsearchidx(A, 0, len(A)-1, C[k])
j = binsearchidx(B, 0, len(B)-1, C[k])
if _3waymax(A[i], B[j], C[k]) < minsofar:
minsofar = _3waymax(A[i], B[j], C[k])
return minsofar
| [
"sramachandran@riverbed.com"
] | sramachandran@riverbed.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.