diff --git a/pool/shard006/C++/0083647_UIPathSelector.cpp b/pool/shard006/C++/0083647_UIPathSelector.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f5a357fdbbc67d10bba51d3fa64734431a32d396
--- /dev/null
+++ b/pool/shard006/C++/0083647_UIPathSelector.cpp
@@ -0,0 +1,74 @@
+/*
+This file is part of AlgAudio.
+
+AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
+
+AlgAudio is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+AlgAudio is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with AlgAudio. If not, see .
+*/
+#include "nfd.h"
+#include "UI/UIPathSelector.hpp"
+#include "UI/UIBox.hpp"
+#include "UI/UITextEntry.hpp"
+#include "UI/UIButton.hpp"
+
+namespace AlgAudio{
+
+UIPathSelector::UIPathSelector(std::weak_ptr parent_window, std::string p)
+ : UIHBox(parent_window), path(p)
+{
+
+}
+
+std::shared_ptr UIPathSelector::Create(std::weak_ptr w, std::string text)
+{
+ std::shared_ptr res(new UIPathSelector(w,text));
+ res->Init();
+ return res;
+}
+
+void UIPathSelector::Init()
+{
+ child_button = UIButton::Create(window,"...");
+ child_entry = UITextEntry::Create(window,path);
+ Insert(child_entry, UIBox::PackMode::WIDE);
+ Insert(child_button, UIBox::PackMode::TIGHT);
+
+ child_button->SetBorder(false);
+ child_button->SetCustomSize(Size2D(16,16));
+ child_button->SetInnerMargin(0);
+
+ subscriptions += child_button->on_clicked.Subscribe([this](){
+ OpenDialog();
+ });
+ subscriptions += child_entry->on_edited.Subscribe([this](){
+ path = child_entry->GetText();
+ });
+}
+
+void UIPathSelector::OpenDialog(){
+ nfdchar_t *outPath = nullptr;
+ nfdresult_t result = NFD_OpenDialog( NULL, (path=="") ? NULL : path.c_str() , &outPath );
+ if(result == NFD_OKAY){
+ path = outPath;
+ on_selected.Happen(path);
+ child_entry->SetText(path);
+ free(outPath);
+ }
+}
+
+void UIPathSelector::SetName(std::string t){
+ child_entry->SetDefaultText(t);
+}
+
+} // namespace AlgAudio
diff --git a/pool/shard006/C++/0083648_current.cpp b/pool/shard006/C++/0083648_current.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..37b568222e416a3d8f8d433379069dc4c986e22b
--- /dev/null
+++ b/pool/shard006/C++/0083648_current.cpp
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "glk/alan3/current.h"
+
+namespace Glk {
+namespace Alan3 {
+
+/* PUBLIC DATA */
+CurVars current;
+bool gameStateChanged = FALSE;
+
+void CurVars::synchronize(Common::Serializer &s) {
+ s.syncAsSint32LE(syntax);
+ s.syncAsSint32LE(verb);
+ s.syncAsSint32LE(location);
+ s.syncAsSint32LE(actor);
+ s.syncAsSint32LE(instance);
+ s.syncAsSint32LE(tick);
+ s.syncAsSint32LE(score);
+ s.syncAsSint32LE(visits);
+ s.syncAsSint32LE(sourceLine);
+ s.syncAsSint32LE(sourceFile);
+ s.syncAsUint32LE(meta);
+}
+
+} // End of namespace Alan3
+} // End of namespace Glk
diff --git a/pool/shard006/C++/0083654_82A.cpp b/pool/shard006/C++/0083654_82A.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8d8e99a9f49149e2145da8c365bd5e15e93c9fcd
--- /dev/null
+++ b/pool/shard006/C++/0083654_82A.cpp
@@ -0,0 +1,34 @@
+#include
+#include
+#include
+#include
+
+int main() {
+ int n;
+ scanf("%d", &n);
+ int rd = 0;
+ while (pow(2, rd)*5 < n) {
+ n -= pow(2, rd)*5;
+ rd++;
+ }
+ //printf("n = %d, rd = %d\n", n, rd);
+ int take = pow(2, rd);
+ switch (n%take==0?(n/take)-1:n/take) {
+ case 0:
+ printf("Sheldon\n");
+ break;
+ case 1:
+ printf("Leonard\n");
+ break;
+ case 2:
+ printf("Penny\n");
+ break;
+ case 3:
+ printf("Rajesh\n");
+ break;
+ default:
+ printf("Howard\n");
+ break;
+ }
+ return 0;
+}
diff --git a/pool/shard006/C++/0083657_main.cpp b/pool/shard006/C++/0083657_main.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..450e89db80b090356f89257cdb3e161a8ccba28a
--- /dev/null
+++ b/pool/shard006/C++/0083657_main.cpp
@@ -0,0 +1,211 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "cat.h"
+
+float average(std::string s);
+void readin(std::ifstream &in, std::vector &cats);
+void print(std::ofstream &out, std::vector &cats);
+void print_extraLines(std::ofstream &out, std::vector &cats);
+void print_extraSpaces(std::ofstream &out, std::vector &cats);
+void print_lineOrder(std::ofstream &out, const std::vector &cats);
+void print_frontSpacing(std::ofstream &out, std::vector &cats);
+void print_columnSpacing(std::ofstream &out, std::vector &cats);
+
+//========================================================================================================
+
+int main(int argc, char* argv[])
+{
+ //check command line arguments
+ if(argc != 3)
+ {
+ std::cerr << "Wrong number of command line arguments" << std::endl;
+ exit(1);
+ }
+
+ //open input stream
+ std::ifstream in(argv[1]);
+ if(!in.good())
+ {
+ std::cerr << "Error opening input file" << std::endl;
+ exit(1);
+ }
+
+ //open output stream
+ std::ofstream out(argv[2]);
+ if(!out.good())
+ {
+ std::cerr << "Error opening output file" << std::endl;
+ }
+
+ std::vector cats;
+
+ readin(in, cats);
+
+ //call a print function
+
+ //print(out, cats);
+ //print_extraLines(out, cats);
+ //print_extraSpaces(out, cats);
+ //print_lineOrder(out, cats);
+ //print_frontSpacing(out, cats);
+ print_columnSpacing(out, cats);
+
+ return 0;
+}
+
+//============================================================================================================
+
+//extracts the lower and upper of the range in the string and averages them
+float average(std::string s)
+{
+ //get lower value of the range
+ std::size_t dash = s.find('-');
+ std::size_t start = 0;
+ std::string lowerValue = s.substr(start, dash);
+
+ //get upper value of the range
+ start = dash+1;
+ std::string upperValue = s.substr(start);
+
+ //convert strings to ints
+ int lower;
+ int upper;
+ std::istringstream(lowerValue) >> lower;
+ std::istringstream(upperValue) >> upper;
+
+ return (float)(upper + lower) / 2;
+}
+
+//read in from the input file
+void readin(std::ifstream &in, std::vector &cats)
+{
+ std::string breed, lifeSpan, weight;
+ std::string interesting = "";
+ std::string s;
+ std::string classifier;
+ std::string unit;
+
+ in >> classifier;
+
+ while(!in.eof())
+ {
+ //take in the breed, life span as a string, weight as a string
+ in >> breed;
+ in >> classifier >> lifeSpan >> unit;
+ in >> classifier >> weight >> unit;
+ in >> classifier >> s;
+
+ //take in the interesting fact about the cat breed
+ while(!in.eof() && s != "BREED:")
+ {
+ interesting += s + " ";
+ in >> s;
+ }
+
+ //get the average from the range of values
+ float weightAverage = average(weight);
+ float lifeSpanAverage = average(lifeSpan);
+
+ cats.push_back(Cat(breed, lifeSpanAverage, weightAverage, interesting));
+
+ interesting = "";
+ }
+}
+
+//---------------------------------------------------------------------------------------------------------------------------
+//functions to print
+
+//print the output as expected
+void print(std::ofstream &out, std::vector &cats)
+{
+ std::sort(cats.begin(), cats.end(), sortCats);
+ std::string spacing = " ";
+ for(unsigned int i = 0; i < cats.size(); i++)
+ {
+ out << cats[i].getBreed() << std::endl;
+ out << spacing << "Average Lifespan: " << cats[i].getAverageLifeSpan() << std::endl;
+ out << spacing << "Average Weight: " << cats[i].getAverageSize() << std::endl;
+ out << spacing << "Intersting Fact: " << cats[i].getInterestingFact() << std::endl;
+ }
+}
+
+//print the output with extra newlines at the end of every line
+void print_extraLines(std::ofstream &out, std::vector &cats)
+{
+ std::sort(cats.begin(), cats.end(), sortCats);
+ std::string spacing = " ";
+ for(unsigned int i = 0; i < cats.size(); i++)
+ {
+ out << cats[i].getBreed() << std::endl << std::endl;
+ out << spacing << "Average Lifespan: " << cats[i].getAverageLifeSpan()
+ << std::endl << std::endl;
+ out << spacing << "Average Weight: " << cats[i].getAverageSize()
+ << std::endl << std::endl;
+ out << spacing << "Intersting Fact: " << cats[i].getInterestingFact()
+ << std::endl << std::endl;
+ }
+}
+
+//print the output with extra spaces at the end of every line
+void print_extraSpaces(std::ofstream &out, std::vector &cats)
+{
+ std::sort(cats.begin(), cats.end(), sortCats);
+ std::string spacing = " ";
+ for(unsigned int i = 0; i < cats.size(); i++)
+ {
+ out << cats[i].getBreed() << " " << std::endl;
+ out << spacing << "Average Lifespan: " << cats[i].getAverageLifeSpan()
+ << " " << std::endl;
+ out << spacing << "Average Weight: " << cats[i].getAverageSize()
+ << " " << std::endl;
+ out << spacing << "Intersting Fact: " << cats[i].getInterestingFact()
+ << " " << std::endl;
+ }
+}
+
+//print the output with the lines in the wrong order
+void print_lineOrder(std::ofstream &out, const std::vector &cats)
+{
+ std::string spacing = " ";
+ for(unsigned int i = 0; i < cats.size(); i++)
+ {
+ out << cats[i].getBreed() << std::endl;
+ out << spacing << "Average Lifespan: " << cats[i].getAverageLifeSpan() << std::endl;
+ out << spacing << "Average Weight: " << cats[i].getAverageSize() << std::endl;
+ out << spacing << "Intersting Fact: " << cats[i].getInterestingFact() << std::endl;
+ }
+}
+
+//print the output with the spacing in front off (expected: 5 spaces)
+void print_frontSpacing(std::ofstream &out, std::vector &cats)
+{
+ std::sort(cats.begin(), cats.end(), sortCats);
+ std::string spacing = " ";
+ for(unsigned int i = 0; i < cats.size(); i++)
+ {
+ out << cats[i].getBreed() << std::endl;
+ out << spacing << "Average Lifespan: " << cats[i].getAverageLifeSpan() << std::endl;
+ out << spacing << "Average Weight: " << cats[i].getAverageSize() << std::endl;
+ out << spacing << "Intersting Fact: " << cats[i].getInterestingFact() << std::endl;
+ }
+}
+
+//print the output with the column spacing off
+//(expected: 1 space between 1st column and 2nd, 1st column the length of the longest attribute)
+void print_columnSpacing(std::ofstream &out, std::vector &cats)
+{
+ std::sort(cats.begin(), cats.end(), sortCats);
+ std::string spacing = " ";
+ for(unsigned int i = 0; i < cats.size(); i++)
+ {
+ out << cats[i].getBreed() << std::endl;
+ out << spacing << "Average Lifespan: " << cats[i].getAverageLifeSpan() << std::endl;
+ out << spacing << "Average Weight: " << cats[i].getAverageSize() << std::endl;
+ out << spacing << "Intersting Fact: " << cats[i].getInterestingFact() << std::endl;
+ }
+}
\ No newline at end of file
diff --git a/pool/shard006/C++/0083662_user_script_slave.cc b/pool/shard006/C++/0083662_user_script_slave.cc
new file mode 100644
index 0000000000000000000000000000000000000000..afd065ff82d596bcc00566440feeb3cfb9ba0821
--- /dev/null
+++ b/pool/shard006/C++/0083662_user_script_slave.cc
@@ -0,0 +1,180 @@
+// Copyright (c) 2009 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 "chrome/renderer/user_script_slave.h"
+
+#include "app/resource_bundle.h"
+#include "base/histogram.h"
+#include "base/logging.h"
+#include "base/perftimer.h"
+#include "base/pickle.h"
+#include "base/shared_memory.h"
+#include "base/string_util.h"
+#include "googleurl/src/gurl.h"
+#include "webkit/api/public/WebScriptSource.h"
+#include "webkit/glue/webframe.h"
+
+#include "grit/renderer_resources.h"
+
+using WebKit::WebScriptSource;
+using WebKit::WebString;
+
+// These two strings are injected before and after the Greasemonkey API and
+// user script to wrap it in an anonymous scope.
+static const char kUserScriptHead[] = "(function (unsafeWindow) {\n";
+static const char kUserScriptTail[] = "\n})(window);";
+
+// Creates a convenient reference to a content script's parent extension.
+// TODO(mpcomplete): self.onConnect is deprecated. Remove it at 1.0.
+// http://code.google.com/p/chromium/issues/detail?id=16356
+static const char kInitExtension[] =
+ "chrome.extension = new chrome.Extension('%s');"
+ "chrome.self.onConnect = chrome.extension.onConnect;";
+
+UserScriptSlave::UserScriptSlave()
+ : shared_memory_(NULL),
+ script_deleter_(&scripts_),
+ user_script_start_line_(0) {
+ // TODO: Only windows supports resources and only windows supports user
+ // scrips, so only load the Greasemonkey API on windows. Fix this when
+ // better cross platofrm support is available.
+#if defined(OS_WIN)
+ api_js_ = ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_GREASEMONKEY_API_JS);
+#endif
+
+ // Count the number of lines that will be injected before the user script.
+ StringPiece::size_type pos = 0;
+ while ((pos = api_js_.find('\n', pos)) != StringPiece::npos) {
+ user_script_start_line_++;
+ pos++;
+ }
+
+ // NOTE: There is actually one extra line in the injected script because the
+ // function header includes a newline as well. But WebKit expects the
+ // numbering to be one-based, not zero-based, so actually *not* accounting for
+ // this extra line ends us up with the right offset.
+}
+
+bool UserScriptSlave::UpdateScripts(base::SharedMemoryHandle shared_memory) {
+ scripts_.clear();
+
+ // Create the shared memory object (read only).
+ shared_memory_.reset(new base::SharedMemory(shared_memory, true));
+ if (!shared_memory_.get())
+ return false;
+
+ // First get the size of the memory block.
+ if (!shared_memory_->Map(sizeof(Pickle::Header)))
+ return false;
+ Pickle::Header* pickle_header =
+ reinterpret_cast(shared_memory_->memory());
+
+ // Now map in the rest of the block.
+ int pickle_size = sizeof(Pickle::Header) + pickle_header->payload_size;
+ shared_memory_->Unmap();
+ if (!shared_memory_->Map(pickle_size))
+ return false;
+
+ // Unpickle scripts.
+ void* iter = NULL;
+ size_t num_scripts = 0;
+ Pickle pickle(reinterpret_cast(shared_memory_->memory()),
+ pickle_size);
+ pickle.ReadSize(&iter, &num_scripts);
+
+ scripts_.reserve(num_scripts);
+ for (size_t i = 0; i < num_scripts; ++i) {
+ scripts_.push_back(new UserScript());
+ UserScript* script = scripts_.back();
+ script->Unpickle(pickle, &iter);
+
+ // Note that this is a pointer into shared memory. We don't own it. It gets
+ // cleared up when the last renderer or browser process drops their
+ // reference to the shared memory.
+ for (size_t j = 0; j < script->js_scripts().size(); ++j) {
+ const char* body = NULL;
+ int body_length = 0;
+ CHECK(pickle.ReadData(&iter, &body, &body_length));
+ script->js_scripts()[j].set_external_content(
+ StringPiece(body, body_length));
+ }
+ for (size_t j = 0; j < script->css_scripts().size(); ++j) {
+ const char* body = NULL;
+ int body_length = 0;
+ CHECK(pickle.ReadData(&iter, &body, &body_length));
+ script->css_scripts()[j].set_external_content(
+ StringPiece(body, body_length));
+ }
+ }
+
+ return true;
+}
+
+bool UserScriptSlave::InjectScripts(WebFrame* frame,
+ UserScript::RunLocation location) {
+ PerfTimer timer;
+ int num_matched = 0;
+
+ for (size_t i = 0; i < scripts_.size(); ++i) {
+ std::vector sources;
+ UserScript* script = scripts_[i];
+ if (!script->MatchesUrl(frame->GetURL()))
+ continue; // This frame doesn't match the script url pattern, skip it.
+
+ ++num_matched;
+ // CSS files are always injected on document start before js scripts.
+ if (location == UserScript::DOCUMENT_START) {
+ for (size_t j = 0; j < script->css_scripts().size(); ++j) {
+ UserScript::File& file = script->css_scripts()[j];
+ frame->InsertCSSStyles(file.GetContent().as_string());
+ }
+ }
+ if (script->run_location() == location) {
+ for (size_t j = 0; j < script->js_scripts().size(); ++j) {
+ UserScript::File &file = script->js_scripts()[j];
+ std::string content = file.GetContent().as_string();
+
+ // We add this dumb function wrapper for standalone user script to
+ // emulate what Greasemonkey does.
+ if (script->is_standalone()) {
+ content.insert(0, kUserScriptHead);
+ content += kUserScriptTail;
+ }
+ sources.push_back(WebScriptSource(
+ WebString::fromUTF8(content.c_str(), content.length()),
+ file.url()));
+ }
+ }
+
+ if (!sources.empty()) {
+ if (script->is_standalone()) {
+ // For standalone scripts, we try to emulate the Greasemonkey API.
+ sources.insert(sources.begin(),
+ WebScriptSource(WebString::fromUTF8(api_js_.as_string())));
+ } else {
+ // Setup chrome.self to contain an Extension object with the correct
+ // ID.
+ sources.insert(sources.begin(),
+ WebScriptSource(WebString::fromUTF8(
+ StringPrintf(kInitExtension, script->extension_id().c_str()))));
+ }
+
+ frame->ExecuteScriptInNewContext(&sources.front(), sources.size());
+ }
+ }
+
+ // Log debug info.
+ if (location == UserScript::DOCUMENT_START) {
+ HISTOGRAM_COUNTS_100("UserScripts:DocStart:Count", num_matched);
+ HISTOGRAM_TIMES("UserScripts:DocStart:Time", timer.Elapsed());
+ } else {
+ HISTOGRAM_COUNTS_100("UserScripts:DocEnd:Count", num_matched);
+ HISTOGRAM_TIMES("UserScripts:DocEnd:Time", timer.Elapsed());
+ }
+
+ LOG(INFO) << "Injected " << num_matched << " user scripts into " <<
+ frame->GetURL().spec();
+ return true;
+}
diff --git a/pool/shard006/C++/0083663_MPHasher.cpp b/pool/shard006/C++/0083663_MPHasher.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2136e59a3d83b65276fa35d9401b71088ebd6011
--- /dev/null
+++ b/pool/shard006/C++/0083663_MPHasher.cpp
@@ -0,0 +1,78 @@
+#include "MPHasher.h"
+#include "EventTypeName.h"
+#include
+
+namespace mParticle {
+ __attribute__((no_sanitize("integer")))
+ int Hasher::hashFromString(const string &stringToHash) {
+ if (stringToHash.empty()) {
+ return 0;
+ }
+
+ string lowerCaseStringToHash = stringToHash;
+ transform(lowerCaseStringToHash.begin(), lowerCaseStringToHash.end(), lowerCaseStringToHash.begin(), ::tolower);
+
+ int hash = 0;
+ for (auto &character : lowerCaseStringToHash) {
+ hash = ((hash << 5) - hash) + character;
+ }
+
+ return hash;
+ }
+
+ string Hasher::hashString(string stringToHash) {
+ if (stringToHash.empty()) {
+ return "";
+ }
+
+ auto hash = Hasher::hashFromString(stringToHash);
+
+ auto hashString = to_string(hash);
+ return hashString;
+ }
+
+ vector Hasher::hashedEventTypes(const vector &eventTypes) {
+ vector hashedTypes;
+
+ if (eventTypes.empty()) {
+ return hashedTypes;
+ }
+
+ for (auto &eventType : eventTypes) {
+ auto eventTypeString = to_string(eventType);
+ auto hashedEventType = Hasher::hashString(eventTypeString);
+ hashedTypes.push_back(hashedEventType);
+ }
+
+ return hashedTypes;
+ }
+
+ vector Hasher::hashedAllEventTypes() {
+ vector eventTypes(EventTypeName::count);
+
+ int i = 0;
+ for_each(eventTypes.begin(), eventTypes.end(), [&i](int &eventType) {eventType = i++;});
+
+ vector hashes = Hasher::hashedEventTypes(eventTypes);
+ return hashes;
+ }
+
+ string Hasher::hashEvent(string eventName, string eventType) {
+ eventName.append(eventType);
+ return Hasher::hashString(eventName);
+ }
+
+ __attribute__((no_sanitize("integer")))
+ int64_t Hasher::hashFNV1a(const char *bytes, int length) {
+ // FNV-1a hashing
+ int64_t rampHash = 0xcbf29ce484222325;
+
+ int i = 0;
+ while (i < length) {
+ rampHash = (rampHash ^ bytes[i]) * 0x100000001B3;
+ i += 1;
+ }
+
+ return rampHash;
+ }
+}
diff --git a/pool/shard006/C++/0083666_clientsideeffects_test.cpp b/pool/shard006/C++/0083666_clientsideeffects_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..34ace22d7e97a940cb613fc841ada4f54144606e
--- /dev/null
+++ b/pool/shard006/C++/0083666_clientsideeffects_test.cpp
@@ -0,0 +1,302 @@
+//======== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ========
+//
+// The copyright to the contents herein is the property of Valve, L.L.C.
+// The contents may be used and/or copied only with the written permission of
+// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
+// the agreement/contract under which the contents have been supplied.
+//
+// Purpose:
+//
+// $Workfile: $
+// $NoKeywords: $
+//=============================================================================
+#include "cbase.h"
+#include "engine/IEngineSound.h"
+#include "view.h"
+
+#include "fx_line.h"
+#include "fx_discreetline.h"
+#include "fx_quad.h"
+#include "clientsideeffects.h"
+
+#include "SoundEmitterSystemBase.h"
+#include "tier0/vprof.h"
+
+//FIXME: All these functions will be moved out to FX_Main.CPP or a individual folder
+
+/*
+==================================================
+FX_AddStaticLine
+==================================================
+*/
+
+void FX_AddStaticLine( const Vector& start, const Vector& end, float scale, float life, const char *materialName, unsigned char flags )
+{
+ CFXStaticLine *t = new CFXStaticLine( "StaticLine", start, end, scale, life, materialName, flags );
+ assert( t );
+
+ //Throw it into the list
+ clienteffects->AddEffect( t );
+}
+
+/*
+==================================================
+FX_AddDiscreetLine
+==================================================
+*/
+
+void FX_AddDiscreetLine( const Vector& start, const Vector& direction, float velocity, float length, float clipLength, float scale, float life, const char *shader )
+{
+ CFXDiscreetLine *t = new CFXDiscreetLine( "Line", start, direction, velocity, length, clipLength, scale, life, shader );
+ assert( t );
+
+ //Throw it into the list
+ clienteffects->AddEffect( t );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void FX_AddQuad( const FXQuadData_t &data )
+{
+ CFXQuad *quad = new CFXQuad( data );
+
+ Assert( quad != NULL );
+
+ clienteffects->AddEffect( quad );
+}
+//-----------------------------------------------------------------------------
+// Purpose: Parameter heavy version
+//-----------------------------------------------------------------------------
+void FX_AddQuad( const Vector &origin,
+ const Vector &normal,
+ float startSize,
+ float endSize,
+ float sizeBias,
+ float startAlpha,
+ float endAlpha,
+ float alphaBias,
+ float yaw,
+ float deltaYaw,
+ const Vector &color,
+ float lifeTime,
+ const char *shader,
+ unsigned int flags )
+{
+ FXQuadData_t data;
+
+ //Setup the data
+ data.SetAlpha( startAlpha, endAlpha );
+ data.SetScale( startSize, endSize );
+ data.SetFlags( flags );
+ data.SetMaterial( shader );
+ data.SetNormal( normal );
+ data.SetOrigin( origin );
+ data.SetLifeTime( lifeTime );
+ data.SetColor( color[0], color[1], color[2] );
+ data.SetScaleBias( sizeBias );
+ data.SetAlphaBias( alphaBias );
+ data.SetYaw( yaw, deltaYaw );
+
+ //Output it
+ FX_AddQuad( data );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Creates a test effect
+//-----------------------------------------------------------------------------
+void CreateTestEffect( void )
+{
+ //NOTENOTE: Add any test effects here
+ //FX_BulletPass( NULL, NULL );
+}
+
+/*
+==================================================
+UTIL_NearestPointOnLine
+==================================================
+*/
+
+float UTIL_NearestPointOnLine( const Vector& start, const Vector& end, const Vector& target, Vector& out )
+{
+ Vector lineDir, targetDir;
+ float dot;
+
+ //Find the direction of the line
+ VectorSubtract( end, start, lineDir );
+ VectorNormalize( lineDir );
+
+ //Find the direction of the target to the line's path
+ VectorSubtract( target, start, targetDir );
+
+ //Find the nearest point to the target on that line
+ dot = DotProduct( targetDir, lineDir );
+ VectorScale( lineDir, dot, out );
+ VectorAdd( start, out, out );
+
+ //Find the distance to the nearest point
+ VectorSubtract( out, target, targetDir );
+
+ return VectorLength( targetDir );
+}
+
+/*
+==================================================
+FX_PlayerTracer
+==================================================
+*/
+
+#define TRACER_BASE_OFFSET 8
+
+void FX_PlayerTracer( Vector& start, Vector& end )
+{
+ VPROF_BUDGET( "FX_PlayerTracer", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
+ Vector shotDir, dStart, dEnd;
+ float length;
+
+ //Find the direction of the tracer
+ VectorSubtract( end, start, shotDir );
+ length = VectorNormalize( shotDir );
+
+ //We don't want to draw them if they're too close to us
+ if ( length < 256 )
+ return;
+
+ //Randomly place the tracer along this line, with a random length
+ VectorMA( start, TRACER_BASE_OFFSET + random->RandomFloat( -24.0f, 64.0f ), shotDir, dStart );
+ VectorMA( dStart, ( length * random->RandomFloat( 0.1f, 0.6f ) ), shotDir, dEnd );
+
+ //Create the line
+ CFXStaticLine *t;
+ const char *materialName;
+
+ //materialName = ( random->RandomInt( 0, 1 ) ) ? "effects/tracer_middle" : "effects/tracer_middle2";
+ materialName = "effects/spark";
+
+ t = new CFXStaticLine( "Tracer", dStart, dEnd, random->RandomFloat( 0.5f, 0.75f ), 0.01f, materialName, 0 );
+ assert( t );
+
+ //Throw it into the list
+ clienteffects->AddEffect( t );
+}
+
+/*
+==================================================
+FX_Tracer
+==================================================
+*/
+// Tracer must be this close to be considered for hearing
+#define TRACER_MAX_HEAR_DIST (6*12)
+#define TRACER_SOUND_TIME_MIN 0.10f
+#define TRACER_SOUND_TIME_MAX 0.10f
+
+
+class CBulletWhizTimer : public CAutoGameSystem
+{
+public:
+ void LevelInitPreEntity()
+ {
+ m_nextWhizTime = 0;
+ }
+
+ float m_nextWhizTime;
+};
+
+// Client-side tracking for whiz noises
+CBulletWhizTimer g_BulletWhiz;
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : &vecStart -
+// &vecDir -
+// iTracerType -
+//-----------------------------------------------------------------------------
+void FX_TracerSound( const Vector &start, const Vector &end, int iTracerType )
+{
+ const char *pszSoundName = NULL;
+
+ switch( iTracerType )
+ {
+ case TRACER_TYPE_DEFAULT:
+ pszSoundName = "Bullets.DefaultNearmiss";
+ break;
+
+ case TRACER_TYPE_GUNSHIP:
+ pszSoundName = "Bullets.GunshipNearmiss";
+ break;
+
+ case TRACER_TYPE_STRIDER:
+ pszSoundName = "Bullets.StriderNearmiss";
+ break;
+
+ default:
+ return;
+ break;
+ }
+
+ if( pszSoundName )
+ {
+ //Get out shot direction and length
+ float totalDist;
+ Vector shotDir;
+
+ VectorSubtract( end, start, shotDir );
+ totalDist = VectorNormalize( shotDir );
+
+ float dt = g_BulletWhiz.m_nextWhizTime - gpGlobals->curtime;
+
+ //If needed, make a bullet whiz noise
+ if ( dt <= 0 )
+ {
+ Vector vNear, dStart, dEnd;
+
+ //Find the nearest point to our view on the bullet's path
+ float vDist = UTIL_NearestPointOnLine( start, end, MainViewOrigin(), vNear );
+
+ //See if we should play a bullet whizz
+ if ( vDist <= TRACER_MAX_HEAR_DIST )
+ {
+ CLocalPlayerFilter filter;
+ CSoundParameters params;
+
+ if( C_BaseEntity::GetParametersForSound( pszSoundName, params ) )
+ {
+ enginesound->EmitSound( filter, SOUND_FROM_WORLD, CHAN_STATIC, params.soundname, params.volume, SNDLVL_TO_ATTN(params.soundlevel), 0, params.pitch, &start, &shotDir, false);
+ }
+
+ //Don't play another bullet whiz for this client until this time has run out
+ g_BulletWhiz.m_nextWhizTime = gpGlobals->curtime + random->RandomFloat( TRACER_SOUND_TIME_MIN, TRACER_SOUND_TIME_MAX );
+
+ }
+ }
+ }
+}
+
+
+void FX_Tracer( Vector& start, Vector& end, int velocity, bool makeWhiz )
+{
+ VPROF_BUDGET( "FX_Tracer", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
+ //Don't make small tracers
+ float dist;
+ Vector dir;
+
+ VectorSubtract( end, start, dir );
+ dist = VectorNormalize( dir );
+
+ // Don't make short tracers.
+ if ( dist < 256 )
+ {
+ return;
+ }
+
+ float length = random->RandomFloat( 64.0f, 128.0f );
+ float life = ( dist + length ) / velocity; //NOTENOTE: We want the tail to finish its run as well
+
+ //Add it
+ FX_AddDiscreetLine( start, dir, velocity, length, dist, random->RandomFloat( 0.75f, 0.9f ), life, "effects/spark" );
+
+ if( makeWhiz )
+ {
+ FX_TracerSound( start, end, TRACER_TYPE_DEFAULT );
+ }
+}
diff --git a/pool/shard006/C++/0083671_test_context_provider_factory.cc b/pool/shard006/C++/0083671_test_context_provider_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8ac73bec144c3a57ba8cc976e53fdbb721d8620
--- /dev/null
+++ b/pool/shard006/C++/0083671_test_context_provider_factory.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2013 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 "webkit/gpu/test_context_provider_factory.h"
+
+#include "base/logging.h"
+#include "cc/output/context_provider.h"
+#include "webkit/gpu/context_provider_in_process.h"
+
+namespace webkit {
+namespace gpu {
+
+static TestContextProviderFactory* context_provider_instance = NULL;
+
+// static
+TestContextProviderFactory* TestContextProviderFactory::GetInstance() {
+ if (!context_provider_instance)
+ context_provider_instance = new TestContextProviderFactory();
+ return context_provider_instance;
+}
+
+TestContextProviderFactory::TestContextProviderFactory() {}
+
+TestContextProviderFactory::~TestContextProviderFactory() {}
+
+scoped_refptr TestContextProviderFactory::
+ OffscreenContextProviderForMainThread() {
+ if (!main_thread_ || main_thread_->DestroyedOnMainThread()) {
+ main_thread_ = ContextProviderInProcess::Create();
+ if (main_thread_ && !main_thread_->BindToCurrentThread())
+ main_thread_ = NULL;
+ }
+ return main_thread_;
+}
+
+scoped_refptr TestContextProviderFactory::
+ OffscreenContextProviderForCompositorThread() {
+ if (!compositor_thread_ ||
+ compositor_thread_->DestroyedOnMainThread())
+ compositor_thread_ = ContextProviderInProcess::Create();
+ return compositor_thread_;
+}
+
+} // namespace gpu
+} // namespace webkit
diff --git a/pool/shard006/C++/0083679_rtcp_format_remb_unittest.cc b/pool/shard006/C++/0083679_rtcp_format_remb_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..88463e4718f812db2ccfac743ea74f81a7feae93
--- /dev/null
+++ b/pool/shard006/C++/0083679_rtcp_format_remb_unittest.cc
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "webrtc/common_types.h"
+#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
+#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
+#include "webrtc/typedefs.h"
+
+namespace {
+
+using namespace webrtc;
+
+
+class TestTransport : public Transport {
+ public:
+ TestTransport(RTCPReceiver* rtcp_receiver) :
+ rtcp_receiver_(rtcp_receiver) {
+ }
+
+ virtual int SendPacket(int /*channel*/, const void* /*data*/, int /*len*/) {
+ return -1;
+ }
+ virtual int SendRTCPPacket(int /*channel*/,
+ const void *packet,
+ int packetLength) {
+ RTCPUtility::RTCPParserV2 rtcpParser((uint8_t*)packet,
+ (int32_t)packetLength,
+ true); // Allow non-compound RTCP
+
+ EXPECT_TRUE(rtcpParser.IsValid());
+ RTCPHelp::RTCPPacketInformation rtcpPacketInformation;
+ EXPECT_EQ(0, rtcp_receiver_->IncomingRTCPPacket(rtcpPacketInformation,
+ &rtcpParser));
+
+ EXPECT_EQ((uint32_t)kRtcpRemb,
+ rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRemb);
+ EXPECT_EQ((uint32_t)1234,
+ rtcpPacketInformation.receiverEstimatedMaxBitrate);
+ return packetLength;
+ }
+ private:
+ RTCPReceiver* rtcp_receiver_;
+};
+
+
+class RtcpFormatRembTest : public ::testing::Test {
+ protected:
+ static const uint32_t kRemoteBitrateEstimatorMinBitrateBps = 30000;
+
+ RtcpFormatRembTest()
+ : over_use_detector_options_(),
+ system_clock_(Clock::GetRealTimeClock()),
+ receive_statistics_(ReceiveStatistics::Create(system_clock_)),
+ remote_bitrate_observer_(),
+ remote_bitrate_estimator_(
+ RemoteBitrateEstimatorFactory().Create(
+ &remote_bitrate_observer_,
+ system_clock_,
+ kMimdControl,
+ kRemoteBitrateEstimatorMinBitrateBps)) {}
+ virtual void SetUp();
+ virtual void TearDown();
+
+ OverUseDetectorOptions over_use_detector_options_;
+ Clock* system_clock_;
+ ModuleRtpRtcpImpl* dummy_rtp_rtcp_impl_;
+ scoped_ptr receive_statistics_;
+ RTCPSender* rtcp_sender_;
+ RTCPReceiver* rtcp_receiver_;
+ TestTransport* test_transport_;
+ MockRemoteBitrateObserver remote_bitrate_observer_;
+ scoped_ptr remote_bitrate_estimator_;
+};
+
+void RtcpFormatRembTest::SetUp() {
+ RtpRtcp::Configuration configuration;
+ configuration.id = 0;
+ configuration.audio = false;
+ configuration.clock = system_clock_;
+ configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get();
+ dummy_rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration);
+ rtcp_sender_ =
+ new RTCPSender(0, false, system_clock_, receive_statistics_.get());
+ rtcp_receiver_ = new RTCPReceiver(0, system_clock_, dummy_rtp_rtcp_impl_);
+ test_transport_ = new TestTransport(rtcp_receiver_);
+
+ EXPECT_EQ(0, rtcp_sender_->Init());
+ EXPECT_EQ(0, rtcp_sender_->RegisterSendTransport(test_transport_));
+}
+
+void RtcpFormatRembTest::TearDown() {
+ delete rtcp_sender_;
+ delete rtcp_receiver_;
+ delete dummy_rtp_rtcp_impl_;
+ delete test_transport_;
+}
+
+TEST_F(RtcpFormatRembTest, TestBasicAPI) {
+ EXPECT_FALSE(rtcp_sender_->REMB());
+ EXPECT_EQ(0, rtcp_sender_->SetREMBStatus(true));
+ EXPECT_TRUE(rtcp_sender_->REMB());
+ EXPECT_EQ(0, rtcp_sender_->SetREMBStatus(false));
+ EXPECT_FALSE(rtcp_sender_->REMB());
+
+ EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, 0, NULL));
+}
+
+TEST_F(RtcpFormatRembTest, TestNonCompund) {
+ uint32_t SSRC = 456789;
+ EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpNonCompound));
+ EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, 1, &SSRC));
+ RTCPSender::FeedbackState feedback_state(dummy_rtp_rtcp_impl_);
+ EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));
+}
+
+TEST_F(RtcpFormatRembTest, TestCompund) {
+ uint32_t SSRCs[2] = {456789, 98765};
+ EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound));
+ EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, 2, SSRCs));
+ RTCPSender::FeedbackState feedback_state(dummy_rtp_rtcp_impl_);
+ EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));
+}
+} // namespace
diff --git a/pool/shard006/C++/0083681_viewbasis_funcs.cpp b/pool/shard006/C++/0083681_viewbasis_funcs.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f5f00cd3f4857d1ba73117423db3a75401597c26
--- /dev/null
+++ b/pool/shard006/C++/0083681_viewbasis_funcs.cpp
@@ -0,0 +1,112 @@
+/*
+ *** Qt GUI: View Basis dialog functions
+ *** src/gui/viewbasis_funcs.cpp
+ Copyright T. Youngs 2007-2015
+
+ This file is part of Aten.
+
+ Aten is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Aten is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Aten. If not, see .
+*/
+
+#include "main/aten.h"
+#include "gui/viewbasis.h"
+#include "gui/mainwindow.h"
+#include "base/messenger.h"
+#include "base/sysfunc.h"
+#include "model/model.h"
+
+// Constructor
+AtenViewBasis::AtenViewBasis(QWidget* parent, Qt::WindowFlags flags) : QDialog(parent,flags)
+{
+ // Private variables
+ target_ = NULL;
+
+ ui.setupUi(this);
+}
+
+void AtenViewBasis::showWindow(Model* m)
+{
+ // Clear old contents
+ ui.BasisTable->clear();
+ ui.BasisTable->setColumnCount(10);
+ ui.BasisTable->setHorizontalHeaderLabels(QStringList() << "Atom" << "Shell" << "Type" << "Exponent" << "Coefficients" << " " << " " << " " << " " << " " );
+ // Check model pointer
+ if (m == NULL) return;
+ // If no basis definition exists in the supplied model, try to look at the trajectory parent
+ target_ = m;
+ if ((target_->basisShells() == NULL) && (target_->parent() != NULL))
+ {
+ target_ = target_->parent();
+ Messenger::print("No basis definition found in trajectory frame - looking in parent model...");
+ }
+ // Determine total row count
+ BasisShell *bas;
+ BasisPrimitive* prim;
+ int row = 0, shell, lastid = -1, n, ncartesians = 0;
+ Dnchar text;
+ for (bas = target_->basisShells(); bas != NULL; bas = bas->next) row += bas->nPrimitives();
+ ui.BasisTable->setRowCount(row);
+ ui.BasisShellsLabel->setText(itoa(target_->nBasisShells()));
+ // Populate table
+ QTableWidgetItem *tabitem;
+ row = 0;
+ shell = 0;
+ for (bas = target_->basisShells(); bas != NULL; bas = bas->next)
+ {
+ ++shell;
+ ncartesians += BasisShell::nCartesianFunctions(bas->type());
+ // Create atom id item?
+ if (lastid != bas->atomId())
+ {
+ lastid = bas->atomId();
+ tabitem = new QTableWidgetItem();
+ text.sprintf("%i (%s)\n", lastid+1, m->atom(lastid) != NULL ? Elements().symbol(m->atom(lastid)) : "NULL");
+ tabitem->setText(text.get());
+ ui.BasisTable->setItem(row, AtenViewBasis::AtomIdColumn, tabitem);
+ }
+ // Add in shell data
+ tabitem = new QTableWidgetItem();
+ tabitem->setText(itoa(shell));
+ ui.BasisTable->setItem(row, AtenViewBasis::ShellColumn, tabitem);
+ tabitem = new QTableWidgetItem();
+ tabitem->setText(BasisShell::basisShellType(bas->type()));
+ ui.BasisTable->setItem(row, AtenViewBasis::TypeColumn, tabitem);
+
+ // Cycle over primitives
+ n = 0;
+ for (prim = bas->primitives(); prim != NULL; prim = prim->next)
+ {
+ tabitem = new QTableWidgetItem();
+ tabitem->setText(ftoa(prim->exponent()));
+ ui.BasisTable->setItem(row, AtenViewBasis::ExponentColumn, tabitem);
+ for (n = 0; n < prim->nCoefficients(); ++n)
+ {
+ tabitem = new QTableWidgetItem();
+ tabitem->setText(ftoa(prim->coefficient(n)));
+ ui.BasisTable->setItem(row, AtenViewBasis::CoefficientColumn+n, tabitem);
+ }
+ row++;
+ }
+ }
+ ui.BasisCartesiansLabel->setText(itoa(ncartesians));
+ // Resize columns
+ for (n=0; nresizeColumnToContents(n);
+ show();
+}
+
+void AtenViewBasis::dialogFinished(int result)
+{
+ accept();
+}
+
diff --git a/pool/shard006/C++/0083683_osc_route_observer.cc b/pool/shard006/C++/0083683_osc_route_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..576b92d1bb507a09de9be7345a8affc87aaeea56
--- /dev/null
+++ b/pool/shard006/C++/0083683_osc_route_observer.cc
@@ -0,0 +1,107 @@
+/*
+ Copyright (C) 2009 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "boost/lambda/lambda.hpp"
+
+#include "ardour/route.h"
+#include "ardour/audio_track.h"
+#include "ardour/midi_track.h"
+
+#include "osc.h"
+#include "osc_route_observer.h"
+
+#include "i18n.h"
+
+using namespace std;
+using namespace sigc;
+using namespace PBD;
+using namespace ARDOUR;
+using namespace boost;
+
+OSCRouteObserver::OSCRouteObserver (boost::shared_ptr r, lo_address a)
+ : _route (r)
+{
+ addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
+
+ _route->PropertyChanged.connect (name_changed_connection, MISSING_INVALIDATOR, boost::bind (&OSCRouteObserver::name_changed, this, boost::lambda::_1), OSC::instance());
+
+ if (dynamic_pointer_cast(_route) || dynamic_pointer_cast(_route)) {
+
+ boost::shared_ptr