hexsha
stringlengths
40
40
size
int64
19
11.4M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
270
max_stars_repo_name
stringlengths
5
110
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
270
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
270
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
19
11.4M
avg_line_length
float64
1.93
229k
max_line_length
int64
12
688k
alphanum_fraction
float64
0.07
0.99
matches
listlengths
1
10
ad38a3c966d568fce285bcde8089e87e71232f1c
3,578
cpp
C++
data.cpp
aditya-srikanth/DAA_Assignment_2
2750f548a73bb10fea62470ecea4a6b64b74e0ed
[ "MIT" ]
null
null
null
data.cpp
aditya-srikanth/DAA_Assignment_2
2750f548a73bb10fea62470ecea4a6b64b74e0ed
[ "MIT" ]
null
null
null
data.cpp
aditya-srikanth/DAA_Assignment_2
2750f548a73bb10fea62470ecea4a6b64b74e0ed
[ "MIT" ]
null
null
null
#include "data.h" /** * @brief * The default file path for the dataset */ const std::string Data::DEFAULT_PATH = "./data/DataPoints.txt"; /** * @brief * The default delimiter used within the dataset */ const std::string Data::DEFAULT_DELIM = ","; /** * @brief * The default location of the attempts used to find the line of best fit. */ const std::string Data::LINES_LOCATION = "data/lines.txt"; /** * @brief Construct a new Data:: Data object * The default constructor which makes use of the default path and the defult delimiter */ Data::Data(){ this->x_min = std::numeric_limits<double>::max(); this->x_max = std::numeric_limits<double>::min(); this->path = DEFAULT_PATH; this->delim = DEFAULT_DELIM; file_handle.open(LINES_LOCATION,std::ios::out); } /** * @brief Construct a new Data:: Data object * This creates a handle that extracts data from a user defined location. * @param path * The path to the dataset * @param delim * The delimiter used within the dataset */ Data::Data(std::string path,std::string delim){ this->x_min = std::numeric_limits<double>::max(); this->x_max = std::numeric_limits<double>::min(); this->path = path; this->delim = delim; file_handle.open(LINES_LOCATION,std::ios::out); } /** * @brief * This function helps split a string according to a delimiter * @param str * The input string * @param delim * The delimiter used to delimit parts within the string * @return std::vector<std::string> */ std::vector<std::string> Data::split(const char *str, char delim ) { std::vector<std::string> result; do { const char *begin = str; while(*str != delim && *str) str++; result.push_back(std::string(begin, str)); } while (0 != *str++); // First check then update return result; } /**std::fstream file_handle; file_handle.open(LINES_LOCATION,std::ios::out); * @brief * This function reads the data in the path defined within the constructor * @return std::vector<Node> */ std::vector<Node> Data::read_data(){ std::fstream file_handle; file_handle.open(path,std::ios::in); std::vector<Node> values; if(file_handle.is_open()){ std::cout<<"File found, extracting the data\n"; std::string line; while(std::getline(file_handle,line)){ std::vector<std::string> temp = split(line.c_str(),delim.at(0)); char* term; double x = strtod(temp[0].c_str(),&term); x_max = (x > x_max)? x:x_max; x_min = (x < x_min)? x:x_min; if(*term!=0){ std::cout<<"Not a double\n"; exit(EXIT_FAILURE); } double y = strtod(temp[1].c_str(),&term); if(*term!=0){ std::cout<<"Not a double\n"; exit(EXIT_FAILURE); } Node temp_node = Node(x,y); values.push_back(temp_node); } std::cout<<"Data extracted successfully\n"; } else{ std::cout<<"The file is not found, check the path name\n"; exit(EXIT_FAILURE); } return values; } /** * @brief * This function is used to give the output to the lines.txt file which contains data for the visualizer. * @param input * The string that will be written into the file */ void Data::write_tries(std::string input){ if(this->file_handle.is_open()){ this->file_handle << input << '\n' ; } else{ std::cout<<"Unable to find the file lines.txt, in the data file. HINT:Define the data folder\n"; exit(EXIT_FAILURE); } } /** * @brief * This function returns a pair containing the most extreme x coordinates. * @return std::pair<double,double> */ std::pair<double,double> Data::get_extrema(){ return std::make_pair(this->x_min,this->x_max); }
26.701493
105
0.66322
[ "object", "vector" ]
ad3ad9e22d0302764afd6cfb02970e72f5328ccf
3,450
cpp
C++
tests/core/Object.test.cpp
ASxa86/azule
9bf89dfc5a80f296b02edd3ac608d9a90e4ea26b
[ "MIT" ]
1
2018-10-19T18:00:19.000Z
2018-10-19T18:00:19.000Z
tests/core/Object.test.cpp
ASxa86/azule
9bf89dfc5a80f296b02edd3ac608d9a90e4ea26b
[ "MIT" ]
7
2019-06-13T00:48:55.000Z
2020-05-05T00:18:42.000Z
tests/core/Object.test.cpp
ASxa86/AGE
9bf89dfc5a80f296b02edd3ac608d9a90e4ea26b
[ "MIT" ]
null
null
null
#include <azule/core/ChildEvent.h> #include <azule/core/Object.h> #include <gtest/gtest.h> using namespace azule; class ObjectOne : public Object { public: ObjectOne() : ChildAdded{0}, ChildRemoved{0} { // this->addChildAddedHandler([this](ChildEvent* x) { // ASSERT_TRUE(x != nullptr); // EXPECT_EQ(this->getChild(), x->getChild()); // ChildAdded++; //}); // this->addChildRemovedHandler([this](ChildEvent* x) { // ASSERT_TRUE(x != nullptr); // EXPECT_TRUE(x->getChild() != nullptr); // ChildRemoved++; //}); } int ChildAdded; int ChildRemoved; }; class ObjectTwo : public Object { public: ObjectTwo() { EXPECT_NO_THROW(this->addChild(std::make_shared<Object>())); } }; TEST(Object, Constructor) { EXPECT_NO_THROW(Object()); EXPECT_NO_THROW(auto m = std::make_shared<Object>()); EXPECT_TRUE(std::make_shared<Object>() != nullptr); } TEST(Object, setID) { const auto object = std::make_shared<Object>(); const auto id = std::string("id"); object->setID(id); EXPECT_EQ(id, object->getID()); } TEST(Object, getParent) { const auto parent = std::make_shared<Object>(); auto child = std::make_shared<Object>(); auto cPtr = child.get(); EXPECT_TRUE(parent->addChild(std::move(child))); EXPECT_EQ(parent, cPtr->getParent()); } TEST(Object, getParent_Recursive) { const auto parent = std::make_shared<ObjectTwo>(); auto child = std::make_shared<Object>(); auto subchild = std::make_shared<Object>(); const auto cPtr = child.get(); const auto scPtr = subchild.get(); EXPECT_TRUE(parent->addChild(std::move(child))); EXPECT_TRUE(cPtr->addChild(std::move(subchild))); EXPECT_EQ(parent, scPtr->getParent<ObjectTwo>(Object::FindOption::Recursive)); } TEST(Object, addChild) { const auto parent = std::make_shared<Object>(); auto child = std::make_shared<Object>(); EXPECT_TRUE(parent->addChild(child)); EXPECT_EQ(child, parent->getChild()); } TEST(Object, removeChild) { const auto parent = std::make_shared<Object>(); auto child = std::make_shared<Object>(); auto cPtr = child.get(); EXPECT_TRUE(parent->addChild(std::move(child))); EXPECT_TRUE(cPtr->remove()); EXPECT_TRUE(parent->getChildren().empty()); } TEST(Object, getChild) { const auto parent = std::make_shared<Object>(); EXPECT_TRUE(parent->addChild(std::make_shared<ObjectOne>())); EXPECT_TRUE(parent->addChild(std::make_shared<ObjectTwo>())); EXPECT_TRUE(parent->getChild<ObjectOne>() != nullptr); EXPECT_TRUE(parent->getChild<ObjectTwo>() != nullptr); } TEST(Object, getChildren) { const auto parent = std::make_shared<Object>(); EXPECT_TRUE(parent->addChild(std::make_shared<ObjectOne>())); EXPECT_TRUE(parent->addChild(std::make_shared<ObjectTwo>())); EXPECT_EQ(size_t{2}, parent->getChildren().size()); EXPECT_EQ(size_t{1}, parent->getChildren<ObjectOne>().size()); EXPECT_EQ(size_t{1}, parent->getChildren<ObjectTwo>().size()); } // TEST(Object, childAdded) //{ // const auto parent = std::make_shared<ObjectOne>(); // // EXPECT_TRUE(parent->addChild(std::make_shared<Object>())); // EXPECT_TRUE(parent->addChild(std::make_shared<Object>())); // EXPECT_EQ(parent->getChildren().size(), parent->ChildAdded); //} // // TEST(Object, childRemoved) //{ // const auto parent = std::make_shared<ObjectOne>(); // auto child = std::make_shared<Object>(); // const auto child = child.get(); // // EXPECT_TRUE(parent->addChild(child)); // EXPECT_TRUE(child->remove()); // EXPECT_EQ(1, parent->ChildRemoved); //}
25
79
0.694783
[ "object" ]
ad3cc5134dae5d340f9fc099222a344e2630e364
9,689
cc
C++
content/browser/accessibility/hit_testing_browsertest.cc
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2021-05-24T13:52:28.000Z
2021-05-24T13:53:10.000Z
content/browser/accessibility/hit_testing_browsertest.cc
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
content/browser/accessibility/hit_testing_browsertest.cc
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
3
2018-03-12T07:58:10.000Z
2019-08-31T04:53:58.000Z
// 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 "base/logging.h" #include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test_utils.h" #include "content/public/test/test_utils.h" #include "content/shell/browser/shell.h" #include "content/test/accessibility_browser_test_utils.h" #include "net/dns/mock_host_resolver.h" #include "testing/gtest/include/gtest/gtest.h" namespace content { class AccessibilityHitTestingBrowserTest : public ContentBrowserTest { public: AccessibilityHitTestingBrowserTest() {} ~AccessibilityHitTestingBrowserTest() override {} protected: BrowserAccessibility* HitTestAndWaitForResultWithEvent( const gfx::Point& point, ui::AXEvent event_to_fire) { WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(shell()->web_contents()); FrameTree* frame_tree = web_contents->GetFrameTree(); BrowserAccessibilityManager* manager = web_contents->GetRootBrowserAccessibilityManager(); AccessibilityNotificationWaiter event_waiter( shell()->web_contents(), kAccessibilityModeComplete, event_to_fire); for (FrameTreeNode* node : frame_tree->Nodes()) event_waiter.ListenToAdditionalFrame(node->current_frame_host()); ui::AXActionData action_data; action_data.action = ui::AX_ACTION_HIT_TEST; action_data.target_point = point; action_data.hit_test_event_to_fire = event_to_fire; manager->delegate()->AccessibilityPerformAction(action_data); event_waiter.WaitForNotification(); RenderFrameHostImpl* target_frame = event_waiter.event_render_frame_host(); BrowserAccessibilityManager* target_manager = target_frame->browser_accessibility_manager(); int event_target_id = event_waiter.event_target_id(); BrowserAccessibility* hit_node = target_manager->GetFromID(event_target_id); return hit_node; } BrowserAccessibility* HitTestAndWaitForResult(const gfx::Point& point) { return HitTestAndWaitForResultWithEvent(point, ui::AX_EVENT_HOVER); } BrowserAccessibility* CallCachingAsyncHitTest(const gfx::Point& point) { WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(shell()->web_contents()); FrameTree* frame_tree = web_contents->GetFrameTree(); BrowserAccessibilityManager* manager = web_contents->GetRootBrowserAccessibilityManager(); gfx::Point screen_point = point + manager->GetViewBounds().OffsetFromOrigin(); // Each call to CachingAsyncHitTest results in at least one HOVER // event received. Block until we receive it. AccessibilityNotificationWaiter hover_waiter(shell()->web_contents(), kAccessibilityModeComplete, ui::AX_EVENT_HOVER); for (FrameTreeNode* node : frame_tree->Nodes()) hover_waiter.ListenToAdditionalFrame(node->current_frame_host()); BrowserAccessibility* result = manager->CachingAsyncHitTest(screen_point); hover_waiter.WaitForNotification(); return result; } }; IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, HitTestOutsideDocumentBoundsReturnsRoot) { NavigateToURL(shell(), GURL(url::kAboutBlankURL)); // Load the page. AccessibilityNotificationWaiter waiter(shell()->web_contents(), kAccessibilityModeComplete, ui::AX_EVENT_LOAD_COMPLETE); const char url_str[] = "data:text/html," "<!doctype html>" "<html><head><title>Accessibility Test</title></head>" "<body>" "<a href='#'>" "This is some text in a link" "</a>" "</body></html>"; GURL url(url_str); NavigateToURL(shell(), url); waiter.WaitForNotification(); BrowserAccessibility* hit_node = HitTestAndWaitForResult(gfx::Point(-1, -1)); ASSERT_TRUE(hit_node != NULL); ASSERT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, hit_node->GetRole()); } IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, HitTestingInIframes) { ASSERT_TRUE(embedded_test_server()->Start()); NavigateToURL(shell(), GURL(url::kAboutBlankURL)); AccessibilityNotificationWaiter waiter(shell()->web_contents(), kAccessibilityModeComplete, ui::AX_EVENT_LOAD_COMPLETE); GURL url(embedded_test_server()->GetURL( "/accessibility/html/iframe-coordinates.html")); NavigateToURL(shell(), url); waiter.WaitForNotification(); WaitForAccessibilityTreeToContainNodeWithName( shell()->web_contents(), "Ordinary Button"); WaitForAccessibilityTreeToContainNodeWithName( shell()->web_contents(), "Scrolled Button"); // Send a series of hit test requests, and for each one // wait for the hover event in response, verifying we hit the // correct object. // (50, 50) -> "Button" BrowserAccessibility* hit_node; hit_node = HitTestAndWaitForResult(gfx::Point(50, 50)); ASSERT_TRUE(hit_node != NULL); ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); ASSERT_EQ("Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); // (50, 305) -> div in first iframe hit_node = HitTestAndWaitForResult(gfx::Point(50, 305)); ASSERT_TRUE(hit_node != NULL); ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); // (50, 350) -> "Ordinary Button" hit_node = HitTestAndWaitForResult(gfx::Point(50, 350)); ASSERT_TRUE(hit_node != NULL); ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); ASSERT_EQ("Ordinary Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); // (50, 455) -> "Scrolled Button" hit_node = HitTestAndWaitForResult(gfx::Point(50, 455)); ASSERT_TRUE(hit_node != NULL); ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); ASSERT_EQ("Scrolled Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); // (50, 505) -> div in second iframe hit_node = HitTestAndWaitForResult(gfx::Point(50, 505)); ASSERT_TRUE(hit_node != NULL); ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); // (50, 505) -> div in second iframe // but with a different event hit_node = HitTestAndWaitForResultWithEvent(gfx::Point(50, 505), ui::AX_EVENT_ALERT); ASSERT_NE(hit_node, nullptr); ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); } IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, CachingAsyncHitTestingInIframes) { ASSERT_TRUE(embedded_test_server()->Start()); NavigateToURL(shell(), GURL(url::kAboutBlankURL)); AccessibilityNotificationWaiter waiter(shell()->web_contents(), kAccessibilityModeComplete, ui::AX_EVENT_LOAD_COMPLETE); GURL url(embedded_test_server()->GetURL( "/accessibility/hit_testing/hit_testing.html")); NavigateToURL(shell(), url); waiter.WaitForNotification(); WaitForAccessibilityTreeToContainNodeWithName( shell()->web_contents(), "Ordinary Button"); WaitForAccessibilityTreeToContainNodeWithName( shell()->web_contents(), "Scrolled Button"); // For each point we try, the first time we call CachingAsyncHitTest it // should FAIL and return the wrong object, because this test page has // been designed to confound local synchronous hit testing using // z-indexes. However, calling CachingAsyncHitTest a second time should // return the correct result (since CallCachingAsyncHitTest waits for the // HOVER event to be received). // (50, 50) -> "Button" BrowserAccessibility* hit_node; hit_node = CallCachingAsyncHitTest(gfx::Point(50, 50)); ASSERT_TRUE(hit_node != NULL); ASSERT_NE(ui::AX_ROLE_BUTTON, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 50)); ASSERT_EQ("Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); // (50, 305) -> div in first iframe hit_node = CallCachingAsyncHitTest(gfx::Point(50, 305)); ASSERT_TRUE(hit_node != NULL); ASSERT_NE(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 305)); ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); // (50, 350) -> "Ordinary Button" hit_node = CallCachingAsyncHitTest(gfx::Point(50, 350)); ASSERT_TRUE(hit_node != NULL); ASSERT_NE(ui::AX_ROLE_BUTTON, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 350)); ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); ASSERT_EQ("Ordinary Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); // (50, 455) -> "Scrolled Button" hit_node = CallCachingAsyncHitTest(gfx::Point(50, 455)); ASSERT_TRUE(hit_node != NULL); ASSERT_NE(ui::AX_ROLE_BUTTON, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 455)); ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); ASSERT_EQ("Scrolled Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); // (50, 505) -> div in second iframe hit_node = CallCachingAsyncHitTest(gfx::Point(50, 505)); ASSERT_TRUE(hit_node != NULL); ASSERT_NE(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 505)); ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); } } // namespace content
41.762931
80
0.716379
[ "object" ]
ad3d762845cbfd3665724e13b6fb67b4abfdce62
38,510
hh
C++
include/click/multithread.hh
regufo/fastclick
d56d31c722266ea5d0cfd31435e81ca10dda5e69
[ "BSD-3-Clause-Clear" ]
129
2015-10-08T14:38:35.000Z
2022-03-06T14:54:44.000Z
include/click/multithread.hh
nic-bench/fastclick
2812f0684050cec07e08f30d643ed121871cf25d
[ "BSD-3-Clause-Clear" ]
241
2016-02-17T16:17:58.000Z
2022-03-15T09:08:33.000Z
include/click/multithread.hh
nic-bench/fastclick
2812f0684050cec07e08f30d643ed121871cf25d
[ "BSD-3-Clause-Clear" ]
61
2015-12-17T01:46:58.000Z
2022-02-07T22:25:19.000Z
// -*- c-basic-offset: 4 -*- #ifndef CLICK_MULTITHREAD_HH #define CLICK_MULTITHREAD_HH #include <click/config.h> #include <click/glue.hh> #include <click/vector.hh> #include <click/bitvector.hh> #include <click/machine.hh> #include <click/sync.hh> #if CLICK_LINUXMODULE # error This file is not meant for Kernel mode #endif CLICK_DECLS /* * Read efficient version of per thread, by giving a bitvector telling * which threads will be used, a mapping can be used to only read from * variables actually used * * Mapping is from index inside the storage vector to thread id */ template <typename T> class per_thread_oread : public per_thread<T> { public: void compress(Bitvector usable) { mapping.resize(usable.weight(),0); int id = 0; for (int i = 0; i < usable.size(); i++) { if (usable[i]) { mapping[id] = i; id++; } } per_thread<T>::_size = id; } inline bool initialized() { return mapping.size() > 0; } inline T& get_value(int i) const{ return per_thread<T>::storage[mapping[i]].v; } inline void set_value(int i, T v) { per_thread<T>::storage[mapping[i]].v = v; } private: Vector<unsigned int> mapping; }; /* * Memory efficient version which only duplicate the variable per thread * actually used, given a bitvector telling which one they are. However * this comes at the price of one more indirection as we * need a table to map thread ids to positions inside the storage * vector. The mapping table itself is a vector of integers, so * if your data structure is not bigger than two ints, it is not worth it. */ template <typename T> class per_thread_omem { private: typedef struct { T v; } CLICK_CACHE_ALIGN AT; AT* storage; Vector<unsigned int> mapping; unsigned _size; public: per_thread_omem() : storage(0),mapping(),_size(0) { } ~per_thread_omem() { if (storage) delete[] storage; } void initialize(Bitvector usable, T v=T()) { _size = usable.weight(); storage = new AT[_size]; mapping.resize(click_max_cpu_ids(), 0); int id = 0; for (unsigned i = 0; i < click_max_cpu_ids(); i++) { if (usable[i]) { storage[id].v = v; mapping[i] = id++; } } } inline T* operator->() const { return &(storage[mapping[click_current_cpu_id()]].v); } inline T& operator*() const { return storage[mapping[click_current_cpu_id()]].v; } inline T& operator+=(const T& add) const { storage[mapping[click_current_cpu_id()]].v += add; return storage[mapping[click_current_cpu_id()]].v; } inline T& operator++() const { // prefix ++ return ++(storage[mapping[click_current_cpu_id()]].v); } inline T operator++(int) const { // postfix ++ return storage[mapping[click_current_cpu_id()]].v++; } inline T& operator--() const { return --(storage[mapping[click_current_cpu_id()]].v); } inline T operator--(int) const { return storage[mapping[click_current_cpu_id()]].v--; } inline T& operator=(T value) const { set(value); return storage[mapping[click_current_cpu_id()]].v; } inline void set(T v) { storage[mapping[click_current_cpu_id()]].v = v; } inline void setAll(T v) { for (int i = 0; i < weight(); i++) storage[i].v = v; } inline T& get() const{ return storage[mapping[click_current_cpu_id()]].v; } inline T& get_value_for_thread(int thread_id) const{ return storage[mapping[thread_id]].v; } inline void set_value_for_thread(int thread_id, T v) { storage[mapping[thread_id]].v = v; } inline T& get_value(int i) const { return storage[i].v; } inline void set_value(int i, T v) { storage[i] = v; } inline unsigned weight() const { return _size; } }; /** * Convenient class to have MP and non-MP version of the same thimg eg : * * per_thread_arithmetic::sum(a); will work if a is an int or if a is a per_thread<int> */ class per_thread_arithmetic { public: static int sum(int i) { return i; } static unsigned usum(unsigned i) { return i; } static int sum(per_thread<int> &v) { PER_THREAD_SUM(unsigned, s, v); return s; } static unsigned sum(per_thread<unsigned> &v) { PER_THREAD_SUM(unsigned, s, v); return s; } static void set(int &i, int v) { i = v; } static void uset(unsigned &i, unsigned v) { i = v; } static void set(per_thread<int> &pt, int v) { PER_THREAD_SET(pt , v); } static void uset(per_thread<unsigned> &pt, unsigned v) { PER_THREAD_SET(pt , v); } #if HAVE_INT64_TYPES static int64_t sum_long(int64_t i) { return i; } static uint64_t usum_long(uint64_t i) { return i; } static void set_long(int64_t &i, int64_t v) { i = v; } static void uset_long(uint64_t &i, uint64_t v) { i = v; } static int64_t sum_long(per_thread<int64_t> &v) { PER_THREAD_SUM(int64_t, s, v); return s; } static int64_t usum_long(per_thread<uint64_t> &v) { PER_THREAD_SUM(uint64_t, s, v); return s; } static void set_long(per_thread<int64_t> &pt, int64_t v) { PER_THREAD_SET(pt, v); } static void uset_long(per_thread<uint64_t> &pt, uint64_t v) { PER_THREAD_SET(pt, v); } #endif }; /** * unprotected_rcu_singlewriter implements a very simple SINGLE * writer, multiple-reader rcu. * * rcu allows to do a kind of atomic write with any structure. A temp copy * is made for the writer, and when the writer has finished his write, he * commits the change by changing the pointer for all subsequent readers. * * Unlike usual RCU implementation, this one does not need lock for readers, * however memory will be corrupted if N subsequent writes happens while a * reader is obtaining a reference. If N cannot be asserted in your use-case, * this structure is not for you. Hence, the unprotected in the name to attract * attention to this fact. * * This works by having a ring of N elements. The writer updates the next * element of the ring, and when it has finished, it updates the current ring * index to the next element. For fast wrap-up computing, N must be * a power of 2 and at least 2. * * Using a ring allows for getting rid of atomic reference count, but introduces * the N problem. * * For this to work, the template class must be able to copy itself with "=", eg : * T b; * b.do_something(); * T a = b; * This is true for primitive, but you may need to implement operator= for class * * Usage : * unprotected_rcu_singlewriter<my_struct,2> rcu_struct; * reader : * click_chatter("Member is %d.", rcu_struct.read().member); * click_chatter("Member is %d.", rcu_struct->member); //Same, more convenient * writer : * my_struct &tmp_write = rcu_struct->write_begin(); * tmp_write->member++; * rcu_struct->write_commit(); */ template <typename T, int N> class unprotected_rcu_singlewriter { public: unprotected_rcu_singlewriter() : rcu_current(0) { } unprotected_rcu_singlewriter(T v) : rcu_current(0) { storage[rcu_current] = v; } ~unprotected_rcu_singlewriter() { } inline void initialize(T v) { storage[rcu_current] = v; } inline const T& read_begin() { return storage[rcu_current]; } inline void read_end() { } inline const T& read() const { return storage[rcu_current]; } inline const T operator*() const { return read(); } inline const T* operator->() const { return &read(); } inline T& write_begin() { int rcu_next = (rcu_current + 1) & (N - 1); storage[rcu_next] = storage[rcu_current]; return storage[rcu_next]; } inline void write_commit() { click_write_fence(); rcu_current = (rcu_current + 1) & (N - 1); } inline void write_abort() { } inline const T& read_begin(int) { return read_begin(); } inline void read_end(int) { return read_end(); } protected: T storage[N]; volatile int rcu_current; }; /** * unprotected_rcu works like unprotected_rcu_singlewriter but can have multiple writer. * * Usage is the same but attempt to write use a spinlock. In handlers or * other slow path, use this version. In other cases, double check if there could * be multiple writers at the same time, and if not, use unprotected_rcu_singlewriter. * * Failing to call write_commit() will cause a dead lock !!! * * To abort a write, use write_abort(); */ template <typename T,int N> class unprotected_rcu : public unprotected_rcu_singlewriter<T,N> { public: unprotected_rcu() : _write_lock() { } inline T& write_begin() { _write_lock.acquire(); return this->unprotected_rcu_singlewriter<T,N>::write_begin(); } inline void write_commit() { this->unprotected_rcu_singlewriter<T,N>::write_commit(); _write_lock.release(); } inline void write_abort() { _write_lock.release(); } private: Spinlock _write_lock; }; /** * Wrap a pointer to V with a reference count. Call get() and put() * to get and put reference. When created, it has a reference count of 1 * when the call to put() goes to 0, it calls delete on the pointer. */ template <typename T> class shared { public: shared() { _refcnt = 0; } shared(T p) : _p(p) { _refcnt = 0; } class ptr { public: inline ptr() : _v(0) {}; inline ptr(shared<T>* v) : _v(v) {_v->get();} inline ~ptr() { release(); } inline T* operator->() { return &_v->_p; } inline T* get() { return &_v->_p; } inline T& operator*() { return _v->_p; } inline ptr(const ptr &o) { _v = o._v; o._v = 0; } inline uint32_t refcnt() { return _v->_refcnt; } inline void assign(shared<T>* v) { release(); _v = v; _v->get(); } inline void assign_release(ptr &o) { release(); _v = o._v; o._v = 0; } inline void operator=(const ptr &o) { release(); _v = o._v; if (_v) _v->get(); } inline void release() { if (_v) _v->put(); _v = 0; } inline operator bool() const { return _v; } private: mutable shared<T>* _v; }; //shared does not support write_ptr, we typedef for convenience typedef ptr write_ptr; inline ptr operator->() { return ptr(this); } inline ptr read() { return ptr(this); } inline ptr write() { return write_ptr(this); } inline void get(ptr &o) { o.assign(this); } uint32_t refcnt() { return _refcnt; } inline bool unshared() { return _refcnt == 0; } inline bool write_held() { return hasref(); } inline bool hasref() { return _refcnt > 0; } T* unprotected_ptr() { return &_p; } private: T _p; atomic_uint32_t _refcnt; inline void get() { _refcnt++; } inline void put() { click_read_fence(); _refcnt--; } }; /** * Wrapper class to easily build a non-RW protected equivalent of shared */ template <typename T> class not_shared { public: not_shared() { } not_shared(T p) : _p(p) { } class ptr { public: inline ptr() : _v(0) {}; inline ptr(shared<T>* v) : _v(v) {_v->get();} inline ~ptr() { release(); } inline T* operator->() { return &_v->_p; } inline T* get() { return &_v->_p; } inline T& operator*() { return _v->_p; } inline ptr(const ptr &o) { _v = o._v; o._v = 0; } inline void assign(shared<T>* v) { release(); _v = v; _v->get(); } inline void assign_release(ptr &o) { release(); _v = o._v; o._v = 0; } inline void operator=(const ptr &o) { release(); _v = o._v; if (_v) _v->get(); } inline void release() { if (_v) _v->put(); _v = 0; } inline operator bool() const { return _v; } private: mutable not_shared<T>* _v; }; //shared does not support write_ptr, we typedef for convenience typedef ptr write_ptr; inline ptr operator->() { return ptr(this); } inline ptr read() { return ptr(this); } inline ptr write() { return write_ptr(this); } inline void get(ptr &o) { o.assign(this); } T* unprotected_ptr() { return &_p; } inline bool unshared() { return true; } inline bool write_held() { return true; } inline bool hasref() { return true; } private: T _p; inline void get() { } inline void put() { } }; /** * Multiple reader / single writer lock * * Enclose read critical section with read_begin()/read_end() * and write critical section with write_begin()/write_end() * * The lock is based on an atomic counter. * The lock is NOT reentrant. * * Carefull : calling write_begin while read is held or vice versa will end up in a deadlock */ class RWLock { public: RWLock() { _refcnt = 0; } /** * Start a read critical section * * You MUST call read_end() after calling read_begin(). You may also * call read_to_write(), but see read_to_write documentation for * specificities to use, as it may fail. */ inline void read_begin() { uint32_t current_refcnt; do { current_refcnt = _refcnt; #if ! CLICK_ATOMIC_COMPARE_SWAP } while ((int32_t)current_refcnt < 0 || (!_refcnt.compare_and_swap(current_refcnt,current_refcnt+1))); #else } while ((int32_t)current_refcnt < 0 || (_refcnt.compare_swap(current_refcnt,current_refcnt+1) != current_refcnt)); #endif } /** * Finish a read critical section */ inline void read_end() { click_read_fence(); _refcnt--; } /** * Add one more reader. * * You MUST have called read_begin() before this. * You MUST call as many time read_end as you called read_get + read_begin(). */ inline void read_get() { _refcnt++; } /** * Start a write critical section. * * This function will spin loop while readers have the lock. */ inline void write_begin() { #if ! CLICK_ATOMIC_COMPARE_SWAP while (!_refcnt.compare_and_swap(0,-1)) click_relax_fence(); #else while (_refcnt.compare_swap(0,-1) != 0) click_relax_fence(); #endif } /** * Start a write critical section only if nobody has the lock. */ inline bool write_attempt() CLICK_WARN_UNUSED_RESULT { #if ! CLICK_ATOMIC_COMPARE_SWAP return (_refcnt.compare_and_swap(0,-1)); #else return (_refcnt.compare_swap(0,-1) == 0); #endif } /** * Grab a second write reference on an already held write * @pre refcnt < 0 * @pre write_begin() has been called before */ inline void write_get() { _refcnt--; } /** * Release a write reference. */ inline void write_end() { click_write_fence(); _refcnt++; } /** * Convert a write lock to a read lock. */ inline void write_to_read() { click_write_fence(); assert(_refcnt == (uint32_t)-1); _refcnt = 1; } /** * Try to become a writer while read is held. This is unlikely but * this may fail, in which case this function returns false. You * have to assume that any pointer to the protected object is now * bad (a writer has grabbed the write lock while you released the read) * The unlikeliness of this event makes this function worth it, * if this is unacceptable, directly grab a write reference. * TLDR : if false, you have loosed your read lock and neither * acquired the write. * NEVER have read_to_write in a loop. The correct usage is : * * retry: * read_begin(); * //read_something * //compute something * if (read_to_write()) * //write result * else * goto retry; * * One may think that if read_to_write() fail, you could call * write_begin(). Actually this is wrong, as another writer * may have taken the lock while calling read_to_write(), and * changed the value. The whole computation would therefore not * be atomic anymore. Instead of the "goto retry", one * may check the read value has not changed after doing a write_begin() */ inline bool read_to_write() CLICK_WARN_UNUSED_RESULT; inline uint32_t refcnt() { return _refcnt; } private: atomic_uint32_t _refcnt; }; /** * A template to protect an object with RWLock. */ template <class V> class __rwlock : public RWLock { public: __rwlock() : _v(){ } __rwlock(V v) : _v(v) { } V _v; V* operator->() { return &_v; } V& operator*() { return _v; } }; /** * Read XOR Write lock, "prefer read" variant * * Allow either multiple reader or multiple * writer. When a reader arrives, writers stop taking the usecount. The reader * has access once all writer finish. * * To stop writer from locking, the reader will CAS a very low value. * * If max_writer is 1, this becomes rwlock, but with a priority on the reads */ class rXwlockPR { public: rXwlockPR() : max_write(-65535) { _refcnt = 0; } rXwlockPR(int32_t max_writers) { _refcnt = 0; set_max_writers(max_writers); } void set_max_writers(int32_t max_writers) { assert(max_writers < 65535); read_begin(); max_write = - max_writers; read_end(); } inline void read_begin() { uint32_t current_refcnt; do { current_refcnt = _refcnt; if (unlikely((int32_t)current_refcnt < 0)) { if ((int32_t)current_refcnt <= -65536) { //Just wait for the other reader out there to win } else { #if ! CLICK_ATOMIC_COMPARE_SWAP if (_refcnt.compare_and_swap(current_refcnt,current_refcnt - 65536)) { #else if (_refcnt.compare_swap(current_refcnt,current_refcnt - 65536) == current_refcnt) { #endif //We could lower the value, so wait for it to reach -65536 (0 writer but one reader waiting) and continue do { click_relax_fence(); } while((int32_t)_refcnt != -65536); //When it is -65536, driver cannot take it and reader are waiting, so we can set it directly _refcnt = 1; break; } } } else { // >= 0, just grab another reader (>0) #if ! CLICK_ATOMIC_COMPARE_SWAP if (likely(_refcnt.compare_and_swap(current_refcnt,current_refcnt+1))) #else if (likely(_refcnt.compare_swap(current_refcnt,current_refcnt+1) == current_refcnt)) #endif break; } click_relax_fence(); } while (1); } inline void read_end() { click_read_fence(); _refcnt--; } inline void read_get() { _refcnt++; } inline void write_begin() { uint32_t current_refcnt; do { current_refcnt = _refcnt; if (likely((int32_t)current_refcnt <= 0 && (int32_t)current_refcnt > max_write)) { #if ! CLICK_ATOMIC_COMPARE_SWAP if (_refcnt.compare_and_swap(current_refcnt,current_refcnt - 1)) #else if (_refcnt.compare_swap(current_refcnt,current_refcnt - 1) == current_refcnt) #endif break; } click_relax_fence(); } while (1); } inline void write_end() { click_write_fence(); _refcnt++; } private: atomic_uint32_t _refcnt; int32_t max_write; } CLICK_CACHE_ALIGN; /** * Read XOR Write lock, "prefer write" variant * * Allow either multiple reader or multiple * writer. When a reader arrives, writers stop taking the usecount. The reader * has access once all writer finish. * * To stop writer from locking, the reader will CAS a very low value. * * If max_writer is 1, this becomes rwlock, but with a priority on the write */ class rXwlockPW { public: rXwlockPW() : max_write(-65535) { _refcnt = 0; } rXwlockPW(int32_t max_writers) { _refcnt = 0; set_max_writers(max_writers); } void set_max_writers(int32_t max_writers) { assert(max_writers < 65535); write_begin(); max_write = - max_writers; write_end(); } inline void write_begin() { uint32_t current_refcnt; do { current_refcnt = _refcnt; if (unlikely((int32_t)current_refcnt < 0)) { if ((int32_t)current_refcnt <= -65536) { //Just wait for the other reader out there to win } else { #if ! CLICK_ATOMIC_COMPARE_SWAP if (_refcnt.compare_and_swap(current_refcnt,current_refcnt - 65536)) { #else if (_refcnt.compare_swap(current_refcnt,current_refcnt - 65536) == current_refcnt) { #endif //We could lower the value, so wait for it to reach -65536 (0 writer but one reader waiting) and continue do { click_relax_fence(); } while((int32_t)_refcnt != -65536); //When it is -65536, driver cannot take it and reader are waiting, so we can set it directly _refcnt = 1; break; } } } else { // >= 0, just grab another reader (>0) #if ! CLICK_ATOMIC_COMPARE_SWAP if (likely(_refcnt.compare_and_swap(current_refcnt,current_refcnt+1))) #else if (likely(_refcnt.compare_swap(current_refcnt,current_refcnt+1) == current_refcnt)) #endif break; } click_relax_fence(); } while (1); } inline void write_end() { click_write_fence(); _refcnt--; } inline void write_get() { _refcnt++; } inline void read_begin() { uint32_t current_refcnt; do { current_refcnt = _refcnt; if (likely((int32_t)current_refcnt <= 0 && (int32_t)current_refcnt > max_write)) { #if ! CLICK_ATOMIC_COMPARE_SWAP if (_refcnt.compare_and_swap(current_refcnt,current_refcnt - 1)) #else if (_refcnt.compare_swap(current_refcnt,current_refcnt - 1) == current_refcnt) #endif break; } click_relax_fence(); } while (1); } inline void read_end() { click_read_fence(); _refcnt++; } private: atomic_uint32_t _refcnt; int32_t max_write; } CLICK_CACHE_ALIGN; class rXwlock { public: rXwlock() { _refcnt = 0; } inline void read_begin() { uint32_t current_refcnt; current_refcnt = _refcnt; #if ! CLICK_ATOMIC_COMPARE_SWAP while ((int32_t)current_refcnt < 0 || !_refcnt.compare_and_swap(current_refcnt,current_refcnt+1)) { #else while ((int32_t)current_refcnt < 0 || _refcnt.compare_swap(current_refcnt,current_refcnt+1) != current_refcnt) { #endif click_relax_fence(); current_refcnt = _refcnt; } } void set_max_writers(int32_t max_writers) { (void)max_writers; } inline void read_end() { click_read_fence(); _refcnt--; } inline void read_get() { _refcnt++; } inline void write_begin() { uint32_t current_refcnt; current_refcnt = _refcnt; #if ! CLICK_ATOMIC_COMPARE_SWAP while ((int32_t)current_refcnt > 0 || !_refcnt.compare_and_swap(current_refcnt,current_refcnt-1)) { #else while ((int32_t)current_refcnt > 0 || _refcnt.compare_swap(current_refcnt,current_refcnt-1) != current_refcnt) { #endif click_relax_fence(); current_refcnt = _refcnt; } } inline void write_end() { click_write_fence(); _refcnt++; } private: atomic_uint32_t _refcnt; } CLICK_CACHE_ALIGN; /** * Shared-pointer based rwlock */ template <typename V> class rwlock { public: rwlock() : _v() { } rwlock(V v) : _v(v) { } class ptr { public : ptr(const ptr &o) { _p = o._p; if (_p) _p->read_get(); } void release() { if (_p) _p->read_end(); _p = 0; } ~ptr() { release(); } const V* operator->() const { return &_p->_v; } const V& operator*() const { return _p->_v; } void operator=(const ptr &o) { _p = o._p; if (_p) { _p->read_begin(); } } inline uint32_t refcnt() { return _p->refcnt(); } /** * Assign a rwlock to this pointer, grabbing the read lock. */ inline void assign(rwlock<V>* v) { release(); _p = &v->_v; if (_p) _p->read_begin(); } inline operator bool() const { return _p; } ptr() : _p(0) {}; private: __rwlock<V>* _p; ptr(__rwlock<V>* p) : _p(p) {}; //Read must be held friend class rwlock<V>; }; class write_ptr { public : write_ptr(const write_ptr &o) { _p = o._p; if (_p) { _p->write_get(); } } void release() { if (_p) _p->write_end(); _p = 0; } ~write_ptr() { release(); } V* operator->() { return &_p->_v; } V& operator*() { return _p->_v; } void operator=(const write_ptr &o) { if (o._p) _p->write_end(); _p = o._p; if (_p) { _p->write_get(); } } uint32_t refcnt() { return _p->refcnt(); } /** * Assign a rwlock to this pointer, grabbing the write lock. */ inline void assign(rwlock<V>* v) { release(); _p = &v->_v; if (_p) _p->write_begin(); } /** * Copy the ownership of a given write pointer and release that * pointer. */ inline void assign_release(write_ptr& o) { release(); _p = o._p; o._p = 0; } inline operator bool() const { return _p; } write_ptr() : _p(0) {}; private: __rwlock<V>* _p; write_ptr(__rwlock<V>* p) : _p(p) {}; //Write must be held friend class rwlock<V>; }; ptr read() { _v.read_begin(); return ptr(&_v); } write_ptr write() { _v.write_begin(); return write_ptr(&_v); } /** * Destroys the given read pointer and return a write pointer. * * This may fail, in which case the returned and the given pointer * are both null. * * In any case attempting to access the given read pointer will cause segfault */ write_ptr read_to_write(const ptr &o) { o._p = 0; if (_v.read_to_write()) { return write_ptr(_v); } return write_ptr(); } /** * Destroys the given write pointer and return a read pointer. * * Attempting to access the given write pointer afterwards will cause segfault */ ptr write_to_read(const write_ptr &o) { o._p = 0; _v.write_to_read(); return const_ptr(_v); } V* unprotected_ptr() { return &_v._v; } uint32_t refcnt() { return _v.refcnt(); } private: __rwlock<V> _v; }; inline bool RWLock::read_to_write() { /* Sadly, read_to_write is more complex than write_to_read, * because * two readers could want to become writer at the same time, * probably having some reference that will become invalid if * someone else grab the write. In this case one of them must * fail and retry again, or we'll have a deadlock. * * The trick is to add 1000 to the refcnt, only one potential * writer will be able to do that so after that we can wait for * the count to be 1000000 (no more reader) and make it -1 */ click_write_fence(); //All that being said, we make a first attempt in case we would be the only reader #if ! CLICK_ATOMIC_COMPARE_SWAP if (_refcnt.compare_and_swap(1,-1)) #else if (_refcnt.compare_swap(1,-1) == 1) #endif return true; uint32_t current_refcnt; uint32_t new_refcnt; do { current_refcnt = _refcnt; new_refcnt = current_refcnt+1000000; if (current_refcnt > 1000000) { read_end(); click_relax_fence(); return false; } #if ! CLICK_ATOMIC_COMPARE_SWAP } while (!_refcnt.compare_and_swap(current_refcnt,new_refcnt)); while (!_refcnt.compare_and_swap(1000001,-1)) click_relax_fence(); #else } while (_refcnt.compare_swap(current_refcnt,new_refcnt) != current_refcnt); while (_refcnt.compare_swap(1000001,-1) != 1000001) click_relax_fence(); #endif return true; } /** * click_rcu is the ultimate version of the RCU series, the more * protected one which will always work but also the slowest one. * * The problem of unprotected_rcu* is solved by keeping * a reference count of the amount of readers using any current * bucket. The writer will wait for all readers to finish before * overwriting the next available slot. * * Here, the writers exclude each other by setting the refcnt * to -1 atomically, if the value was 0. They will spinloop around * the refcnt until each other writer has finished. * * It is not as bad as a critical section/interrupt like in kernel, * but those lock operation still have a non-negligeable cost. * * It may be difficult to see that writer cannot overwrite a bucket that is * currently being accessed, here is a helping example : * A reads index * B write and advance * C write and advance, check refcnt[A], CAS 0 -> -1 * A writes refcnt[A] -> CAS fail * * The ring has 2 values, so one writer can update one bucket while readers * may still read the other bucket. */ template <typename T> class click_rcu { public: click_rcu() : rcu_current(0) { refcnt[0] = 0; refcnt[1] = 0; } click_rcu(T v) : rcu_current(0) { refcnt[0] = 0; refcnt[1] = 0; initialize(v); } ~click_rcu() {} inline void initialize(T v) { storage[rcu_current] = v; } /** * A loop is needed to avoid a race condition where thread A reads * rcu_current, then writer B does a full write, start a second write * before A update the refcnt. A would then inc the refcnt, * and get a reference while B is in fact writing that bucket. * * The solution is the following one: * When the refcnt for the next bucket is 0, the writer is writing -1 as * the refcnt. This is done atomicly using a CAS instruction. * * In the reader, we check if the refcnt is -1 (current write), and if not we CAS * refcnt+1. We loop until the CAS worked so we know that we made a "refcnt++" * without any writer starting to write in the bucket. * * Also, the same rcu_current_local must be passed to read_end * as we need to down the actual refcnt we incremented, and rcu_current * may be incremented by 1 before we finish our reading. */ inline const T& read_begin(int &rcu_current_local) { uint32_t current_refcnt; do { rcu_current_local = rcu_current; click_read_fence(); current_refcnt = refcnt[rcu_current_local].value(); #if ! CLICK_ATOMIC_COMPARE_SWAP if (current_refcnt == (uint32_t)-1 || !(refcnt[rcu_current_local].compare_and_swap(current_refcnt,current_refcnt+1))) { #else if (current_refcnt == (uint32_t)-1 || (refcnt[rcu_current_local].compare_swap(current_refcnt,current_refcnt+1) != current_refcnt)) { #endif click_relax_fence(); } else { break; } } while (1); click_write_fence(); //The reference is holded now, we are sure that no writer will edit this until read_end is called. return storage[rcu_current_local]; } inline void read_end(const int &rcu_current_local) { click_compiler_fence(); //No reorder of refcnt-- refcnt[rcu_current_local]--; } inline T read() { int flags; T v = read_begin(flags); read_end(flags); return v; } /** * No need for lock of writers anymore. We atomicly set the refcnt to -1 if * the value is 0, if another writer is writing, it would have done the * same. * If no readers are reading, the refcnt would not be 0. */ inline T& write_begin() { int rcu_next; retry: do { rcu_next = (rcu_current + 1) & 1; #if ! CLICK_ATOMIC_COMPARE_SWAP } while (!refcnt[rcu_next].compare_and_swap(0,-1)); #else } while (refcnt[rcu_next].compare_swap(0,-1) != 0); #endif /*As the other writer writes the refcnt before rcu_current, we could *have grabbed the new actual bucket*/ if (rcu_next == rcu_current) { refcnt[rcu_next] = 0; goto retry; } //Refcnt is now -1, and we are the only writer storage[rcu_next] = storage[rcu_current]; return storage[rcu_next]; } inline void write_commit() { int rcu_next = (rcu_current + 1) & 1; rcu_current = rcu_next; click_write_fence(); refcnt[rcu_next] = 0; } inline void write_abort() { /*Just set the refcnt to 0, as rcu_current is not changed, another writer will grab the same bucket, and the readers will not see a thing*/ click_write_fence(); refcnt[(rcu_current + 1) & 1] = 0; } inline void write(const T &v) { write_begin() = v; write_commit(); } protected: atomic_uint32_t refcnt[2]; T storage[2]; volatile int rcu_current; }; /** * Fast RCU that avoids heavy locked CAS by using a per-thread writer epoch */ template <typename T> class fast_rcu { public: #define RCU_N 2 fast_rcu() : _rcu_current(0), _epochs(0), _write_epoch(1) { } fast_rcu(T v) : _rcu_current(0), _epochs(0), _write_epoch(1){ initialize(v); } ~fast_rcu() {} inline void initialize(T v) { _storage[_rcu_current].v = v; } inline const T& read_begin(int &) { int w_epoch = _write_epoch; *_epochs = w_epoch; click_write_fence(); //Actually read rcu_current after storing epoch int rcu_current_local = _rcu_current; click_read_fence();//Do not read _rcu_current later //The reference is holded now, we are sure that no writer will edit this until read_end is called. return _storage[rcu_current_local].v; } inline void read_end(const int &) { click_compiler_fence(); //No load or store after writing the epoch bak to 0 *_epochs = 0; } inline T read() { int flags; T v = read_begin(flags); read_end(flags); return v; } inline T& write_begin(int& rcu_current_local) { _write_lock.acquire(); rcu_current_local = _rcu_current; int rcu_next = (rcu_current_local + 1) & (RCU_N - 1); int bad_epoch = (_write_epoch - RCU_N) + 1; unsigned i = 0; loop: for (; i < _epochs.weight(); i ++) { int te = _epochs.get_value(i); if (unlikely(te != 0 && te == bad_epoch)) { click_relax_fence(); goto loop; } //TODO : if allow RCU_N > 2, compute a min_epoch at the same time so next writer can avoid looping } //All epochs are 0 (no accessed, or at least not to the current ptr) _storage[rcu_next].v = _storage[rcu_current_local].v; return _storage[rcu_next].v; } inline void write_commit(int rcu_current_local) { click_write_fence(); //Prevent write to finish after this _rcu_current = (rcu_current_local + 1) & 1; click_compiler_fence(); //Write epoch must happen after rcu_current, to be sure that thr old bucket is not read and accessed with the new epoch. ++_write_epoch; _write_lock.release(); } protected: typedef struct { T v; } CLICK_CACHE_ALIGN AT; volatile int _rcu_current; per_thread<volatile int> _epochs; AT _storage[2]; volatile int _write_epoch; Spinlock _write_lock; }; CLICK_ENDDECLS #endif
25.302234
152
0.573799
[ "object", "vector" ]
ad470283ce63c2ab298f265dd302783d3fdf13c0
4,209
cpp
C++
ImpGears/PipelineES3/CubeMap.cpp
Lut1n/IGBarkAndLeafEditor
bbda30f6f4510da4184dc6f6d9db698f81dea519
[ "MIT" ]
1
2021-02-09T18:42:02.000Z
2021-02-09T18:42:02.000Z
ImpGears/PipelineES3/CubeMap.cpp
Lut1n/IGBarkAndLeafEditor
bbda30f6f4510da4184dc6f6d9db698f81dea519
[ "MIT" ]
null
null
null
ImpGears/PipelineES3/CubeMap.cpp
Lut1n/IGBarkAndLeafEditor
bbda30f6f4510da4184dc6f6d9db698f81dea519
[ "MIT" ]
null
null
null
#include <PipelineES3/CubeMap.h> #include <PipelineES3/GlError.h> #include <iostream> IMPGEARS_BEGIN std::uint32_t CubeMap::_s_count = 0; //-------------------------------------------------------------- CubeMap::CubeMap(const std::string& name) : _videoID(0) , _name(name) { glGenTextures(1, &_videoID); GL_CHECKERROR("gen CubeMap"); _s_count++; } //-------------------------------------------------------------- CubeMap::~CubeMap() { glDeleteTextures(1, &_videoID); GL_CHECKERROR("delete CubeMap"); _videoID = 0; _s_count--; } //-------------------------------------------------------------- void CubeMap::loadFromMemory(std::uint8_t* buf, std::uint32_t width, std::uint32_t height, int chnls, int faceID) { std::int32_t glInternalFormat = 0; std::int32_t glDataFormat = 0; std::int32_t glDataType = GL_UNSIGNED_BYTE; if(chnls == 1) { // case PixelFormat_R16 : glDataFormat = GL_ALPHA; glInternalFormat = GL_ALPHA; } else if(chnls == 3) { glDataFormat = GL_RGB; glInternalFormat = GL_RGB; } else if(chnls == 4) { glDataFormat = GL_RGBA; glInternalFormat = GL_RGBA; } else if(chnls == 2) { // case PixelFormat_R16 : // glDataFormat = GL_DEPTH_COMPONENT; // glInternalFormat = GL_DEPTH_COMPONENT16; } else { std::cerr << "impError : " << _name << " CubeMap format error (" << chnls << " chnls)" << std::endl; } // glActiveTexture(GL_TEXTURE0); bind(); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+faceID, 0, glInternalFormat, width, height,0, glDataFormat, glDataType, buf); GL_CHECKERROR("CubeMap update gpu Texture"); unbind(); update(); } //-------------------------------------------------------------- void CubeMap::saveToMemory(std::uint8_t* buf, std::uint32_t width, std::uint32_t height, int chnls, int faceID) { std::int32_t glDataFormat = 0; std::int32_t glDataType = GL_UNSIGNED_BYTE; if(chnls == 1) { glDataFormat = GL_ALPHA; // glInternalFormat = GL_DEPTH_COMPONENT16; } else if(chnls == 3) { glDataFormat = GL_RGB; // glInternalFormat = GL_RGB; } else if(chnls == 4) { glDataFormat = GL_RGBA; // glInternalFormat = GL_RGBA; } // glActiveTexture(GL_TEXTURE0); bind(); // glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X+faceID, 0, glDataFormat, glDataType, buf); unbind(); } //-------------------------------------------------------------- void CubeMap::loadFromImage(const std::vector<Image::Ptr>& img) { _sources = img; for(int i=0; i<6; ++i) loadFromMemory(img[i]->data(), img[i]->width(),img[i]->height(),img[i]->channels(), i); } //-------------------------------------------------------------- void CubeMap::saveToImage(std::vector<Image::Ptr>& img) { for(int i=0; i<6; ++i) { saveToMemory(img[i]->data(), img[i]->width(),img[i]->height(),img[i]->channels(), i); GL_CHECKERROR("CubeMap::saveToImage"); } } //-------------------------------------------------------------- void CubeMap::update() { std::int32_t glFilterMagValue = GL_LINEAR; std::int32_t glWrapMode = GL_CLAMP_TO_EDGE; GLint glFilterMinValue = glFilterMagValue; // glActiveTexture(GL_TEXTURE0); bind(); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, glWrapMode); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, glWrapMode); // glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, glWrapMode); GL_CHECKERROR("CubeMap update 1"); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, glFilterMagValue); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, glFilterMinValue); GL_CHECKERROR("CubeMap update 2"); unbind(); } //-------------------------------------------------------------- void CubeMap::bind() const { glBindTexture(GL_TEXTURE_CUBE_MAP, _videoID); GL_CHECKERROR("bind CubeMap"); } //-------------------------------------------------------------- void CubeMap::unbind() const { glBindTexture(GL_TEXTURE_CUBE_MAP, 0); } IMPGEARS_END
27.154839
125
0.560228
[ "vector" ]
ad48ef82b46aa333092be3d2c573de32e9b6724f
3,320
cpp
C++
src/song_map.cpp
Gypsophino-dev/Gypsophino
484325bd5db36d99cdc13048646695b94f656111
[ "WTFPL" ]
null
null
null
src/song_map.cpp
Gypsophino-dev/Gypsophino
484325bd5db36d99cdc13048646695b94f656111
[ "WTFPL" ]
null
null
null
src/song_map.cpp
Gypsophino-dev/Gypsophino
484325bd5db36d99cdc13048646695b94f656111
[ "WTFPL" ]
null
null
null
#include "song_map.hpp" namespace pt = boost::property_tree; namespace gyp { // class song_map void song_map::load(const std::string& filename) { pt::ptree tree; pt::read_json(filename, tree); track_number = tree.get<int>("track_number"); bpm = tree.get<int>("bpm"); base_fraction = tree.get<int>("base_fraction"); difficulty = tree.get<int>("difficulty"); song_duration = tree.get<int>("song_duration"); object_count = tree.get<int>("object_count"); offset = tree.get<float>("offset"); song_author = tree.get<std::string>("song_author"); name = tree.get<std::string>("name"); map_author = tree.get<std::string>("map_author"); difficulty_name = tree.get<std::string>("difficulty_name"); music_path = tree.get<std::string>("music_path"); notes = std::vector<std::vector<int>>(track_number, std::vector<int>()); for (pt::ptree::value_type &single_track : tree.get_child("notes")) { for (pt::ptree::value_type &single_note : single_track.second.get_child("time")) { notes[single_track.second.get<int>("track")].push_back( single_note.second.get_value<int>()); } } } void song_map::save(const std::string& filename) { pt::ptree tree; tree.put("track_number", track_number); tree.put("bpm", bpm); tree.put("base_fraction", base_fraction); tree.put("difficulty", difficulty); tree.put("song_duration", song_duration); tree.put("object_count", object_count); tree.put("offset", offset); tree.put("song_author", song_author); tree.put("name", name); tree.put("map_author", map_author); tree.put("difficulty_name", difficulty_name); tree.put("music_path", music_path); pt::ptree notes_tree; for (int i = 0; i < track_number; i++) { pt::ptree single_track; pt::ptree single_track_time; for (int t : notes[i]) { pt::ptree single_note; single_note.put_value(t); single_track_time.push_back(std::make_pair("", single_note)); } single_track.put("track", i); single_track.push_back(std::make_pair("time", single_track_time)); notes_tree.push_back(std::make_pair("", single_track)); } tree.push_back(std::make_pair("notes", notes_tree)); pt::write_json(filename, tree); } // class song_map_db void song_map_db::load(const std::string& filename) { pt::ptree tree; pt::read_json(filename, tree); tree.get<int>("song_map_number"); for (pt::ptree::value_type &single_song : tree.get_child("song_maps")) { content.emplace_back(single_song.second.get_value<std::string>(), song_map()); content.back().second.load(content.back().first); } } void song_map_db::save(const std::string& filename) { pt::ptree tree; tree.put("song_map_number", song_map_number); pt::ptree song_maps_tree; for (const std::pair<std::string, song_map> &single_song : content) { pt::ptree single_song_path; single_song_path.put_value(single_song.first); song_maps_tree.push_back(std::make_pair("", single_song_path)); } tree.push_back(std::make_pair("song_maps", song_maps_tree)); pt::write_json(filename, tree); } template <typename Compare> void song_map_db::sort(Compare comp) { std::sort(content.begin(), content.end(), comp); } song_map &song_map_db::operator[](size_t index) { return content[index].second; } } // namespace gyp
32.54902
74
0.686446
[ "vector" ]
ad49470a482e5cf6fd7c604ec04a151d6e6203c5
3,195
tpp
C++
include/mgcpp/expressions/dmat_dmat_mult.tpp
MGfoundation/mgcpp
66c072191e58871637bcb3b76701a79a4ae89779
[ "BSL-1.0" ]
48
2018-01-02T03:47:18.000Z
2021-09-09T05:55:45.000Z
include/mgcpp/expressions/dmat_dmat_mult.tpp
MGfoundation/mgcpp
66c072191e58871637bcb3b76701a79a4ae89779
[ "BSL-1.0" ]
24
2017-12-27T18:03:13.000Z
2018-07-02T09:00:30.000Z
include/mgcpp/expressions/dmat_dmat_mult.tpp
MGfoundation/mgcpp
66c072191e58871637bcb3b76701a79a4ae89779
[ "BSL-1.0" ]
6
2018-01-14T14:06:10.000Z
2018-10-16T08:43:01.000Z
// Copyright RedPortal, mujjingun 2017 - 2018. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <mgcpp/expressions/dmat_dmat_mult.hpp> namespace mgcpp { /* namespace internal { template <typename LhsExpr, typename RhsExpr> inline decltype(auto) dmat_dmat_mult_subgraph_matcher( dmat_dmat_mult_expr<LhsExpr, RhsExpr> const& expr) { auto const& lhs = mgcpp::eval(expr._lhs); auto const& rhs = mgcpp::eval(expr._rhs); return strict::mult(lhs, rhs); } template <typename LhsScal, typename LhsMat, typename RhsExpr> inline decltype(auto) dmat_dmat_mult_subgraph_matcher( dmat_dmat_mult_expr<scalar_dmat_mult_expr<LhsScal, LhsMat>, RhsExpr> const& expr) { using value_type = typename RhsExpr::value_type; using result_type = typename dmat_dmat_mult_expr<scalar_dmat_mult_expr<LhsScal, LhsMat>, RhsExpr>::result_type; auto const& alpha = mgcpp::eval(expr._lhs._scal_expr); auto const& A = mgcpp::eval(expr._lhs._dmat_expr); auto const& B = mgcpp::eval(expr._rhs); size_t m = A.shape()[0]; size_t n = B.shape()[1]; return strict::gemm(alpha, A, B, value_type(), result_type({m, n}, value_type())); } template <typename RhsScal, typename RhsMat, typename LhsExpr> inline decltype(auto) dmat_dmat_mult_subgraph_matcher( dmat_dmat_mult_expr<LhsExpr, scalar_dmat_mult_expr<RhsScal, RhsMat>> const& expr) { using value_type = typename LhsExpr::value_type; using result_type = typename dmat_dmat_mult_expr< LhsExpr, scalar_dmat_mult_expr<RhsScal, RhsMat>>::result_type; auto const& alpha = mgcpp::eval(expr._rhs._scal_expr); auto const& A = mgcpp::eval(expr._lhs); auto const& B = mgcpp::eval(expr._rhs._dmat_expr); size_t m = A.shape()[0]; size_t n = B.shape()[1]; return strict::gemm(alpha, A, B, value_type(), result_type({m, n}, value_type())); } } // namespace internal template <typename LhsExpr, typename RhsExpr> inline dmat_dmat_mult_expr<LhsExpr, RhsExpr>::dmat_dmat_mult_expr( LhsExpr const& lhs, RhsExpr const& rhs) noexcept : _lhs(lhs), _rhs(rhs) {} template <typename LhsExpr, typename RhsExpr> inline dmat_dmat_mult_expr<LhsExpr, RhsExpr>::dmat_dmat_mult_expr( LhsExpr&& lhs, RhsExpr&& rhs) noexcept : _lhs(std::move(lhs)), _rhs(std::move(rhs)) {} template <typename LhsExpr, typename RhsExpr> typename dmat_dmat_mult_expr<LhsExpr, RhsExpr>::result_type dmat_dmat_mult_expr<LhsExpr, RhsExpr>::eval() const { return internal::dmat_dmat_mult_subgraph_matcher(*this); } */ template <typename LhsExpr, typename RhsExpr> dmat_dmat_mult_expr<LhsExpr, RhsExpr> operator*( dmat_expr<LhsExpr> const& lhs, dmat_expr<RhsExpr> const& rhs) noexcept { return dmat_dmat_mult_expr<LhsExpr, RhsExpr>(~lhs, ~rhs); } template <typename LhsExpr, typename RhsExpr> dmat_dmat_mult_expr<LhsExpr, RhsExpr> mult( dmat_expr<LhsExpr> const& lhs, dmat_expr<RhsExpr> const& rhs) noexcept { return dmat_dmat_mult_expr<LhsExpr, RhsExpr>(~lhs, ~rhs); } } // namespace mgcpp
33.631579
79
0.714241
[ "shape" ]
ad4d58ca7230ee432f2e3f7f4272943c53bd8167
1,576
cpp
C++
example/naughtyfication.cpp
LAGonauta/YoloRT
7f8259bdb9060593d868a246cbc796118c829acf
[ "MIT" ]
5
2021-02-06T01:43:35.000Z
2022-02-14T10:27:25.000Z
example/naughtyfication.cpp
LAGonauta/YoloRT
7f8259bdb9060593d868a246cbc796118c829acf
[ "MIT" ]
null
null
null
example/naughtyfication.cpp
LAGonauta/YoloRT
7f8259bdb9060593d868a246cbc796118c829acf
[ "MIT" ]
null
null
null
#include <winrt/Windows.UI.Notifications.h> #include <winrt/Windows.Data.Xml.Dom.h> #include <iostream> #include <locale> #include <codecvt> using std::cerr; static std::wbuffer_convert<std::codecvt_utf8_utf16<wchar_t>> converting_stderr_buf{ cerr.rdbuf() }; std::wostream wcerr{ &converting_stderr_buf }; template<std::wostream &Stream> struct wflusher { ~wflusher(){ Stream.flush(); } }; static wflusher<wcerr> wcerr_flusher; using std::wstring_view; using namespace std::string_view_literals; int main() try { using namespace winrt::Windows::UI::Notifications; using mgr = ToastNotificationManager; auto toastdoc = mgr::GetTemplateContent( ToastTemplateType::ToastText01 ); toastdoc.SelectSingleNode(L"//text").InnerText(L"hello world"); wcerr <<"markup: LR\"("<< wstring_view{toastdoc.GetXml()} <<")\"\n"; const auto aumid = L"mjk.YoloRT.NaughtyExample"sv; //application user model ID mgr::CreateToastNotifier(aumid).Show( ToastNotification{toastdoc} ); /* For the notification to be shown, the AUMID needs to have been registered in the system, which is currently outside the scope of this example. One (the only?) way to do that is putting an AUMID-bearing shortcut into the start menu. See, e.g., https://docs.microsoft.com/en-us/previous-versions\ /windows/desktop/legacy/hh802762(v=vs.85) */ } catch ( const winrt::hresult_error &e ) { wcerr <<"error 0x"<< std::hex << e.code() <<": "<< wstring_view{e.message()} << '\n'; return 1; } catch ( const std::exception &e ) { cerr << e.what() << '\n'; return 1; }
29.185185
80
0.709391
[ "model" ]
ad4dd53cbe4a19deb1e15f29ceff0808c15ada21
2,238
cpp
C++
Graph/Second Shortest Path.cpp
ArniRahman/Algorithms
081b3eae5564685fd0acc3261c946d89e9dc75ba
[ "MIT" ]
null
null
null
Graph/Second Shortest Path.cpp
ArniRahman/Algorithms
081b3eae5564685fd0acc3261c946d89e9dc75ba
[ "MIT" ]
null
null
null
Graph/Second Shortest Path.cpp
ArniRahman/Algorithms
081b3eae5564685fd0acc3261c946d89e9dc75ba
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; const int N = 5001; struct node{ int degree; int x; int y; }; bool operator<(node a, node b) { return a.y > b.y; } priority_queue< node> q; void dijkstra(int s, int n, int popped[][N], int value[][N], vector <node> V[]) { for(int i=0;i<2;i++) { for(int j=0;j<N;j++) { value[i][j] = INT_MAX; } } value[0][s] = 0; node p; p.degree = 0; p.x = s; p.y = value[0][s]; q.push(p); while(!q.empty()) { node u = q.top(); q.pop(); if(popped[u.degree][u.x]==1) continue; popped[u.degree][u.x] = 1; for(int i = 0;i<V[u.x].size();i++) { node v; v = V[u.x][i]; int temp = v.y+value[u.degree][u.x]; if(popped[v.degree][v.x]==0 && temp <value[0][v.x]) { value[1][v.x] = value[0][v.x]; v.y = value[1][v.x]; v.degree = 1; q.push(v); value[0][v.x] = temp; v.y = value[0][v.x]; v.degree = 0; q.push(v); } else if ( temp >value[0][v.x] && temp <value[1][v.x]) { value[1][v.x] = temp; v.y = value[1][v.x]; v.degree = 1; q.push(v); } } } } int main() { int t; cin>>t; int cnt2 = 0; while(t--) { cnt2++; vector <node> V[N]; int popped[2][N], value[2][N]; for(int i=0;i<2;i++) { for(int j=0;j<N;j++) { popped[i][j] = 0; value[i][j] = 0; } } int n,E; cin>>n>>E; for( int i=0;i<E;i++) { int u,v,w; cin>>u>>v>>w; node p; p.x = v; p.y = w; p.degree = 0; V[u].push_back(p); p.x = u; V[v].push_back(p); } dijkstra(1,n,popped,value,V); cout<<"Case "<<cnt2<<": "<<value[1][n]<<endl; } return 0; }
15.87234
79
0.344057
[ "vector" ]
ad5191536f92817d132066970aa0a85b07aadd31
5,195
cc
C++
src/lib/yang/tests/adaptor_config_unittests.cc
telekom/dt-kea-netconf
f347df353d58827d6deb09f281d3680ab089e7af
[ "Apache-2.0" ]
2
2021-06-29T09:56:34.000Z
2021-06-29T09:56:39.000Z
src/lib/yang/tests/adaptor_config_unittests.cc
telekom/dt-kea-netconf
f347df353d58827d6deb09f281d3680ab089e7af
[ "Apache-2.0" ]
null
null
null
src/lib/yang/tests/adaptor_config_unittests.cc
telekom/dt-kea-netconf
f347df353d58827d6deb09f281d3680ab089e7af
[ "Apache-2.0" ]
null
null
null
// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> #include <yang/adaptor_config.h> #include <testutils/io_utils.h> #include <testutils/user_context_utils.h> #include <gtest/gtest.h> using namespace std; using namespace isc; using namespace isc::data; using namespace isc::test; using namespace isc::yang; namespace { /// @brief Fixture class that helps testing AdaptorConfig struct AdaptorConfigTest : public ::testing::Test { /// @brief Load an example JSON config /// /// @param fname name of the file (expected to be a valid JSON config) /// @param v6 - false=v4, true=v6 /// @param result - JSON converted by a AdaptorConfig::preprocess[4/6] void testFile(const std::string& fname, bool v6, ElementPtr& result) { ElementPtr json; ElementPtr reference_json; string decommented = decommentJSONfile(fname); EXPECT_NO_THROW(json = Element::fromJSONFile(decommented, true)); reference_json = moveComments(json); // remove the temporary file EXPECT_NO_THROW(::remove(decommented.c_str())); string before = json->str(); if (v6) { ASSERT_NO_THROW(AdaptorConfig::preProcess6(json)); } else { ASSERT_NO_THROW(AdaptorConfig::preProcess4(json)); } string after = json->str(); EXPECT_FALSE(before.empty()); EXPECT_FALSE(after.empty()); result = json; } }; TEST_F(AdaptorConfigTest, loadExamples4) { vector<string> configs = { "advanced.json", "all-keys-netconf.json", "backends.json", "cassandra.json", "classify.json", "classify2.json", "comments.json", "config-backend.json", "dhcpv4-over-dhcpv6.json", "global-reservations.json", "ha-load-balancing-primary.json", "hooks.json", "hooks-radius.json", "leases-expiration.json", "multiple-options.json", "mysql-reservations.json", "pgsql-reservations.json", "reservations.json", "several-subnets.json", "shared-network.json", "single-subnet.json", "with-ddns.json" }; ElementPtr x; for (int i = 0; i<configs.size(); i++) { x.reset(); testFile(string(CFG_EXAMPLES) + "/kea4/" + configs[i], false, x); ASSERT_TRUE(x); } } TEST_F(AdaptorConfigTest, loadExamples6) { vector<string> configs = { "advanced.json", "all-keys-netconf.json", "backends.json", "cassandra.json", "classify.json", "classify2.json", "comments.json", "config-backend.json", "dhcpv4-over-dhcpv6.json", "duid.json", "global-reservations.json", "ha-hot-standby.json", "hooks.json", "iPXE.json", "leases-expiration.json", "multiple-options.json", "mysql-reservations.json", "pgsql-reservations.json", "reservations.json", "several-subnets.json", "shared-network.json", "simple.json", "softwire46.json", "stateless.json", "tee-times.json", "with-ddns.json" }; ElementPtr x; for (int i = 0; i<configs.size(); i++) { x.reset(); testFile(string(CFG_EXAMPLES) + "/kea6/" + configs[i], true, x); ASSERT_TRUE(x); } } /// In general, the AdatorConfig class doesn't need very thorough /// direct tests, as there will be tests that will process whole /// configuration that will in turn use AdaptorConfig calls. /// Nevertheless, here are some ideas for tests. We hope to have /// them implemented one day. /// /// @todo: Check subnet-id assigned in subnets using any config /// @todo: Check shared-networks assign id using kea4/shared-network.json /// @todo: Check option classes using kea4/classify2.json /// @todo: Check option data using kea6/with-ddns.json /// @todo: Check option defs using kea6/dhcpv4-over-dhcpv6.json } // anonymous namespace
36.328671
73
0.505871
[ "vector" ]
ad5311e8a8276ca4b8dd68c38549a92f91f2f59f
3,939
cpp
C++
src/yslam/src/lidar_v1.cpp
yanghq13/slam
8b05da546b5a8616141ad46e4ae743b9165e3b6f
[ "Apache-2.0" ]
null
null
null
src/yslam/src/lidar_v1.cpp
yanghq13/slam
8b05da546b5a8616141ad46e4ae743b9165e3b6f
[ "Apache-2.0" ]
null
null
null
src/yslam/src/lidar_v1.cpp
yanghq13/slam
8b05da546b5a8616141ad46e4ae743b9165e3b6f
[ "Apache-2.0" ]
null
null
null
// 添加头文件后需要在CMakelists添加相应的包 // ros用 #include <ros/ros.h> #include <sensor_msgs/PointCloud2.h> #include <std_msgs/String.h> // 数学 #include <cmath> // 世界统一坐标系 #include <tf/transform_datatypes.h> #include <tf/transform_broadcaster.h> // pcl #include <pcl_conversions/pcl_conversions.h> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <pcl/filters/voxel_grid.h> #include <pcl/kdtree/kdtree_flann.h> ros::Publisher PubLaserCloudUp, PubLaserCloudDown; // 点云数据回调函数 void cloud_CallHandler(const sensor_msgs::PointCloud2 ros_cloud) { // 初始化 static tf::TransformBroadcaster br; tf::Transform t; tf::Quaternion q; // 设置原点 t.setOrigin(tf::Vector3(0,0,0)); // 设置四元数 q.setW(1); q.setX(0); q.setY(0); q.setZ(0); // 转换坐标系 t.setRotation(q); // 发送变换信息,PointCloud2的header.stamp为时间戳 br.sendTransform(tf::StampedTransform(t,ros_cloud.header.stamp,"map","map_child")); // 点云转换pcl格式 pcl::PointCloud<pcl::PointXYZ> laserClouIn; pcl::fromROSMsg(ros_cloud,laserClouIn); // 计数用于循环 int cloudSize = laserClouIn.points.size(); int count = cloudSize; // PointXYZI包含强度intensity pcl::PointXYZI point; // 判定各点的线数,按线数保存 int N_SCANS = 16; // 激光线数 std::vector<pcl::PointCloud<pcl::PointXYZI>> laserCloudScans(N_SCANS); for(int i=0;i<cloudSize;i++) { // 获取输入点云 point.x = laserClouIn.points[i].x; point.y = laserClouIn.points[i].y; point.z = laserClouIn.points[i].z; // 点云仰角,三角函数求的都是弧度 float angle = 0; angle = atan2(point.z , sqrt(point.x * point.x + point.y * point.y)); angle = angle * 180 / M_PI; // 按线数保存 int scanID = 0; if(N_SCANS == 16) { // angle在[-15°,+15°]之间,对应1~16线,+0.5相当于四舍五入 // 这个公式算出来的 [-15°,0°]相当1~8线 // [0°,15°]相当9~16线 scanID = int((angle + 15) / 2 + 0.5); // ROS_INFO("点云ID是:[%d]", scanID); // 防止scanID越界 if(scanID > (N_SCANS-1) || scanID <0) { // scanID越界之后,继续下一个循环 count --; continue; } } // 放入数组 laserCloudScans[scanID].push_back(point); } // 按1-8,9-16线保存,Ptr为pcl的点云指针,c++的智能指针,不需要写delete pcl::PointCloud<pcl::PointXYZI>::Ptr laserCloudUp(new pcl::PointCloud<pcl::PointXYZI>()); pcl::PointCloud<pcl::PointXYZI>::Ptr laserCloudDown(new pcl::PointCloud<pcl::PointXYZI>()); // [-15°,0°]相当1~8线,属于down for(int i=0;i<N_SCANS/2;i++) { *laserCloudDown += laserCloudScans[i]; } // [0°,15°]相当9~16线,属于up for(int i=N_SCANS/2;i<N_SCANS;i++) { *laserCloudUp += laserCloudScans[i]; } // pcl转ros输出格式,map是统一坐标系 sensor_msgs::PointCloud2 laserCloudUpOutMsg; pcl::toROSMsg(*laserCloudUp, laserCloudUpOutMsg); laserCloudUpOutMsg.header.stamp = ros_cloud.header.stamp; // 时间戳 laserCloudUpOutMsg.header.frame_id = "map"; PubLaserCloudUp.publish(laserCloudUpOutMsg); sensor_msgs::PointCloud2 laserCloudDownOutMsg; pcl::toROSMsg(*laserCloudDown, laserCloudDownOutMsg); laserCloudDownOutMsg.header.stamp = ros_cloud.header.stamp; // 时间戳 laserCloudDownOutMsg.header.frame_id = "map"; PubLaserCloudDown.publish(laserCloudDownOutMsg); } int main(int argc, char **argv) { // ros初始化 ros::init(argc,argv,"lidar"); ros::NodeHandle n; setlocale(LC_ALL,""); // 中文语言包 ROS_INFO("初始化成功"); // std::cout<<"初始化成功"<<std::endl; // 订阅消息 ros::Subscriber cloud_sub = n.subscribe("/velodyne_points", 100, cloud_CallHandler); ROS_INFO("订阅消息成功"); // 发布消息 PubLaserCloudUp = n.advertise<sensor_msgs::PointCloud2>("/velodyne_cloud_up", 100); PubLaserCloudDown = n.advertise<sensor_msgs::PointCloud2>("/velodyne_cloud_down",100); ROS_INFO("发布消息成功"); // ros消息回调函数,即程序到这就不会往下执行了,相当于在这里停止 ros::spin(); return 0; }
28.135714
95
0.626809
[ "vector", "transform" ]
ad548f3d4ef2148d0f7fa8fa6a20340483341fc6
58,799
cc
C++
src/main/resources/com/nec/arrow/functions/cpp/frovedis/text/words.cc
sapt1/SparkCyclone
78864ec627577c84cda0c66abf7fc97d862f8831
[ "Apache-2.0" ]
null
null
null
src/main/resources/com/nec/arrow/functions/cpp/frovedis/text/words.cc
sapt1/SparkCyclone
78864ec627577c84cda0c66abf7fc97d862f8831
[ "Apache-2.0" ]
null
null
null
src/main/resources/com/nec/arrow/functions/cpp/frovedis/text/words.cc
sapt1/SparkCyclone
78864ec627577c84cda0c66abf7fc97d862f8831
[ "Apache-2.0" ]
null
null
null
#pragma once #include "words.hpp" #include "find.hpp" #include "find.cc" #include "../core/radix_sort.hpp" #include "../core/set_operations.hpp" #include "../core/lower_bound.hpp" #include "../core/upper_bound.hpp" #include "../core/prefix_sum.hpp" #include "../core/find_condition.hpp" #include "char_int_conv.hpp" #include <stdexcept> using namespace std; namespace frovedis { void remove_doc_heading(const vector<int>& v, vector<size_t>& sep, vector<size_t>& len, const string& del) { for(size_t i = 0; i < sep.size(); i++) { auto head_end = find(v.data() + sep[i], len[i], del); size_t doc_start_offset = 0; if(head_end.size() != 0) doc_start_offset = head_end[0] + del.size(); sep[i] += doc_start_offset; len[i] -= doc_start_offset; } } std::vector<int> concat_docs(const vector<int>& v, const vector<size_t>& sep, const vector<size_t>& len, const int del, vector<size_t>& doc_start) { auto vp = v.data(); auto sep_size = sep.size(); auto sepp = sep.data(); auto lenp = len.data(); size_t total = 0; for(size_t i = 0; i < sep_size; i++) total += lenp[i]; total += sep_size; // for delimiter vector<int> ret(total); auto retp = ret.data(); size_t crnt_pos = 0; doc_start.resize(sep_size); auto doc_startp = doc_start.data(); for(size_t i = 0; i < sep_size; i++) { doc_startp[i] = crnt_pos; auto crnt_retp = retp + crnt_pos; auto crnt_v = vp + sepp[i]; auto len = lenp[i]; for(size_t j = 0; j < len; j++) { crnt_retp[j] = crnt_v[j]; } crnt_retp[len] = del; crnt_pos += (len + 1); } return ret; } void split_to_words(const int* vp, size_t size, size_t offset, vector<size_t>& starts, vector<size_t>& lens, const string& delims) { if(size == 0) { starts.resize(0); lens.resize(0); return; } auto delims_size = delims.size(); if(delims_size > 1) { vector<vector<size_t>> seps(delims_size); for(size_t i = 0; i < delims_size; i++) { seps[i] = find(vp, size, delims.substr(i,1)); } vector<size_t> merged; set_multimerge(seps, merged); auto merged_size = merged.size(); starts.resize(merged_size+1); auto startsp = starts.data(); auto crnt_startsp = startsp + 1; // 1st element is set to 0 auto mergedp = merged.data(); for(size_t i = 0; i < merged_size; i++) crnt_startsp[i] = mergedp[i]; int lastdelim = false; int lastchar = vp[size-1]; for(size_t i = 0; i < delims_size; i++) { if(lastchar == static_cast<int>(delims[i])) { lastdelim = true; break; } } if(lastdelim) starts.resize(starts.size()-1); auto num_words = starts.size(); startsp[0] = offset; for(size_t i = 0; i < num_words-1; i++) { startsp[i+1] += (1 + offset); } lens.resize(num_words); auto lensp = lens.data(); for(size_t i = 0; i < num_words-1; i++) { lensp[i] = startsp[i+1] - startsp[i] - 1; } if(lastdelim) { lensp[num_words-1] = size + offset - startsp[num_words-1] - 1; } else { lensp[num_words-1] = size + offset - startsp[num_words-1]; } } else if(delims_size == 1) { auto sep = find(vp, size, delims); auto sep_size = sep.size(); int lastdelim = (vp[size-1] == static_cast<int>(delims[0])); auto num_words = lastdelim ? sep_size : sep_size + 1; starts.resize(num_words); auto startsp = starts.data(); auto sepp = sep.data(); startsp[0] = offset; for(size_t i = 0; i < num_words-1; i++) { startsp[i+1] = sepp[i] + 1 + offset; } lens.resize(num_words); auto lensp = lens.data(); for(size_t i = 0; i < num_words-1; i++) { lensp[i] = startsp[i+1] - startsp[i] - 1; } if(lastdelim) { lensp[num_words-1] = size + offset - startsp[num_words-1] - 1; } else { lensp[num_words-1] = size + offset - startsp[num_words-1]; } } else { starts.resize(0); lens.resize(0); } } void split_to_words(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens, const string& delims) { split_to_words(v.data(), v.size(), 0, starts, lens, delims); } void print_words(const int* vp, size_t* starts, size_t* lens, size_t num_words) { for(size_t i = 0; i < num_words; i++) { auto start = starts[i]; auto len = lens[i]; for(size_t j = 0; j < len; j++) { cout << static_cast<char>(vp[start+j]); } cout << " "; } cout << endl; } void print_words(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); print_words(v.data(), starts.data(), lens.data(), starts.size()); } void trim_head(const int* vp, size_t* starts, size_t* lens, size_t num_words, const string& to_trim) { size_t size = num_words; vector<size_t> crnt(num_words), work(num_words); auto crntp = crnt.data(); auto workp = work.data(); auto to_trim_size = to_trim.size(); vector<int> to_trim_int(to_trim_size); for(size_t i = 0; i < to_trim_size; i++) { to_trim_int[i] = static_cast<int>(to_trim[i]); } auto to_trim_intp = to_trim_int.data(); for(size_t i = 0; i < num_words; i++) crnt[i] = i; while(size > 0) { auto each = size / WORDS_VLEN; if(each % 2 == 0 && each > 1) each--; // TODO: specialize each == 0 case would improve performance... size_t rest = size - each * WORDS_VLEN; size_t out_ridx[WORDS_VLEN]; #pragma _NEC vreg(out_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) { out_ridx[i] = each * i; } for(size_t j = 0; j < each; j++) { int trim_flag_ridx[WORDS_VLEN]; #pragma _NEC vreg(trim_flag_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) trim_flag_ridx[i] = 0; size_t pos_ridx[WORDS_VLEN]; #pragma _NEC vreg(pos_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) pos_ridx[i] = crntp[j + each * i]; for(size_t k = 0; k < to_trim_size; k++) { #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VLEN; i++) { if(lens[pos_ridx[i]] > 0 && vp[starts[pos_ridx[i]]] == to_trim_intp[k]) { trim_flag_ridx[i] = 1; } } } #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VLEN; i++) { if(trim_flag_ridx[i]) { starts[pos_ridx[i]]++; lens[pos_ridx[i]]--; workp[out_ridx[i]++] = pos_ridx[i]; } } } size_t rest_idx_start = each * WORDS_VLEN; size_t rest_idx = rest_idx_start; for(size_t j = 0; j < rest; j++) { int trim_flag = 0; size_t pos = crntp[j + rest_idx_start]; for(size_t k = 0; k < to_trim_size; k++) { if(lens[pos] > 0 && vp[starts[pos]] == to_trim_intp[k]) { trim_flag = 1; } } if(trim_flag) { starts[pos]++; lens[pos]--; workp[rest_idx++] = pos; } } size_t sizes[WORDS_VLEN]; for(size_t i = 0; i < WORDS_VLEN; i++) { sizes[i] = out_ridx[i] - each * i; } size_t total = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { total += sizes[i]; } size_t rest_size = rest_idx - rest_idx_start; total += rest_size; size = total; size_t current = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { for(size_t j = 0; j < sizes[i]; j++) { crntp[current + j] = workp[each * i + j]; } current += sizes[i]; } for(size_t j = 0; j < rest_size; j++) { crntp[current + j] = workp[rest_idx_start + j]; } } } void trim_head(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens, const string& to_trim) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); trim_head(v.data(), starts.data(), lens.data(), starts.size(), to_trim); } void trim_tail(const int* vp, size_t* starts, size_t* lens, size_t num_words, const string& to_trim) { size_t size = num_words; vector<size_t> crnt(num_words), work(num_words); auto crntp = crnt.data(); auto workp = work.data(); auto to_trim_size = to_trim.size(); vector<int> to_trim_int(to_trim_size); for(size_t i = 0; i < to_trim_size; i++) { to_trim_int[i] = static_cast<int>(to_trim[i]); } auto to_trim_intp = to_trim_int.data(); for(size_t i = 0; i < num_words; i++) crnt[i] = i; while(size > 0) { auto each = size / WORDS_VLEN; if(each % 2 == 0 && each > 1) each--; // TODO: specialize each == 0 case would improve performance... size_t rest = size - each * WORDS_VLEN; size_t out_ridx[WORDS_VLEN]; #pragma _NEC vreg(out_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) { out_ridx[i] = each * i; } for(size_t j = 0; j < each; j++) { int trim_flag_ridx[WORDS_VLEN]; #pragma _NEC vreg(trim_flag_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) trim_flag_ridx[i] = 0; size_t pos_ridx[WORDS_VLEN]; #pragma _NEC vreg(pos_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) pos_ridx[i] = crntp[j + each * i]; for(size_t k = 0; k < to_trim_size; k++) { #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VLEN; i++) { if(lens[pos_ridx[i]] > 0 && vp[starts[pos_ridx[i]] + lens[pos_ridx[i]]-1] == to_trim_intp[k]) { trim_flag_ridx[i] = 1; } } } #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VLEN; i++) { if(trim_flag_ridx[i]) { lens[pos_ridx[i]]--; workp[out_ridx[i]++] = pos_ridx[i]; } } } size_t rest_idx_start = each * WORDS_VLEN; size_t rest_idx = rest_idx_start; for(size_t j = 0; j < rest; j++) { int trim_flag = 0; size_t pos = crntp[j + rest_idx_start]; for(size_t k = 0; k < to_trim_size; k++) { if(lens[pos] > 0 && vp[starts[pos]+lens[pos]-1] == to_trim_intp[k]) { trim_flag = 1; } } if(trim_flag) { lens[pos]--; workp[rest_idx++] = pos; } } size_t sizes[WORDS_VLEN]; for(size_t i = 0; i < WORDS_VLEN; i++) { sizes[i] = out_ridx[i] - each * i; } size_t total = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { total += sizes[i]; } size_t rest_size = rest_idx - rest_idx_start; total += rest_size; size = total; size_t current = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { for(size_t j = 0; j < sizes[i]; j++) { crntp[current + j] = workp[each * i + j]; } current += sizes[i]; } for(size_t j = 0; j < rest_size; j++) { crntp[current + j] = workp[rest_idx_start + j]; } } } void trim_tail(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens, const string& to_trim) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); trim_tail(v.data(), starts.data(), lens.data(), starts.size(), to_trim); } void trim(const int* vp, size_t* starts, size_t* lens, size_t num_words, const string& to_trim) { trim_head(vp, starts, lens, num_words, to_trim); trim_tail(vp, starts, lens, num_words, to_trim); } void trim(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens, const string& to_trim) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); trim(v.data(), starts.data(), lens.data(), starts.size(), to_trim); } void trim_noalpha_head(const int* vp, size_t* starts, size_t* lens, size_t num_words) { size_t size = num_words; vector<size_t> crnt(num_words), work(num_words); auto crntp = crnt.data(); auto workp = work.data(); for(size_t i = 0; i < num_words; i++) crnt[i] = i; while(size > 0) { auto each = size / WORDS_VLEN; if(each % 2 == 0 && each > 1) each--; // TODO: specialize each == 0 case would improve performance... size_t rest = size - each * WORDS_VLEN; size_t out_ridx[WORDS_VLEN]; #pragma _NEC vreg(out_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) { out_ridx[i] = each * i; } for(size_t j = 0; j < each; j++) { #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VLEN; i++) { auto pos = crntp[j + each * i]; auto loaded = vp[starts[pos]]; if(lens[pos] > 0 && (loaded < 'A' || loaded > 'z' || (loaded < 'a' && loaded > 'Z'))) { starts[pos]++; lens[pos]--; workp[out_ridx[i]++] = pos; } } } size_t rest_idx_start = each * WORDS_VLEN; size_t rest_idx = rest_idx_start; for(size_t j = 0; j < rest; j++) { size_t pos = crntp[j + rest_idx_start]; auto loaded = vp[starts[pos]]; if(lens[pos] > 0 && (loaded < 'A' || loaded > 'z' || (loaded < 'a' && loaded > 'Z'))) { starts[pos]++; lens[pos]--; workp[rest_idx++] = pos; } } size_t sizes[WORDS_VLEN]; for(size_t i = 0; i < WORDS_VLEN; i++) { sizes[i] = out_ridx[i] - each * i; } size_t total = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { total += sizes[i]; } size_t rest_size = rest_idx - rest_idx_start; total += rest_size; size = total; size_t current = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { for(size_t j = 0; j < sizes[i]; j++) { crntp[current + j] = workp[each * i + j]; } current += sizes[i]; } for(size_t j = 0; j < rest_size; j++) { crntp[current + j] = workp[rest_idx_start + j]; } } } void trim_noalpha_head(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); trim_noalpha_head(v.data(), starts.data(), lens.data(), starts.size()); } void trim_noalpha_tail(const int* vp, size_t* starts, size_t* lens, size_t num_words) { size_t size = num_words; vector<size_t> crnt(num_words), work(num_words); auto crntp = crnt.data(); auto workp = work.data(); for(size_t i = 0; i < num_words; i++) crnt[i] = i; while(size > 0) { auto each = size / WORDS_VLEN; if(each % 2 == 0 && each > 1) each--; // TODO: specialize each == 0 case would improve performance... size_t rest = size - each * WORDS_VLEN; size_t out_ridx[WORDS_VLEN]; #pragma _NEC vreg(out_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) { out_ridx[i] = each * i; } for(size_t j = 0; j < each; j++) { #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VLEN; i++) { auto pos = crntp[j + each * i]; auto loaded = vp[starts[pos] + lens[pos]-1]; if(lens[pos] > 0 && (loaded < 'A' || loaded > 'z' || (loaded < 'a' && loaded > 'Z'))) { lens[pos]--; workp[out_ridx[i]++] = pos; } } } size_t rest_idx_start = each * WORDS_VLEN; size_t rest_idx = rest_idx_start; for(size_t j = 0; j < rest; j++) { size_t pos = crntp[j + rest_idx_start]; auto loaded = vp[starts[pos] + lens[pos]-1]; if(lens[pos] > 0 && (loaded < 'A' || loaded > 'z' || (loaded < 'a' && loaded > 'Z'))) { lens[pos]--; workp[rest_idx++] = pos; } } size_t sizes[WORDS_VLEN]; for(size_t i = 0; i < WORDS_VLEN; i++) { sizes[i] = out_ridx[i] - each * i; } size_t total = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { total += sizes[i]; } size_t rest_size = rest_idx - rest_idx_start; total += rest_size; size = total; size_t current = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { for(size_t j = 0; j < sizes[i]; j++) { crntp[current + j] = workp[each * i + j]; } current += sizes[i]; } for(size_t j = 0; j < rest_size; j++) { crntp[current + j] = workp[rest_idx_start + j]; } } } void trim_noalpha_tail(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); trim_noalpha_tail(v.data(), starts.data(), lens.data(), starts.size()); } void trim_noalpha(const int* vp, size_t* starts, size_t* lens, size_t num_words) { trim_noalpha_head(vp, starts, lens, num_words); trim_noalpha_tail(vp, starts, lens, num_words); } void trim_noalpha(const vector<int>& v, vector<size_t>& starts, vector<size_t>& lens) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); trim_noalpha(v.data(), starts.data(), lens.data(), starts.size()); } void remove_null(size_t* starts, size_t* lens, size_t& size) { if(size == 0) return; vector<size_t> starts_buf(size), lens_buf(size); auto starts_bufp = starts_buf.data(); auto lens_bufp = lens_buf.data(); size_t each = size / WORDS_VLEN; // maybe 0 if(each % 2 == 0 && each > 1) each--; if(each == 0) { size_t current = 0; for(size_t i = 0; i < size; i++) { if(lens[i] != 0) { starts_bufp[current] = starts[i]; lens_bufp[current] = lens[i]; current++; } } size = current; for(size_t i = 0; i < current; i++) { starts[i] = starts_buf[i]; lens[i] = lens_buf[i]; } } else { size_t rest = size - each * WORDS_VLEN; size_t out_ridx[WORDS_VLEN]; // never remove this vreg! this is needed folowing vovertake #pragma _NEC vreg(out_ridx) for(size_t i = 0; i < WORDS_VLEN; i++) { out_ridx[i] = each * i; } #pragma _NEC vob for(size_t j = 0; j < each; j++) { #pragma cdir nodep #pragma _NEC ivdep #pragma _NEC vovertake for(size_t i = 0; i < WORDS_VLEN; i++) { auto loaded_len = lens[j + each * i]; if(loaded_len != 0) { starts_bufp[out_ridx[i]] = starts[j + each * i]; lens_bufp[out_ridx[i]] = loaded_len; out_ridx[i]++; } } } size_t rest_idx_start = each * WORDS_VLEN; size_t rest_idx = rest_idx_start; for(size_t j = 0; j < rest; j++) { auto loaded_len = lens[j + rest_idx_start]; if(loaded_len != 0) { starts_bufp[rest_idx] = starts[j + rest_idx_start]; lens_bufp[rest_idx] = loaded_len; rest_idx++; } } size_t sizes[WORDS_VLEN]; for(size_t i = 0; i < WORDS_VLEN; i++) { sizes[i] = out_ridx[i] - each * i; } size_t total = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { total += sizes[i]; } size_t rest_size = rest_idx - rest_idx_start; total += rest_size; size = total; size_t current = 0; for(size_t i = 0; i < WORDS_VLEN; i++) { for(size_t j = 0; j < sizes[i]; j++) { starts[current + j] = starts_bufp[each * i + j]; lens[current + j] = lens_bufp[each * i + j]; } current += sizes[i]; } for(size_t j = 0; j < rest_size; j++) { starts[current + j] = starts_bufp[rest_idx_start + j]; lens[current + j] = lens_bufp[rest_idx_start + j]; } } } void remove_null(vector<size_t>& starts, vector<size_t>& lens) { if(starts.size() != lens.size()) throw runtime_error("size of starts and lens are diffent"); auto num_words = starts.size(); remove_null(starts.data(), lens.data(), num_words); vector<size_t> ret_starts(num_words), ret_lens(num_words); auto ret_startsp = ret_starts.data(); auto ret_lensp = ret_lens.data(); auto startsp = starts.data(); auto lensp = lens.data(); for(size_t i = 0; i < num_words; i++) { ret_startsp[i] = startsp[i]; ret_lensp[i] = lensp[i]; } starts.swap(ret_starts); lens.swap(ret_lens); } struct words_substr_helper { words_substr_helper(){} words_substr_helper(size_t c) : c(c) {} int operator()(size_t a) const {return a < c;} size_t c; //SERIALIZE(c) }; void substr(size_t* starts, size_t* lens, size_t num_words, size_t pos, size_t num) { auto fail = find_condition(lens, num_words, words_substr_helper(pos+num)); if(fail.size() != 0) throw std::runtime_error("substr: pos + num is larger than length at: " + std::to_string(fail[0])); for(size_t i = 0; i < num_words; i++) { starts[i] += pos; lens[i] = num; } } void substr(size_t* starts, size_t* lens, size_t num_words, size_t pos) { auto fail = find_condition(lens, num_words, words_substr_helper(pos)); if(fail.size() != 0) throw std::runtime_error("substr: pos is larger than length at: " + std::to_string(fail[0])); for(size_t i = 0; i < num_words; i++) { starts[i] += pos; lens[i] -= pos; } } void substr(std::vector<size_t>& starts, std::vector<size_t>& lens, size_t pos, size_t num) { substr(starts.data(), lens.data(), starts.size(), pos, num); } void substr(std::vector<size_t>& starts, std::vector<size_t>& lens, size_t pos) { substr(starts.data(), lens.data(), starts.size(), pos); } words split_to_words(const std::vector<int>& v, const std::string& delims) { words ret; split_to_words(v, ret.starts, ret.lens, delims); ret.chars = v; return ret; } words split_to_words(std::vector<int>&& v, const std::string& delims) { words ret; split_to_words(v, ret.starts, ret.lens, delims); ret.chars.swap(v); return ret; } std::vector<size_t> convert_position_to_word_count(const std::vector<size_t>& doc_starts, const std::vector<size_t>& word_starts) { return lower_bound(word_starts, doc_starts); } words merge_words(const words& a, const words& b) { words r; auto a_chars_size = a.chars.size(); auto b_chars_size = b.chars.size(); auto a_starts_size = a.starts.size(); auto b_starts_size = b.starts.size(); r.chars.resize(a_chars_size + b_chars_size); r.starts.resize(a_starts_size + b_starts_size); r.lens.resize(a_starts_size + b_starts_size); auto a_charsp = a.chars.data(); auto b_charsp = b.chars.data(); auto r_charsp = r.chars.data(); for(size_t i = 0; i < a_chars_size; i++) { r_charsp[i] = a_charsp[i]; } auto crnt_r_charsp = r_charsp + a_chars_size; for(size_t i = 0; i < b_chars_size; i++) { crnt_r_charsp[i] = b_charsp[i]; } auto a_startsp = a.starts.data(); auto b_startsp = b.starts.data(); auto r_startsp = r.starts.data(); for(size_t i = 0; i < a_starts_size; i++) { r_startsp[i] = a_startsp[i]; } auto crnt_r_startsp = r_startsp + a_starts_size; for(size_t i = 0; i < b_starts_size; i++) { crnt_r_startsp[i] = b_startsp[i] + a_chars_size; } auto a_lensp = a.lens.data(); auto b_lensp = b.lens.data(); auto r_lensp = r.lens.data(); for(size_t i = 0; i < a_starts_size; i++) { r_lensp[i] = a_lensp[i]; } auto crnt_r_lensp = r_lensp + a_starts_size; for(size_t i = 0; i < b_starts_size; i++) { crnt_r_lensp[i] = b_lensp[i]; } return r; } words merge_multi_words(const vector<words>& vecwords) { words r; auto vecwords_size = vecwords.size(); size_t total_chars_size = 0; size_t total_starts_size = 0; for(size_t i = 0; i < vecwords_size; i++) { total_chars_size += vecwords[i].chars.size(); total_starts_size += vecwords[i].starts.size(); } r.chars.resize(total_chars_size); r.starts.resize(total_starts_size); r.lens.resize(total_starts_size); auto r_charsp = r.chars.data(); auto crnt_r_charsp = r_charsp; for(size_t i = 0; i < vecwords_size; i++) { auto crnt_charsp = vecwords[i].chars.data(); auto crnt_chars_size = vecwords[i].chars.size(); for(size_t j = 0; j < crnt_chars_size; j++) { crnt_r_charsp[j] = crnt_charsp[j]; } crnt_r_charsp += crnt_chars_size; } auto r_startsp = r.starts.data(); auto crnt_r_startsp = r_startsp; size_t crnt_shift = 0; for(size_t i = 0; i < vecwords_size; i++) { auto crnt_startsp = vecwords[i].starts.data(); auto crnt_starts_size = vecwords[i].starts.size(); for(size_t j = 0; j < crnt_starts_size; j++) { crnt_r_startsp[j] = crnt_startsp[j] + crnt_shift; } crnt_r_startsp += crnt_starts_size; crnt_shift += vecwords[i].chars.size(); } auto r_lensp = r.lens.data(); auto crnt_r_lensp = r_lensp; for(size_t i = 0; i < vecwords_size; i++) { auto crnt_lensp = vecwords[i].lens.data(); auto crnt_lens_size = vecwords[i].lens.size(); for(size_t j = 0; j < crnt_lens_size; j++) { crnt_r_lensp[j] = crnt_lensp[j]; } crnt_r_lensp += crnt_lens_size; } return r; } // quite similar to concat_docs, but vectorization is differnt // since words are short // delimiter is also added to the end of the vector vector<int> concat_words(const vector<int>& v, const vector<size_t>& starts, const vector<size_t>& lens, const string& delim, vector<size_t>& new_starts) { auto starts_size = starts.size(); if(starts_size == 0) { new_starts.resize(0); return vector<int>(); } auto vp = v.data(); auto startsp = starts.data(); auto lensp = lens.data(); auto delim_size = delim.size(); size_t total = 0; for(size_t i = 0; i < starts_size; i++) total += lensp[i]; total += starts_size * delim_size; // for delimiter vector<int> ret(total); auto retp = ret.data(); new_starts.resize(starts_size); auto new_startsp = new_starts.data(); auto lens_size = lens.size(); vector<size_t> lenstmp(lens_size); auto lenstmpp = lenstmp.data(); for(size_t i = 0; i < lens_size; i++) lenstmpp[i] = lensp[i] + delim_size; prefix_sum(lenstmpp, new_startsp+1, lens_size-1); auto each = starts_size / WORDS_VLEN; // not loop raking auto rest = starts_size - each * WORDS_VLEN; for(size_t i = 0; i < each; i++) { size_t starts_vreg[WORDS_VLEN]; #pragma _NEC vreg(starts_vreg) size_t lens_vreg[WORDS_VLEN]; #pragma _NEC vreg(lens_vreg) size_t new_starts_vreg[WORDS_VLEN]; #pragma _NEC vreg(new_starts_vreg) for(size_t v = 0; v < WORDS_VLEN; v++) { starts_vreg[v] = startsp[i * WORDS_VLEN + v]; lens_vreg[v] = lensp[i * WORDS_VLEN + v]; new_starts_vreg[v] = new_startsp[i * WORDS_VLEN + v]; } size_t max = 0; for(size_t v = 0; v < WORDS_VLEN; v++) { if(max < lens_vreg[v]) max = lens_vreg[v]; } #pragma _NEC novector for(size_t j = 0; j < max; j++) { #pragma _NEC ivdep #pragma _NEC vovertake for(size_t v = 0; v < WORDS_VLEN; v++) { if(lens_vreg[v] > j) { retp[new_starts_vreg[v] + j] = vp[starts_vreg[v] + j]; } } } } size_t i = each; size_t starts_vreg2[WORDS_VLEN]; size_t lens_vreg2[WORDS_VLEN]; size_t new_starts_vreg2[WORDS_VLEN]; for(size_t v = 0; v < rest; v++) { starts_vreg2[v] = startsp[i * WORDS_VLEN + v]; lens_vreg2[v] = lensp[i * WORDS_VLEN + v]; new_starts_vreg2[v] = new_startsp[i * WORDS_VLEN + v]; } size_t max = 0; for(size_t v = 0; v < rest; v++) { if(max < lens_vreg2[v]) max = lens_vreg2[v]; } #pragma _NEC novector for(size_t j = 0; j < max; j++) { #pragma _NEC ivdep #pragma _NEC vovertake for(size_t v = 0; v < rest; v++) { if(lens_vreg2[v] > j) { retp[new_starts_vreg2[v] + j] = vp[starts_vreg2[v] + j]; } } } for(size_t d = 0; d < delim_size; d++) { int crnt_delim = delim[d]; #pragma _NEC ivdep #pragma _NEC vovertake for(size_t i = 1; i < starts_size; i++) { retp[new_startsp[i]-delim_size+d] = crnt_delim; } retp[ret.size()-delim_size+d] = crnt_delim; } return ret; } std::vector<int> concat_words(const words& w, const string& delim, vector<size_t>& new_starts) { return concat_words(w.chars, w.starts, w.lens, delim, new_starts); } struct is_not_zero_like { int operator()(size_t a) const {return !(a == 0);} }; struct is_zero_like { int operator()(size_t a) const {return a == 0;} }; struct is_char_like { is_char_like(int to_comp) : to_comp(to_comp) {} int operator()(int a) const {return a == to_comp;} int to_comp; }; void advance_char_like(const vector<int>& chars, vector<size_t>& crnt_pos, vector<size_t>& crnt_lens, vector<size_t>& crnt_idx, int crnt_char) { auto non_zero = find_condition(crnt_lens, is_not_zero_like()); auto non_zero_size = non_zero.size(); auto crnt_pos_size = crnt_pos.size(); if(non_zero_size != crnt_pos_size) { vector<size_t> next_pos(non_zero_size); vector<size_t> next_lens(non_zero_size); vector<size_t> next_idx(non_zero_size); auto next_posp = next_pos.data(); auto next_lensp = next_lens.data(); auto next_idxp = next_idx.data(); auto crnt_posp = crnt_pos.data(); auto crnt_lensp = crnt_lens.data(); auto crnt_idxp = crnt_idx.data(); auto non_zerop = non_zero.data(); #pragma _NEC ivdep #pragma _NEC vovertake #pragma _NEC vob for(size_t i = 0; i < non_zero_size; i++) { next_posp[i] = crnt_posp[non_zerop[i]]; next_lensp[i] = crnt_lensp[non_zerop[i]]; next_idxp[i] = crnt_idxp[non_zerop[i]]; } crnt_pos.swap(next_pos); crnt_lens.swap(next_lens); crnt_idx.swap(next_idx); } auto char_found = find_condition_index(chars, crnt_pos, is_char_like(crnt_char)); auto char_found_size = char_found.size(); vector<size_t> next_pos(char_found_size); vector<size_t> next_lens(char_found_size); vector<size_t> next_idx(char_found_size); auto next_posp = next_pos.data(); auto next_lensp = next_lens.data(); auto next_idxp = next_idx.data(); auto crnt_posp = crnt_pos.data(); auto crnt_lensp = crnt_lens.data(); auto crnt_idxp = crnt_idx.data(); auto char_foundp = char_found.data(); #pragma _NEC ivdep #pragma _NEC vovertake #pragma _NEC vob for(size_t i = 0; i < char_found_size; i++) { next_posp[i] = crnt_posp[char_foundp[i]] + 1; next_lensp[i] = crnt_lensp[char_foundp[i]] - 1; next_idxp[i] = crnt_idxp[char_foundp[i]]; } crnt_pos.swap(next_pos); crnt_lens.swap(next_lens); crnt_idx.swap(next_idx); } // return multiple candidates in one word // "%ab" need to match "acab"; 1st and 3rd pos need to be returned for "a" void advance_until_char_like(const vector<int>& chars, const vector<size_t>& starts, const vector<size_t>& lens, vector<size_t>& crnt_pos, vector<size_t>& crnt_lens, vector<size_t>& crnt_idx, int crnt_char) { std::vector<std::vector<size_t>> hit_pos, hit_idx; hit_pos.reserve(1000); hit_idx.reserve(1000); while(true) { auto non_zero = find_condition(crnt_lens, is_not_zero_like()); auto non_zero_size = non_zero.size(); if(non_zero_size == 0) break; auto crnt_pos_size = crnt_pos.size(); if(non_zero_size != crnt_pos_size) { vector<size_t> next_pos(non_zero_size); vector<size_t> next_lens(non_zero_size); vector<size_t> next_idx(non_zero_size); auto next_posp = next_pos.data(); auto next_lensp = next_lens.data(); auto next_idxp = next_idx.data(); auto crnt_posp = crnt_pos.data(); auto crnt_lensp = crnt_lens.data(); auto crnt_idxp = crnt_idx.data(); auto non_zerop = non_zero.data(); #pragma _NEC ivdep #pragma _NEC vovertake #pragma _NEC vob for(size_t i = 0; i < non_zero_size; i++) { next_posp[i] = crnt_posp[non_zerop[i]]; next_lensp[i] = crnt_lensp[non_zerop[i]]; next_idxp[i] = crnt_idxp[non_zerop[i]]; } crnt_pos.swap(next_pos); crnt_lens.swap(next_lens); crnt_idx.swap(next_idx); } auto hit = find_condition_index(chars, crnt_pos, is_char_like(crnt_char)); auto hit_size = hit.size(); if(hit_size > 0) { std::vector<size_t> hit_pos_tmp(hit_size); std::vector<size_t> hit_idx_tmp(hit_size); auto hit_pos_tmpp = hit_pos_tmp.data(); auto hit_idx_tmpp = hit_idx_tmp.data(); auto crnt_posp = crnt_pos.data(); auto crnt_idxp = crnt_idx.data(); auto hitp = hit.data(); #pragma _NEC ivdep #pragma _NEC vovertake #pragma _NEC vob for(size_t i = 0; i < hit_size; i++) { hit_pos_tmpp[i] = crnt_posp[hitp[i]]; hit_idx_tmpp[i] = crnt_idxp[hitp[i]]; } hit_pos.push_back(hit_pos_tmp); hit_idx.push_back(hit_idx_tmp); } crnt_pos_size = crnt_pos.size(); auto crnt_posp = crnt_pos.data(); auto crnt_lensp = crnt_lens.data(); for(size_t i = 0; i < crnt_pos_size; i++) { crnt_posp[i]++; crnt_lensp[i]--; } } set_multimerge_pair(hit_idx, hit_pos, crnt_idx, crnt_pos); auto crnt_idx_size = crnt_idx.size(); crnt_lens.resize(crnt_idx_size); auto crnt_idxp = crnt_idx.data(); auto crnt_posp = crnt_pos.data(); auto crnt_lensp = crnt_lens.data(); auto startsp = starts.data(); auto lensp = lens.data(); for(size_t i = 0; i < crnt_idx_size; i++) { crnt_posp[i]++; } #pragma _NEC ivdep #pragma _NEC vovertake #pragma _NEC vob for(size_t i = 0; i < crnt_idx_size; i++) { crnt_lensp[i] = lensp[crnt_idxp[i]] - (crnt_posp[i] - startsp[crnt_idxp[i]]); } } std::vector<size_t> like(const std::vector<int>& chars, const std::vector<size_t>& starts, const std::vector<size_t>& lens, const std::string& to_search, int wild_card, int escape) { auto to_search_size = to_search.size(); if(to_search_size == 0) return find_condition(lens, is_zero_like()); if(to_search[to_search_size-1] == escape) throw runtime_error("like: format error. last char is escape"); auto starts_size = starts.size(); auto startsp = starts.data(); auto lensp = lens.data(); std::vector<size_t> crnt_pos(starts_size), crnt_lens(starts_size); std::vector<size_t> crnt_idx(starts_size); auto crnt_posp = crnt_pos.data(); auto crnt_lensp = crnt_lens.data(); auto crnt_idxp = crnt_idx.data(); for(size_t i = 0; i < starts_size; i++) { crnt_posp[i] = startsp[i]; crnt_lensp[i] = lensp[i]; crnt_idxp[i] = i; } bool is_in_wildcard = false; bool is_in_escape = false; for(size_t i = 0; i < to_search_size; i++) { int crnt_char = static_cast<int>(to_search[i]); if(is_in_escape && is_in_wildcard) { advance_until_char_like(chars, starts, lens, crnt_pos, crnt_lens, crnt_idx, crnt_char); is_in_wildcard = false; is_in_escape = false; } else if(is_in_escape && !is_in_wildcard) { advance_char_like(chars, crnt_pos, crnt_lens, crnt_idx, crnt_char); is_in_escape = false; } else if(!is_in_escape && is_in_wildcard) { if(crnt_char == escape) { is_in_escape = true; continue; } else if(crnt_char == wild_card) { // does not make sense, though continue; } else { advance_until_char_like(chars, starts, lens, crnt_pos, crnt_lens, crnt_idx, crnt_char); is_in_wildcard = false; } } else if(!is_in_escape && !is_in_wildcard) { if(crnt_char == escape) { is_in_escape = true; continue; } else if(crnt_char == wild_card) { is_in_wildcard = true; continue; } else { advance_char_like(chars, crnt_pos, crnt_lens, crnt_idx, crnt_char); } } } if(is_in_wildcard) { return set_unique(crnt_idx); } else { auto r = find_condition(crnt_lens, is_zero_like()); auto r_size = r.size(); std::vector<size_t> ret_idx(r_size); auto ret_idxp = ret_idx.data(); auto rp = r.data(); auto crnt_idxp = crnt_idx.data(); #pragma _NEC ivdep #pragma _NEC vovertake #pragma _NEC vob for(size_t i = 0; i < r_size; i++) { ret_idxp[i] = crnt_idxp[rp[i]]; } return set_unique(ret_idx); } } std::vector<size_t> like(const words& w, const std::string& to_search, int wild_card, int escape) { return like(w.chars, w.starts, w.lens, to_search, wild_card, escape); } struct quote_and_escape_char { int operator()(int a) const {return ((a == '\"') || (a == '\\'));} }; // quote by "..." and escape '"' and '\' by '\' for saving csv file void quote_and_escape(words& ws) { if(ws.starts.size() == 0) return; vector<size_t> new_starts; // later ' ' is replaced by '"' auto new_chars_concat = concat_words(ws, " ", new_starts); auto new_chars_size = new_chars_concat.size(); vector<int> new_chars(new_chars_size); auto new_chars_concatp = new_chars_concat.data(); auto new_charsp = new_chars.data(); new_charsp[0] = ' '; for(size_t i = 0; i < new_chars_size - 1; i++) { new_charsp[i+1] = new_chars_concatp[i]; } {vector<int> tmp; tmp.swap(new_chars_concat);} // clear auto lensp = ws.lens.data(); auto new_startsp = new_starts.data(); auto starts_size = new_starts.size(); for(size_t i = 0; i < starts_size; i++) { lensp[i] += 2; } auto to_escape = find_condition(new_chars, quote_and_escape_char()); auto to_escape_size = to_escape.size(); vector<int> ret_chars; if(to_escape_size != 0) { ret_chars.resize(new_chars_size + to_escape_size); auto ret_charsp = ret_chars.data(); auto to_escapep = to_escape.data(); size_t start = 0; for(size_t i = 0; i < to_escape_size; i++) { size_t end = to_escapep[i]; for(size_t j = start; j < end; j++) { ret_charsp[i + j] = new_charsp[j]; } ret_charsp[i + end] = '\\'; start = end; } for(size_t j = start; j < new_chars_size; j++) { ret_charsp[to_escape_size + j] = new_charsp[j]; } auto escape_starts = upper_bound(new_starts, to_escape); auto escape_starts_size = escape_starts.size(); auto escape_startsp = escape_starts.data(); start = 0; for(size_t i = 0; i < escape_starts_size; i++) { auto estart = escape_startsp[i]; /* -1 is safe because to_escape_size != 0 (last word is at starts_size) */ lensp[estart-1]++; auto end = estart; for(size_t j = start; j < end; j++) { new_startsp[j] += i; } start = end; } for(size_t j = start; j < starts_size; j++) { new_startsp[j] += escape_starts_size; } } else { ret_chars.swap(new_chars); } auto ret_charsp = ret_chars.data(); #pragma _NEC ivdep #pragma _NEC vovertake #pragma _NEC vob for(size_t i = 0; i < starts_size; i++) { ret_charsp[new_startsp[i]] = '"'; ret_charsp[new_startsp[i] + lensp[i] - 1] = '"'; } ws.chars.swap(ret_chars); ws.starts.swap(new_starts); } words vector_string_to_words(const vector<string>& str) { words ret; auto size = str.size(); if(size == 0) return ret; auto strp = str.data(); ret.lens.resize(size); auto lensp = ret.lens.data(); for(size_t i = 0; i < size; i++) { lensp[i] = strp[i].size(); } ret.starts.resize(size); auto startsp = ret.starts.data(); prefix_sum(lensp, startsp+1, size-1); auto total_size = startsp[size-1] + lensp[size-1]; ret.chars.resize(total_size); auto charsp = ret.chars.data(); if(is_bigendian()) throw runtime_error("big endian is not supported"); std::vector<uint32_t*> intstrp(size); auto intstrpp = intstrp.data(); for(size_t i = 0; i < size; i++) { intstrpp[i] = reinterpret_cast<uint32_t*>(const_cast<char*>(strp[i].data())); } std::vector<size_t> pos(size); // int pos; actual_pos / 4 auto posp = pos.data(); for(size_t i = 0; i < size; i++) { posp[i] = 0; } size_t num_block = size / WORDS_VECTOR_BLOCK; size_t rest = size - num_block * WORDS_VECTOR_BLOCK; for(size_t b = 0; b < num_block; b++) { int still_working = true; while(still_working) { still_working = false; #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VECTOR_BLOCK; i++) { auto idx = b * WORDS_VECTOR_BLOCK + i; if(posp[idx] * 4 + 3 < lensp[idx]) { still_working = true; auto packed = *(intstrpp[idx] + posp[idx]); charsp[startsp[idx] + posp[idx] * 4] = packed & 0xFF; charsp[startsp[idx] + posp[idx] * 4 + 1] = (packed >> 8) & 0xFF; charsp[startsp[idx] + posp[idx] * 4 + 2] = (packed >> 16) & 0xFF; charsp[startsp[idx] + posp[idx] * 4 + 3] = (packed >> 24) & 0xFF; posp[idx]++; } } } for(size_t i = 0; i < WORDS_VECTOR_BLOCK; i++) { auto idx = b * WORDS_VECTOR_BLOCK + i; auto pos4 = posp[idx] * 4; auto crnt_strp = strp[idx].data(); auto lensp_idx = lensp[idx]; for(size_t j = pos4; j < lensp_idx; j++) { charsp[startsp[idx] + j] = crnt_strp[j]; } } } int still_working = true; while(still_working) { still_working = false; #pragma _NEC ivdep for(size_t i = 0; i < rest; i++) { auto idx = num_block * WORDS_VECTOR_BLOCK + i; if(posp[idx] * 4 + 3 < lensp[idx]) { still_working = true; auto packed = *(intstrpp[idx] + posp[idx]); charsp[startsp[idx] + posp[idx] * 4] = packed & 0xFF; charsp[startsp[idx] + posp[idx] * 4 + 1] = (packed >> 8)& 0xFF; charsp[startsp[idx] + posp[idx] * 4 + 2] = (packed >> 16) & 0xFF; charsp[startsp[idx] + posp[idx] * 4 + 3] = (packed >> 24) & 0xFF; posp[idx]++; } } } for(size_t i = 0; i < rest; i++) { auto idx = num_block * WORDS_VECTOR_BLOCK + i; auto pos4 = posp[idx] * 4; auto crnt_strp = strp[idx].data(); auto lensp_idx = lensp[idx]; for(size_t j = pos4; j < lensp_idx; j++) { charsp[startsp[idx] + j] = crnt_strp[j]; } } return ret; } vector<string> words_to_vector_string(const words& ws) { auto size = ws.starts.size(); if(size == 0) return vector<string>(); vector<string> str(size); auto strp = str.data(); auto lensp = ws.lens.data(); for(size_t i = 0; i < size; i++) { strp[i].resize(lensp[i]); } auto startsp = ws.starts.data(); auto charsp = ws.chars.data(); if(is_bigendian()) throw runtime_error("big endian is not supported"); std::vector<uint32_t*> intstrp(size); auto intstrpp = intstrp.data(); for(size_t i = 0; i < size; i++) { intstrpp[i] = reinterpret_cast<uint32_t*>(const_cast<char*>(strp[i].data())); } std::vector<size_t> pos(size); // int pos; actual_pos / 4 auto posp = pos.data(); for(size_t i = 0; i < size; i++) { posp[i] = 0; } size_t num_block = size / WORDS_VECTOR_BLOCK; size_t rest = size - num_block * WORDS_VECTOR_BLOCK; for(size_t b = 0; b < num_block; b++) { int still_working = true; while(still_working) { still_working = false; #pragma _NEC ivdep for(size_t i = 0; i < WORDS_VECTOR_BLOCK; i++) { auto idx = b * WORDS_VECTOR_BLOCK + i; if(posp[idx] * 4 + 3 < lensp[idx]) { still_working = true; *(intstrpp[idx] + posp[idx]) = charsp[startsp[idx] + posp[idx] * 4] + (charsp[startsp[idx] + posp[idx] * 4 + 1] << 8) + (charsp[startsp[idx] + posp[idx] * 4 + 2] << 16) + (charsp[startsp[idx] + posp[idx] * 4 + 3] << 24); posp[idx]++; } } } for(size_t i = 0; i < WORDS_VECTOR_BLOCK; i++) { auto idx = b * WORDS_VECTOR_BLOCK + i; auto pos4 = posp[idx] * 4; auto crnt_strp = const_cast<char*>(strp[idx].data()); auto lensp_idx = lensp[idx]; for(size_t j = pos4; j < lensp_idx; j++) { crnt_strp[j] = charsp[startsp[idx] + j]; } } } int still_working = true; while(still_working) { still_working = false; #pragma _NEC ivdep for(size_t i = 0; i < rest; i++) { auto idx = num_block * WORDS_VECTOR_BLOCK + i; if(posp[idx] * 4 + 3 < lensp[idx]) { still_working = true; *(intstrpp[idx] + posp[idx]) = charsp[startsp[idx] + posp[idx] * 4] + (charsp[startsp[idx] + posp[idx] * 4 + 1] << 8) + (charsp[startsp[idx] + posp[idx] * 4 + 2] << 16) + (charsp[startsp[idx] + posp[idx] * 4 + 3] << 24); posp[idx]++; } } } for(size_t i = 0; i < rest; i++) { auto idx = num_block * WORDS_VECTOR_BLOCK + i; auto pos4 = posp[idx] * 4; auto crnt_strp = const_cast<char*>(strp[idx].data()); auto lensp_idx = lensp[idx]; for(size_t j = pos4; j < lensp_idx; j++) { crnt_strp[j] = charsp[startsp[idx] + j]; } } return str; } void search(const std::vector<int>& chars, const std::vector<size_t>& starts, const std::vector<size_t>& lens, const std::string& to_search, std::vector<size_t>& idx, std::vector<size_t>& pos) { auto to_search_size = to_search.size(); if(to_search_size == 0) { idx.resize(0); pos.resize(0); return; } auto starts_size = starts.size(); auto startsp = starts.data(); auto lensp = lens.data(); std::vector<size_t> crnt_pos(starts_size), crnt_lens(starts_size); std::vector<size_t> crnt_idx(starts_size); auto crnt_posp = crnt_pos.data(); auto crnt_lensp = crnt_lens.data(); auto crnt_idxp = crnt_idx.data(); for(size_t i = 0; i < starts_size; i++) { crnt_posp[i] = startsp[i]; crnt_lensp[i] = lensp[i]; crnt_idxp[i] = i; } // size of to_search is guarantted not to be zero int crnt_char = static_cast<int>(to_search[0]); advance_until_char_like(chars, starts, lens, crnt_pos, crnt_lens, crnt_idx, crnt_char); for(size_t i = 1; i < to_search_size; i++) { crnt_char = static_cast<int>(to_search[i]); advance_char_like(chars, crnt_pos, crnt_lens, crnt_idx, crnt_char); } crnt_posp = crnt_pos.data(); auto crnt_posp_size = crnt_pos.size(); crnt_idxp = crnt_idx.data(); for(size_t i = 0; i < crnt_posp_size; i++) { crnt_posp[i] -= (to_search_size + startsp[crnt_idxp[i]]); } idx.swap(crnt_idx); pos.swap(crnt_pos); } void search(const words& w, const std::string& to_search, std::vector<size_t>& idx, std::vector<size_t>& pos) { search(w.chars, w.starts, w.lens, to_search, idx, pos); } void replace(const std::vector<int>& chars, const std::vector<size_t>& starts, const std::vector<size_t>& lens, std::vector<int>& ret_chars, std::vector<size_t>& ret_starts, std::vector<size_t>& ret_lens, const std::string& from, const std::string& to) { std::vector<size_t> idx, pos; search(chars, starts, lens, from, idx, pos); auto sep_idx = set_separate(idx); auto sep_idx_size = sep_idx.size(); std::vector<size_t> num_occurrence(sep_idx_size-1); auto num_occurrence_size = num_occurrence.size(); auto sep_idxp = sep_idx.data(); auto num_occurrencep = num_occurrence.data(); for(size_t i = 0; i < num_occurrence_size; i++) { num_occurrencep[i] = sep_idxp[i+1] - sep_idxp[i]; } auto starts_size = starts.size(); std::vector<size_t> all_num_occurrence(starts_size); auto all_num_occurrencep = all_num_occurrence.data(); auto idxp = idx.data(); #pragma _NEC ivdep for(size_t i = 0; i < num_occurrence_size; i++) { all_num_occurrencep[idxp[sep_idxp[i]]] = num_occurrencep[i]; } auto pfx_all_num_occurrence = prefix_sum(all_num_occurrence); auto total_occurrence = pfx_all_num_occurrence[starts_size-1]; std::vector<size_t> starts_work(starts_size + total_occurrence * 2); auto starts_work_size = starts_work.size(); std::vector<size_t> lens_work(starts_work_size); std::vector<size_t> original_starts_idx(starts_size); auto original_starts_idxp = original_starts_idx.data(); auto pfx_all_num_occurrencep = pfx_all_num_occurrence.data(); for(size_t i = 1; i < starts_size; i++) { original_starts_idxp[i] = i + pfx_all_num_occurrencep[i-1] * 2; } auto starts_workp = starts_work.data(); auto lens_workp = lens_work.data(); auto startsp = starts.data(); auto lensp = lens.data(); #pragma _NEC ivdep for(size_t i = 0; i < starts_size; i++) { starts_workp[original_starts_idxp[i]] = startsp[i]; lens_workp[original_starts_idxp[i]] = lensp[i]; } auto chars_size = chars.size(); auto to_int = char_to_int(to); auto to_int_size = to_int.size(); std::vector<int> chars_work(chars_size + to_int_size); auto chars_workp = chars_work.data(); auto charsp = chars.data(); for(size_t i = 0; i < chars_size; i++) { chars_workp[i] = charsp[i]; } auto to_intp = to_int.data(); for(size_t i = 0; i < to_int_size; i++) { chars_workp[chars_size + i] = to_intp[i]; } auto to_start = chars_size; auto to_size = to_int_size; auto from_size = from.size(); std::vector<size_t> search_idx(sep_idx_size - 1); auto search_idx_size = search_idx.size(); auto search_idxp = search_idx.data(); for(size_t i = 0; i < search_idx_size; i++) { search_idxp[i] = sep_idxp[i]; } std::vector<size_t> original_num_occurrence(num_occurrence_size); auto original_num_occurrencep = original_num_occurrence.data(); for(size_t i = 0; i < num_occurrence_size; i++) { original_num_occurrencep[i] = num_occurrencep[i]; } // separate 1st iteration: num_occurence is always greater than 0 auto posp = pos.data(); #pragma _NEC ivdep for(size_t i = 0; i < search_idx_size; i++) { auto search_pos = search_idxp[i]; auto crnt_word = idxp[search_pos]; auto crnt_pos = posp[search_pos]; auto work_idx = original_starts_idxp[crnt_word]; lens_workp[work_idx] = crnt_pos; starts_workp[work_idx+1] = to_start; lens_workp[work_idx+1] = to_size; starts_workp[work_idx+2] = startsp[crnt_word] + crnt_pos + from_size; } for(size_t i = 0; i < num_occurrence_size; i++) {num_occurrencep[i]--;} auto non_zero = find_condition(num_occurrence, is_not_zero_like()); auto zero = find_condition(num_occurrence, is_zero_like()); auto zero_size = zero.size(); auto zerop = zero.data(); for(size_t i = 0; i < zero_size; i++) { auto search_pos = search_idxp[zerop[i]]; auto crnt_word = idxp[search_pos]; auto crnt_pos = posp[search_pos]; auto work_idx = original_starts_idxp[crnt_word]; lens_workp[work_idx+2] = lensp[crnt_word] - crnt_pos - from_size; } { auto non_zero_size = non_zero.size(); std::vector<size_t> new_num_occurrence(non_zero_size); std::vector<size_t> new_search_idx(non_zero_size); auto new_num_occurrencep = new_num_occurrence.data(); auto new_search_idxp = new_search_idx.data(); auto non_zerop = non_zero.data(); #pragma _NEC ivdep for(size_t i = 0; i < non_zero_size; i++) { new_num_occurrencep[i] = num_occurrencep[non_zerop[i]]; new_search_idxp[i] = search_idxp[non_zerop[i]] + 1; } num_occurrence.swap(new_num_occurrence); search_idx.swap(new_search_idx); } size_t iter = 1; while(true) { search_idx_size = search_idx.size(); search_idxp = search_idx.data(); num_occurrence_size = num_occurrence.size(); num_occurrencep = num_occurrence.data(); if(search_idx_size == 0) break; #pragma _NEC ivdep for(size_t i = 0; i < search_idx_size; i++) { auto search_pos = search_idxp[i]; auto crnt_word = idxp[search_pos]; auto crnt_pos = posp[search_pos]; auto work_idx = original_starts_idxp[crnt_word] + iter * 2; lens_workp[work_idx] = crnt_pos - posp[search_pos-1] - from_size; starts_workp[work_idx+1] = to_start; lens_workp[work_idx+1] = to_size; starts_workp[work_idx+2] = startsp[crnt_word] + crnt_pos + from_size; } for(size_t i = 0; i < num_occurrence_size; i++) {num_occurrencep[i]--;} auto non_zero = find_condition(num_occurrence, is_not_zero_like()); auto zero = find_condition(num_occurrence, is_zero_like()); auto zero_size = zero.size(); auto zerop = zero.data(); #pragma _NEC ivdep for(size_t i = 0; i < zero_size; i++) { auto search_pos = search_idxp[zerop[i]]; auto crnt_word = idxp[search_pos]; auto crnt_pos = posp[search_pos]; auto work_idx = original_starts_idxp[crnt_word] + iter * 2; lens_workp[work_idx+2] = lensp[crnt_word] - crnt_pos - from_size; } { auto non_zero_size = non_zero.size(); std::vector<size_t> new_num_occurrence(non_zero_size); std::vector<size_t> new_search_idx(non_zero_size); auto new_num_occurrencep = new_num_occurrence.data(); auto new_search_idxp = new_search_idx.data(); auto non_zerop = non_zero.data(); #pragma _NEC ivdep for(size_t i = 0; i < non_zero_size; i++) { new_num_occurrencep[i] = num_occurrencep[non_zerop[i]]; new_search_idxp[i] = search_idxp[non_zerop[i]] + 1; } num_occurrence.swap(new_num_occurrence); search_idx.swap(new_search_idx); } iter++; } std::vector<size_t> new_starts; ret_chars = concat_words(chars_work, starts_work, lens_work, "", new_starts); ret_starts.resize(starts_size); auto ret_startsp = ret_starts.data(); auto new_startsp = new_starts.data(); #pragma _NEC ivdep for(size_t i = 0; i < starts_size; i++) { ret_startsp[i] = new_startsp[original_starts_idxp[i]]; } ret_lens.resize(starts_size); auto ret_lensp = ret_lens.data(); for(size_t i = 0; i < starts_size; i++) { ret_lensp[i] = lensp[i]; } // might be negative size_t size_diff = (size_t)to_size - (size_t)from_size; #pragma _NEC ivdep for(size_t i = 0; i < sep_idx_size-1; i++) { ret_lensp[idxp[sep_idxp[i]]] += size_diff * original_num_occurrencep[i]; } } words replace(const words& w, const std::string& from, const std::string& to) { words ret; replace(w.chars, w.starts, w.lens, ret.chars, ret.starts, ret.lens, from, to); return ret; } void prepend(const std::vector<int>& chars, const std::vector<size_t>& starts, const std::vector<size_t>& lens, std::vector<int>& ret_chars, std::vector<size_t>& ret_starts, std::vector<size_t>& ret_lens, const std::string& to_prepend) { auto to_prepend_size = to_prepend.size(); auto new_chars = concat_words(chars, starts, lens, to_prepend, ret_starts); auto new_chars_size = new_chars.size(); ret_chars.resize(new_chars_size); auto ret_charsp = ret_chars.data(); auto new_charsp = new_chars.data(); for(size_t i = 0; i < new_chars_size - to_prepend_size; i++) { ret_charsp[i + to_prepend_size] = new_charsp[i]; } for(size_t i = 0; i < to_prepend_size; i++) { ret_charsp[i] = new_charsp[new_chars_size - to_prepend_size + i]; } auto lens_size = lens.size(); ret_lens.resize(lens_size); auto ret_lensp = ret_lens.data(); auto lensp = lens.data(); for(size_t i = 0; i < lens_size; i++) { ret_lensp[i] = lensp[i] + to_prepend_size; } } words prepend(const words& w, const std::string& to_prepend) { words ret; prepend(w.chars, w.starts, w.lens, ret.chars, ret.starts, ret.lens, to_prepend); return ret; } void append(const std::vector<int>& chars, const std::vector<size_t>& starts, const std::vector<size_t>& lens, std::vector<int>& ret_chars, std::vector<size_t>& ret_starts, std::vector<size_t>& ret_lens, const std::string& to_append) { auto to_append_size = to_append.size(); ret_chars = concat_words(chars, starts, lens, to_append, ret_starts); auto lens_size = lens.size(); ret_lens.resize(lens_size); auto ret_lensp = ret_lens.data(); auto lensp = lens.data(); for(size_t i = 0; i < lens_size; i++) { ret_lensp[i] = lensp[i] + to_append_size; } } words append(const words& w, const std::string& to_append) { words ret; append(w.chars, w.starts, w.lens, ret.chars, ret.starts, ret.lens, to_append); return ret; } words horizontal_concat_words(std::vector<words>& vec_words) { if(vec_words.size() == 0) return words(); auto num_words = vec_words[0].starts.size(); auto vec_words_size = vec_words.size(); for(size_t i = 1; i < vec_words_size; i++) { if(vec_words[i].starts.size() != num_words) throw std::runtime_error ("horizontal_concat_words: different number of words"); } std::vector<size_t> each_chars_size(vec_words_size); auto each_chars_sizep = each_chars_size.data(); for(size_t i = 0; i < vec_words_size; i++) { each_chars_sizep[i] = vec_words[i].chars.size(); } std::vector<size_t> pfx_chars_size(vec_words_size+1); // to make it exclusive auto pfx_chars_sizep = pfx_chars_size.data(); prefix_sum(each_chars_sizep, pfx_chars_sizep+1, vec_words_size); size_t concat_chars_size = pfx_chars_size[vec_words_size]; std::vector<int> concat_chars(concat_chars_size); auto concat_charsp = concat_chars.data(); for(size_t i = 0; i < vec_words_size; i++) { auto crnt_charsp = vec_words[i].chars.data(); auto crnt_chars_size = vec_words[i].chars.size(); auto crnt_concat_charsp = concat_charsp + pfx_chars_sizep[i]; for(size_t j = 0; j < crnt_chars_size; j++) { crnt_concat_charsp[j] = crnt_charsp[j]; } } words ret; std::vector<size_t> new_starts; { words tmp; tmp.starts.resize(num_words * vec_words_size); tmp.lens.resize(num_words * vec_words_size); tmp.chars.swap(concat_chars); auto tmp_startsp = tmp.starts.data(); auto tmp_lensp = tmp.lens.data(); for(size_t i = 0; i < vec_words_size; i++) { auto crnt_startsp = vec_words[i].starts.data(); auto crnt_lensp = vec_words[i].lens.data(); auto starts_shift = pfx_chars_sizep[i]; for(size_t j = 0; j < num_words; j++) { tmp_startsp[vec_words_size * j + i] = crnt_startsp[j] + starts_shift; tmp_lensp[vec_words_size * j + i] = crnt_lensp[j]; } } ret.chars = concat_words(tmp, "", new_starts); } ret.starts.resize(num_words); ret.lens.resize(num_words); auto ret_startsp = ret.starts.data(); auto new_startsp = new_starts.data(); for(size_t i = 0; i < num_words; i++) { ret_startsp[i] = new_startsp[i * vec_words_size]; } auto ret_lensp = ret.lens.data(); for(size_t i = 0; i < vec_words_size; i++) { auto crnt_lensp = vec_words[i].lens.data(); for(size_t j = 0; j < num_words; j++) { ret_lensp[j] += crnt_lensp[j]; } } return ret; } }
33.773119
82
0.605861
[ "vector" ]
ad5b8747883597b7f4d398a0f8765dff0360c99f
3,172
cpp
C++
clang/test/CXX/class.derived/class.abstract/p3.cpp
medismailben/llvm-project
e334a839032fe500c3bba22bf976ab7af13ce1c1
[ "Apache-2.0" ]
3,102
2015-01-04T02:28:35.000Z
2022-03-30T12:53:41.000Z
clang/test/CXX/class.derived/class.abstract/p3.cpp
medismailben/llvm-project
e334a839032fe500c3bba22bf976ab7af13ce1c1
[ "Apache-2.0" ]
3,740
2019-01-23T15:36:48.000Z
2022-03-31T22:01:13.000Z
clang/test/CXX/class.derived/class.abstract/p3.cpp
medismailben/llvm-project
e334a839032fe500c3bba22bf976ab7af13ce1c1
[ "Apache-2.0" ]
1,868
2015-01-03T04:27:11.000Z
2022-03-25T13:37:35.000Z
// RUN: %clang_cc1 -std=c++1z -verify %s struct A { A() {} A(int) : A() {} // ok virtual void f() = 0; // expected-note 1+{{unimplemented}} }; template<typename> struct SecretlyAbstract { SecretlyAbstract(); SecretlyAbstract(int); virtual void f() = 0; // expected-note 1+{{unimplemented}} }; using B = SecretlyAbstract<int>; using C = SecretlyAbstract<float>; using D = SecretlyAbstract<char>[1]; B b; // expected-error {{abstract class}} D d; // expected-error {{abstract class}} template<int> struct N; // Note: C is not instantiated anywhere in this file, so we never discover that // it is in fact abstract. The C++ standard suggests that we need to // instantiate in all cases where abstractness could affect the validity of a // program, but that breaks a *lot* of code, so we don't do that. // // FIXME: Once DR1640 is resolved, remove the check on forming an abstract // array type entirely. The only restriction we need is that you can't create // an object of abstract (most-derived) type. // An abstract class shall not be used // - as a parameter type void f(A&); void f(A); // expected-error {{abstract class}} void f(A[1]); // expected-error {{abstract class}} void f(B); // expected-error {{abstract class}} void f(B[1]); // expected-error {{abstract class}} void f(C); void f(C[1]); void f(D); // expected-error {{abstract class}} void f(D[1]); // expected-error {{abstract class}} // - as a function return type A &f(N<0>); A *f(N<1>); A f(N<2>); // expected-error {{abstract class}} A (&f(N<3>))[2]; // expected-error {{abstract class}} B f(N<4>); // expected-error {{abstract class}} B (&f(N<5>))[2]; // expected-error {{abstract class}} C f(N<6>); C (&f(N<7>))[2]; // - as the type of an explicit conversion void g(A&&); void h() { A(); // expected-error {{abstract class}} A(0); // expected-error {{abstract class}} A{}; // expected-error {{abstract class}} A{0}; // expected-error {{abstract class}} (A)(0); // expected-error {{abstract class}} (A){}; // expected-error {{abstract class}} (A){0}; // expected-error {{abstract class}} D(); // expected-error {{array type}} D{}; // expected-error {{abstract class}} D{0}; // expected-error {{abstract class}} (D){}; // expected-error {{abstract class}} (D){0}; // expected-error {{abstract class}} } template<typename T> void t(T); // expected-note 2{{abstract class}} void i(A &a, B &b, C &c, D &d) { // FIXME: These should be handled consistently. We currently reject the first // two early because we (probably incorrectly, depending on dr1640) take // abstractness into account in forming implicit conversion sequences. t(a); // expected-error {{no matching function}} t(b); // expected-error {{no matching function}} t(c); // expected-error {{allocating an object of abstract class type}} t(d); // ok, decays to pointer } struct E : A { E() : A() {} // ok E(int n) : A( A(n) ) {} // expected-error {{abstract class}} }; namespace std { template<typename T> struct initializer_list { const T *begin, *end; initializer_list(); }; } std::initializer_list<A> ila = {1, 2, 3, 4}; // expected-error {{abstract class}}
32.367347
81
0.648487
[ "object" ]
ad5c128b6ebd67a81a9abf139bbee7e71454103c
6,343
cpp
C++
src/main_Pitcher.cpp
ybdarrenwang/ProFeXor
5ea6e8d40e07807c0f7db2b6b479bba6c14528fd
[ "BSD-3-Clause" ]
1
2019-05-21T06:48:28.000Z
2019-05-21T06:48:28.000Z
src/main_Pitcher.cpp
ybdarrenwang/ProFeXor
5ea6e8d40e07807c0f7db2b6b479bba6c14528fd
[ "BSD-3-Clause" ]
null
null
null
src/main_Pitcher.cpp
ybdarrenwang/ProFeXor
5ea6e8d40e07807c0f7db2b6b479bba6c14528fd
[ "BSD-3-Clause" ]
null
null
null
#include "Normalizer.h" #include "MeanSubtraction.h" #include "MovingWindowMeanSub.h" #include "MaxSubtraction.h" #include "ContourSmoother.h" #include "MovingWindowSmoother.h" #include "ContourInterpolater.h" #include "CubicSplineInterpolater.h" #include "LinearInterpolater.h" #include "Config.h" #include "util.h" #include "mymath.h" using namespace std; void usage(const char *prog, const string &normalizeMode, const int &w_s, const string &interpolateMode) { cout<< "\n" << "\"Pitcher\" for pitch contour pre-processing, by Darren Yow-Bang Wang, 2013/07\n\n" << "Perform pitch contour interpolation, smoothing and normalization.\n\n" << "Usage: " << prog << " [options] ...\n" << "Options:\n" << " -i file_list each row are one input pitch file and its corresponding output\n" << " pitch file, separated by whitespace\n" << " -pitchNorm m [window_size] set pitch contour normalization mode to m (default: " << normalizeMode << ")\n" << " utt: subtract the mean pitch of the utterance\n" << " win: subtract the mean pitch within the range of context window\n" << " off: pitch contour won't be normalized\n" << "\n" << " -pitchSmooth window_size enable pitch contour moving window smoothing (default: " << w_s << ")\n" << "\n" << " -pitchInterpolate i set pitch contour interpolation mode to i (default: " << interpolateMode << ")\n" << " spline: Cubic Spline interpolation\n" << " linear: Linear interpolation\n" << "\n" << endl; exit(1); } void ReadArguments(int argc, char **argv, string &in_list, string &interpolateMode, string &normalizeMode, int &w_n, int &w_s) { // read arguments if( argc < 2 ) { usage(argv[0], normalizeMode, w_s, interpolateMode); exit(0); } vector<string> Args; for(unsigned int i=1; i!=argc; ++i) { string tmpstr(argv[i]); Args.push_back( tmpstr ); } cout << "====== Read options ======" << endl; for(unsigned int i=0; i!=Args.size(); ++i) { if( Args[i] == "-i" && Args.size() > i ) { i++; in_list = Args[i]; cout<<"Input file list: "<<in_list<<endl; } else if( Args[i] == "-pitchNorm" && Args.size() > i ) { i++; normalizeMode = Args[i]; if (normalizeMode == "win") { i++; stringstream ss(Args[i]); ss >> w_n; } } else if( Args[i] == "-pitchInterpolate" && Args.size() > i ) { i++; interpolateMode = Args[i]; } else if( Args[i] == "-pitchSmooth" && Args.size() > i ) { i++; stringstream ss(Args[i]); ss >> w_s; } } } /** * Load pitch contour from f0 file, take log, and perform normalization, interpolation and smoothing.\n * Note: Because Normalizer::Normalize() requires UtteranceInfo* for the begin/end time of utterance, * here I create a "fake" UtteranceInfo* info which only records the beginning and end silence of * utterance. */ int main(int argc, char **argv) { string in_list = ""; ContourSmoother* pitchContourSmoother=0; ContourInterpolater* pitchContourInterpolater=0; Normalizer* pitchContourNormalizer=0; // set default arguments string normalizeMode = "utt", interpolateMode = "spline"; int w_n = 50, w_s = 0; // Load arguments ReadArguments(argc, argv, in_list, interpolateMode, normalizeMode, w_n, w_s); // initialize pitch processors if (w_s > 0) { cout<<"Pitch contour smoothing: moving window smoothing with window size = "<<w_s<<" frames"<<endl; pitchContourSmoother = new MovingWindowSmoother(w_s); } else { cout<<"Pitch contour smoothing: disabled"<<endl; pitchContourSmoother = 0; } if (normalizeMode == "utt") { cout<<"Pitch contour normalization: subtracting mean pitch of each utterance"<<endl; pitchContourNormalizer = new MeanSubtraction(); } else if (normalizeMode == "win") { cout<<"Pitch contour normalization: moving average subtraction with window size = "<<w_n<<" frames"<<endl; pitchContourNormalizer = new MovingWindowMeanSub(w_n); } else if (normalizeMode == "off") { cout<<"Pitch contour normalization: disabled"<<endl; pitchContourNormalizer = 0; } else { cerr<<"[Error] unknown pitch contour normalization mode: "<<normalizeMode<<endl; exit(1); } if (interpolateMode == "spline") { cout<<"Pitch contour interpolation: Cubic Spline"<<endl; pitchContourInterpolater = new CubicSplineInterpolater(); } else if (interpolateMode == "linear") { cout<<"Pitch contour interpolation: Linear"<<endl; pitchContourInterpolater = new LinearInterpolater(); } else { cerr<<"[Error] unknown pitch contour interpolation mode: "<<interpolateMode<<endl; exit(1); } // Prepare for I/O ifstream ifs_list(in_list.c_str()); if (!ifs_list.is_open()) { cerr<<"[Error] cannot open file list "<<in_list<<endl; exit(1); } // Begin processing vector<double> pitchContour; UtteranceInfo info; string line; vector<string> ioFiles; //while(!getLine(ifs_list, line)) while(getline(ifs_list, line)) { ioFiles = split(line); LoadF0(ioFiles[0], pitchContour); // create fake utterance information vector<int> fakeTimeLabel(4, 0); int uttBeginTime=0, uttEndTime=pitchContour.size()-1; while (uttBeginTime<pitchContour.size() & pitchContour[uttBeginTime]==0) ++uttBeginTime; while (uttEndTime>0 & pitchContour[uttEndTime]==0) --uttEndTime; fakeTimeLabel[3] = uttBeginTime; info.AddUnit(fakeTimeLabel); fakeTimeLabel[0] = uttEndTime+1; info.AddUnit(fakeTimeLabel); // take log, perform normalization, interpolation and smoothing Vector_log(pitchContour); if (pitchContourInterpolater != 0) pitchContourInterpolater->Interpolate(pitchContour); if (pitchContourSmoother != 0) pitchContourSmoother->Smooth(pitchContour); if (pitchContourNormalizer != 0) pitchContourNormalizer->Normalize(pitchContour, &info); // output ofstream ofs_f0(ioFiles[1].c_str()); if (!ofs_f0.is_open()) { cerr<<"[Error] cannot open "<<ioFiles[1]<<endl; return 1; } cout<<"Writing "<<ioFiles[1]<<"......"<<endl; for (unsigned int i=0; i!=pitchContour.size(); ++i) ofs_f0<<pitchContour[i]<<"\n"; ofs_f0.close(); pitchContour.clear(); info.Clear(); } return 0; }
29.09633
126
0.652215
[ "vector" ]
ad5d50aaf6174ac78e02cf03e0bfd10acb5bba5e
2,280
hpp
C++
src/engine/scene/Sky.hpp
kosua20/Rendu
6b8e730f16658738572bc2f49e08fc4a2c59df07
[ "MIT" ]
399
2019-05-25T16:05:59.000Z
2022-03-31T23:38:04.000Z
src/engine/scene/Sky.hpp
kosua20/Rendu
6b8e730f16658738572bc2f49e08fc4a2c59df07
[ "MIT" ]
3
2019-07-23T21:03:33.000Z
2020-12-14T12:47:51.000Z
src/engine/scene/Sky.hpp
kosua20/Rendu
6b8e730f16658738572bc2f49e08fc4a2c59df07
[ "MIT" ]
20
2019-06-08T17:15:01.000Z
2022-03-21T11:20:14.000Z
#pragma once #include "scene/Object.hpp" #include "resources/ResourcesManager.hpp" #include "system/Codable.hpp" #include "Common.hpp" /** \brief Represent a background environment with atmospheric scattering. The sun direction can be animated. \ingroup Scene \see AtmosphericScattering */ class Sky final : public Object { public: /** Constructor. \param options data loading and storage options */ explicit Sky(Storage options); /** Apply the animations for a frame duration. \param fullTime the time since the launch of the application \param frameTime the time elapsed since the last frame */ void update(double fullTime, double frameTime) override; /** Setup a sky environment parameters from a list of key-value tuples. The following keywords will be searched for: \verbatim bgsky: direction: X,Y,Z animations: ... \endverbatim \param params the parameters tuple \param options data loading and storage options */ void decode(const KeyValues & params, Storage options) override; /** Generate a key-values representation of the object. See decode for the keywords and layout. \return a tuple representing the object. */ KeyValues encode() const override; /** Reference to the sun direction. \return the normalized sun direction */ const glm::vec3 & direction() const { return _sunDirection; } /** \brief Atmosphere parameters. Default values correspond to Earth-like atmosphere. */ struct AtmosphereParameters { glm::vec3 sunColor = glm::vec3(1.474f, 1.8504f, 1.91198f); ///< Sun direct color. glm::vec3 kRayleigh = glm::vec3(5.5e-6f, 13.0e-6f, 22.4e-6f); ///< Rayleigh coefficients. float groundRadius = 6371e3f; ///< Radius of the planet. float topRadius = 6471e3f; ///< Radius of the atmosphere. float sunIntensity = 20.0f; ///< Sun intensity. float kMie = 21e-6f; ///< Mie coefficients. float heightRayleigh = 8000.0f; ///< Mie characteristic height. float heightMie = 1200.0f; ///< Mie characteristic height. float gMie = 0.758f; ///< Mie g constant. float sunRadius = 0.04675f; ///< Sun angular radius. float sunRadiusCos = 0.998f; ///< Cosine of the sun angular radius. }; private: Animated<glm::vec3> _sunDirection { glm::vec3(0.0f, 1.0f, 0.0f) }; ///< The sun direction. };
33.043478
117
0.716667
[ "object" ]
ad5e7679c84aedfffa8c6ee5911949589bc06039
2,219
cpp
C++
src/gvt/render/data/scene/Image.cpp
TACC/GravIT
0a79dc74036c11669075198e01b30a92a8150693
[ "BSD-3-Clause" ]
24
2015-08-13T20:16:11.000Z
2020-03-02T17:03:17.000Z
src/gvt/render/data/scene/Image.cpp
TACC/GravIT
0a79dc74036c11669075198e01b30a92a8150693
[ "BSD-3-Clause" ]
16
2015-10-16T03:42:37.000Z
2019-08-07T21:54:47.000Z
src/gvt/render/data/scene/Image.cpp
TACC/GravIT
0a79dc74036c11669075198e01b30a92a8150693
[ "BSD-3-Clause" ]
8
2015-08-25T15:07:35.000Z
2019-03-10T11:00:32.000Z
/* ======================================================================================= This file is released as part of GraviT - scalable, platform independent ray tracing tacc.github.io/GraviT Copyright 2013-2015 Texas Advanced Computing Center, The University of Texas at Austin All rights reserved. Licensed under the BSD 3-Clause License, (the "License"); you may not use this file except in compliance with the License. A copy of the License is included with this software in the file LICENSE. If your copy does not contain the License, you may obtain a copy of the License at: http://opensource.org/licenses/BSD-3-Clause 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 limitations under the License. GraviT is funded in part by the US National Science Foundation under awards ACI-1339863, ACI-1339881 and ACI-1339840 ======================================================================================= */ // // Image.C // #include <gvt/render/data/scene/Image.h> #include <gvt/core/Debug.h> #include <fstream> #include <iostream> #include <mpi.h> #include <sstream> using namespace gvt::render::data::scene; void Image::Write() { if (MPI::COMM_WORLD.Get_rank() != 0) return; std::string ext; switch (format) { case PPM: ext = ".ppm"; break; default: return; } std::stringstream header; header << "P6" << std::endl; header << width << " " << height << std::endl; header << "255" << std::endl; std::fstream file; file.open((filename + ext).c_str(), std::fstream::out | std::fstream::trunc | std::fstream::binary); file << header.str(); // reverse row order so image is correctly oriented for (int j = height - 1; j >= 0; j--) { int offset = j * width; for (int i = 0; i < width; ++i) { int index = 3 * (offset + i); file << rgb[index + 0] << rgb[index + 1] << rgb[index + 2]; } } std::cout << std::endl; file.close(); }
30.39726
102
0.615593
[ "render" ]
ad602e360baa246aee7292e00fcbcd9b09ec7faa
15,005
cpp
C++
src/settingsgen/settingsgen.cpp
trademarks/OpenTTD
fd7fca73cf61a2960e8df8fa221b179d23ae3ef0
[ "Unlicense" ]
8
2016-10-21T09:01:43.000Z
2021-05-31T06:32:14.000Z
src/settingsgen/settingsgen.cpp
blackberry/OpenTTD
fd7fca73cf61a2960e8df8fa221b179d23ae3ef0
[ "Unlicense" ]
null
null
null
src/settingsgen/settingsgen.cpp
blackberry/OpenTTD
fd7fca73cf61a2960e8df8fa221b179d23ae3ef0
[ "Unlicense" ]
4
2017-05-16T00:15:58.000Z
2020-08-06T01:46:31.000Z
/* $Id$ */ /* * This file is part of OpenTTD. * OpenTTD 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, version 2. * OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file settingsgen.cpp Tool to create computer-readable settings. */ #include "../stdafx.h" #include "../string_func.h" #include "../strings_type.h" #include "../misc/getoptdata.h" #include "../ini_type.h" #include "../core/smallvec_type.hpp" #include <stdarg.h> #if (!defined(WIN32) && !defined(WIN64)) || defined(__CYGWIN__) #include <unistd.h> #include <sys/stat.h> #endif #ifdef __MORPHOS__ #ifdef stderr #undef stderr #endif #define stderr stdout #endif /* __MORPHOS__ */ /** * Report a fatal error. * @param s Format string. * @note Function does not return. */ void NORETURN CDECL error(const char *s, ...) { char buf[1024]; va_list va; va_start(va, s); vsnprintf(buf, lengthof(buf), s, va); va_end(va); fprintf(stderr, "FATAL: %s\n", buf); exit(1); }; static const int OUTPUT_BLOCK_SIZE = 16000; ///< Block size of the buffer in #OutputBuffer. /** Output buffer for a block of data. */ class OutputBuffer { public: /** Prepare buffer for use. */ void Clear() { this->size = 0; } /** * Add text to the output buffer. * @param text Text to store. * @param length Length of the text in bytes. * @return Number of bytes actually stored. */ int Add(const char *text, int length) { int store_size = min(length, OUTPUT_BLOCK_SIZE - this->size); assert(store_size >= 0); assert(store_size <= OUTPUT_BLOCK_SIZE); MemCpyT(this->data + this->size, text, store_size); this->size += store_size; return store_size; } /** * Dump buffer to the output stream. * @param out_fp Stream to write the \a data to. */ void Write(FILE *out_fp) const { if (fwrite(this->data, 1, this->size, out_fp) != (size_t)this->size) { fprintf(stderr, "Error: Cannot write output\n"); } } /** * Does the block have room for more data? * @return \c true if room is available, else \c false. */ bool HasRoom() const { return this->size < OUTPUT_BLOCK_SIZE; } int size; ///< Number of bytes stored in \a data. char data[OUTPUT_BLOCK_SIZE]; ///< Stored data. }; /** Temporarily store output. */ class OutputStore { public: OutputStore() { this->Clear(); } /** Clear the temporary storage. */ void Clear() { this->output_buffer.Clear(); } /** * Add text to the output storage. * @param text Text to store. * @param length Length of the text in bytes, \c 0 means 'length of the string'. */ void Add(const char *text, int length = 0) { if (length == 0) length = strlen(text); if (length > 0 && this->BufferHasRoom()) { int stored_size = this->output_buffer[this->output_buffer.Length() - 1].Add(text, length); length -= stored_size; text += stored_size; } while (length > 0) { OutputBuffer *block = this->output_buffer.Append(); block->Clear(); // Initialize the new block. int stored_size = block->Add(text, length); length -= stored_size; text += stored_size; } } /** * Write all stored output to the output stream. * @param out_fp Stream to write the \a data to. */ void Write(FILE *out_fp) const { for (const OutputBuffer *out_data = this->output_buffer.Begin(); out_data != this->output_buffer.End(); out_data++) { out_data->Write(out_fp); } } private: /** * Does the buffer have room without adding a new #OutputBuffer block? * @return \c true if room is available, else \c false. */ bool BufferHasRoom() const { uint num_blocks = this->output_buffer.Length(); return num_blocks > 0 && this->output_buffer[num_blocks - 1].HasRoom(); } typedef SmallVector<OutputBuffer, 2> OutputBufferVector; ///< Vector type for output buffers. OutputBufferVector output_buffer; ///< Vector of blocks containing the stored output. }; /** Derived class for loading INI files without going through Fio stuff. */ struct SettingsIniFile : IniLoadFile { /** * Construct a new ini loader. * @param list_group_names A \c NULL terminated list with group names that should be loaded as lists instead of variables. @see IGT_LIST * @param seq_group_names A \c NULL terminated list with group names that should be loaded as lists of names. @see IGT_SEQUENCE */ SettingsIniFile(const char * const *list_group_names = NULL, const char * const *seq_group_names = NULL) : IniLoadFile(list_group_names, seq_group_names) { } virtual FILE *OpenFile(const char *filename, size_t *size) { /* Open the text file in binary mode to prevent end-of-line translations * done by ftell() and friends, as defined by K&R. */ FILE *in = fopen(filename, "rb"); if (in == NULL) return NULL; fseek(in, 0L, SEEK_END); *size = ftell(in); fseek(in, 0L, SEEK_SET); // Seek back to the start of the file. return in; } virtual void ReportFileError(const char * const pre, const char * const buffer, const char * const post) { error("%s%s%s", pre, buffer, post); } }; OutputStore _stored_output; ///< Temporary storage of the output, until all processing is done. static const char *PREAMBLE_GROUP_NAME = "pre-amble"; ///< Name of the group containing the pre amble. static const char *POSTAMBLE_GROUP_NAME = "post-amble"; ///< Name of the group containing the post amble. static const char *TEMPLATES_GROUP_NAME = "templates"; ///< Name of the group containing the templates. static const char *DEFAULTS_GROUP_NAME = "defaults"; ///< Name of the group containing default values for the template variables. /** * Load the INI file. * @param filename Name of the file to load. * @return Loaded INI data. */ static IniLoadFile *LoadIniFile(const char *filename) { static const char * const seq_groups[] = {PREAMBLE_GROUP_NAME, POSTAMBLE_GROUP_NAME, NULL}; IniLoadFile *ini = new SettingsIniFile(NULL, seq_groups); ini->LoadFromDisk(filename); return ini; } /** * Dump a #IGT_SEQUENCE group into #_stored_output. * @param ifile Loaded INI data. * @param group_name Name of the group to copy. */ static void DumpGroup(IniLoadFile *ifile, const char * const group_name) { IniGroup *grp = ifile->GetGroup(group_name, 0, false); if (grp != NULL && grp->type == IGT_SEQUENCE) { for (IniItem *item = grp->item; item != NULL; item = item->next) { if (item->name) { _stored_output.Add(item->name); _stored_output.Add("\n", 1); } } } } /** * Find the value of a template variable. * @param name Name of the item to find. * @param grp Group currently being expanded (searched first). * @param defaults Fallback group to search, \c NULL skips the search. * @return Text of the item if found, else \c NULL. */ static const char *FindItemValue(const char *name, IniGroup *grp, IniGroup *defaults) { IniItem *item = grp->GetItem(name, false); if (item == NULL && defaults != NULL) item = defaults->GetItem(name, false); if (item == NULL || item->value == NULL) return NULL; return item->value; } /** * Output all non-special sections through the template / template variable expansion system. * @param ifile Loaded INI data. */ static void DumpSections(IniLoadFile *ifile) { static const int MAX_VAR_LENGTH = 64; static const char * const special_group_names[] = {PREAMBLE_GROUP_NAME, POSTAMBLE_GROUP_NAME, DEFAULTS_GROUP_NAME, TEMPLATES_GROUP_NAME, NULL}; IniGroup *default_grp = ifile->GetGroup(DEFAULTS_GROUP_NAME, 0, false); IniGroup *templates_grp = ifile->GetGroup(TEMPLATES_GROUP_NAME, 0, false); if (templates_grp == NULL) return; /* Output every group, using its name as template name. */ for (IniGroup *grp = ifile->group; grp != NULL; grp = grp->next) { const char * const *sgn; for (sgn = special_group_names; *sgn != NULL; sgn++) if (strcmp(grp->name, *sgn) == 0) break; if (*sgn != NULL) continue; IniItem *template_item = templates_grp->GetItem(grp->name, false); // Find template value. if (template_item == NULL || template_item->value == NULL) { fprintf(stderr, "settingsgen: Warning: Cannot find template %s\n", grp->name); continue; } /* Prefix with #if/#ifdef/#ifndef */ static const char * const pp_lines[] = {"if", "ifdef", "ifndef", NULL}; int count = 0; for (const char * const *name = pp_lines; *name != NULL; name++) { const char *condition = FindItemValue(*name, grp, default_grp); if (condition != NULL) { _stored_output.Add("#", 1); _stored_output.Add(*name); _stored_output.Add(" ", 1); _stored_output.Add(condition); _stored_output.Add("\n", 1); count++; } } /* Output text of the template, except template variables of the form '$[_a-z0-9]+' which get replaced by their value. */ const char *txt = template_item->value; while (*txt != '\0') { if (*txt != '$') { _stored_output.Add(txt, 1); txt++; continue; } txt++; if (*txt == '$') { // Literal $ _stored_output.Add(txt, 1); txt++; continue; } /* Read variable. */ char variable[MAX_VAR_LENGTH]; int i = 0; while (i < MAX_VAR_LENGTH - 1) { if (!(txt[i] == '_' || (txt[i] >= 'a' && txt[i] <= 'z') || (txt[i] >= '0' && txt[i] <= '9'))) break; variable[i] = txt[i]; i++; } variable[i] = '\0'; txt += i; if (i > 0) { /* Find the text to output. */ const char *valitem = FindItemValue(variable, grp, default_grp); if (valitem != NULL) _stored_output.Add(valitem); } else { _stored_output.Add("$", 1); } } _stored_output.Add("\n", 1); // \n after the expanded template. while (count > 0) { _stored_output.Add("#endif\n"); count--; } } } /** * Copy a file to the output. * @param fname Filename of file to copy. * @param out_fp Output stream to write to. */ static void CopyFile(const char *fname, FILE *out_fp) { if (fname == NULL) return; FILE *in_fp = fopen(fname, "r"); if (in_fp == NULL) { fprintf(stderr, "settingsgen: Warning: Cannot open file %s for copying\n", fname); return; } char buffer[4096]; size_t length; do { length = fread(buffer, 1, lengthof(buffer), in_fp); if (fwrite(buffer, 1, length, out_fp) != length) { fprintf(stderr, "Error: Cannot copy file\n"); break; } } while (length == lengthof(buffer)); fclose(in_fp); } /** * Compare two files for identity. * @param n1 First file. * @param n2 Second file. * @return True if both files are identical. */ static bool CompareFiles(const char *n1, const char *n2) { FILE *f2 = fopen(n2, "rb"); if (f2 == NULL) return false; FILE *f1 = fopen(n1, "rb"); if (f1 == NULL) error("can't open %s", n1); size_t l1, l2; do { char b1[4096]; char b2[4096]; l1 = fread(b1, 1, sizeof(b1), f1); l2 = fread(b2, 1, sizeof(b2), f2); if (l1 != l2 || memcmp(b1, b2, l1) != 0) { fclose(f2); fclose(f1); return false; } } while (l1 != 0); fclose(f2); fclose(f1); return true; } /** Options of settingsgen. */ static const OptionData _opts[] = { GETOPT_NOVAL( 'v', "--version"), GETOPT_NOVAL( 'h', "--help"), GETOPT_GENERAL('h', '?', NULL, ODF_NO_VALUE), GETOPT_VALUE( 'o', "--output"), GETOPT_VALUE( 'b', "--before"), GETOPT_VALUE( 'a', "--after"), GETOPT_END(), }; /** * Process a single INI file. * The file should have a [templates] group, where each item is one template. * Variables in a template have the form '\$[_a-z0-9]+' (a literal '$' followed * by one or more '_', lowercase letters, or lowercase numbers). * * After loading, the [pre-amble] group is copied verbatim if it exists. * * For every group with a name that matches a template name the template is written. * It starts with a optional '#if' line if an 'if' item exists in the group. The item * value is used as condition. Similarly, '#ifdef' and '#ifndef' lines are also written. * Below the macro processor directives, the value of the template is written * at a line with its variables replaced by item values of the group being written. * If the group has no item for the variable, the [defaults] group is tried as fall back. * Finally, '#endif' lines are written to match the macro processor lines. * * Last but not least, the [post-amble] group is copied verbatim. * * @param fname Ini file to process. @return Exit status of the processing. */ static void ProcessIniFile(const char *fname) { IniLoadFile *ini_data = LoadIniFile(fname); DumpGroup(ini_data, PREAMBLE_GROUP_NAME); DumpSections(ini_data); DumpGroup(ini_data, POSTAMBLE_GROUP_NAME); delete ini_data; } /** * And the main program (what else?) * @param argc Number of command-line arguments including the program name itself. * @param argv Vector of the command-line arguments. */ int CDECL main(int argc, char *argv[]) { const char *output_file = NULL; const char *before_file = NULL; const char *after_file = NULL; GetOptData mgo(argc - 1, argv + 1, _opts); for (;;) { int i = mgo.GetOpt(); if (i == -1) break; switch (i) { case 'v': puts("$Revision$"); return 0; case 'h': puts("settingsgen - $Revision$\n" "Usage: settingsgen [options] ini-file...\n" "with options:\n" " -v, --version Print version information and exit\n" " -h, -?, --help Print this help message and exit\n" " -b FILE, --before FILE Copy FILE before all settings\n" " -a FILE, --after FILE Copy FILE after all settings\n" " -o FILE, --output FILE Write output to FILE\n"); return 0; case 'o': output_file = mgo.opt; break; case 'a': after_file = mgo.opt; break; case 'b': before_file = mgo.opt; break; case -2: fprintf(stderr, "Invalid arguments\n"); return 1; } } _stored_output.Clear(); for (int i = 0; i < mgo.numleft; i++) ProcessIniFile(mgo.argv[i]); /* Write output. */ if (output_file == NULL) { CopyFile(before_file, stdout); _stored_output.Write(stdout); CopyFile(after_file, stdout); } else { static const char * const tmp_output = "tmp2.xxx"; FILE *fp = fopen(tmp_output, "w"); if (fp == NULL) { fprintf(stderr, "settingsgen: Warning: Cannot open file %s\n", tmp_output); return 1; } CopyFile(before_file, fp); _stored_output.Write(fp); CopyFile(after_file, fp); fclose(fp); if (CompareFiles(tmp_output, output_file)) { /* Files are equal. tmp2.xxx is not needed. */ unlink(tmp_output); } else { /* Rename tmp2.xxx to output file. */ #if defined(WIN32) || defined(WIN64) unlink(output_file); #endif if (rename(tmp_output, output_file) == -1) error("rename() failed"); } } return 0; }
28.967181
185
0.659447
[ "vector" ]
ad66ec0f83a5b8b0c73b5727c63aa081ce63bac9
791
cpp
C++
atcoder/abc154D_dice_in_line.cpp
uninhm/kyopro
bf6ed9cbf6a5e46cde0291f7aa9d91a8ddf1f5a3
[ "BSD-3-Clause" ]
31
2020-05-13T01:07:55.000Z
2021-07-13T07:53:26.000Z
atcoder/abc154D_dice_in_line.cpp
uninhm/kyopro
bf6ed9cbf6a5e46cde0291f7aa9d91a8ddf1f5a3
[ "BSD-3-Clause" ]
10
2020-05-20T07:22:09.000Z
2021-07-19T03:52:13.000Z
atcoder/abc154D_dice_in_line.cpp
uninhm/kyopro
bf6ed9cbf6a5e46cde0291f7aa9d91a8ddf1f5a3
[ "BSD-3-Clause" ]
14
2020-05-11T05:58:36.000Z
2021-12-07T03:20:43.000Z
// https://atcoder.jp/contests/abc154/tasks/abc154_d #include<iostream> #include<numeric> #include<iomanip> #include<vector> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> max_values(n); for (auto &it : max_values) cin >> it; vector<int> legit(k); long long max = 0; for (int i = 0; i + k <= n; i++) { auto begining = max_values.begin() + i; long long current = accumulate(begining, begining+k, 0); if (current > max) { legit = {begining, begining+k}; max = current; } } long double sum = 0.0L; for (auto v : legit) { double factor = 1.0L / v; sum += (((v + 1.0L) * v) / 2L) * factor; } cout << setprecision(15) << sum <<endl; return 0; }
23.264706
64
0.533502
[ "vector" ]
ad6b5f6362dd17a0e81ac1a3a92a540c49996027
5,010
hpp
C++
framework/include/minko/input/Touch.hpp
undeadinu/minko
9171805751fb3a50c6fcab0b78892cdd4253ee11
[ "BSD-3-Clause" ]
null
null
null
framework/include/minko/input/Touch.hpp
undeadinu/minko
9171805751fb3a50c6fcab0b78892cdd4253ee11
[ "BSD-3-Clause" ]
null
null
null
framework/include/minko/input/Touch.hpp
undeadinu/minko
9171805751fb3a50c6fcab0b78892cdd4253ee11
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (c) 2014 Aerys 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 "minko/Common.hpp" #include "minko/Signal.hpp" #include "minko/AbstractCanvas.hpp" #include "minko/Any.hpp" namespace minko { namespace input { class Touch { public: typedef std::shared_ptr<Touch> Ptr; typedef struct TouchPoint { float x; float y; float dX; float dY; } TouchPoint; protected: std::shared_ptr<AbstractCanvas> _canvas; std::map<int, TouchPoint> _touches; // identifier to x/y dx/dy std::vector<int> _identifiers; Signal<Ptr, int, float, float>::Ptr _touchMove; Signal<Ptr, int, float, float>::Ptr _touchDown; Signal<Ptr, int, float, float>::Ptr _touchUp; // Gestures Signal<Ptr>::Ptr _swipeRight; Signal<Ptr>::Ptr _swipeLeft; Signal<Ptr>::Ptr _swipeUp; Signal<Ptr>::Ptr _swipeDown; Signal<Ptr, float>::Ptr _pinchZoom; Signal<Ptr, float, float>::Ptr _tap; Signal<Ptr, float, float>::Ptr _doubleTap; Signal<Ptr, float, float>::Ptr _longHold; public: inline std::map<int, TouchPoint> touches() { return _touches; } inline std::vector<int> identifiers() { return _identifiers; } inline int numTouches() { return _identifiers.size(); } inline TouchPoint touch(int identifier) { return _touches[identifier]; } inline Signal<Ptr, int, float, float>::Ptr touchMove() { return _touchMove; } inline Signal<Ptr, int, float, float>::Ptr touchDown() { return _touchDown; } inline Signal<Ptr, int, float, float>::Ptr touchUp() { return _touchUp; } inline Signal<Ptr>::Ptr swipeLeft() { return _swipeLeft; } inline Signal<Ptr>::Ptr swipeRight() { return _swipeRight; } inline Signal<Ptr>::Ptr swipeUp() { return _swipeUp; } inline Signal<Ptr>::Ptr swipeDown() { return _swipeDown; } inline Signal<Ptr, float>::Ptr pinchZoom() { return _pinchZoom; } inline Signal<Ptr, float, float>::Ptr tap() { return _tap; } inline Signal<Ptr, float, float>::Ptr doubleTap() { return _doubleTap; } inline Signal<Ptr, float, float>::Ptr longHold() { return _longHold; } float averageX(); float averageY(); float averageDX(); float averageDY(); void resetDeltas(); protected: Touch(std::shared_ptr<AbstractCanvas> canvas); }; } }
26.230366
97
0.467465
[ "vector" ]
ad6e57bfaee373016c9adb4e4f5b654df60eb820
8,670
cpp
C++
src/linux_parser.cpp
ohasanliUW/CppND-System-Monitor
91f6508ba59704fae4c0c859fa1540263587693b
[ "MIT" ]
null
null
null
src/linux_parser.cpp
ohasanliUW/CppND-System-Monitor
91f6508ba59704fae4c0c859fa1540263587693b
[ "MIT" ]
null
null
null
src/linux_parser.cpp
ohasanliUW/CppND-System-Monitor
91f6508ba59704fae4c0c859fa1540263587693b
[ "MIT" ]
null
null
null
#include <dirent.h> #include <unistd.h> #include <string> #include <vector> #include <numeric> #include <iostream> #include "linux_parser.h" using std::stof; using std::string; using std::to_string; using std::vector; // DONE: An example of how to read data from the filesystem string LinuxParser::OperatingSystem() { string line; string key; string value; std::ifstream filestream(kOSPath); if (filestream.is_open()) { while (std::getline(filestream, line)) { std::replace(line.begin(), line.end(), ' ', '_'); std::replace(line.begin(), line.end(), '=', ' '); std::replace(line.begin(), line.end(), '"', ' '); std::istringstream linestream(line); while (linestream >> key >> value) { if (key == "PRETTY_NAME") { std::replace(value.begin(), value.end(), '_', ' '); return value; } } } } return value; } // DONE: An example of how to read data from the filesystem string LinuxParser::Kernel() { string kernel, dummy, version; string line; std::ifstream stream(kProcDirectory + kVersionFilename); if (stream.is_open()) { std::getline(stream, line); std::istringstream linestream(line); linestream >> kernel >> dummy >> version; } return kernel + " " + version; } // BONUS: Update this to use std::filesystem vector<int> LinuxParser::Pids() { vector<int> pids; //std::filesystem::path file(kProcDirectory); DIR* directory = opendir(kProcDirectory.c_str()); struct dirent* file; while ((file = readdir(directory)) != nullptr) { // Is this a directory? if (file->d_type == DT_DIR) { // Is every character of the name a digit? string filename(file->d_name); if (std::all_of(filename.begin(), filename.end(), isdigit)) { int pid = stoi(filename); pids.push_back(pid); } } } closedir(directory); return pids; } // DONE: Read and return the system memory utilization float LinuxParser::MemoryUtilization() { std::ifstream stream(kProcDirectory + kMeminfoFilename); long memTotal = 0, memFree = 0; if (stream.is_open()) { string line; while (std::getline(stream, line)) { std::istringstream linestream(line); string key; int val; linestream >> key >> val; // Remove ':' character from the key if any key.erase(std::remove(key.begin(), key.end(), ':'), key.end()); if (key == "MemTotal") { memTotal = val; } else if (key == "MemFree") { memFree = val; } } return static_cast<float>(memTotal - memFree) / memTotal; } return 0.0; } // DONE: Read and return the system uptime long LinuxParser::UpTime() { std::ifstream stream(kProcDirectory + kUptimeFilename); string line; long uptime; if (!stream.is_open()) { return -1; } std::getline(stream, line); std::istringstream linestream(line); linestream >> uptime; return uptime; } // TODO: Read and return the number of jiffies for the system long LinuxParser::Jiffies() { auto stats {LinuxParser::CpuUtilization()}; long total = std::accumulate(stats.begin(), stats.end(), 0, [](int t, std::string e) {return t + std::stol(e);}); return total; } // Read process stats static vector<string> read_process_stats(int pid) { std::ifstream statf(LinuxParser::kProcDirectory + to_string(pid) + LinuxParser::kStatFilename); vector<string> stats; if (!statf.is_open()) { return stats; } string line; if (!std::getline(statf, line)) { return stats; } // add all words into a vector std::istringstream iss(line); string word; while(iss >> word) { stats.push_back(word); } return stats; } // TODO: Read and return the number of active jiffies for a PID long LinuxParser::ActiveJiffies(int pid) { auto stats = read_process_stats(pid); if (stats.empty()) { return -1; } long int utime {std::stol(stats[13])}; long int stime {std::stol(stats[14])}; long int cutime {std::stol(stats[15])}; long int cstime {std::stol(stats[16])}; long int total = utime + stime + cutime + cstime; return total; } // TODO: Read and return the number of active jiffies for the system long LinuxParser::ActiveJiffies() { auto stats {LinuxParser::CpuUtilization()}; return std::stol(stats[0]) + std::stol(stats[2]); } // TODO: Read and return the number of idle jiffies for the system long LinuxParser::IdleJiffies() { auto stats = LinuxParser::CpuUtilization(); return std::stol(stats[LinuxParser::kIdle_]) + std::stol(stats[LinuxParser::kIOwait_]); } // DONE: Read and return CPU utilization vector<string> LinuxParser::CpuUtilization() { std::ifstream stream(kProcDirectory + kStatFilename); std::vector<string> words; if (!stream.is_open()) { return words; } string line, word; std::getline(stream, line); std::istringstream linestream(line); // ignore the first word linestream >> word; // push every other word into vector while(linestream >> word) { words.push_back(word); } return words; } // DONE: Read and return the total number of processes int LinuxParser::TotalProcesses() { string line; std::ifstream statsf(kProcDirectory + kStatFilename); if (!statsf.is_open()) { return -1; } while(std::getline(statsf, line)) { int numRunProcs = 0; string key; std::istringstream linestream(line); linestream >> key >> numRunProcs; if (key == "processes") { return numRunProcs; } } return -1; } // DONE: Read and return the number of running processes int LinuxParser::RunningProcesses() { string line; std::ifstream statsf(kProcDirectory + kStatFilename); if (!statsf.is_open()) { return -1; } while(std::getline(statsf, line)) { int numRunProcs = 0; string key; std::istringstream linestream(line); linestream >> key >> numRunProcs; if (key == "procs_running") { return numRunProcs; } } return -1; } // Read and return the command associated with a process string LinuxParser::Command(int pid) { string line; std::ifstream cmdf(kProcDirectory + to_string(pid) + kCmdlineFilename); if(!cmdf.is_open()) { return string(); } std::getline(cmdf, line); return line; } // Read and return the memory used by a process string LinuxParser::Ram(int pid) { string line; std::ifstream statusf(kProcDirectory + to_string(pid) + kStatusFilename); if (!statusf.is_open()) { return string(); } while (std::getline(statusf, line)) { string key; int vmsize; std::istringstream linestream(line); linestream >> key; if (key == "VmSize:") { linestream >> vmsize; return std::to_string(vmsize / 1000); } } return string(); } // DONE: Read and return the user ID associated with a process string LinuxParser::Uid(int pid) { string line; std::ifstream statusf(kProcDirectory + to_string(pid) + kStatusFilename); if (!statusf.is_open()) { return string(); } while (std::getline(statusf, line)) { string key, uid; std::istringstream linestream(line); linestream >> key; if (key == "Uid:") { linestream >> uid; return uid; } } return string(); } // DONE: Read and return the user associated with a process string LinuxParser::User(int pid) { string line, uid; uid = LinuxParser::Uid(pid); std::ifstream passwdf(kPasswordPath); if (!passwdf.is_open()) { return string(); } // iterate lines of passwd file until user with uid is found while (std::getline(passwdf, line)) { string user, x, uid2; std::replace(line.begin(), line.end(), ':', ' '); std::istringstream iss(line); iss >> user >> x >> uid2; if (uid2 == uid) { return user; } } return string(); } // TODO: Read and return the uptime of a process long LinuxParser::UpTime(int pid) { auto stats = read_process_stats(pid); auto uptime = LinuxParser::UpTime(); if (stats.empty() || uptime == -1) { return 0; } return uptime - std::stol(stats[21]) / sysconf(_SC_CLK_TCK); }
24.560907
99
0.597924
[ "vector" ]
ad76d23b2fa3e2f2fed4e953cc60844380423f06
3,272
cpp
C++
tests/unittests/op/conv.cpp
graphcore/popart
15ce5b098638dc34a4d41ae2a7621003458df798
[ "MIT" ]
61
2020-07-06T17:11:46.000Z
2022-03-12T14:42:51.000Z
tests/unittests/op/conv.cpp
graphcore/popart
15ce5b098638dc34a4d41ae2a7621003458df798
[ "MIT" ]
1
2021-02-25T01:30:29.000Z
2021-11-09T11:13:14.000Z
tests/unittests/op/conv.cpp
graphcore/popart
15ce5b098638dc34a4d41ae2a7621003458df798
[ "MIT" ]
6
2020-07-15T12:33:13.000Z
2021-11-07T06:55:00.000Z
// Copyright (c) 2021 Graphcore Ltd. All rights reserved. #define BOOST_TEST_MODULE Test_Op_Conv #include <boost/test/unit_test.hpp> #include <popart/ir.hpp> #include <popart/op/conv.hpp> using namespace popart; BOOST_AUTO_TEST_CASE(TestRestoreParams) { Ir ir; Graph &g = ir.getMainGraph(); auto convAttr = Attributes(); auto convOpts = MultiConvOptions(ir.getSessionOptions().convolutionOptions, convAttr); Op::Settings settings(g, "test_conv"); auto autoPad = AutoPad::VALID; auto op = g.createOp<ConvOp>(Onnx::Operators::Conv_1, settings, std::vector<int64_t>(), std::vector<int64_t>(), std::vector<int64_t>(), 1, autoPad, convOpts); const TensorInfo dataInfo{DataType::FLOAT, Shape{1, 1, 2, 2}}; const std::vector<float> dataData(dataInfo.nelms()); const TensorId dataTensor = "dataTensor"; g.getTensors().addVarInit( dataTensor, dataInfo, dataData.data(), "dataTensorInit"); op->connectInTensor(0, dataTensor); const TensorInfo weightInfo{DataType::FLOAT, Shape{1, 1, 2, 2}}; const std::vector<float> weightData(weightInfo.nelms()); const TensorId weightTensor = "weightTensor"; g.getTensors().addVarInit( weightTensor, weightInfo, weightData.data(), "weightTensorInit"); op->connectInTensor(1, weightTensor); ConvParameters testParams; testParams.type = DataType::FLOAT; testParams.batchSize = 1; // These get overwritten based on the tensor inputs testParams.numInChannelsPerGroup = 1; testParams.numOutChannelsPerGroup = 1; testParams.numGroups = 1; testParams.inputShape = {2, 2}; testParams.kernelShape = {2, 2}; // These need to work testParams.inputTransformation.lowerTruncation = {9, 10}; testParams.inputTransformation.upperTruncation = {11, 12}; testParams.inputTransformation.dilation = {13, 14}; testParams.inputTransformation.lowerPadding = {15, 16}; testParams.inputTransformation.upperPadding = {17, 18}; // These must be false testParams.inputTransformation.flip = {false, false}; // This works testParams.kernelTransformation.dilation = {19, 20}; // These must be zero testParams.kernelTransformation.lowerPadding = {0, 0}; testParams.kernelTransformation.upperPadding = {0, 0}; // These must be false testParams.kernelTransformation.flip = {false, false}; // These need to work testParams.kernelTransformation.lowerTruncation = {21, 22}; testParams.kernelTransformation.upperTruncation = {23, 24}; testParams.outputTransformation.lowerTruncation = {25, 26}; testParams.outputTransformation.upperTruncation = {27, 28}; testParams.outputTransformation.stride = {29, 30}; testParams.outputTransformation.lowerPadding = {31, 32}; testParams.outputTransformation.upperPadding = {33, 34}; std::vector<ConvParameters> paramsVec; paramsVec.push_back(testParams); logging::warn("About to call op->restoreAttributesFromParams"); op->restoreAttributesFromParams(paramsVec); auto paramsOut = op->getParameters(); BOOST_TEST(testParams == paramsOut); };
34.083333
76
0.682152
[ "shape", "vector" ]
ad78b55f3067dcccece039e33f6de254fe9c6b7a
47,809
cpp
C++
src/imaging/ossimGeneralRasterTileSource.cpp
DigitalGlobe/ossim
a03729866f15bcf3bf210e14d395c683321b12bc
[ "MIT" ]
1
2018-03-04T10:45:56.000Z
2018-03-04T10:45:56.000Z
src/imaging/ossimGeneralRasterTileSource.cpp
IvanLJF/ossim
2e0143f682b9884a09ff2598ef8737f29e44fbdf
[ "MIT" ]
null
null
null
src/imaging/ossimGeneralRasterTileSource.cpp
IvanLJF/ossim
2e0143f682b9884a09ff2598ef8737f29e44fbdf
[ "MIT" ]
null
null
null
//******************************************************************* // // License: LGPL // // See LICENSE.txt file in the top level directory for more details. // // Author: David Burken // // Description: // // Contains class definition for ossimGeneralRasterTileSource. //******************************************************************* // $Id: ossimGeneralRasterTileSource.cpp 22763 2014-05-06 14:07:51Z dburken $ #include <ossim/imaging/ossimGeneralRasterTileSource.h> #include <ossim/base/ossimConstants.h> #include <ossim/base/ossimDpt.h> #include <ossim/base/ossimEndian.h> #include <ossim/base/ossimErrorContext.h> #include <ossim/base/ossimFilename.h> #include <ossim/base/ossimInterleaveTypeLut.h> #include <ossim/base/ossimIpt.h> #include <ossim/base/ossimIrect.h> #include <ossim/base/ossimKeywordlist.h> #include <ossim/base/ossimKeywordNames.h> #include <ossim/base/ossimScalarTypeLut.h> #include <ossim/base/ossimStreamFactoryRegistry.h> #include <ossim/base/ossimTrace.h> #include <ossim/imaging/ossimImageDataFactory.h> #include <ossim/imaging/ossimImageGeometryRegistry.h> #include <ossim/projection/ossimMapProjectionFactory.h> #include <ossim/projection/ossimMapProjection.h> #include <ossim/support_data/ossimFgdcXmlDoc.h> RTTI_DEF1_INST(ossimGeneralRasterTileSource, "ossimGeneralRasterTileSource", ossimImageHandler) static ossimTrace traceDebug("ossimGeneralRasterTileSource:debug"); // For interleave type enum to string conversions. static const ossimInterleaveTypeLut ILUT; //******************************************************************* // Public Constructor: //******************************************************************* ossimGeneralRasterTileSource::ossimGeneralRasterTileSource() : ossimImageHandler(), m_tile(0), m_buffer(0), m_lineBuffer(0), m_bufferInterleave(OSSIM_BIL), m_fileStrList(0), m_rasterInfo(), m_bufferRect(0, 0, 0, 0), m_swapBytesFlag(false), m_bufferSizeInPixels(0), m_outputBandList(0) {} ossimGeneralRasterTileSource::~ossimGeneralRasterTileSource() { close(); } ossimRefPtr<ossimImageData> ossimGeneralRasterTileSource::getTile( const ossimIrect& tile_rect, ossim_uint32 resLevel) { if ( m_tile.valid() == false ) { allocateTile(); // First time through... } if (m_tile.valid()) { // Image rectangle must be set prior to calling getTile. m_tile->setImageRectangle(tile_rect); if ( getTile( m_tile.get(), resLevel ) == false ) { if (m_tile->getDataObjectStatus() != OSSIM_NULL) { m_tile->makeBlank(); } } } return m_tile; } bool ossimGeneralRasterTileSource::getTile(ossimImageData* result, ossim_uint32 resLevel) { bool status = false; //--- // Not open, this tile source bypassed, or invalid res level, // return a blank tile. //--- if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) && result && (result->getNumberOfBands() == getNumberOfOutputBands()) ) { //--- // Check for overview tile. Some overviews can contain r0 so always // call even if resLevel is 0. Method returns true on success, false // on error. //--- status = getOverviewTile(resLevel, result); if (status) { if(getOutputScalarType() == OSSIM_USHORT11) { //--- // Temp fix: // The overview handler could return a tile of OSSIM_UINT16 if // the max sample value was not set to 2047. //--- result->setScalarType(OSSIM_USHORT11); } else if(getOutputScalarType() == OSSIM_USHORT12) { result->setScalarType(OSSIM_USHORT12); } else if(getOutputScalarType() == OSSIM_USHORT13) { result->setScalarType(OSSIM_USHORT13); } else if(getOutputScalarType() == OSSIM_USHORT14) { result->setScalarType(OSSIM_USHORT14); } else if(getOutputScalarType() == OSSIM_USHORT15) { result->setScalarType(OSSIM_USHORT15); } } if (!status) // Did not get an overview tile. { status = true; //--- // Subtract any sub image offset to get the zero based image space // rectangle. //--- ossimIrect tile_rect = result->getImageRectangle(); // This should be the zero base image rectangle for this res level. ossimIrect image_rect = getImageRectangle(resLevel); //--- // See if any point of the requested tile is in the image. //--- if ( tile_rect.intersects(image_rect) ) { // Make the tile rectangle zero base. result->setImageRectangle(tile_rect); // Initialize the tile if needed as we're going to stuff it. if (result->getDataObjectStatus() == OSSIM_NULL) { result->initialize(); } ossimIrect clip_rect = tile_rect.clipToRect(image_rect); if ( ! tile_rect.completely_within(m_bufferRect) ) { // A new buffer must be loaded. if ( !tile_rect.completely_within(clip_rect) ) { //--- // Start with a blank tile since the whole tile buffer will // not be // filled. //--- result->makeBlank(); } // Reallocate the buffer if needed. if ( m_bufferSizeInPixels != result->getSize() ) { allocateBuffer( result ); } ossimIpt size(static_cast<ossim_int32>(result->getWidth()), static_cast<ossim_int32>(result->getHeight())); if( !fillBuffer(clip_rect.ul(), size) ) { ossimNotify(ossimNotifyLevel_WARN) << "Error from fill buffer..." << std::endl; //--- // Error in filling buffer. //--- setErrorStatus(); status = false; } } result->loadTile(m_buffer, m_bufferRect, clip_rect, m_bufferInterleave); result->validate(); // Set the rectangle back. result->setImageRectangle(tile_rect); } else // No intersection. { result->makeBlank(); } } } return status; } bool ossimGeneralRasterTileSource::fillBuffer(const ossimIpt& origin, const ossimIpt& size) { static const char MODULE[] = "ossimGeneralRasterTileSource::fillBuffer"; // Note: InterleaveType enumerations in "constants.h" file. bool status = false; switch ( m_rasterInfo.interleaveType() ) { case OSSIM_BIP: { status = fillBIP(origin, size); break; } case OSSIM_BIL: { status = fillBIL(origin, size); break; } case OSSIM_BSQ: { status = fillBSQ(origin, size); break; } case OSSIM_BSQ_MULTI_FILE: { status = fillBsqMultiFile(origin, size); break; } default: { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " ERROR:\n" << " Unsupported interleave type: " << ILUT.getEntryString(m_rasterInfo.interleaveType()) << std::endl; } } if (status && m_swapBytesFlag) { ossimEndian oe; oe.swap(m_rasterInfo.getImageMetaData().getScalarType(), m_buffer, m_bufferSizeInPixels); } return status; } bool ossimGeneralRasterTileSource::fillBIP(const ossimIpt& origin, const ossimIpt& size ) { static const char MODULE[] = "ossimGeneralRasterTileSource::fillBIP "; m_bufferRect.set_ul(origin); m_bufferRect.set_lry(min( (origin.y + size.y -1), m_rasterInfo.imageRect().lr().y)); m_bufferRect.set_lrx(min( (origin.x + size.x -1), m_rasterInfo.imageRect().lr().x)); const ossim_int32 WIDTH = static_cast<ossim_int32>( m_bufferRect.width() ); const ossim_int32 HEIGHT = static_cast<ossim_int32>( m_bufferRect.height() ); const ossim_int32 INPUT_BANDS = m_rasterInfo.numberOfBands(); const ossim_int32 OUTPUT_BANDS = static_cast<ossim_int32>( m_outputBandList.size() ); const ossim_int32 BYTES_PER_PIXEL = m_rasterInfo.bytesPerPixel(); const ossim_int32 INPUT_BYTES_PER_SAMPLE = BYTES_PER_PIXEL * INPUT_BANDS; const ossim_int32 OUTPUT_BYTES_PER_SAMPLE = BYTES_PER_PIXEL * OUTPUT_BANDS; // Seek position. std::streamoff rasterOffset = m_rasterInfo.offsetToFirstValidSample() + origin.y * m_rasterInfo.bytesPerRawLine() + origin.x * INPUT_BYTES_PER_SAMPLE; // Input line buffer, all bands. std::streamsize inputLineBufferWidth = WIDTH * INPUT_BYTES_PER_SAMPLE; // Output buffer width: std::streamsize outputLineBufferWidth = WIDTH * OUTPUT_BYTES_PER_SAMPLE; #if 0 /* Please keep for debug. (drb) */ ossimNotify(ossimNotifyLevel_DEBUG) << "\nDEBUG:" << "\norigin: " << origin << "\nSeek position: " << rasterOffset << "\ninputLineBufferWidth: " << inputLineBufferWidth << "\noutputLineBufferWidth: " << outputLineBufferWidth << "\nINPUT_BANDS: " << INPUT_BANDS << "\nOUTPUT_BANDS: " << OUTPUT_BANDS << std::endl; #endif ossim_int32 bufferOffset = 0; // Line loop: ossim_int32 currentLine = 0; while ( currentLine < HEIGHT ) { // Seek to line. m_fileStrList[0]->seekg(rasterOffset, ios::beg); if (!(*m_fileStrList[0])) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << " ERROR:\n" << " Seek error! Returning with error..." << std::endl; return false; } // Read image data from line for all bands into line buffer. m_fileStrList[0]->read( (char*)m_lineBuffer, inputLineBufferWidth ); if ( m_fileStrList[0]->gcount() != inputLineBufferWidth ) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nERROR: Reading image line." << std::endl; return false; } // Sample loop: for ( ossim_int32 sample = 0; sample < WIDTH; ++sample ) { // Band loop: for ( ossim_int32 band = 0; band < OUTPUT_BANDS; ++band ) { ossim_int32 selectedBand = static_cast<ossim_int32>(m_outputBandList[band]); memcpy( (void*)(m_buffer + bufferOffset + sample * OUTPUT_BYTES_PER_SAMPLE + band * BYTES_PER_PIXEL), (void*)(m_lineBuffer + sample * INPUT_BYTES_PER_SAMPLE + selectedBand * BYTES_PER_PIXEL), BYTES_PER_PIXEL ); } } ++currentLine; bufferOffset += outputLineBufferWidth; rasterOffset += m_rasterInfo.bytesPerRawLine(); } return true; } // End: bool ossimGeneralRasterTileSource::fillBipBandSelect(... bool ossimGeneralRasterTileSource::fillBIL(const ossimIpt& origin, const ossimIpt& size) { static const char MODULE[] = "ossimGeneralRasterTileSource::fillBIL"; //*** // This will fill a buffer the full width of valid samples * tileHeight(). //*** m_bufferRect.set_ul(origin); m_bufferRect.set_lry(min((origin.y + size.y - 1), m_rasterInfo.imageRect().lr().y)); m_bufferRect.set_lrx(min((origin.x + size.x - 1), m_rasterInfo.imageRect().lr().x)); ossim_sint64 currentLine = origin.y; // Bytes in one line all bands. const std::streamoff LINE_OFFSET = m_rasterInfo.bytesPerRawLine() * m_rasterInfo.numberOfBands(); // Start seek position. std::streamoff offset = ( m_rasterInfo.offsetToFirstValidSample() + currentLine * LINE_OFFSET + origin.x * m_rasterInfo.bytesPerPixel() ); //--- // Loop through and process lines. //--- ossim_int32 linesProcessed = 0; std::streamsize buffer_width = m_bufferRect.width() * m_rasterInfo.bytesPerPixel(); ossim_uint8* buf = m_buffer; #if 0 /* Please leave for debug. (drb) */ ossimNotify(ossimNotifyLevel_DEBUG) << "\nDEBUG:" << "\norigin: " << origin << "\nSeek position: " << offset << "\nStarting line number: " << currentLine << "\nbuffer_width: " << buffer_width << std::endl; #endif // Line loop: while ((currentLine <= static_cast<ossim_sint64>(m_rasterInfo.imageRect().lr().y)) && linesProcessed < size.y) { // Band loop: std::vector<ossim_uint32>::const_iterator i = m_outputBandList.begin(); while ( i != m_outputBandList.end() ) { ossim_int64 band = static_cast<ossim_sint64>( (*i) ); const std::streamoff bandOffset = band * m_rasterInfo.bytesPerRawLine(); // Seek to line. m_fileStrList[0]->seekg(offset + bandOffset, ios::beg); if (!m_fileStrList[0]) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << " ERROR:\n" << " Seek error! Returning with error..." << std::endl; return false; } // Read the line of image data. m_fileStrList[0]->read( (char*)buf, buffer_width ); if ( m_fileStrList[0]->gcount() != buffer_width ) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nERROR: Reading image line." << "\ncurrentLine: " << currentLine << std::endl; return false; } buf += buffer_width; ++i; } // End of band loop. ++linesProcessed; ++currentLine; offset += LINE_OFFSET; } // End: line loop return true; } //******************************************************************* // Private Method: //******************************************************************* bool ossimGeneralRasterTileSource::fillBSQ(const ossimIpt& origin, const ossimIpt& size) { static const char MODULE[] = "ossimGeneralRasterTileSource::fillBSQ"; // This will fill a buffer the full width of valid samples * tileHeight(). m_bufferRect.set_ul(origin); m_bufferRect.set_lry(min((origin.y + size.y -1), m_rasterInfo.imageRect().lr().y)); m_bufferRect.set_lrx(min((origin.x + size.x - 1), m_rasterInfo.imageRect().lr().x)); // Start seek position. std::streamoff startSeekPosition = m_rasterInfo.offsetToFirstValidSample() + origin.y * m_rasterInfo.bytesPerRawLine() + origin.x * m_rasterInfo.bytesPerPixel(); std::streamsize buffer_width = m_bufferRect.width() * m_rasterInfo.bytesPerPixel(); ossim_uint8* buf = (ossim_uint8*)m_buffer; std::streamoff bandOffset = m_rasterInfo.bytesPerRawLine() * m_rasterInfo.rawLines(); #if 0 /* Please leave for debug. (drb) */ ossimNotify(ossimNotifyLevel_DEBUG) << "\nDEBUG:" << "\norigin: " << origin << "\nSeek position: " << startSeekPosition << "\nStarting line number: " << origin.y << "\nbuffer_width: " << buffer_width << "\nbytesPerRawLine(): " << m_rasterInfo.bytesPerRawLine() << "\nm_rasterInfo.offsetToFirstValidSample(): " << m_rasterInfo.offsetToFirstValidSample() << "\nbandOffset: " << bandOffset << std::endl; #endif ossim_int32 num_bands = m_rasterInfo.numberOfBands(); ossim_int32 height = size.y; // Band loop: for (ossim_int32 band = 0; band < num_bands; ++band) { ossim_sint64 currentLine = origin.y; ossim_sint64 linesProcessed = 0; std::streamoff offset = startSeekPosition + (band * bandOffset); // Line loop: while (currentLine <= m_rasterInfo.imageRect().lr().y && linesProcessed < height) { // Seek to line. m_fileStrList[0]->seekg(offset, ios::beg); if (!m_fileStrList[0]) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << " ERROR:\n" << " Seek error! Returning with error..." << std::endl; return false; } // Read the line of image data. m_fileStrList[0]->read( (char*)buf, buffer_width ); if ( m_fileStrList[0]->gcount() != buffer_width ) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nERROR: Reading image line." << "\ncurrentLine: " << currentLine << std::endl; return false; } // Increment everybody accordingly. buf += buffer_width; offset += m_rasterInfo.bytesPerRawLine(); ++linesProcessed; ++currentLine; } // End of line loop. } // End of band loop. return true; } //******************************************************************* // Private Method: //******************************************************************* bool ossimGeneralRasterTileSource::fillBsqMultiFile(const ossimIpt& origin, const ossimIpt& size) { static const char MODULE[] = "ossimGeneralRasterTileSource::fillBsqMultiFile"; if (traceDebug()) CLOG << " Entered..." << std::endl; // This will fill a buffer the full width of valid samples * tileHeight(). m_bufferRect.set_ul(origin); m_bufferRect.set_lry(min((origin.y + size.y -1), m_rasterInfo.imageRect().lr().y)); m_bufferRect.set_lrx(min((origin.x + size.x - 1), m_rasterInfo.imageRect().lr().x)); //--- // Start seek position. //--- std::streamoff startSeekPosition = m_rasterInfo.offsetToFirstValidSample() + origin.y * m_rasterInfo.bytesPerRawLine() + origin.x * m_rasterInfo.bytesPerPixel(); //--- // Loop through and process lines. //--- std::streamsize buffer_width = m_bufferRect.width() * m_rasterInfo.bytesPerPixel(); ossim_uint8* buf = (ossim_uint8*)m_buffer; #if 0 if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "\nDEBUG:" << "\norigin: " << origin << "\nSeek position: " << startSeekPosition << "\nStarting line number: " << origin.y << "\nbuffer_width: " << buffer_width << "\nbuffer_rect: " << m_bufferRect << "\nbytesPerRawLine(): " << m_rasterInfo.bytesPerRawLine() << "\nm_rasterInfo.offsetToFirstValidSample(): " << m_rasterInfo.offsetToFirstValidSample() << std::endl; } #endif // ossim_int32 num_bands = m_rasterInfo.numberOfBands(); std::vector<ossim_uint32>::const_iterator bandIter = m_outputBandList.begin(); while ( bandIter != m_outputBandList.end() ) { ossim_int32 currentLine = origin.y; ossim_int32 linesProcessed = 0; ossim_int64 offset = startSeekPosition; while (currentLine <= m_rasterInfo.imageRect().lr().y && linesProcessed < size.y) { //--- // Seek to line. //--- m_fileStrList[ *bandIter ]->seekg(offset, ios::beg); if ( !m_fileStrList[ *bandIter ] ) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << " ERROR:\n" << " Seek error! Returning with error..." << std::endl; return false; } //--- // Read the line of image data. //--- m_fileStrList[ *bandIter ]->read((char*)buf, buffer_width); if ( m_fileStrList[ *bandIter ]->gcount() != buffer_width) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nERROR: Reading image line." << "\ncurrentLine: " << currentLine << std::endl; return false; } // Increment everybody accordingly. buf += buffer_width; offset += m_rasterInfo.bytesPerRawLine(); ++linesProcessed; ++currentLine; } // End of line loop. ++bandIter; // Next band... } // End: while ( bandIter ! = m_outputBandList.end() ) return true; } //******************************************************************* // Public method: //******************************************************************* bool ossimGeneralRasterTileSource::saveState(ossimKeywordlist& kwl, const char* prefix) const { // Our stuff: m_rasterInfo.saveState(kwl, prefix); // Base class: bool result = ossimImageHandler::saveState(kwl, prefix); if ( result && isBandSelector() && m_outputBandList.size() ) { if ( isIdentityBandList( m_outputBandList ) == false ) { // If we're not identity output the bands. ossimString bandsString; ossim::toSimpleStringList(bandsString, m_outputBandList); kwl.add(prefix, ossimKeywordNames::BANDS_KW, bandsString, true); } } return result; } //******************************************************************* // Public method: //******************************************************************* bool ossimGeneralRasterTileSource::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool result = false; m_outputBandList.clear(); if ( ossimImageHandler::loadState(kwl, prefix) ) { // Set the band list if key is present. std::string pfx = ( prefix ? prefix : "" ); std::string key = ossimKeywordNames::BANDS_KW; ossimString value; value.string() = kwl.findKey( pfx, key ); if ( value.size() ) { ossim::toSimpleVector( m_outputBandList, value ); } result = open(); } return result; } //******************************************************************* // Public method: //******************************************************************* ossimScalarType ossimGeneralRasterTileSource::getOutputScalarType() const { return m_rasterInfo.getImageMetaData().getScalarType(); } //******************************************************************* // Public method: //******************************************************************* ossim_uint32 ossimGeneralRasterTileSource::getTileWidth() const { ossim_uint32 result = 0; if ( m_tile.valid() ) { m_tile->getWidth(); } else { ossimIpt tileSize; ossim::defaultTileSize(tileSize); result = tileSize.x; } return result; } //******************************************************************* // Public method: //******************************************************************* ossim_uint32 ossimGeneralRasterTileSource::getTileHeight() const { ossim_uint32 result = 0; if ( m_tile.valid() ) { m_tile->getHeight(); } else { ossimIpt tileSize; ossim::defaultTileSize(tileSize); result = tileSize.y; } return result; } //******************************************************************* // Public method: //******************************************************************* bool ossimGeneralRasterTileSource::isValidRLevel(ossim_uint32 reduced_res_level) const { static const char MODULE[] = "ossimGeneralRasterTileSource::isValidRLevel"; if (reduced_res_level == 0) { return true; } else if (theOverview.valid()) { return theOverview->isValidRLevel(reduced_res_level); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Invalid reduced_res_level: " << reduced_res_level << "\nHighest available: " << (getNumberOfDecimationLevels() - 1) << std::endl; return false; } } //******************************************************************* // Public method: //******************************************************************* ossim_uint32 ossimGeneralRasterTileSource::getNumberOfLines(ossim_uint32 reduced_res_level) const { if (reduced_res_level == 0) { return m_rasterInfo.validLines(); } else if (theOverview.valid()) { return theOverview->getNumberOfLines(reduced_res_level); } return 0; } //******************************************************************* // Public method: //******************************************************************* ossim_uint32 ossimGeneralRasterTileSource::getNumberOfSamples( ossim_uint32 reduced_res_level) const { if (reduced_res_level == 0) { return m_rasterInfo.validSamples(); } else if (theOverview.valid()) { return theOverview->getNumberOfSamples(reduced_res_level); } return 0; } double ossimGeneralRasterTileSource::getNullPixelValue(ossim_uint32 band) const { return m_rasterInfo.getImageMetaData().getNullPix(band); } double ossimGeneralRasterTileSource::getMinPixelValue(ossim_uint32 band)const { return m_rasterInfo.getImageMetaData().getMinPix(band); } double ossimGeneralRasterTileSource::getMaxPixelValue(ossim_uint32 band)const { return m_rasterInfo.getImageMetaData().getMaxPix(band); } bool ossimGeneralRasterTileSource::open() { static const char MODULE[] = "ossimGeneralRasterTileSource::open"; if (traceDebug()) CLOG << " Entered..." << std::endl; bool result = false; if(isOpen()) { close(); } //--- // Find the header file: // // We need lines, samples, bands, scalar and interleave at a minimum: // // A general raster image requires a keyword list to get essential image // information or meta data as its sometimes called. The meta data file // can have four types of extensions: ".omd", ".hdr", ".kwl" and xml. // Look for them in that order. // Note that the ".omd" extension is for "Ossim Meta Data" and was made // up to avoid conflicting with other software packages ".hdr" files. //--- if ( m_rasterInfo.open( theImageFile ) ) { theMetaData = m_rasterInfo.getImageMetaData(); result = initializeHandler(); if ( result ) { completeOpen(); if ( isBandSelector() && m_outputBandList.size() && ( isIdentityBandList( m_outputBandList ) == false ) ) { // This does range checking and will pass to overview if open. setOutputBandList( m_outputBandList ); } } } if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " Exit status: " << (result?"true":"false") << std::endl; } return result; } bool ossimGeneralRasterTileSource::open( const ossimGeneralRasterInfo& info ) { if( isOpen() ) { close(); } m_rasterInfo = info; bool result = initializeHandler(); if ( result ) { completeOpen(); if ( isBandSelector() && m_outputBandList.size() && ( isIdentityBandList( m_outputBandList ) == false ) ) { // This does range checking and will pass to overview if open. setOutputBandList( m_outputBandList ); } } return result; } bool ossimGeneralRasterTileSource::initializeHandler() { //--- // This private method assumes that "m_rasterInfo" object has been // initialized. Note that "close() should have already been called if // there was an open file prior to this. //--- std::vector<ossimFilename> aList = m_rasterInfo.getImageFileList(); for (ossim_uint32 i=0; i<aList.size(); ++i) { ossimFilename f = aList[i]; // open it... std::shared_ptr<ossim::istream> is = ossim::StreamFactoryRegistry::instance()-> createIstream(f); // check the stream... if( is ) { // Check the file stream. if ( is->fail() ) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; ossimNotify(ossimNotifyLevel_WARN) << "ossimGeneralRasterTileSource::open" << " ERROR:\n" << "Cannot open: " << f.c_str() << std::endl; is = 0; return false; } } // Check the file size (removed). m_fileStrList.push_back(is); // Add it to the list... } if ((aList.size()==1) && theImageFile.empty()) { theImageFile = aList[0]; } // Set the buffer interleave type. m_bufferInterleave = m_rasterInfo.interleaveType(); if (m_bufferInterleave == OSSIM_BSQ_MULTI_FILE) { m_bufferInterleave = OSSIM_BSQ; } if ( m_outputBandList.empty() ) { // Set starting output band list to identity. ossimImageSource::getOutputBandList( m_outputBandList ); } //--- // Get the byte order of the image data and host machine. If different, // set the swap bytes flag... //--- if (m_rasterInfo.getImageDataByteOrder() != ossim::byteOrder()) { m_swapBytesFlag = true; } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimGeneralRasterTileSource::initializeHandler()" << " DEBUG:" << "\nScalar type: " << ossimScalarTypeLut::instance()-> getEntryString(m_rasterInfo.getImageMetaData().getScalarType()) << "\nByte swapping is " << (m_swapBytesFlag?"enabled.":"not enabled.") // << "\nm_bufferSizeInPixels: " << m_bufferSizeInPixels // << "\nbuffer size: " << buffer_size << "\nRasterInfo:\n"; m_rasterInfo.print(ossimNotify(ossimNotifyLevel_DEBUG)); } return true; } bool ossimGeneralRasterTileSource::isOpen() const { bool result = false; if (m_fileStrList.size() > 0) { if( m_fileStrList[0] ) { result = !(m_fileStrList[0]->fail()); } } return result; } void ossimGeneralRasterTileSource::close() { ossimImageHandler::close(); // base class m_tile = 0; // Not a leak, ref ptr. if ( m_buffer ) { delete [] m_buffer; m_buffer = 0; m_bufferSizeInPixels = 0; // Must zero out for check in getTile method. } if ( m_lineBuffer ) { delete [] m_lineBuffer; m_lineBuffer = 0; } std::vector< shared_ptr<ossim::istream> >::iterator is = m_fileStrList.begin(); while (is != m_fileStrList.end()) { (*is) = 0; ++is; } m_fileStrList.clear(); } ossim_uint32 ossimGeneralRasterTileSource::getImageTileWidth() const { return 0; } ossim_uint32 ossimGeneralRasterTileSource::getImageTileHeight() const { return 0; } ossimString ossimGeneralRasterTileSource::getShortName()const { return ossimString("ossim_raster"); } ossimString ossimGeneralRasterTileSource::getLongName()const { return ossimString("general raster reader"); } ossim_uint32 ossimGeneralRasterTileSource::getNumberOfInputBands() const { return m_rasterInfo.getImageMetaData().getNumberOfBands(); } ossim_uint32 ossimGeneralRasterTileSource::getNumberOfOutputBands() const { ossim_uint32 result = 0; if ( isBandSelector() && m_outputBandList.size() ) { result = (ossim_uint32)m_outputBandList.size(); } else { result = m_rasterInfo.getImageMetaData().getNumberOfBands(); } return result; } ossimKeywordlist ossimGeneralRasterTileSource::getHdrInfo(ossimFilename hdrFile) { ossimKeywordlist kwl; char delimeter = ' '; kwl.change_delimiter(delimeter); kwl.addFile(hdrFile); kwl.downcaseKeywords(); ossimKeywordlist geoKwl; ossim_uint32 lines = 0; ossim_uint32 samples = 0; ossim_float32 noData = -9999; ossimString scalarType = "ossim_uint8"; ossim_int32 numBands = 1; // ossim_int32 skipBytes = 0; ossim_int32 numBits = -1; ossimString chPixelType = "N"; // not defined ossimString interleaveType = "BIL"; ossimString byteOrder; bool noDataFound = false; const char* lookup = kwl.find("ncols"); if (lookup) { samples = ossimString(lookup).toUInt32(); geoKwl.add(ossimKeywordNames::NUMBER_SAMPLES_KW, samples); } lookup = kwl.find("nrows"); if (lookup) { lines = ossimString(lookup).toUInt32(); geoKwl.add(ossimKeywordNames::NUMBER_LINES_KW, lines); } // lookup = kwl.find("skipbytes"); // if (lookup) // { // skipBytes = ossimString(lookup).toInt(); // } lookup = kwl.find("nbands"); if (lookup) { numBands = ossimString(lookup).toInt(); } lookup = kwl.find("nodata"); if (lookup) { noData = ossimString(lookup).toFloat32(); noDataFound = true; } lookup = kwl.find("nodata_value"); if (lookup) { noData = ossimString(lookup).toFloat32(); noDataFound = true; } lookup = kwl.find("nbits"); if (lookup) { numBits = ossimString(lookup).toInt(); } lookup = kwl.find("pixeltype"); if (lookup) { chPixelType = ossimString(lookup); } lookup = kwl.find("layout"); if (lookup) { interleaveType = ossimString(lookup); } lookup = kwl.find("byteorder"); if (lookup) { byteOrder = ossimString(lookup); } if (numBits == -1) { FILE* fp; ossim_int64 size = 0; fp = fopen(theImageFile.c_str(), "r"); if (fp != 0) { fseek(fp, 0, SEEK_END); size = ftell(fp); } fclose(fp); if (lines > 0 && samples > 0) { ossim_int32 numBytes = size/samples/lines/numBands; if( numBytes > 0 && numBytes != 3 ) { numBits = numBytes*8; if( numBytes == 4 ) { chPixelType = "F"; } } } } if( numBits == 16 ) { if (chPixelType == "S") { scalarType = "ossim_sint16"; } else { scalarType = "ossim_uint16"; // default } } else if( numBits == 32 ) { if( chPixelType == "S") { scalarType = "ossim_sint32"; } else if( chPixelType == "F") { scalarType = "ossim_float32"; } else { scalarType = "ossim_uint32"; // default } } else if( numBits == 8 ) { scalarType = "ossim_uint8"; numBits = 8; } else if( numBits < 8 && numBits >= 1 ) { scalarType = "ossim_uint8"; } else if(numBits == -1) { if( chPixelType == "F") { scalarType = "ossim_float32"; numBits = 32; } else { scalarType = "ossim_uint8"; numBits = 8; } } if (noDataFound) { for (ossim_int32 i = 0; i < numBands; i++) { ossimString prefix = "band" + ossimString::toString(i+1) + ": "; geoKwl.add(prefix, ossimKeywordNames::NULL_VALUE_KW, noData); } } geoKwl.add(ossimKeywordNames::NUMBER_BANDS_KW, numBands); geoKwl.add(ossimKeywordNames::SCALAR_TYPE_KW, scalarType); geoKwl.add(ossimKeywordNames::INTERLEAVE_TYPE_KW, interleaveType); return geoKwl; } ossimKeywordlist ossimGeneralRasterTileSource::getXmlInfo(ossimFilename xmlFile) { ossimKeywordlist kwl; ossimFgdcXmlDoc file; if (file.open(xmlFile)) { ossimString scalarType = "ossim_uint8"; ossim_int32 numBits = -1; ossimString interleaveType = "BIL"; ossimIpt size; ossim_int32 samples = 0; ossim_int32 lines = 0; if (file.getImageSize(size)) { samples = size.x; lines = size.y; } if (samples > 0) { kwl.add(ossimKeywordNames::NUMBER_SAMPLES_KW, samples); } if (lines > 0) { kwl.add(ossimKeywordNames::NUMBER_LINES_KW, lines); } ossim_int32 bands = file.getNumberOfBands(); if (bands > 0) { kwl.add(ossimKeywordNames::NUMBER_BANDS_KW, bands); } else { if (samples > 0 && lines > 0)//if there is no bands info but samples and lines info, default number of bands to 1 { bands = 1; kwl.add(ossimKeywordNames::NUMBER_BANDS_KW, bands); } } ossimString eainfo; file.getPath("/metadata/eainfo/detailed/enttyp/enttypd", eainfo); if (numBits == -1) { if ( (lines > 0) && (samples > 0) && (bands > 0) ) { ossim_int64 size = theImageFile.fileSize(); ossim_int32 numBytes = size/samples/lines/bands; if( numBytes > 0 && numBytes != 3 ) { numBits = numBytes*8; } } } if( numBits == 16 ) { scalarType = "ossim_uint16"; // default } else if( numBits == 32 ) { if(eainfo.contains("float")) { scalarType = "ossim_float32"; } else { scalarType = "ossim_uint32"; // default } } else if( numBits == 8 ) { scalarType = "ossim_uint8"; numBits = 8; } else if( numBits < 8 && numBits >= 1 ) { scalarType = "ossim_uint8"; } kwl.add(ossimKeywordNames::SCALAR_TYPE_KW, scalarType); kwl.add(ossimKeywordNames::INTERLEAVE_TYPE_KW, interleaveType); } return kwl; } ossimRefPtr<ossimImageGeometry> ossimGeneralRasterTileSource::getImageGeometry() { if ( !theGeometry.valid() ) { // Check for external geom: theGeometry = getExternalImageGeometry(); if ( !theGeometry.valid() ) { theGeometry = new ossimImageGeometry(); ossimString ext = theImageFile.ext(); ossimFilename hdrFile = theImageFile; ossimFilename xmlFile = theImageFile; hdrFile = hdrFile.setExtension("hdr"); xmlFile = xmlFile.setExtension("xml"); if (hdrFile.exists()) { ossimKeywordlist geoKwl; ossimKeywordlist kwl(hdrFile, ' '); kwl.downcaseKeywords(); ossim_uint32 lines = 0; ossim_uint32 samples = 0; ossim_float32 ll_lon = 0.0; ossim_float32 ll_lat = 0.0; ossim_float32 xCellSize = 1.0; ossim_float32 yCellSize = 1.0; const char* lookup = kwl.find("ncols"); if (lookup) { samples = ossimString(lookup).toUInt32(); geoKwl.add(ossimKeywordNames::NUMBER_SAMPLES_KW, samples); } lookup = kwl.find("nrows"); if (lookup) { lines = ossimString(lookup).toUInt32(); geoKwl.add(ossimKeywordNames::NUMBER_LINES_KW, lines); } lookup = kwl.find("cellsize"); if (lookup) { xCellSize = ossimString(lookup).toFloat32(); yCellSize = xCellSize; geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT, yCellSize); geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON, xCellSize); } lookup = kwl.find("xdim"); if (lookup) { xCellSize = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON, xCellSize); } lookup = kwl.find("ydim"); if (lookup) { yCellSize = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT, yCellSize); } lookup = kwl.find("xllcenter"); if (lookup) { ossim_float32 centerX = ossimString(lookup).toFloat32(); ll_lon = centerX + xCellSize * 0.5; geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon); } lookup = kwl.find("yllcenter"); if (lookup) { ossim_float32 centerY = ossimString(lookup).toFloat32(); ll_lat = (centerY + (lines - 1) * yCellSize) + yCellSize * 0.5; geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat); } lookup = kwl.find("xllcorner"); if (lookup) { ll_lon = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon); } lookup = kwl.find("yllcorner"); if (lookup) { ossim_uint32 centerY = ossimString(lookup).toFloat32(); ll_lat = centerY + lines * yCellSize; geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat); } lookup = kwl.find("ulxmap"); if (lookup) { ll_lon = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon); } lookup = kwl.find("ulymap"); if (lookup) { ossim_uint32 centerY = ossimString(lookup).toFloat32(); ll_lat = centerY + lines * yCellSize; geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat); } kwl.add(ossimKeywordNames::ORIGIN_LATITUDE_KW, ll_lat); geoKwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection"); geoKwl.add(ossimKeywordNames::DATUM_KW, ossimDatumFactory::instance()->wgs84()-> code()); ossimRefPtr<ossimProjection> proj = ossimMapProjectionFactory::instance()-> createProjection(geoKwl); if ( proj.valid() ) { theGeometry->setProjection(proj.get()); } } else if (xmlFile.exists()) { ossimFgdcXmlDoc file; if ( file.open(xmlFile) ) { ossimRefPtr<ossimProjection> proj = file.getProjection(); if ( !proj.valid() ) { proj = file.getGridCoordSysProjection(); } if ( proj.valid() ) { theGeometry->setProjection(proj.get()); } } } // xml file exist... } // Matches second if ( !theGeometry.valid() ) //--- // WARNING: // Must have theGeometry at this point or the next call to // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop // as it does a recursive call back to ossimImageHandler::getImageGeometry(). //--- // Check for set projection. if ( !theGeometry->getProjection() ) { // Try factories for projection. ossimImageGeometryRegistry::instance()->extendGeometry(this); } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } // Matches first if ( !theGeometry.valid() ) return theGeometry; } bool ossimGeneralRasterTileSource::isBandSelector() const { bool result = false; if ( ( m_rasterInfo.interleaveType() == OSSIM_BSQ_MULTI_FILE ) || ( m_rasterInfo.interleaveType() == OSSIM_BIP ) || ( m_rasterInfo.interleaveType() == OSSIM_BIL ) ) { result = true; } if ( result && theOverview.valid() ) { result = theOverview->isBandSelector(); } return result; } bool ossimGeneralRasterTileSource::setOutputBandList(const std::vector<ossim_uint32>& band_list) { bool result = false; if ( isBandSelector() ) { // Making a copy as passed in list could be our m_outputBandList. std::vector<ossim_uint32> inputList = band_list; result = ossimImageHandler::setOutputBandList( inputList, m_outputBandList ); if ( result && m_tile.valid() ) { if ( m_tile->getNumberOfBands() != m_outputBandList.size() ) { m_tile = 0; // Force a reinitialize on next getTile. } } } return result; } void ossimGeneralRasterTileSource::getOutputBandList(std::vector<ossim_uint32>& bandList) const { bandList = m_outputBandList; } void ossimGeneralRasterTileSource::allocateTile() { m_tile = 0; ossim_uint32 bands = 0; if ( m_outputBandList.empty() ) { bands = m_rasterInfo.numberOfBands(); } else { bands = (ossim_uint32)m_outputBandList.size(); } if ( bands ) { m_tile = ossimImageDataFactory::instance()->create( this, m_rasterInfo.getImageMetaData().getScalarType(), bands ); if ( m_tile.valid() ) { // These values can be overridden by loadState... for(ossim_uint32 band = 0; band < bands; ++ band) { m_tile->setNullPix(m_rasterInfo.getImageMetaData().getNullPix(band), band); m_tile->setMinPix(m_rasterInfo.getImageMetaData().getMinPix(band), band); m_tile->setMaxPix(m_rasterInfo.getImageMetaData().getMaxPix(band), band); } m_tile->initialize(); // This does a makeBlank(). } } } void ossimGeneralRasterTileSource::allocateBuffer( const ossimImageData* tile ) { if( m_buffer ) { delete [] m_buffer; m_buffer = 0; m_bufferSizeInPixels = 0; // Must zero out for check in getTile method. } if ( m_lineBuffer ) { delete [] m_lineBuffer; m_lineBuffer = 0; } if ( tile ) { // Store the size of the buffer in pixels for swapping bytes. m_bufferSizeInPixels = tile->getSize(); if ( m_bufferSizeInPixels ) { // Initialize buffer. This is bytes, not pixels. m_buffer = new ossim_uint8[ tile->getSizeInBytes() ]; // Zero out the buffer rect. m_bufferRect = ossimIrect(0, 0, 0, 0); } if ( m_rasterInfo.interleaveType() == OSSIM_BIP ) { // Big enough to hold a whole line all bands. ossim_uint32 widthInBytes = tile->getWidth() * m_rasterInfo.getImageMetaData().getNumberOfBands() * m_rasterInfo.getImageMetaData().getBytesPerPixel(); m_lineBuffer = new ossim_uint8[ widthInBytes ]; } } }
29.584777
122
0.554226
[ "geometry", "object", "vector" ]
ad872cbc96afb7a99ae6c20efc8a0149363fd3e6
631
hh
C++
Exos/Serie04/poisson/grid.hh
vkeller/math-454
0bf3a81214f094dbddec868d3d133986b31f4b01
[ "BSD-2-Clause" ]
1
2021-05-19T13:31:49.000Z
2021-05-19T13:31:49.000Z
Exos/Serie05/poisson/grid.hh
vkeller/math-454
0bf3a81214f094dbddec868d3d133986b31f4b01
[ "BSD-2-Clause" ]
null
null
null
Exos/Serie05/poisson/grid.hh
vkeller/math-454
0bf3a81214f094dbddec868d3d133986b31f4b01
[ "BSD-2-Clause" ]
null
null
null
#ifndef GRID_HH #define GRID_HH /* -------------------------------------------------------------------------- */ #include <vector> /* -------------------------------------------------------------------------- */ class Grid { public: Grid(int m, int n); /// access the value [i][j] of the grid inline float & operator()(int i, int j) { return m_storage[i * m_n + j]; } inline const float & operator()(int i, int j) const { return m_storage[i * m_n + j]; } /// set the grid to 0 void clear(); int m() const; int n() const; private: int m_m, m_n; std::vector<float> m_storage; }; #endif /* GRID_HH */
21.033333
80
0.453249
[ "vector" ]
ad8c050f775927e0cbc98be0350ca3244a1c1449
25,613
cpp
C++
projects/gui/plugins/opencv/drwnOpenCVNodes.cpp
exoad/drwn
3cc9faaa99602cb7ab69af795ec6e4194ff1919f
[ "BSD-3-Clause" ]
40
2015-01-26T21:58:25.000Z
2021-11-03T13:52:40.000Z
projects/gui/plugins/opencv/drwnOpenCVNodes.cpp
exoad/drwn
3cc9faaa99602cb7ab69af795ec6e4194ff1919f
[ "BSD-3-Clause" ]
7
2015-04-08T23:44:17.000Z
2016-05-09T11:29:38.000Z
projects/gui/plugins/opencv/drwnOpenCVNodes.cpp
exoad/drwn
3cc9faaa99602cb7ab69af795ec6e4194ff1919f
[ "BSD-3-Clause" ]
32
2015-01-12T01:47:58.000Z
2022-01-12T10:08:59.000Z
/***************************************************************************** ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT ** Distributed under the terms of the BSD license (see the LICENSE file) ** Copyright (c) 2007-2017, Stephen Gould ** All rights reserved. ** ****************************************************************************** ** FILENAME: drwnOpenCVNodes.cpp ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au> ** *****************************************************************************/ #include <cstdlib> #include "Eigen/Core" #include "cxcore.h" #include "cv.h" #include "highgui.h" #include "drwnBase.h" #include "drwnEngine.h" #include "drwnOpenCVUtils.h" #include "drwnOpenCVNodes.h" using namespace std; using namespace Eigen; // drwnOpenCVImageSourceNode ------------------------------------------------------- drwnOpenCVImageSourceNode::drwnOpenCVImageSourceNode(const char *name, drwnGraph *owner) : drwnNode(name, owner), _extension(".png") { _nVersion = 100; _desc = "Imports images as matrices"; // define ports _outputPorts.push_back(new drwnOutputPort(this, "imageOut", "N-by-3 matrix of image data")); _outputPorts.push_back(new drwnOutputPort(this, "sizeOut", "size of image")); // declare propertys declareProperty("directory", new drwnDirectoryProperty(&_directory)); declareProperty("extension", new drwnStringProperty(&_extension)); } drwnOpenCVImageSourceNode::drwnOpenCVImageSourceNode(const drwnOpenCVImageSourceNode& node) : drwnNode(node), _directory(node._directory), _extension(node._extension) { // declare propertys declareProperty("directory", new drwnDirectoryProperty(&_directory)); declareProperty("extension", new drwnStringProperty(&_extension)); } drwnOpenCVImageSourceNode::~drwnOpenCVImageSourceNode() { // do nothing } // processing void drwnOpenCVImageSourceNode::evaluateForwards() { // clear output tables and then update forwards clearOutput(); updateForwards(); } void drwnOpenCVImageSourceNode::updateForwards() { drwnDataTable *dataOut = _outputPorts[0]->getTable(); drwnDataTable *sizeOut = _outputPorts[1]->getTable(); DRWN_ASSERT((dataOut != NULL) && (sizeOut != NULL)); // list all matching files in the directory vector<string> keys = drwnDirectoryListing(_directory.c_str(), _extension.c_str(), false, false); if (keys.empty()) { DRWN_LOG_WARNING("no files found in \"" << _directory << "\" for node \"" << _name << "\""); return; } // import data DRWN_START_PROGRESS(getName().c_str(), keys.size()); for (vector<string>::const_iterator it = keys.begin(); it != keys.end(); it++) { DRWN_INC_PROGRESS; // don't overwrite existing output records if (dataOut->hasKey(*it)) continue; // load data into record string filename = _directory + DRWN_DIRSEP + *it + _extension; IplImage *img = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_COLOR); if (img == NULL) { DRWN_LOG_ERROR("failed to load image \"" << filename << "\""); continue; } drwnDataRecord *dataRecOut = dataOut->lockRecord(*it); drwnDataRecord *sizeRecOut = sizeOut->lockRecord(*it); dataRecOut->structure().resize(2); dataRecOut->structure() << img->height, img->width; dataRecOut->data() = MatrixXd::Zero(img->width * img->height, 3); sizeRecOut->data() = MatrixXd::Zero(1, 2); sizeRecOut->data()[0] = (double)img->width; sizeRecOut->data()[1] = (double)img->height; int indx = 0; const unsigned char *p = (const unsigned char *)img->imageData; for (int y = 0; y < img->height; y++) { for (int x = 0; x < img->width; x++, indx++) { dataRecOut->data()(indx, 0) = (double)p[3 * x + 2]; dataRecOut->data()(indx, 1) = (double)p[3 * x + 1]; dataRecOut->data()(indx, 2) = (double)p[3 * x + 0]; } p += img->widthStep; } // release memory and records cvReleaseImage(&img); dataOut->unlockRecord(*it); sizeOut->unlockRecord(*it); } DRWN_END_PROGRESS; } // drwnOpenCVImageSinkNode --------------------------------------------------------- drwnOpenCVImageSinkNode::drwnOpenCVImageSinkNode(const char *name, drwnGraph *owner) : drwnNode(name, owner), _extension(".png") { _nVersion = 100; _desc = "Exports matrices as images"; // define ports _inputPorts.push_back(new drwnInputPort(this, "imageIn", "N-by-3 or N-by-1 matrix of image data")); // declare propertys declareProperty("directory", new drwnDirectoryProperty(&_directory)); declareProperty("extension", new drwnStringProperty(&_extension)); } drwnOpenCVImageSinkNode::drwnOpenCVImageSinkNode(const drwnOpenCVImageSinkNode& node) : drwnNode(node), _directory(node._directory), _extension(node._extension) { // declare propertys declareProperty("directory", new drwnDirectoryProperty(&_directory)); declareProperty("extension", new drwnStringProperty(&_extension)); } drwnOpenCVImageSinkNode::~drwnOpenCVImageSinkNode() { // do nothing } // processing void drwnOpenCVImageSinkNode::evaluateForwards() { drwnDataTable *dataIn = _inputPorts[0]->getTable(); if (dataIn == NULL) { DRWN_LOG_ERROR("input port not connected for node \"" << _name << "\""); return; } // export data vector<string> keys = dataIn->getKeys(); DRWN_START_PROGRESS(getName().c_str(), keys.size()); for (vector<string>::const_iterator it = keys.begin(); it != keys.end(); it++) { DRWN_INC_PROGRESS; string filename = _directory + DRWN_DIRSEP + *it + _extension; // export image drwnDataRecord *dataRecIn = dataIn->lockRecord(*it); exportImage(filename, dataRecIn); // release records dataIn->unlockRecord(*it); } DRWN_END_PROGRESS; } void drwnOpenCVImageSinkNode::updateForwards() { drwnDataTable *dataIn = _inputPorts[0]->getTable(); if (dataIn == NULL) { DRWN_LOG_ERROR("input port not connected for node \"" << _name << "\""); return; } // export data vector<string> keys = dataIn->getKeys(); DRWN_START_PROGRESS(getName().c_str(), keys.size()); for (vector<string>::const_iterator it = keys.begin(); it != keys.end(); it++) { DRWN_INC_PROGRESS; string filename = _directory + DRWN_DIRSEP + *it + _extension; // don't overwrite existing output records if (drwnFileExists(filename.c_str())) continue; // export image drwnDataRecord *dataRecIn = dataIn->lockRecord(*it); exportImage(filename, dataRecIn); // release records dataIn->unlockRecord(*it); } DRWN_END_PROGRESS; } void drwnOpenCVImageSinkNode::exportImage(const string &filename, const drwnDataRecord *dataRecIn) const { // convert record to image DRWN_ASSERT(dataRecIn->structure().size() == 2); int height = dataRecIn->structure()[0]; int width = dataRecIn->structure()[1]; DRWN_ASSERT((dataRecIn->numFeatures() == 1) || (dataRecIn->numFeatures() == 3)); DRWN_ASSERT(dataRecIn->numObservations() == width * height); bool bColour = (dataRecIn->numFeatures() == 3); IplImage *img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, bColour ? 3 : 1); int indx = 0; unsigned char *p = (unsigned char *)img->imageData; if (bColour) { for (int y = 0; y < img->height; y++) { for (int x = 0; x < img->width; x++, indx++) { p[3 * x + 2] = (unsigned char)dataRecIn->data()(indx, 0); p[3 * x + 1] = (unsigned char)dataRecIn->data()(indx, 1); p[3 * x + 0] = (unsigned char)dataRecIn->data()(indx, 2); } p += img->widthStep; } } else { for (int y = 0; y < img->height; y++) { for (int x = 0; x < img->width; x++, indx++) { p[x] = (unsigned char)dataRecIn->data()[indx]; } p += img->widthStep; } } // save image cvSaveImage(filename.c_str(), img); cvReleaseImage(&img); } // drwnOpenCVResizeNode ------------------------------------------------------ vector<string> drwnOpenCVResizeNode::_interpolationMethods; drwnOpenCVResizeNode::drwnOpenCVResizeNode(const char *name, drwnGraph *owner) : drwnMultiIONode(name, owner), _defaultWidth(320), _defaultHeight(240), _interpolation(1) { _nVersion = 100; _desc = "Resizes a multi-channel image"; // define interpolation methods if not already done if (_interpolationMethods.empty()) { _interpolationMethods.push_back(string("nearest-neighbour")); _interpolationMethods.push_back(string("bilinear")); _interpolationMethods.push_back(string("area")); _interpolationMethods.push_back(string("bicubic")); } // declare propertys declareProperty("width", new drwnIntegerProperty(&_defaultWidth)); declareProperty("height", new drwnIntegerProperty(&_defaultHeight)); declareProperty("interpolation", new drwnSelectionProperty(&_interpolation, &_interpolationMethods)); // declare ports _inputPorts.push_back(new drwnInputPort(this, "imageIn", "N-by-D image data matrix")); _inputPorts.push_back(new drwnInputPort(this, "newSizeIn", "1-by-2 output image size")); _outputPorts.push_back(new drwnOutputPort(this, "imageOut", "M-by-D image data matrix")); } drwnOpenCVResizeNode::drwnOpenCVResizeNode(const drwnOpenCVResizeNode& node) : drwnMultiIONode(node), _defaultWidth(node._defaultWidth), _defaultHeight(node._defaultHeight), _interpolation(node._interpolation) { // declare propertys declareProperty("width", new drwnIntegerProperty(&_defaultWidth)); declareProperty("height", new drwnIntegerProperty(&_defaultHeight)); declareProperty("interpolation", new drwnSelectionProperty(&_interpolation, &_interpolationMethods)); } drwnOpenCVResizeNode::~drwnOpenCVResizeNode() { // do nothing } // processing bool drwnOpenCVResizeNode::forwardFunction(const string& key, const vector<const drwnDataRecord *>& src, const vector<drwnDataRecord *>& dst) { DRWN_ASSERT((src.size() == 2) && (dst.size() == 1)); // check for input if ((src[0] == NULL) || !src[0]->hasData()) return false; DRWN_ASSERT(src[0]->structure().size() == 2); DRWN_ASSERT(src[0]->numObservations() == src[0]->structure()[0] * src[0]->structure()[1]); // create opencv matrices CvMat *dataIn = cvCreateMat(src[0]->structure()[0], src[0]->structure()[1], CV_32FC1); CvMat *dataOut = NULL; if ((src[1] == NULL) || !src[1]->hasData()) { DRWN_LOG_DEBUG("using default size " << _defaultHeight << "-by-" << _defaultWidth << " for record " << key); dataOut = cvCreateMat(_defaultHeight, _defaultWidth, CV_32FC1); } else { DRWN_ASSERT((src[1]->numObservations() == 1) && (src[1]->numFeatures() == 2)); DRWN_LOG_DEBUG("using input size " << src[1]->data()[1] << "-by-" << src[1]->data()[0] << " for record " << key); dataOut = cvCreateMat((int)src[1]->data()[1], (int)src[1]->data()[0], CV_32FC1); } dst[0]->structure().resize(2); dst[0]->structure() << dataOut->rows, dataOut->cols; dst[0]->data() = MatrixXd::Zero(dataOut->rows * dataOut->cols, src[0]->numFeatures()); // resize each channel int resizeMethod = CV_INTER_LINEAR; switch (_interpolation) { case 0: resizeMethod = CV_INTER_NN; break; case 1: resizeMethod = CV_INTER_LINEAR; break; case 2: resizeMethod = CV_INTER_AREA; break; case 3: resizeMethod = CV_INTER_CUBIC; break; default: DRWN_LOG_ERROR("unrecognized interpolation method " << _interpolation); } DRWN_LOG_DEBUG("processing " << src[0]->numFeatures() << "-channel image of size " << dataIn->cols << "-by-" << dataIn->rows); for (int i = 0; i < src[0]->numFeatures(); i++) { Eigen::Map<MatrixXf>((float *)dataIn->data.ptr, dataIn->rows * dataIn->cols, 1) = src[0]->data().col(i).cast<float>(); cvResize(dataIn, dataOut, resizeMethod); dst[0]->data().col(i) = Eigen::Map<MatrixXf>((float *)dataOut->data.ptr, dataOut->rows * dataOut->cols, 1).cast<double>(); } // free opencv data structures cvReleaseMat(&dataIn); cvReleaseMat(&dataOut); return true; } bool drwnOpenCVResizeNode::backwardGradient(const string& key, const vector<drwnDataRecord *>& src, const vector<const drwnDataRecord *>& dst) { DRWN_NOT_IMPLEMENTED_YET; return false; } // drwnOpenCVFilterBankNode -------------------------------------------------------- drwnOpenCVFilterBankNode::drwnOpenCVFilterBankNode(const char *name, drwnGraph *owner) : drwnSimpleNode(name, owner), _kappa(1.0) { _nVersion = 100; _desc = "17-dimensional (texton) filter bank"; // define ports _inputPorts[0]->setDescription("N-by-3 or N-by-1 matrix of image data"); _outputPorts[0]->setDescription("N-by-17 filter response matrix"); // declare propertys declareProperty("kappa", new drwnDoubleProperty(&_kappa)); } drwnOpenCVFilterBankNode::drwnOpenCVFilterBankNode(const drwnOpenCVFilterBankNode& node) : drwnSimpleNode(node), _kappa(node._kappa) { // declare propertys declareProperty("kappa", new drwnDoubleProperty(&_kappa)); } drwnOpenCVFilterBankNode::~drwnOpenCVFilterBankNode() { // do nothing } // processing bool drwnOpenCVFilterBankNode::forwardFunction(const string& key, const drwnDataRecord *src, drwnDataRecord *dst) { DRWN_ASSERT(dst != NULL); const int NUM_FILTERS = 17; // check input if ((src == NULL) || !src->hasData()) return false; IplImage *img = record2Image(src); if (img == NULL) { return false; } // create output dst->structure() = src->structure(); dst->data() = MatrixXd::Zero(img->height * img->width, NUM_FILTERS); // colour convert image IplImage *imgCIELab = cvCreateImage(cvGetSize(img), IPL_DEPTH_32F, 3); if (img->nChannels == 1) { IplImage *tmp = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3); cvCvtColor(img, tmp, CV_GRAY2BGR); cvConvertScale(tmp, imgCIELab, 1.0 / 255.0, 0.0); cvReleaseImage(&tmp); } else { DRWN_ASSERT(img->nChannels == 3); cvConvertScale(img, imgCIELab, 1.0 / 255.0, 0.0); } cvCvtColor(imgCIELab, imgCIELab, CV_BGR2Lab); IplImage *greyImg = cvCreateImage(cvGetSize(img), IPL_DEPTH_32F, 1); cvSetImageCOI(imgCIELab, 1); cvCopyImage(imgCIELab, greyImg); cvSetImageCOI(imgCIELab, 0); // temporary response matrix CvMat *response = cvCreateMat(img->height, img->width, CV_32FC1); int k = 0; // gaussian filter on all color channels DRWN_LOG_DEBUG("Generating gaussian filter responses..."); IplImage *imgChannel = cvCreateImage(cvGetSize(img), IPL_DEPTH_32F, 1); for (double sigma = 1.0; sigma <= 4.0; sigma *= 2.0) { for (int c = 1; c <= 3; c++) { cvSetImageCOI(imgCIELab, c); cvCopyImage(imgCIELab, imgChannel); cvSmooth(imgChannel, response, CV_GAUSSIAN, 2 * (int)(_kappa * sigma) + 1); dst->data().col(k) = Eigen::Map<MatrixXf>((float *)response->data.ptr, response->rows * response->cols, 1).cast<double>(); k += 1; } cvSetImageCOI(imgCIELab, 0); } cvReleaseImage(&imgChannel); // derivatives of gaussians on just greyscale image DRWN_LOG_DEBUG("Generating derivative of gaussian filter responses..."); for (double sigma = 2.0; sigma <= 4.0; sigma *= 2.0) { // x-direction cvSobel(greyImg, response, 1, 0, 1); cvSmooth(response, response, CV_GAUSSIAN, 2 * (int)(_kappa * sigma) + 1, 2 * (int)(3.0 * _kappa * sigma) + 1); dst->data().col(k) = Eigen::Map<MatrixXf>((float *)response->data.ptr, response->rows * response->cols, 1).cast<double>(); k += 1; // y-direction cvSobel(greyImg, response, 0, 1, 1); cvSmooth(response, response, CV_GAUSSIAN, 2 * (int)(3.0 * _kappa * sigma) + 1, 2 * (int)(_kappa * sigma) + 1); dst->data().col(k) = Eigen::Map<MatrixXf>((float *)response->data.ptr, response->rows * response->cols, 1).cast<double>(); k += 1; } // laplacian of gaussian on just greyscale image DRWN_LOG_DEBUG("Generating laplacian of gaussian filter responses..."); IplImage *tmpImg = cvCreateImage(cvGetSize(greyImg), IPL_DEPTH_32F, 1); for (double sigma = 1.0; sigma <= 8.0; sigma *= 2.0) { cvSmooth(greyImg, tmpImg, CV_GAUSSIAN, 2 * (int)(_kappa * sigma) + 1); cvLaplace(tmpImg, response); dst->data().col(k) = Eigen::Map<MatrixXf>((float *)response->data.ptr, response->rows * response->cols, 1).cast<double>(); k += 1; } // free memory cvReleaseMat(&response); cvReleaseImage(&tmpImg); cvReleaseImage(&greyImg); cvReleaseImage(&imgCIELab); cvReleaseImage(&img); DRWN_ASSERT_MSG(k == NUM_FILTERS, k << " != " << NUM_FILTERS); return true; } bool drwnOpenCVFilterBankNode::backwardGradient(const string& key, drwnDataRecord *src, const drwnDataRecord *dst) { DRWN_NOT_IMPLEMENTED_YET; return false; } // drwnOpenCVIntegralImageNode ----------------------------------------------------- drwnOpenCVIntegralImageNode::drwnOpenCVIntegralImageNode(const char *name, drwnGraph *owner) : drwnSimpleNode(name, owner) { _nVersion = 100; _desc = "produces integral images (for faster computation)"; // define ports _inputPorts[0]->setDescription("H-by-W-by-K matrix of features"); _outputPorts[0]->setDescription("(H+1)-by-(W+1)-by-K matrix of integral features"); } drwnOpenCVIntegralImageNode::drwnOpenCVIntegralImageNode(const drwnOpenCVIntegralImageNode& node) : drwnSimpleNode(node) { // do nothing } drwnOpenCVIntegralImageNode::~drwnOpenCVIntegralImageNode() { // do nothing } // processing bool drwnOpenCVIntegralImageNode::forwardFunction(const string& key, const drwnDataRecord *src, drwnDataRecord *dst) { DRWN_ASSERT(dst != NULL); // check input if ((src == NULL) || !src->hasData()) return false; // create output if (src->hasStructure()) { dst->structure() = src->structure().array() + 1; dst->data() = MatrixXd::Zero(dst->structure()[0] * dst->structure()[1], src->numFeatures()); // TODO DRWN_ASSERT(false); } else { dst->data() = MatrixXd::Zero(src->numObservations() + 1, src->numFeatures()); for (int i = 0; i < src->numObservations(); i++) { dst->data().row(i + 1) = dst->data().row(i) + src->data().row(i); } } return true; } bool drwnOpenCVIntegralImageNode::backwardGradient(const string& key, drwnDataRecord *src, const drwnDataRecord *dst) { DRWN_NOT_IMPLEMENTED_YET; return false; } // drwnOpenCVNeighborhoodFeaturesNode ---------------------------------------- drwnOpenCVNeighborhoodFeaturesNode::drwnOpenCVNeighborhoodFeaturesNode(const char *name, drwnGraph *owner) : drwnSimpleNode(name, owner), _cellSize(3), _bIncludeRow(true), _bIncludeCol(true) { _nVersion = 100; _desc = "computes summary features in neighborhood around each pixel"; // define ports _inputPorts[0]->setDescription("H-by-W-by-K matrix of features"); _outputPorts[0]->setDescription("H-by-W-by-19K matrix of summary features"); // declare propertys declareProperty("cellSize", new drwnRangeProperty(&_cellSize, 1, DRWN_INT_MAX)); declareProperty("includeRow", new drwnBooleanProperty(&_bIncludeRow)); declareProperty("includeCol", new drwnBooleanProperty(&_bIncludeCol)); } drwnOpenCVNeighborhoodFeaturesNode::drwnOpenCVNeighborhoodFeaturesNode(const drwnOpenCVNeighborhoodFeaturesNode& node) : drwnSimpleNode(node), _cellSize(node._cellSize), _bIncludeRow(node._bIncludeRow), _bIncludeCol(node._bIncludeCol) { // declare propertys declareProperty("cellSize", new drwnRangeProperty(&_cellSize, 1, DRWN_INT_MAX)); declareProperty("includeRow", new drwnBooleanProperty(&_bIncludeRow)); declareProperty("includeCol", new drwnBooleanProperty(&_bIncludeCol)); } drwnOpenCVNeighborhoodFeaturesNode::~drwnOpenCVNeighborhoodFeaturesNode() { // do nothing } // processing bool drwnOpenCVNeighborhoodFeaturesNode::forwardFunction(const string& key, const drwnDataRecord *src, drwnDataRecord *dst) { DRWN_ASSERT(dst != NULL); // check input if ((src == NULL) || !src->hasData()) return false; // create output if (src->hasStructure()) { dst->structure() = src->structure(); int height = src->structure()[0]; int width = src->structure()[1]; int nFeatures = 19 * src->numFeatures(); if (_bIncludeRow) nFeatures += 1; if (_bIncludeCol) nFeatures += 1; dst->data() = MatrixXd::Zero(height * width, nFeatures); // copy base features dst->data().block(0, 0, height * width, src->numFeatures()) = src->data(); // extract features as matrices vector<CvMat *> rawFeatures = record2CvMats(src); CvMat *rawSum = cvCreateMat(height + 1, width + 1, CV_64FC1); CvMat *rawSqSum = cvCreateMat(height + 1, width + 1, CV_64FC1); // iterate over features for (int i = 0; i < (int)rawFeatures.size(); i++) { // compute integral image for feature cvIntegral(rawFeatures[i], rawSum, rawSqSum); // compute mean and standard deviation around each pixel int rowIndx = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, rowIndx++) { int colIndx = 18 * i + src->numFeatures(); for (int dy = (int)(-1.5 * _cellSize); dy < _cellSize; dy += _cellSize) { for (int dx = (int)(-1.5 * _cellSize); dx < _cellSize; dx += _cellSize) { CvRect roi = cvRect(x + dx, y + dy, _cellSize, _cellSize); drwnClipRect(roi, height, width); if ((roi.width == 0) || (roi.height == 0)) { dst->data()(rowIndx, colIndx) = src->data()(rowIndx, i); dst->data()(rowIndx, colIndx + 1) = 0.0; } else { // compute mean and variance double mu = CV_MAT_ELEM(*rawSum, double, roi.y, roi.x) + CV_MAT_ELEM(*rawSum, double, roi.y + roi.height, roi.x + roi.width) - CV_MAT_ELEM(*rawSum, double, roi.y + roi.height, roi.x) - CV_MAT_ELEM(*rawSum, double, roi.y, roi.x + roi.width); mu /= (double)(roi.width * roi.height); double sigma = CV_MAT_ELEM(*rawSqSum, double, roi.y, roi.x) + CV_MAT_ELEM(*rawSqSum, double, roi.y + roi.height, roi.x + roi.width) - CV_MAT_ELEM(*rawSqSum, double, roi.y + roi.height, roi.x) - CV_MAT_ELEM(*rawSqSum, double, roi.y, roi.x + roi.width); sigma = std::max(0.0, sigma / (double)(roi.width * roi.height) - mu * mu); dst->data()(rowIndx, colIndx) = mu; dst->data()(rowIndx, colIndx + 1) = sqrt(sigma); } // move to next output column colIndx += 2; } } } } } // add row and column features int rowIndx = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, rowIndx++) { int colIndx = 19 * src->numFeatures(); if (_bIncludeRow) { dst->data()(rowIndx, colIndx) = 2.0 * (double)y / (double)height - 1.0; colIndx += 1; } if (_bIncludeCol) { dst->data()(rowIndx, colIndx) = 2.0 * (double)x / (double)width - 1.0; } } } // free memory cvReleaseMat(&rawSqSum); cvReleaseMat(&rawSum); releaseOpenCVMatrices(rawFeatures); } else { DRWN_LOG_ERROR(getName() << " requires structured data"); return false; } return true; } bool drwnOpenCVNeighborhoodFeaturesNode::backwardGradient(const string& key, drwnDataRecord *src, const drwnDataRecord *dst) { DRWN_NOT_IMPLEMENTED_YET; return false; } // auto registration --------------------------------------------------------- DRWN_AUTOREGISTERNODE("OpenCV", drwnOpenCVImageSourceNode); DRWN_AUTOREGISTERNODE("OpenCV", drwnOpenCVImageSinkNode); DRWN_AUTOREGISTERNODE("OpenCV", drwnOpenCVResizeNode); DRWN_AUTOREGISTERNODE("OpenCV", drwnOpenCVFilterBankNode); DRWN_AUTOREGISTERNODE("OpenCV", drwnOpenCVIntegralImageNode); DRWN_AUTOREGISTERNODE("OpenCV", drwnOpenCVNeighborhoodFeaturesNode);
36.074648
120
0.606059
[ "vector" ]
ad8cb4cd7b4edae2ac2afff00037d39f3e57bbf6
19,797
cpp
C++
irobot_create_common/irobot_create_nodes/src/motion_control/drive_goal_behaviors.cpp
roni-kreinin/create3_sim
637f02b9f7ddcc28de35e5e003c998290a51fccd
[ "BSD-3-Clause" ]
14
2021-10-21T10:43:09.000Z
2022-03-22T13:30:44.000Z
irobot_create_common/irobot_create_nodes/src/motion_control/drive_goal_behaviors.cpp
roni-kreinin/create3_sim
637f02b9f7ddcc28de35e5e003c998290a51fccd
[ "BSD-3-Clause" ]
49
2021-10-20T19:00:08.000Z
2022-03-28T11:12:51.000Z
irobot_create_common/irobot_create_nodes/src/motion_control/drive_goal_behaviors.cpp
roni-kreinin/create3_sim
637f02b9f7ddcc28de35e5e003c998290a51fccd
[ "BSD-3-Clause" ]
10
2021-10-20T16:26:15.000Z
2022-03-21T00:35:24.000Z
// Copyright 2021 iRobot Corporation. All Rights Reserved. // @author Justin Kearns (jkearns@irobot.com) #include <angles/angles.h> #include <irobot_create_nodes/motion_control/drive_goal_behaviors.hpp> #include <geometry_msgs/msg/pose_stamped.hpp> #include <tf2/LinearMath/Quaternion.h> #include <tf2/utils.h> #include <algorithm> #include <memory> #include <string> namespace irobot_create_nodes { //// Helper functions //// geometry_msgs::msg::Twist get_default_velocity_cmd() { geometry_msgs::msg::Twist default_cmd; default_cmd.linear.x = 0; default_cmd.linear.y = 0; default_cmd.linear.z = 0; default_cmd.angular.x = 0; default_cmd.angular.y = 0; default_cmd.angular.z = 0; return default_cmd; } geometry_msgs::msg::PoseStamped get_current_pose_stamped( const rclcpp::Time & current_time, const tf2::Transform & pose) { geometry_msgs::msg::PoseStamped result_pose; result_pose.header.stamp = current_time; result_pose.header.frame_id = "odom"; const tf2::Vector3 & robot_position = pose.getOrigin(); result_pose.pose.position.x = robot_position.getX(); result_pose.pose.position.y = robot_position.getY(); result_pose.pose.position.z = robot_position.getZ(); const tf2::Quaternion & pose_quat = pose.getRotation(); result_pose.pose.orientation.w = pose_quat.getW(); result_pose.pose.orientation.x = pose_quat.getX(); result_pose.pose.orientation.y = pose_quat.getY(); result_pose.pose.orientation.z = pose_quat.getZ(); return result_pose; } //// Implementation for Drive Arc action server //// DriveArcBehavior::DriveArcBehavior( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface, rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_interface, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_interface, rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_interface, std::shared_ptr<BehaviorsScheduler> behavior_scheduler, float servo_speed, const std::string & server_name) : DriveGoalBaseBehavior<irobot_create_msgs::action::DriveArc>(node_base_interface, node_clock_interface, node_logging_interface, node_waitables_interface, behavior_scheduler, server_name), first_iter_(true), translate_speed_(servo_speed) { } void DriveArcBehavior::initialize_goal(const irobot_create_msgs::action::DriveArc::Goal & goal) { first_iter_ = true; float max_speed = std::min(translate_speed_, std::abs(goal.max_translation_speed)); RCLCPP_INFO( logger_, "DriveArc with radius %f, angle %f, max_speed %f", goal.radius, goal.angle, max_speed); const std::lock_guard<std::mutex> lock(drive_arc_params_mutex_); arc_velocity_cmd_ = get_default_velocity_cmd(); arc_velocity_cmd_.linear.x = max_speed; arc_velocity_cmd_.angular.z = std::copysign(max_speed / std::abs(goal.radius), goal.angle); if (goal.translate_direction == irobot_create_msgs::action::DriveArc::Goal::TRANSLATE_BACKWARD) { arc_velocity_cmd_.linear.x *= -1.0f; } remain_angle_travel_ = goal.angle; start_sign_ = std::copysign(1, remain_angle_travel_); } bool DriveArcBehavior::iterate_on_goal( const tf2::Transform & current_pose, BehaviorsScheduler::optional_output_t & output) { double current_angle = tf2::getYaw(current_pose.getRotation()); if (first_iter_) { first_iter_ = false; const std::lock_guard<std::mutex> lock(drive_arc_params_mutex_); last_angle_travel_position_ = current_angle; } // Check termination condition, otherwise send arc velocity { const std::lock_guard<std::mutex> lock(drive_arc_params_mutex_); remain_angle_travel_ -= angles::shortest_angular_distance(last_angle_travel_position_, current_angle); last_angle_travel_position_ = current_angle; int8_t current_sign = std::copysign(1, remain_angle_travel_); if (current_sign != start_sign_) { RCLCPP_INFO(logger_, "Drive Arc traveled commanded angle, succeeded"); return true; } else { float abs_remain_angle_travel = std::abs(remain_angle_travel_); output = arc_velocity_cmd_; if (abs_remain_angle_travel < slow_angle_dist_) { if (abs_remain_angle_travel <= converge_angle_dist_) { RCLCPP_INFO(logger_, "Drive Arc traveled commanded angle, succeeded"); return true; } float scale = abs_remain_angle_travel / slow_angle_dist_; scale = std::max(scale, min_percent_); output->linear.x = arc_velocity_cmd_.linear.x * scale; output->angular.z = arc_velocity_cmd_.angular.z * scale; float abs_linear = std::abs(output->linear.x); if (abs_linear < min_controllable_) { float up_scale = min_controllable_ / abs_linear; output->linear.x *= up_scale; output->angular.z *= up_scale; } } } } return false; } std::shared_ptr<irobot_create_msgs::action::DriveArc::Feedback> DriveArcBehavior::get_feedback( const rclcpp::Duration & time_since_feedback) { if (time_since_feedback > report_feedback_interval_) { auto feedback = std::make_shared<irobot_create_msgs::action::DriveArc::Feedback>(); const std::lock_guard<std::mutex> lock(drive_arc_params_mutex_); feedback->remaining_angle_travel = remain_angle_travel_; return feedback; } return nullptr; } //// Implementation for Drive Distance action server //// DriveDistanceBehavior::DriveDistanceBehavior( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface, rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_interface, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_interface, rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_interface, std::shared_ptr<BehaviorsScheduler> behavior_scheduler, float servo_speed, const std::string & server_name) : DriveGoalBaseBehavior<irobot_create_msgs::action::DriveDistance>(node_base_interface, node_clock_interface, node_logging_interface, node_waitables_interface, behavior_scheduler, server_name), first_iter_(true), translate_speed_(servo_speed) { } void DriveDistanceBehavior::initialize_goal( const irobot_create_msgs::action::DriveDistance::Goal & goal) { first_iter_ = true; const std::lock_guard<std::mutex> lock(drive_distance_params_mutex_); drive_velocity_cmd_ = get_default_velocity_cmd(); goal_travel_ = goal.distance; travel_distance_sq_ = goal_travel_ * goal_travel_; remaining_travel_ = goal_travel_; float max_speed = std::min(translate_speed_, goal.max_translation_speed); RCLCPP_INFO(logger_, "DriveDistance with distance %f, max_speed %f", goal.distance, max_speed); drive_velocity_cmd_.linear.x = std::copysign(max_speed, goal_travel_); } bool DriveDistanceBehavior::iterate_on_goal( const tf2::Transform & current_pose, BehaviorsScheduler::optional_output_t & output) { tf2::Vector3 current_position = current_pose.getOrigin(); if (first_iter_) { first_iter_ = false; const std::lock_guard<std::mutex> lock(drive_distance_params_mutex_); start_position_ = current_position; } { const std::lock_guard<std::mutex> lock(drive_distance_params_mutex_); tf2::Vector3 position_diff = current_position - start_position_; double odom_dist_sq = tf2::tf2Dot(position_diff, position_diff); if (odom_dist_sq >= travel_distance_sq_) { RCLCPP_INFO(logger_, "Drive Distance traveled commanded distance, succeeded"); return true; } else { remaining_travel_ = goal_travel_ - std::sqrt(odom_dist_sq); output = drive_velocity_cmd_; float abs_remaining = std::abs(remaining_travel_); if (abs_remaining <= slow_translate_dist_) { if (abs_remaining <= converge_translate_dist_) { RCLCPP_INFO(logger_, "Drive Distance traveled commanded distance, succeeded"); return true; } abs_remaining = std::max(abs_remaining, min_translate_vel_); float remain_vel = std::copysign(abs_remaining, goal_travel_); if (std::abs(remain_vel) < std::abs(output->linear.x)) { output->linear.x = remain_vel; } } } } return false; } std::shared_ptr<irobot_create_msgs::action::DriveDistance::Feedback> DriveDistanceBehavior:: get_feedback(const rclcpp::Duration & time_since_feedback) { if (time_since_feedback > report_feedback_interval_) { auto feedback = std::make_shared<irobot_create_msgs::action::DriveDistance::Feedback>(); const std::lock_guard<std::mutex> lock(drive_distance_params_mutex_); feedback->remaining_travel_distance = remaining_travel_; return feedback; } return nullptr; } //// Implementation for Rotate Angle action server //// RotateAngleBehavior::RotateAngleBehavior( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface, rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_interface, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_interface, rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_interface, std::shared_ptr<BehaviorsScheduler> behavior_scheduler, float max_rot_speed_radps, const std::string & server_name) : DriveGoalBaseBehavior<irobot_create_msgs::action::RotateAngle>(node_base_interface, node_clock_interface, node_logging_interface, node_waitables_interface, behavior_scheduler, server_name), first_iter_(true), max_rot_speed_radps_(max_rot_speed_radps) { } void RotateAngleBehavior::initialize_goal( const irobot_create_msgs::action::RotateAngle::Goal & goal) { first_iter_ = true; const std::lock_guard<std::mutex> lock(rotate_angle_params_mutex_); rotate_velocity_cmd_ = get_default_velocity_cmd(); remain_angle_travel_ = goal.angle; start_sign_ = std::copysign(1, remain_angle_travel_); float max_speed = std::min(max_rot_speed_radps_, goal.max_rotation_speed); RCLCPP_INFO(logger_, "RotateAngle with angle %f, max_speed %f", goal.angle, max_speed); rotate_velocity_cmd_.angular.z = std::copysign(max_speed, remain_angle_travel_); } bool RotateAngleBehavior::iterate_on_goal( const tf2::Transform & current_pose, BehaviorsScheduler::optional_output_t & output) { double current_angle = tf2::getYaw(current_pose.getRotation()); if (first_iter_) { first_iter_ = false; const std::lock_guard<std::mutex> lock(rotate_angle_params_mutex_); last_angle_travel_position_ = current_angle; } const std::lock_guard<std::mutex> lock(rotate_angle_params_mutex_); remain_angle_travel_ -= angles::shortest_angular_distance(last_angle_travel_position_, current_angle); last_angle_travel_position_ = current_angle; int8_t current_sign = std::copysign(1, remain_angle_travel_); if (current_sign != start_sign_) { RCLCPP_INFO(logger_, "Rotate Angle traveled commanded angle, succeeded"); return true; } else { float abs_remain_angle_travel = std::abs(remain_angle_travel_); output = rotate_velocity_cmd_; if (abs_remain_angle_travel < slow_angle_dist_) { if (abs_remain_angle_travel < converge_angle_dist_) { RCLCPP_INFO(logger_, "Rotate Angle traveled commanded angle, succeeded"); return true; } double slow_speed = std::max(abs_remain_angle_travel, min_angular_vel_); if (slow_speed < std::abs(output->angular.z)) { output->angular.z = std::copysign(slow_speed, remain_angle_travel_); } } } return false; } std::shared_ptr<irobot_create_msgs::action::RotateAngle::Feedback> RotateAngleBehavior::get_feedback(const rclcpp::Duration & time_since_feedback) { if (time_since_feedback > report_feedback_interval_) { auto feedback = std::make_shared<irobot_create_msgs::action::RotateAngle::Feedback>(); const std::lock_guard<std::mutex> lock(rotate_angle_params_mutex_); feedback->remaining_angle_travel = remain_angle_travel_; return feedback; } return nullptr; } //// Implementation for Navigate To Position action server //// NavigateToPositionBehavior::NavigateToPositionBehavior( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface, rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_interface, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_interface, rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_interface, std::shared_ptr<BehaviorsScheduler> behavior_scheduler, float servo_speed, float max_rot_speed_radps, const std::string & server_name) : DriveGoalBaseBehavior<irobot_create_msgs::action::NavigateToPosition>(node_base_interface, node_clock_interface, node_logging_interface, node_waitables_interface, behavior_scheduler, server_name), first_iter_(true), servo_speed_(servo_speed), max_rot_speed_radps_(max_rot_speed_radps), rotate_behavior_(node_base_interface, node_clock_interface, node_logging_interface, node_waitables_interface, behavior_scheduler, max_rot_speed_radps, std::string()), translate_behavior_(node_base_interface, node_clock_interface, node_logging_interface, node_waitables_interface, behavior_scheduler, servo_speed, std::string()) { } void NavigateToPositionBehavior::initialize_goal( const irobot_create_msgs::action::NavigateToPosition::Goal & goal) { first_iter_ = true; const std::lock_guard<std::mutex> lock(navigate_to_position_params_mutex_); nav_goal_ = goal; last_reported_nav_state_ = 0; } bool NavigateToPositionBehavior::iterate_on_goal( const tf2::Transform & current_pose, BehaviorsScheduler::optional_output_t & output) { tf2::Vector3 current_position = current_pose.getOrigin(); if (first_iter_) { first_iter_ = false; const std::lock_guard<std::mutex> lock(navigate_to_position_params_mutex_); nav_state_.navigate_state = irobot_create_msgs::action::NavigateToPosition::Feedback::ROTATING_TO_GOAL_POSITION; tf2::Quaternion goal_quat; tf2::Vector3 goal_position = {nav_goal_.goal_pose.pose.position.x, nav_goal_.goal_pose.pose.position.y, nav_goal_.goal_pose.pose.position.z}; tf2::fromMsg(nav_goal_.goal_pose.pose.orientation, goal_quat); goal_pose_ = tf2::Transform(goal_quat, goal_position); RCLCPP_INFO( logger_, "NavigateToPosition with position x %f, y %f, theta %f", goal_position.getX(), goal_position.getY(), tf2::getYaw(goal_quat)); irobot_create_msgs::action::RotateAngle::Goal rotate_goal; rotate_goal.angle = angle_to_goal(current_pose, goal_pose_); rotate_goal.max_rotation_speed = nav_goal_.max_rotation_speed; rotate_behavior_.initialize_goal(rotate_goal); } const std::lock_guard<std::mutex> lock(navigate_to_position_params_mutex_); bool rotate_to_position = (nav_state_.navigate_state == irobot_create_msgs::action::NavigateToPosition::Feedback::ROTATING_TO_GOAL_POSITION); bool rotate_to_goal_heading = (nav_state_.navigate_state == irobot_create_msgs::action::NavigateToPosition::Feedback::ROTATING_TO_GOAL_ORIENTATION); bool drive_to_goal = (nav_state_.navigate_state == irobot_create_msgs::action::NavigateToPosition::Feedback::DRIVING_TO_GOAL_POSITION); if (rotate_to_position || rotate_to_goal_heading) { if (rotate_behavior_.iterate_on_goal(current_pose, output)) { if (rotate_to_position) { // Transition to drive nav_state_.navigate_state = irobot_create_msgs::action::NavigateToPosition::Feedback::DRIVING_TO_GOAL_POSITION; tf2::Vector3 goal_position = goal_pose_.getOrigin(); tf2::Vector3 pos_diff = goal_position - current_position; float goal_dist = std::hypot(pos_diff.getX(), pos_diff.getY()); irobot_create_msgs::action::DriveDistance::Goal distance_goal; distance_goal.distance = goal_dist; distance_goal.max_translation_speed = nav_goal_.max_translation_speed; translate_behavior_.initialize_goal(distance_goal); drive_to_goal = true; } else { // We are finished return true; } } } if (drive_to_goal) { if (translate_behavior_.iterate_on_goal(current_pose, output)) { if (nav_goal_.achieve_goal_heading) { nav_state_.navigate_state = irobot_create_msgs::action::NavigateToPosition::Feedback::ROTATING_TO_GOAL_ORIENTATION; irobot_create_msgs::action::RotateAngle::Goal rotate_goal; rotate_goal.angle = angles::shortest_angular_distance( tf2::getYaw(current_pose.getRotation()), tf2::getYaw(goal_pose_.getRotation())); rotate_goal.max_rotation_speed = nav_goal_.max_rotation_speed; rotate_behavior_.initialize_goal(rotate_goal); return rotate_behavior_.iterate_on_goal(current_pose, output); } else { // We are finished return true; } } else { // Look for deviation from goal while driving straight and apply small correction float goal_ang_diff = angle_to_goal(current_pose, goal_pose_); if (std::abs(goal_ang_diff) > apply_ang_correction_thresh_) { output->angular.z += goal_ang_diff; } } } return false; } std::shared_ptr<irobot_create_msgs::action::NavigateToPosition::Feedback> NavigateToPositionBehavior ::get_feedback(const rclcpp::Duration & time_since_feedback) { const std::lock_guard<std::mutex> lock(navigate_to_position_params_mutex_); bool has_feedback = false; bool rotate_to_position = (nav_state_.navigate_state == irobot_create_msgs::action::NavigateToPosition::Feedback::ROTATING_TO_GOAL_POSITION); bool rotate_to_goal_heading = (nav_state_.navigate_state == irobot_create_msgs::action::NavigateToPosition::Feedback::ROTATING_TO_GOAL_ORIENTATION); bool drive_to_goal = (nav_state_.navigate_state == irobot_create_msgs::action::NavigateToPosition::Feedback::DRIVING_TO_GOAL_POSITION); std::shared_ptr<irobot_create_msgs::action::NavigateToPosition::Feedback> feedback; if (rotate_to_position || rotate_to_goal_heading) { std::shared_ptr<irobot_create_msgs::action::RotateAngle::Feedback> rotate_feedback = rotate_behavior_.get_feedback(time_since_feedback); if (rotate_feedback) { feedback = std::make_shared<irobot_create_msgs::action::NavigateToPosition::Feedback>( nav_state_); feedback->remaining_angle_travel = rotate_feedback->remaining_angle_travel; has_feedback = true; } } else if (drive_to_goal) { std::shared_ptr<irobot_create_msgs::action::DriveDistance::Feedback> translate_feedback = translate_behavior_.get_feedback(time_since_feedback); if (translate_feedback) { feedback = std::make_shared<irobot_create_msgs::action::NavigateToPosition::Feedback>( nav_state_); feedback->remaining_travel_distance = translate_feedback->remaining_travel_distance; has_feedback = true; } } if ((last_reported_nav_state_ != nav_state_.navigate_state) || has_feedback) { last_reported_nav_state_ = nav_state_.navigate_state; if (!feedback) { feedback = std::make_shared<irobot_create_msgs::action::NavigateToPosition::Feedback>( nav_state_); } feedback->navigate_state = nav_state_.navigate_state; } return feedback; } double NavigateToPositionBehavior::angle_to_goal( const tf2::Transform & start_pose, const tf2::Transform & goal_pose) { const tf2::Vector3 & start_position = start_pose.getOrigin(); const tf2::Vector3 & goal_position = goal_pose.getOrigin(); return angles::shortest_angular_distance( tf2::getYaw(start_pose.getRotation()), std::atan2( goal_position.getY() - start_position.getY(), goal_position.getX() - start_position.getX())); } } // namespace irobot_create_nodes
39.832998
100
0.754811
[ "transform" ]
ad8e4f54388eb4731fceb761c956dd9650844fc2
319
cpp
C++
NOIP/oj.noi.cn/100003.cpp
webturing/CPlusPlus
6b9c671b0c9a7c0d24d937610bf54e9aec9a5a1f
[ "AFL-2.0" ]
14
2018-06-21T14:41:26.000Z
2021-12-19T14:43:51.000Z
NOIP/oj.noi.cn/100003.cpp
webturing/CPlusPlus
6b9c671b0c9a7c0d24d937610bf54e9aec9a5a1f
[ "AFL-2.0" ]
null
null
null
NOIP/oj.noi.cn/100003.cpp
webturing/CPlusPlus
6b9c671b0c9a7c0d24d937610bf54e9aec9a5a1f
[ "AFL-2.0" ]
2
2020-04-20T11:16:53.000Z
2021-01-02T15:58:35.000Z
#include <bits/stdc++.h> using namespace std; typedef unsigned long long LL; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); vector<LL> f(31, 1); for (int i = 2; i < f.size(); i++) f[i] = f[i - 1] + f[i - 2]; int n; cin >> n; cout << f[n] << endl; return 0; }
17.722222
38
0.504702
[ "vector" ]
ad91c32fac6f5cf0a6aa908f5acec0db56722c00
1,600
cpp
C++
something-learned/Algorithms and Data-Structures/Competitive-programming-library/CP/codechef/July long Challenge 17/PSHTTR.cpp
gopala-kr/CR-101
dd27b767cdc0c667655ab8e32e020ed4248bd112
[ "MIT" ]
5
2018-05-09T04:02:04.000Z
2021-02-21T19:27:56.000Z
something-learned/Algorithms and Data-Structures/Competitive-programming-library/CP/codechef/July long Challenge 17/PSHTTR.cpp
gopala-kr/CR-101
dd27b767cdc0c667655ab8e32e020ed4248bd112
[ "MIT" ]
null
null
null
something-learned/Algorithms and Data-Structures/Competitive-programming-library/CP/codechef/July long Challenge 17/PSHTTR.cpp
gopala-kr/CR-101
dd27b767cdc0c667655ab8e32e020ed4248bd112
[ "MIT" ]
5
2018-02-23T22:08:28.000Z
2020-08-19T08:31:47.000Z
// dfs template - everything is 0 indexed #include<bits/stdc++.h> using namespace std; vector<bool> vis; struct gnode{ vector<pair<long, long long> > children; }; class graph{ public: long nodes; vector<gnode> gnodes; graph(long k){ nodes = k; gnodes.resize(k); vis.resize(k); } long long dfs_recurse(long n, long x, long long val, long long ref){ if(n == x) return val; long long ans = 0; vector<pair<long, long long> >::iterator it; for(it = gnodes[n].children.begin();it!=gnodes[n].children.end();it++) if(!vis[it->first]){ vis[it->first] = true; if(it->second <= ref) ans = ans ^ dfs_recurse(it->first, x, val^it->second, ref); else ans = ans ^ dfs_recurse(it->first, x, val, ref); } return ans; } long long dfs(long n, long x, long long val){ fill(vis.begin(),vis.end(),false); vis[n] = true; return dfs_recurse(n, x, 0, val); } void add_node(long c, long k, long long val){ gnodes[c].children.push_back(make_pair(k, val)); gnodes[k].children.push_back(make_pair(c, val)); } }; int main(){ long t; cin>>t; while(t--){ long n,m; cin>>n; graph g(n); for(long i=0;i<n-1;i++){ long a,b; long long c; cin>>a>>b>>c; g.add_node(a-1,b-1,c); } cin>>m; while(m--){ long u,v; long long x; cin>>u>>v>>x; cout<<g.dfs(u-1,v-1,x)<<endl; } } return 0; }
24.615385
78
0.506875
[ "vector" ]
74e866c1a9fea0aac5ae49c209fdde91110ad556
6,492
cpp
C++
src/llvm/lib/Target/JSBackend/NaCl/GlobalizeConstantVectors.cpp
ryoon/rustc-1.19.0
4ca47e69f710b93580101782576ebad2bef64749
[ "ECL-2.0", "Apache-2.0", "MIT-0", "MIT" ]
null
null
null
src/llvm/lib/Target/JSBackend/NaCl/GlobalizeConstantVectors.cpp
ryoon/rustc-1.19.0
4ca47e69f710b93580101782576ebad2bef64749
[ "ECL-2.0", "Apache-2.0", "MIT-0", "MIT" ]
null
null
null
src/llvm/lib/Target/JSBackend/NaCl/GlobalizeConstantVectors.cpp
ryoon/rustc-1.19.0
4ca47e69f710b93580101782576ebad2bef64749
[ "ECL-2.0", "Apache-2.0", "MIT-0", "MIT" ]
null
null
null
//===- GlobalizeConstantVectors.cpp - Globalize constant vector -----------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This pass replaces all constant vector operands by loads of the same // vector value from a constant global. After this pass functions don't // rely on ConstantVector and ConstantDataVector. // // The FlattenGlobals pass can be used to further simplify the globals // that this pass creates. // //===----------------------------------------------------------------------===// #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/InstIterator.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Transforms/NaCl.h" #include <utility> #include <vector> using namespace llvm; namespace { // Must be a ModulePass since it adds globals. class GlobalizeConstantVectors : public ModulePass { public: static char ID; // Pass identification, replacement for typeid GlobalizeConstantVectors() : ModulePass(ID), DL(0) { initializeGlobalizeConstantVectorsPass(*PassRegistry::getPassRegistry()); } virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); } virtual bool runOnModule(Module &M); private: typedef SmallPtrSet<Constant *, 32> Constants; typedef std::pair<Function *, Constants> FunctionConstants; typedef std::vector<FunctionConstants> FunctionConstantList; typedef DenseMap<Constant *, GlobalVariable *> GlobalizedConstants; const DataLayout *DL; void findConstantVectors(const Function &F, Constants &Cs) const; void createGlobalConstantVectors(Module &M, const FunctionConstantList &FCs, GlobalizedConstants &GCs) const; void materializeConstantVectors(Function &F, const Constants &Cs, const GlobalizedConstants &GCs) const; }; const char Name[] = "constant_vector"; } // anonymous namespace char GlobalizeConstantVectors::ID = 0; INITIALIZE_PASS(GlobalizeConstantVectors, "globalize-constant-vectors", "Replace constant vector operands with equivalent loads", false, false) void GlobalizeConstantVectors::findConstantVectors(const Function &F, Constants &Cs) const { for (const_inst_iterator II = inst_begin(F), IE = inst_end(F); II != IE; ++II) { for (User::const_op_iterator OI = II->op_begin(), OE = II->op_end(); OI != OE; ++OI) { Value *V = OI->get(); if (isa<ConstantVector>(V) || isa<ConstantDataVector>(V) || isa<ConstantAggregateZero>(V)) Cs.insert(cast<Constant>(V)); } } } void GlobalizeConstantVectors::createGlobalConstantVectors( Module &M, const FunctionConstantList &FCs, GlobalizedConstants &GCs) const { for (FunctionConstantList::const_iterator FCI = FCs.begin(), FCE = FCs.end(); FCI != FCE; ++FCI) { const Constants &Cs = FCI->second; for (Constants::const_iterator CI = Cs.begin(), CE = Cs.end(); CI != CE; ++CI) { Constant *C = *CI; if (GCs.find(C) != GCs.end()) continue; // The vector has already been globalized. GlobalVariable *GV = new GlobalVariable(M, C->getType(), /* isConstant= */ true, GlobalValue::InternalLinkage, C, Name); GV->setAlignment(DL->getPrefTypeAlignment(C->getType())); GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global); // The content is significant, not the address. GCs[C] = GV; } } } void GlobalizeConstantVectors::materializeConstantVectors( Function &F, const Constants &Cs, const GlobalizedConstants &GCs) const { // The first instruction in a function dominates all others, it is therefore a // safe insertion point. Instruction *FirstInst = F.getEntryBlock().getFirstNonPHI(); for (Constants::const_iterator CI = Cs.begin(), CE = Cs.end(); CI != CE; ++CI) { Constant *C = *CI; GlobalizedConstants::const_iterator GVI = GCs.find(C); assert(GVI != GCs.end()); GlobalVariable *GV = GVI->second; LoadInst *MaterializedGV = new LoadInst(GV, Name, /* isVolatile= */ false, GV->getAlignment(), FirstInst); // Find users of the constant vector. typedef SmallVector<User *, 64> UserList; UserList CVUsers; for (auto U : C->users()) { if (Instruction *I = dyn_cast<Instruction>(U)) if (I->getParent()->getParent() != &F) // Skip uses of the constant vector in other functions: we need to // materialize it in every function which has a use. continue; if (isa<Constant>(U)) // Don't replace global uses of the constant vector: we just created a // new one. This avoid recursive references. // Also, it's not legal to replace a constant's operand with // a non-constant (the load instruction). continue; CVUsers.push_back(U); } // Replace these Users. Must be done separately to avoid invalidating the // User iterator. for (UserList::iterator UI = CVUsers.begin(), UE = CVUsers.end(); UI != UE; ++UI) { User *U = *UI; for (User::op_iterator OI = U->op_begin(), OE = U->op_end(); OI != OE; ++OI) if (dyn_cast<Constant>(*OI) == C) // The current operand is a use of the constant vector, replace it // with the materialized one. *OI = MaterializedGV; } } } bool GlobalizeConstantVectors::runOnModule(Module &M) { DL = &M.getDataLayout(); FunctionConstantList FCs; FCs.reserve(M.size()); for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) { Constants Cs; findConstantVectors(*FI, Cs); if (!Cs.empty()) FCs.push_back(std::make_pair(&*FI, Cs)); } GlobalizedConstants GCs; createGlobalConstantVectors(M, FCs, GCs); for (FunctionConstantList::const_iterator FCI = FCs.begin(), FCE = FCs.end(); FCI != FCE; ++FCI) materializeConstantVectors(*FCI->first, FCI->second, GCs); return FCs.empty(); } ModulePass *llvm::createGlobalizeConstantVectorsPass() { return new GlobalizeConstantVectors(); }
36.677966
107
0.635243
[ "vector" ]
74eb4b1660241dca5dd7378a2ab213523666ac51
15,495
cc
C++
CCA/Components/Arches/SourceTerms/HTConvection.cc
QuocAnh90/Uintah_Aalto
802c236c331b7eb705d408c352969037e4c5b153
[ "MIT" ]
3
2020-06-10T08:21:31.000Z
2020-06-23T18:33:16.000Z
CCA/Components/Arches/SourceTerms/HTConvection.cc
QuocAnh90/Uintah_Aalto
802c236c331b7eb705d408c352969037e4c5b153
[ "MIT" ]
null
null
null
CCA/Components/Arches/SourceTerms/HTConvection.cc
QuocAnh90/Uintah_Aalto
802c236c331b7eb705d408c352969037e4c5b153
[ "MIT" ]
2
2019-12-30T05:48:30.000Z
2020-02-12T16:24:16.000Z
#include <Core/ProblemSpec/ProblemSpec.h> #include <CCA/Ports/Scheduler.h> #include <Core/Grid/MaterialManager.h> #include <Core/Grid/Variables/VarLabel.h> #include <Core/Grid/Variables/VarTypes.h> #include <Core/Grid/Variables/CCVariable.h> #include <CCA/Components/Arches/SourceTerms/HTConvection.h> #include <CCA/Components/Arches/ArchesLabel.h> #include <CCA/Components/Arches/Directives.h> //=========================================================================== using namespace std; using namespace Uintah; HTConvection::HTConvection( std::string src_name, ArchesLabel* field_labels, vector<std::string> req_label_names, std::string type ) : SourceTermBase(src_name, field_labels->d_materialManager, req_label_names, type), _field_labels(field_labels) { _source_grid_type = CC_SRC; _src_label = VarLabel::create( src_name, CCVariable<double>::getTypeDescription() ); } HTConvection::~HTConvection() { VarLabel::destroy(ConWallHT_src_label); } //--------------------------------------------------------------------------- // Method: Problem Setup //--------------------------------------------------------------------------- void HTConvection::problemSetup(const ProblemSpecP& inputdb) { ProblemSpecP db = inputdb; const ProblemSpecP params_root = db->getRootNode(); db->getWithDefault("dTCorrectionFactor", _dTCorrectionFactor, 2.0); //db->getWithDefault("temperature_label", _gas_temperature_name, "temperature"); // db->getWithDefault("density_label", _rho_name, "density"); std::string vol_frac= "volFraction"; _volFraction_varlabel = VarLabel::find(vol_frac); //source terms name,and ... db->findBlock("ConWallHT_src")->getAttribute( "label", ConWallHT_src_name ); _mult_srcs.push_back( ConWallHT_src_name ); ConWallHT_src_label = VarLabel::create( ConWallHT_src_name, CCVariable<double>::getTypeDescription() ); /* if (params_root->findBlock("PhysicalConstants")) { ProblemSpecP db_phys = params_root->findBlock("PhysicalConstants"); db_phys->require("viscosity", _visc); if( _visc == 0 ) { throw InvalidValue("ERROR: HTConvection: problemSetup(): Zero viscosity specified in <PhysicalConstants> section of input file.",__FILE__,__LINE__); } } else { throw InvalidValue("ERROR: HTConvection: problemSetup(): Missing <PhysicalConstants> section in input file!",__FILE__,__LINE__); } */ } //--------------------------------------------------------------------------- // Method: Schedule the calculation of the source term //--------------------------------------------------------------------------- void HTConvection::sched_computeSource( const LevelP& level, SchedulerP& sched, int timeSubStep ) { std::string taskname = "HTConvection::eval"; Task* tsk = scinew Task(taskname, this, &HTConvection::computeSource, timeSubStep); Ghost::GhostType gac = Ghost::AroundCells; // get gas phase temperature label if (VarLabel::find("temperature")) { _gas_temperature_varlabel = VarLabel::find("temperature"); } else { throw InvalidValue("ERROR: HT_convection: can't find gas phase temperature.",__FILE__,__LINE__); } Task::WhichDW which_dw; if (timeSubStep == 0) { tsk->computes(_src_label); tsk->computes(ConWallHT_src_label); which_dw = Task::OldDW; } else { which_dw = Task::NewDW; tsk->modifies(ConWallHT_src_label); tsk->modifies(_src_label); } tsk->requires( Task::OldDW, _volFraction_varlabel, gac, 1 ); tsk->requires( which_dw, _gas_temperature_varlabel, gac, 1 ); sched->addTask(tsk, level->eachPatch(), _materialManager->allMaterials( "Arches" )); } //--------------------------------------------------------------------------- // Method: Actually compute the source term //--------------------------------------------------------------------------- void HTConvection::computeSource( const ProcessorGroup* pc, const PatchSubset* patches, const MaterialSubset* matls, DataWarehouse* old_dw, DataWarehouse* new_dw, int timeSubStep ) { //patch loop for (int p=0; p < patches->size(); p++){ Ghost::GhostType gac = Ghost::AroundCells; const Patch* patch = patches->get(p); int archIndex = 0; int matlIndex = _materialManager->getMaterial( "Arches", archIndex)->getDWIndex(); constCCVariable<double> rho; constCCVariable<double> gasT; constCCVariable<double> volFraction; CCVariable<double> rate; CCVariable<double> ConWallHT_src; double rkg=0.0; double f_T_m=0.0; // face temperature on minus side double f_T_p=0.0; // face temperature on plus side double dT_dn=0.0; DataWarehouse* which_dw; if ( timeSubStep == 0 ){ which_dw = old_dw; new_dw->allocateAndPut( rate, _src_label, matlIndex, patch ); new_dw->allocateAndPut( ConWallHT_src, ConWallHT_src_label, matlIndex, patch ); rate.initialize(0.0); ConWallHT_src.initialize(0.0); } else { which_dw = new_dw; new_dw->getModifiable( rate, _src_label, matlIndex, patch ); new_dw->getModifiable( ConWallHT_src,ConWallHT_src_label, matlIndex, patch ); } old_dw->get( volFraction , _volFraction_varlabel , matlIndex , patch , gac , 1 ); which_dw->get(gasT , _gas_temperature_varlabel, matlIndex , patch , gac, 1 ); Uintah::BlockRange range(patch->getExtraCellLowIndex(), patch->getExtraCellHighIndex()); IntVector lowPindex = patch->getCellLowIndex(); IntVector highPindex = patch->getCellHighIndex(); //Pad for ghosts lowPindex -= IntVector(1,1,1); highPindex += IntVector(1,1,1); Vector Dx = patch->dCell(); Uintah::parallel_for(range, [&](int i, int j, int k) { //bool exper=0; //exper=patch->containsIndex(lowPindex, highPindex, IntVector(i,j,k) ); double cellvol=Dx.x()*Dx.y()*Dx.z(); double delta_n = 0.0; double total_area_face=0.0; rate(i,j,k)=0.0; ConWallHT_src(i,j,k)=0.0; // for computing dT/dn we have 2 scenarios: // (1) cp is a wall: // gasT[cp] gasT[c] // dT_dn = _________ _ ________________ // delta_n delta_n // (2) cm is a wall: // gasT[c] gasT[cm] // Note: Surface temperature of the wall is stored at the cell center. if ( volFraction(i,j,k) > 0. ){ // fluid cell if (patch->containsIndex(lowPindex, highPindex, IntVector(i+1,j,k) )){ delta_n=Dx.x(); f_T_p=gasT(i+1,j,k); f_T_m=gasT(i,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K rate(i,j,k) = volFraction(i+1,j,k) < 1.0 ? rate(i,j,k)+rkg*dT_dn*_dTCorrectionFactor/delta_n :rate(i,j,k);// w/m^3 } if (patch->containsIndex(lowPindex, highPindex, IntVector(i-1,j,k) )) { delta_n=Dx.x(); f_T_p=gasT(i,j,k); f_T_m=gasT(i-1,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K rate(i,j,k) = volFraction(i-1,j,k) < 1.0 ? rate(i,j,k)-rkg*dT_dn*_dTCorrectionFactor/delta_n :rate(i,j,k);// w/m^3 } // Next for the Y direction if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j+1,k) )){ delta_n=Dx.y(); f_T_p=gasT(i,j+1,k); f_T_m=gasT(i,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K rate(i,j,k) = volFraction(i,j+1,k) < 1.0 ? rate(i,j,k)+rkg*dT_dn*_dTCorrectionFactor/delta_n :rate(i,j,k);// w/m^3 } if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j-1,k) )){ delta_n=Dx.y(); f_T_p=gasT(i,j,k); f_T_m=gasT(i,j-1,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K rate(i,j,k) = volFraction(i,j-1,k) < 1.0 ? rate(i,j,k)-rkg*dT_dn*_dTCorrectionFactor/delta_n :rate(i,j,k);// w/m^3 } // Next for the z direction if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j,k+1) )){ delta_n=Dx.z(); f_T_p=gasT(i,j,k+1); f_T_m=gasT(i,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K rate(i,j,k) = volFraction(i,j,k+1) < 1.0 ? rate(i,j,k)+rkg*dT_dn*_dTCorrectionFactor/delta_n :rate(i,j,k);// w/m^3 } if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j,k-1) )) { delta_n=Dx.z(); f_T_p=gasT(i,j,k); f_T_m=gasT(i,j,k-1); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K rate(i,j,k) = volFraction(i,j,k-1) < 1.0 ? rate(i,j,k)-rkg*dT_dn*_dTCorrectionFactor/delta_n :rate(i,j,k);// w/m^3 } }// end for fluid cell if(volFraction(i,j,k) < 1.0){ // wall cells(i,j,k) // x+ direction // std::cout<<i<<j<<k<<"\n"; if (patch->containsIndex(lowPindex, highPindex, IntVector(i+1,j,k) )){ delta_n=Dx.x(); f_T_p=gasT(i+1,j,k); f_T_m=gasT(i,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K ConWallHT_src(i,j,k) = volFraction(i+1,j,k) > 0.0 ? ConWallHT_src(i,j,k)+rkg*dT_dn*_dTCorrectionFactor/delta_n :ConWallHT_src(i,j,k);// w/m^3 total_area_face = volFraction(i+1,j,k) > 0.0 ? total_area_face+Dx.y()*Dx.z() :total_area_face;// w/m^3 } // x- direction if (patch->containsIndex(lowPindex, highPindex, IntVector(i-1,j,k) )) { delta_n=Dx.x(); f_T_p=gasT(i,j,k); f_T_m=gasT(i-1,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K ConWallHT_src(i,j,k) = volFraction(i-1,j,k) > 0.0 ? ConWallHT_src(i,j,k)-rkg*dT_dn*_dTCorrectionFactor/delta_n :ConWallHT_src(i,j,k);// w/m^3 total_area_face = volFraction(i-1,j,k) > 0.0 ? total_area_face+Dx.y()*Dx.z() :total_area_face;// w/m^3 } // Next for the Y+ direction if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j+1,k) )){ delta_n=Dx.y(); f_T_p=gasT(i,j+1,k); f_T_m=gasT(i,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K ConWallHT_src(i,j,k) = volFraction(i,j+1,k) > 0.0 ? ConWallHT_src(i,j,k)+rkg*dT_dn*_dTCorrectionFactor/delta_n :ConWallHT_src(i,j,k);// w/m^3 total_area_face = volFraction(i,j+1,k) > 0.0 ? total_area_face+Dx.x()*Dx.z() :total_area_face;// w/m^3 } // Next for the Y- direction if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j-1,k) )){ delta_n=Dx.y(); f_T_p=gasT(i,j,k); f_T_m=gasT(i,j-1,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K ConWallHT_src(i,j,k) = volFraction(i,j-1,k) > 0.0 ? ConWallHT_src(i,j,k)-rkg*dT_dn*_dTCorrectionFactor/delta_n :ConWallHT_src(i,j,k);// w/m^3 total_area_face = volFraction(i,j-1,k) > 0.0 ? total_area_face+Dx.x()*Dx.z() :total_area_face;// w/m^3 } // Next for the z direction if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j,k+1) )){ delta_n=Dx.z(); f_T_p=gasT(i,j,k+1); f_T_m=gasT(i,j,k); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K ConWallHT_src(i,j,k) = volFraction(i,j,k+1) > 0.0 ? ConWallHT_src(i,j,k)+rkg*dT_dn*_dTCorrectionFactor/delta_n :ConWallHT_src(i,j,k);// w/m^3 total_area_face = volFraction(i,j,k+1) > 0.0 ? total_area_face+Dx.x()*Dx.y() :total_area_face;// w/m^3 } if (patch->containsIndex(lowPindex, highPindex, IntVector(i,j,k-1) )) { delta_n=Dx.z(); f_T_p=gasT(i,j,k); f_T_m=gasT(i,j,k-1); dT_dn = (f_T_p - f_T_m) / delta_n; rkg = ThermalConductGas(f_T_p, f_T_m); // [=] J/s/m/K ConWallHT_src(i,j,k) = volFraction(i,j,k-1) > 0.0 ? ConWallHT_src(i,j,k)-rkg*dT_dn*_dTCorrectionFactor/delta_n :ConWallHT_src(i,j,k);// w/m^3 total_area_face = volFraction(i,j,k-1) > 0.0 ? total_area_face+Dx.x()*Dx.y() :total_area_face;// w/m^3 } ConWallHT_src(i,j,k) =total_area_face>0.0 ? ConWallHT_src(i,j,k)/total_area_face*cellvol :0.0;//W/m2 } }); // end fluid cell loop for computing the }// end patch loop } //--------------------------------------------------------------------------- // Method: Wall heat losss by conduction terms for the gas phase enthalpy Source Terms //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Method: Schedule initialization //--------------------------------------------------------------------------- void HTConvection::sched_initialize( const LevelP& level, SchedulerP& sched ) { string taskname = "HTConvection::initialize"; Task* tsk = scinew Task(taskname, this, &HTConvection::initialize); tsk->computes(_src_label); tsk->computes(ConWallHT_src_label); sched->addTask(tsk, level->eachPatch(), _materialManager->allMaterials( "Arches" )); } void HTConvection::initialize( const ProcessorGroup* pc, const PatchSubset* patches, const MaterialSubset* matls, DataWarehouse* old_dw, DataWarehouse* new_dw ) { //patch loop for (int p=0; p < patches->size(); p++){ const Patch* patch = patches->get(p); int archIndex = 0; int matlIndex = _materialManager->getMaterial( "Arches", archIndex)->getDWIndex(); CCVariable<double> src; CCVariable<double> ConWallHT_src; new_dw->allocateAndPut( src, _src_label, matlIndex, patch ); new_dw->allocateAndPut( ConWallHT_src, ConWallHT_src_label, matlIndex, patch ); src.initialize(0.0); ConWallHT_src.initialize(0.0); } } double HTConvection::ThermalConductGas(double Tg, double Tp){ double tg0[10] = {300., 400., 500., 600., 700., 800., 900., 1000., 1100., 1200. }; double kg0[10] = {.0262, .03335, .03984, .0458, .0512, .0561, .0607, .0648, .0685, .07184}; double T = (Tp+Tg)/2; // Film temperature // CALCULATE UG AND KG FROM INTERPOLATION OF TABLE VALUES FROM HOLMAN // FIND INTERVAL WHERE TEMPERATURE LIES. double kg = 0.0; if( T > 1200.0 ) { kg = kg0[9] * pow( T/tg0[9], 0.58); } else if ( T < 300 ) { kg = kg0[0]; } else { int J = -1; for ( int I=0; I < 9; I++ ) { if ( T > tg0[I] ) { J = J + 1; } } double FAC = ( tg0[J] - T ) / ( tg0[J] - tg0[J+1] ); kg = ( -FAC*( kg0[J] - kg0[J+1] ) + kg0[J] ); } return kg; // I believe this is in J/s/m/K, but not sure }
37.427536
154
0.566699
[ "vector" ]
74f0777c23378d40c690566e94d65ee53f6c8af3
6,444
cc
C++
test/multiscale/recip_comm/test.cc
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
test/multiscale/recip_comm/test.cc
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
test/multiscale/recip_comm/test.cc
SCOREC/amsi
a9d33804e951b397b3a0ca5f07efe854536c8e0a
[ "BSD-3-Clause" ]
null
null
null
#include "test.h" #include "amsiMultiscale.h" #include "amsiControlService.h" #include <mpi.h> #include <iostream> #include <utility> using namespace amsi; const int vsize = 6; // Test data types for communication MPI_Datatype sigma_type; struct Sigma { double v[vsize]; bool operator==(Sigma & other) { bool result = true; for(int i = 0; i < vsize && result; i++) result = other.v[i] == v[i]; return result; } }; int task1_run(int&, char**&, MPI_Comm cm, amsi::Multiscale& multiscale) { int failed = 0; // Retrieve the ControlService auto* cs = multiscale.getControlService(); TaskManager* tm = cs->GetTaskManager(); Task* lt = tm->getLocalTask(); int local_rank = lt->localRank(); int local_data_count = 6 + local_rank * 2; // Create a DataDistribution for this task, set the local data count, and // assembl DataDistribution* dd = createDataDistribution(lt, "micro_init"); (*dd) = local_data_count; Assemble(dd, cm); // Create a CommPattern to communicate from this task to the other size_t pattern_id = cs->CreateCommPattern("micro_init", "macro", "micro"); failed += test_neq(".CreateCommPattern()", static_cast<size_t>(0), pattern_id); // Reconcile the CommPattern with the other task cs->CommPattern_Reconcile(pattern_id); // Create data to communicate std::vector<Sigma> data(local_data_count); for (int ii = 0; ii < local_data_count; ii++) { for(int jj=0;jj<vsize;jj++){ data[ii].v[jj] = 0.5*(local_rank+1) + ii + jj; //data[ii].v[5] = data[ii].v[4] = data[ii].v[3] = data[ii].v[2] = data[ii].v[1] = data[ii].v[0] = 0.5; } } // Perform the communication with the created pattern and the data buffer cs->Communicate(pattern_id,data,sigma_type); //std::cout << "Data size: " << data.size() << " content: " << data << std::endl; //std::cout << "Task 1 rank " << local_rank << " has sent all data" << std::endl; // Create a placeholder CommPattern to reconcile into size_t recv_pattern_id = cs->RecvCommPattern("micro_results", "micro", "", "macro"); // Reconcile the CommPattern from the other task to this one cs->CommPattern_Reconcile(recv_pattern_id); // Recv data from the other task based on the just-reconciled CommPattern std::vector<Sigma> result_data; cs->Communicate(recv_pattern_id,result_data,sigma_type); // bool areequal; // Check the data if(data.size() == result_data.size()) { for(unsigned int ii = 0; ii < data.size(); ii++) { if(data[ii] == result_data[ii]){ continue; } else{ std::cout << "Rank " << local_rank << " : inconsistent data at index " << ii << std::endl; for(int jj=0;jj<vsize;jj++){ std::cout<<" "<<data[ii].v[jj]<<" ?= "<<result_data[ii].v[jj]<<" | "; } std::cout<<std::endl; } } } else{ std::cout<<"Rank:"<<local_rank<<std::endl; std::cout<<"data:"<<std::endl; for(unsigned ii=0;ii<data.size();ii++){ for(int jj=0;jj<vsize;jj++){ std::cout<<" "<<data[ii].v[jj]; } std::cout << std::endl; } std::cout << "result_data:" << std::endl; for (unsigned ii = 0; ii < result_data.size(); ii++) { for (int jj = 0; jj < vsize; jj++) { std::cout << " " << result_data[ii].v[jj]; } std::cout << std::endl; } } failed += test("2-Way Communication", data.size(), result_data.size()); // std::cout << "Task 1 rank " << local_rank << " has recv'd all data" << // std::endl; return failed; } int task2_run(int&, char**&, MPI_Comm cm, amsi::Multiscale& multiscale) { int failed = 0; auto* cs = multiscale.getControlService(); auto* tm = multiscale.getScaleManager(); Task* lt = tm->getLocalTask(); // int local_rank = lt->localRank(); // Create a placeholder CommPattern to reconcile into size_t pattern_id = cs->RecvCommPattern("micro_init", "macro", "", "micro"); failed += test_neq(".RecvCommPattern", static_cast<size_t>(0), pattern_id); // Reconcile the CommPattern from the other task cs->CommPattern_Reconcile(pattern_id); // Recv data std::vector<Sigma> data; cs->Communicate(pattern_id, data, sigma_type); // invert the comm mapping for use as the commpattern for the t2->t1 relation DataDistribution* dd = createDataDistribution(lt, "micro_results"); (*dd) = data.size(); Assemble(dd, cm); // invert the communication pattern used to get in the t1->t2 "send_to_task2" // relation size_t send_pattern_id = cs->CommPattern_UseInverted(pattern_id,"micro_results","micro","macro"); //std::cout << "recv pattern id is " << pattern_id << " send pattern id is " << send_pattern_id << std::endl; // assemble the pieces of the inverted pattern so each process has the full pattern (currently required for reconciliation) cs->CommPattern_Assemble(send_pattern_id); // collective on the task cs->CommPattern_Reconcile(send_pattern_id); // collective on the relation closure cs->Communicate(send_pattern_id,data,sigma_type); // collective on the relation closure //std::cout << "Task 2 rank " << local_rank << " has sent all data" << std::endl; return failed; } int main(int argc, char * argv[]) { int failed = 0; amsi::MPI mpi{argc, argv}; amsi::MultiscaleOptions options{ .scales = {{"macro", 3}, {"micro", 5}}, .relations = {{"macro", "micro"}, {"micro", "macro"}}}; amsi::Multiscale multiscale(options, mpi); std::cout << "Initializing test object(s):" << std::endl; // create an MPI datatypes used in the simulation as coupling data MPI_Type_contiguous(vsize, MPI_DOUBLE, &sigma_type); // Need to commit this new type MPI_Type_commit(&sigma_type); // find size of sigma_type int sigmaTypeSize; MPI_Type_size(sigma_type, &sigmaTypeSize); Task* t1 = multiscale.getScaleManager()->getTask("macro"); Task* t2 = multiscale.getScaleManager()->getTask("micro"); auto* cs = multiscale.getControlService(); failed += test_neq("ControlService::Instance()", static_cast<ControlService*>(NULL), cs); // Set the execution functions for the tasks t1->setExecutionFunction(&task1_run); t2->setExecutionFunction(&task2_run); // Begin execution failed += cs->Execute(argc, argv, multiscale); test("Number failed", 0, failed); return failed; }
39.533742
125
0.637958
[ "object", "vector" ]
74f150792b32376ded05a79f318d398501272b37
248
cc
C++
tests/t00009/t00009.cc
dgoffredo/clang-uml
3b0a454e4e85aee06168439660f0fd71dc4b7a75
[ "Apache-2.0" ]
10
2021-11-16T01:08:05.000Z
2022-03-15T23:51:11.000Z
tests/t00009/t00009.cc
dgoffredo/clang-uml
3b0a454e4e85aee06168439660f0fd71dc4b7a75
[ "Apache-2.0" ]
8
2021-11-16T21:29:41.000Z
2022-03-21T21:22:00.000Z
tests/t00009/t00009.cc
dgoffredo/clang-uml
3b0a454e4e85aee06168439660f0fd71dc4b7a75
[ "Apache-2.0" ]
2
2021-12-04T20:20:06.000Z
2022-02-08T06:33:27.000Z
#include <string> #include <vector> namespace clanguml { namespace t00009 { template <typename T> class A { public: T value; }; class B { public: A<int> aint; A<std::string> *astring; A<std::vector<std::string>> &avector; }; } }
12.4
41
0.629032
[ "vector" ]
74f198d6a9dd1de51a3a0ee153783f820b61f249
7,573
cc
C++
lite/backends/nnadapter/nnadapter/driver/cambricon_mlu/optimizer/fix_quantized_ops.cc
chiaitian/Paddle-Lite
07bfd0705b8351f0e6c9d95bcee71e4ac011fa62
[ "Apache-2.0" ]
3
2021-06-17T11:00:13.000Z
2021-08-10T10:28:59.000Z
lite/backends/nnadapter/nnadapter/driver/cambricon_mlu/optimizer/fix_quantized_ops.cc
chiaitian/Paddle-Lite
07bfd0705b8351f0e6c9d95bcee71e4ac011fa62
[ "Apache-2.0" ]
1
2021-01-06T10:21:22.000Z
2021-01-06T10:21:22.000Z
lite/backends/nnadapter/nnadapter/driver/cambricon_mlu/optimizer/fix_quantized_ops.cc
yingshengBD/Paddle-Lite
eea59b66f61bb2acad471010c9526eeec43a15ca
[ "Apache-2.0" ]
null
null
null
// Copyright (c) 2021 PaddlePaddle 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 "driver/cambricon_mlu/optimizer/fix_quantized_ops.h" #include <vector> #include "utility/debug.h" #include "utility/logging.h" #include "utility/modeling.h" #include "utility/utility.h" namespace nnadapter { namespace cambricon_mlu { static bool NeedInsertQuant(hal::Model* model, hal::Operand* operand) { auto pre_operation = GetOperandProducer(model, operand); if (pre_operation == nullptr || pre_operation->type == NNADAPTER_QUANTIZE) { return false; } if (pre_operation->type == NNADAPTER_RESHAPE) { auto prepre_operation = GetOperandProducer(model, pre_operation->input_operands[0]); if (prepre_operation != nullptr && prepre_operation->type == NNADAPTER_QUANTIZE) { return false; } } return true; } static bool NeedDeleteDequant(hal::Model* model, hal::Operand* operand) { auto next_operations = GetOperandConsumers(model, operand); return !next_operations.empty() && next_operations[0]->type == NNADAPTER_DEQUANTIZE; } // Add a quant operation after input_operand, before reference_operations static hal::Operand* AddQuantOperation( hal::Model* model, hal::Operand* input_operand, const std::vector<hal::Operation*>& reference_operations = {}) { // Insert a new operand after input_operand auto output_operand = AddOperand(model); memcpy(&output_operand->type, &input_operand->type, sizeof(NNAdapterOperandType)); InsertOperand( model, input_operand, output_operand, true, reference_operations); output_operand->type.precision = NNADAPTER_QUANT_INT8_SYMM_PER_LAYER; // Insert a new quant operation between input_operand and output_operand auto quant_operation = AddOperation(model); quant_operation->type = NNADAPTER_QUANTIZE; hal::Operand* axis_operand = AddInt32ConstantOperand(model, 1); float scale = input_operand->type.symm_per_layer_params.scale; hal::Operand* scale_operand = AddFloat32ConstantOperand(model, scale); hal::Operand* zero_point_operand = AddInt32ConstantOperand(model, 0); quant_operation->input_operands = { input_operand, axis_operand, scale_operand, zero_point_operand}; quant_operation->output_operands = {output_operand}; return output_operand; } // Del a dequant operation after output_operand static hal::Operand* DelDequantOperation(hal::Model* model, hal::Operand* output_operand) { auto next_operations = GetOperandConsumers(model, output_operand); auto dequant_operation = next_operations[0]; auto dequant_output_operand = dequant_operation->output_operands[0]; auto dequant_post_operations = GetOperandConsumers(model, dequant_output_operand); for (auto operation : dequant_post_operations) { for (int i = 0; i < operation->input_operands.size(); i++) { if (dequant_output_operand == operation->input_operands[i]) { operation->input_operands[i] = output_operand; } } } RemoveOperand(model, dequant_output_operand); RemoveOperation(model, dequant_operation); return output_operand; } // Return quant operations after/before reference_operand // For example: // If graph is: // // conv0_int8 -> var -> conv3_int8 // conv1_int8 --| |--> conv4_int8 // conv2_float32 --| |--> conv5_float32 // // return {conv0_int8, conv1_int8}, if after is true. // return {conv3_int8, conv4_int8}, if after is false. static std::vector<hal::Operation*> GetQuantOpsAroundOperand( const std::vector<hal::Operation*>& operations, hal::Operand* reference_operand, bool after, const std::vector<NNAdapterOperationCode>& valid_quant_ops_type) { std::vector<hal::Operation*> target_operations; for (auto operation : operations) { if (std::find(valid_quant_ops_type.begin(), valid_quant_ops_type.end(), operation->type) == valid_quant_ops_type.end() || operation->output_operands[0]->type.precision != NNADAPTER_QUANT_INT8_SYMM_PER_LAYER) { continue; } std::vector<nnadapter::hal::Operand*> operands; if (after) { operands = operation->input_operands; } else { operands = operation->output_operands; } if (std::find(operands.begin(), operands.end(), reference_operand) != operands.end()) { target_operations.push_back(operation); } } return target_operations; } static void InsertQuant(hal::Model* model) { std::vector<NNAdapterOperationCode> valid_quant_ops_type{ NNADAPTER_CONV_2D, NNADAPTER_FULLY_CONNECTED}; std::vector<hal::Operation*> operations = SortOperationsInTopologicalOrder(model); for (auto operation : operations) { auto input_operands = operation->input_operands; if (std::find(valid_quant_ops_type.begin(), valid_quant_ops_type.end(), operation->type) == valid_quant_ops_type.end() || input_operands[0]->type.precision == NNADAPTER_FLOAT32) { continue; } if (NeedInsertQuant(model, input_operands[0])) { // Brother int8 ops share the same input. auto reference_operations = GetQuantOpsAroundOperand( operations, input_operands[0], true, valid_quant_ops_type); AddQuantOperation(model, input_operands[0], reference_operations); } } } static void DeleteDequant(hal::Model* model) { std::vector<NNAdapterOperationCode> valid_quant_ops_type{ NNADAPTER_CONV_2D, NNADAPTER_FULLY_CONNECTED}; std::vector<hal::Operation*> operations = SortOperationsInTopologicalOrder(model); for (auto operation : operations) { auto input_operands = operation->input_operands; if (std::find(valid_quant_ops_type.begin(), valid_quant_ops_type.end(), operation->type) == valid_quant_ops_type.end() || input_operands[0]->type.precision == NNADAPTER_FLOAT32) { continue; } auto output_operand = operation->output_operands[0]; if (NeedDeleteDequant(model, output_operand)) { DelDequantOperation(model, output_operand); } } } // MLU int8 conv or fc only support float32 out. static void ChangeQuantizedOpOutPrecision(hal::Model* model) { std::vector<NNAdapterOperationCode> valid_quant_ops_type{ NNADAPTER_CONV_2D, NNADAPTER_FULLY_CONNECTED}; std::vector<hal::Operation*> operations = SortOperationsInTopologicalOrder(model); for (auto operation : operations) { if (std::find(valid_quant_ops_type.begin(), valid_quant_ops_type.end(), operation->type) == valid_quant_ops_type.end()) { auto output_operand = operation->output_operands[0]; auto output_type = output_operand->type; output_type.precision = NNAdapterOperandPrecisionCode::NNADAPTER_FLOAT32; } } } void FixQuantizedOps(hal::Model* model) { InsertQuant(model); DeleteDequant(model); ChangeQuantizedOpOutPrecision(model); } } // namespace cambricon_mlu } // namespace nnadapter
38.247475
79
0.71372
[ "vector", "model" ]
74f252fb7c50e2305f084d1be3e12e3a11a4d613
4,941
cpp
C++
framework/box.cpp
MaximilianMargraf/programmiersprachen-raytracer
76436308bb3b149a7d54ac1d8ae1ab800e594103
[ "MIT" ]
null
null
null
framework/box.cpp
MaximilianMargraf/programmiersprachen-raytracer
76436308bb3b149a7d54ac1d8ae1ab800e594103
[ "MIT" ]
null
null
null
framework/box.cpp
MaximilianMargraf/programmiersprachen-raytracer
76436308bb3b149a7d54ac1d8ae1ab800e594103
[ "MIT" ]
null
null
null
#include "box.hpp" Box::Box(): Shape(), min{glm::vec3(0.0, 0.0, 0.0)}, max{glm::vec3(1.0, 1.0, 1.0)} { world_transformation_[0] = glm::vec4{1.0f, 0.0f, 0.0f, 0.0f}; world_transformation_[1] = glm::vec4{0.0f, 1.0f, 0.0f, 0.0f}; world_transformation_[2] = glm::vec4{0.0f, 0.0f, 1.0f, 0.0f}; world_transformation_[3] = glm::vec4{0.0f, 0.0f, 0.0f, 1.0f}; world_transformation_inv_ = glm::inverse(world_transformation_); } Box::Box(glm::vec3 v, glm::vec3 w): Shape(), min{v}, max{w} { float tmp = 0.0; if(max.x < min.x){ tmp = max.x; max.x = min.x; min.x = tmp; } if(max.y < min.y){ tmp = max.y; max.y = min.y; min.y = tmp; } if(max.z < min.z){ tmp = max.z; max.z = min.z; min.z = tmp; } world_transformation_[0] = glm::vec4{1.0f, 0.0f, 0.0f, 0.0f}; world_transformation_[1] = glm::vec4{0.0f, 1.0f, 0.0f, 0.0f}; world_transformation_[2] = glm::vec4{0.0f, 0.0f, 1.0f, 0.0f}; world_transformation_[3] = glm::vec4{0.0f, 0.0f, 0.0f, 1.0f}; world_transformation_inv_ = glm::inverse(world_transformation_); } Box::Box(glm::vec3 v, glm::vec3 w, std::string name, std::shared_ptr<Material> mat): Shape(name, mat), min{v}, max{w} { float tmp = 0.0; if(max.x < min.x){ tmp = max.x; max.x = min.x; min.x = tmp; } if(max.y < min.y){ tmp = max.y; max.y = min.y; min.y = tmp; } if(max.z < min.z){ tmp = max.z; max.z = min.z; min.z = tmp; } world_transformation_[0] = glm::vec4{1.0f, 0.0f, 0.0f, 0.0f}; world_transformation_[1] = glm::vec4{0.0f, 1.0f, 0.0f, 0.0f}; world_transformation_[2] = glm::vec4{0.0f, 0.0f, 1.0f, 0.0f}; world_transformation_[3] = glm::vec4{0.0f, 0.0f, 0.0f, 1.0f}; world_transformation_inv_ = glm::inverse(world_transformation_); } Box::~Box(){} glm::vec3 Box::getMin() const{ return min; } glm::vec3 Box::getMax() const{ return max; } float Box::area() const{ float length = abs(max.x - min.x); float width = abs(max.y - min.y); float height = abs(max.z - min.y); return 2 * length * width + 2 * length * height + 2 * width * height; } float Box::volume() const{ float length = abs(max.x - min.x); float width = abs(max.y - min.y); float height = abs(max.z - min.z); return length * width * height; } std::ostream& Box::print(std::ostream& os) const{ Shape::print(os); os << "Min: "<<min.x<<", "<<min.y<<", "<<min.z<< "\nMax: "<<max.x<<", "<<max.y<<", "<<max.z<<"\n"; return os; } HitPoint Box::intersect(Ray const& r){ HitPoint hit; Ray ray = transformRay(world_transformation_inv_, r); float tmin = -INFINITY, tmax = INFINITY; //check if the ray is between the x boundaries float t1 = (min.x - ray.origin.x)/ray.direction.x; float t2 = (max.x - ray.origin.x)/ray.direction.x; tmin = std::max(tmin,std::min(t1,t2)); tmax = std::min(tmax,std::max(t1,t2)); // check if ray is between y boundaries t1 = (min.y - ray.origin.y)/ray.direction.y; t2 = (max.y - ray.origin.y)/ray.direction.y; tmin = std::max(tmin,std::min(t1,t2)); tmax = std::min(tmax,std::max(t1,t2)); // check if ray is between z boundaries t1 = (min.z - ray.origin.z)/ray.direction.z; t2 = (max.z - ray.origin.z)/ray.direction.z; tmin = std::max(tmin,std::min(t1,t2)); tmax = std::min(tmax,std::max(t1,t2)); // if the box was intersected, calculate everything needed if (tmax > std::max(0.0F, tmin)) { hit.distance = sqrt(tmin*tmin*( ray.direction.x*ray.direction.x + ray.direction.y*ray.direction.y + ray.direction.z*ray.direction.z )); hit.intersection_point = this->calc_intersection_point(ray, hit.distance); hit.intersected = true; hit.material = material; hit.normal = this->calc_n(hit); hit.name = name_; hit.intersection_point = glm::vec3(world_transformation_* glm::vec4(hit.intersection_point,1.0)); hit.normal = glm::normalize(glm::vec3( glm::transpose(world_transformation_inv_)*glm::vec4(hit.normal, 0.0))); hit.direction = glm::normalize(r.direction); } return hit; } void Box::translate(glm::vec3 const& translation){ min += translation; max += translation; } void Box::scale(glm::vec3 const& factor){ } std::ostream& operator<<(std::ostream& os, Box const& s){ s.print(os); return os; } glm::vec3 Box::calc_intersection_point(Ray const& ray, float distance){ glm::vec3 s_pt{ray.origin + ray.direction*distance}; return s_pt; } // get the correct normal depending on which size was hit glm::vec3 Box::calc_n(HitPoint const& hit){ auto surface_pt = hit.intersection_point; if(surface_pt.x == Approx(min.x)) { return glm::vec3{-1.0,0.0,0.0}; } if(surface_pt.y == Approx(min.y)) { return glm::vec3{0.0,-1.0,0.0}; } if(surface_pt.z == Approx(min.z)) { return glm::vec3{0.0,0.0,-1.0}; } if(surface_pt.x == Approx(max.x)) { return glm::vec3{1.0,0.0,0.0}; } if(surface_pt.y == Approx(max.y)) { return glm::vec3{0.0,1.0,0.0}; } if(surface_pt.z == Approx(max.z)) { return glm::vec3{0.0,0.0,1.0}; } }
25.338462
84
0.626189
[ "shape" ]
74f45ba8e6efbb0249ab93c850a9ea49ed96e7d7
606
hpp
C++
libs/options/include/fcppt/options/optional_short_name_fwd.hpp
freundlich/fcppt
17df1b1ad08bf2435f6902d5465e3bc3fe5e3022
[ "BSL-1.0" ]
13
2015-02-21T18:35:14.000Z
2019-12-29T14:08:29.000Z
libs/options/include/fcppt/options/optional_short_name_fwd.hpp
cpreh/fcppt
17df1b1ad08bf2435f6902d5465e3bc3fe5e3022
[ "BSL-1.0" ]
5
2016-08-27T07:35:47.000Z
2019-04-21T10:55:34.000Z
libs/options/include/fcppt/options/optional_short_name_fwd.hpp
freundlich/fcppt
17df1b1ad08bf2435f6902d5465e3bc3fe5e3022
[ "BSL-1.0" ]
8
2015-01-10T09:22:37.000Z
2019-12-01T08:31:12.000Z
// Copyright Carl Philipp Reh 2009 - 2021. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef FCPPT_OPTIONS_OPTIONAL_SHORT_NAME_FWD_HPP_INCLUDED #define FCPPT_OPTIONS_OPTIONAL_SHORT_NAME_FWD_HPP_INCLUDED #include <fcppt/optional/object_fwd.hpp> #include <fcppt/options/short_name_fwd.hpp> namespace fcppt::options { /** \brief An optional short name. \ingroup fcpptoptions */ using optional_short_name = fcppt::optional::object<fcppt::options::short_name>; } #endif
25.25
80
0.765677
[ "object" ]
74f517ea97fd71909179c1f297340189c035f316
2,993
hpp
C++
include/codegen/include/System/Runtime/Remoting/Messaging/ObjRefSurrogate.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
1
2021-11-12T09:29:31.000Z
2021-11-12T09:29:31.000Z
include/codegen/include/System/Runtime/Remoting/Messaging/ObjRefSurrogate.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
null
null
null
include/codegen/include/System/Runtime/Remoting/Messaging/ObjRefSurrogate.hpp
Futuremappermydud/Naluluna-Modifier-Quest
bfda34370764b275d90324b3879f1a429a10a873
[ "MIT" ]
2
2021-10-03T02:14:20.000Z
2021-11-12T09:29:36.000Z
// Autogenerated from CppHeaderCreator on 7/27/2020 3:09:50 PM // Created by Sc2ad // ========================================================================= #pragma once #pragma pack(push, 8) // Begin includes #include "utils/typedefs.h" // Including type: System.Object #include "System/Object.hpp" // Including type: System.Runtime.Serialization.ISerializationSurrogate #include "System/Runtime/Serialization/ISerializationSurrogate.hpp" #include "utils/il2cpp-utils.hpp" // Completed includes // Begin forward declares // Forward declaring namespace: System::Runtime::Serialization namespace System::Runtime::Serialization { // Forward declaring type: SerializationInfo class SerializationInfo; // Forward declaring type: StreamingContext struct StreamingContext; // Forward declaring type: ISurrogateSelector class ISurrogateSelector; } // Completed forward declares // Type namespace: System.Runtime.Remoting.Messaging namespace System::Runtime::Remoting::Messaging { // Autogenerated type: System.Runtime.Remoting.Messaging.ObjRefSurrogate class ObjRefSurrogate : public ::Il2CppObject, public System::Runtime::Serialization::ISerializationSurrogate { public: // public System.Void GetObjectData(System.Object obj, System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext sc) // Offset: 0xDFA4A4 // Implemented from: System.Runtime.Serialization.ISerializationSurrogate // Base method: System.Void ISerializationSurrogate::GetObjectData(System.Object obj, System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext sc) void GetObjectData(::Il2CppObject* obj, System::Runtime::Serialization::SerializationInfo* si, System::Runtime::Serialization::StreamingContext sc); // public System.Object SetObjectData(System.Object obj, System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext sc, System.Runtime.Serialization.ISurrogateSelector selector) // Offset: 0xDFA5A8 // Implemented from: System.Runtime.Serialization.ISerializationSurrogate // Base method: System.Object ISerializationSurrogate::SetObjectData(System.Object obj, System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext sc, System.Runtime.Serialization.ISurrogateSelector selector) ::Il2CppObject* SetObjectData(::Il2CppObject* obj, System::Runtime::Serialization::SerializationInfo* si, System::Runtime::Serialization::StreamingContext sc, System::Runtime::Serialization::ISurrogateSelector* selector); // public System.Void .ctor() // Offset: 0xDFA614 // Implemented from: System.Object // Base method: System.Void Object::.ctor() static ObjRefSurrogate* New_ctor(); }; // System.Runtime.Remoting.Messaging.ObjRefSurrogate } DEFINE_IL2CPP_ARG_TYPE(System::Runtime::Remoting::Messaging::ObjRefSurrogate*, "System.Runtime.Remoting.Messaging", "ObjRefSurrogate"); #pragma pack(pop)
61.081633
250
0.777147
[ "object" ]
74f569687be00eee9709b48c691ffcca5a2d5130
669
cc
C++
src/codeforces/accepted/567a.cc
cbarnson/UVa
0dd73fae656613e28b5aaf5880c5dad529316270
[ "Unlicense", "MIT" ]
2
2019-09-07T17:00:26.000Z
2020-08-05T02:08:35.000Z
src/codeforces/accepted/567a.cc
cbarnson/UVa
0dd73fae656613e28b5aaf5880c5dad529316270
[ "Unlicense", "MIT" ]
null
null
null
src/codeforces/accepted/567a.cc
cbarnson/UVa
0dd73fae656613e28b5aaf5880c5dad529316270
[ "Unlicense", "MIT" ]
null
null
null
// Problem # : 567a // Created on : 2018-10-29 14:09:19 #include <bits/stdc++.h> #define FR(i, n) for (int i = 0; i < (int)(n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vi A(n); for (auto &x : A) cin >> x; FR(i, n) { int x = A[i]; int mi = (i == 0 ? abs(A[i + 1] - x) : (i == n - 1 ? abs(A[i - 1] - x) : min(abs(A[i - 1] - x), abs(A[i + 1] - x)))); int mx = max(abs(A.front() - x), abs(A.back() - x)); cout << mi << " " << mx << endl; } }
21.580645
76
0.45142
[ "vector" ]
74fcd70902c3ed71eb02e494fe9a7c515fd61c63
5,466
cpp
C++
tests/src/containers/actions_test.cpp
BlurringShadow/stdsharp-utility
320ed15d660b4e23dfa42ed2ed5857e97a0513de
[ "Unlicense" ]
null
null
null
tests/src/containers/actions_test.cpp
BlurringShadow/stdsharp-utility
320ed15d660b4e23dfa42ed2ed5857e97a0513de
[ "Unlicense" ]
null
null
null
tests/src/containers/actions_test.cpp
BlurringShadow/stdsharp-utility
320ed15d660b4e23dfa42ed2ed5857e97a0513de
[ "Unlicense" ]
null
null
null
#include "containers/actions_test.h" #include "containers/actions.h" #include "type_traits/object.h" namespace stdsharp::test::containers::actions { using namespace std; using namespace std::ranges; using namespace boost::ut; using namespace bdd; using namespace stdsharp::functional; using namespace stdsharp::ranges; using namespace stdsharp::containers; using namespace stdsharp::containers::actions; namespace { template<typename T> using dummy_predicate_t = bool(const T&); template<typename T> concept vec_req = requires( vector<T> v, decltype(v.cbegin()) iter, T value, dummy_predicate_t<T> dummy_predicate // ) { stdsharp::containers::actions::emplace(v, iter, std::move(value)); stdsharp::containers::actions::emplace_back(v, std::move(value)); stdsharp::containers::actions::emplace_front(v, std::move(value)); // TODO: MSVC bug stdsharp::containers::actions::erase_fn{}(v, value); stdsharp::containers::actions::erase(v, iter); stdsharp::containers::actions::erase(v, iter, iter); stdsharp::containers::actions::erase_if(v, dummy_predicate); stdsharp::containers::actions::pop_front(v); stdsharp::containers::actions::pop_back(v); stdsharp::containers::actions::resize(v, 0); }; template<typename T> concept set_req = requires( set<T> v, decltype(v.cbegin()) iter, T value, dummy_predicate_t<T> dummy_predicate // ) { stdsharp::containers::actions::emplace(v, std::move(value)); stdsharp::containers::actions::erase(v, value); stdsharp::containers::actions::erase(v, iter); stdsharp::containers::actions::erase(v, iter, iter); stdsharp::containers::actions::erase_if(v, dummy_predicate); }; template<typename T> concept unordered_map_req = requires( unordered_map<T, int> v, decltype(v.cbegin()) iter, T value, dummy_predicate_t<pair<const T, int>> dummy_predicate // ) { // TODO: MSVC bug stdsharp::containers::actions::emplace_fn{}(v, std::move(value), 0); stdsharp::containers::actions::erase(v, value); stdsharp::containers::actions::erase(v, iter); stdsharp::containers::actions::erase(v, iter, iter); stdsharp::containers::actions::erase_if(v, dummy_predicate); }; void vector_actions_test() { feature("vector actions") = []<typename T>(const type_identity<T>) { constexpr auto v = vec_req<T>; println(fmt::format("current type {}", reflection::type_name<T>())); static_expect<v>(); } | tuple{type_identity<int>{}, type_identity<unique_ptr<float>>{}}; struct range_as_iterators_params { vector<int> initial_v_list; initializer_list<int> expected_v_list; }; // clang-format off feature("range as iterators") = [](range_as_iterators_params params) // clang-format on { auto& v_list = params.initial_v_list; const auto unique_op = [&v_list = v_list] { stdsharp::containers::actions::erase( v_list, v_list | decompose_to<>(rng_as_iters) | ::ranges::unique, v_list.cend() // ); }; println(fmt::format("current value: {}", v_list)); unique_op(); println(fmt::format("after first unique operation, values are: {}", v_list)); v_list | decompose_to<>(rng_as_iters) | std::ranges::sort; println(fmt::format("after sort, values are: {}", v_list)); unique_op(); expect(std::ranges::equal(params.expected_v_list, v_list)) << // fmt::format("actual values are: {}", v_list); // clang-format off } | tuple{ range_as_iterators_params{{1, 2, 1, 1, 3, 3, 3, 4, 5, 4}, {1, 2, 3, 4, 5}} }; // clang-format on } void set_actions_test() { feature("set actions") = []<typename T>(const type_identity<T>) { println(fmt::format("current type {}", reflection::type_name<T>())); static_expect<set_req<T>>(); } | tuple{type_identity<int>{}}; } void unordered_map_actions_test() { feature("unordered map actions") = []<typename T>(const type_identity<T>) { constexpr auto v = unordered_map_req<T>; println(fmt::format("current type {}", reflection::type_name<T>())); static_expect<v>(); } | tuple{type_identity<int>{}, type_identity<unique_ptr<long>>{}}; } } boost::ut::suite& actions_test() { static boost::ut::suite suite = [] { vector_actions_test(); set_actions_test(); unordered_map_actions_test(); }; return suite; } }
34.594937
99
0.536956
[ "object", "vector" ]
2d041ba2e18c14c3838a79a11fcda8a7e56456b8
157,626
cpp
C++
lpg2/src/CSharpAction.cpp
kuafuwang/LPG2
5cda43c109633d951facbeac361e060dd6d59dcd
[ "MIT" ]
2
2021-08-05T12:16:59.000Z
2021-08-05T13:09:19.000Z
lpg2/src/CSharpAction.cpp
kuafuwang/LPG2
5cda43c109633d951facbeac361e060dd6d59dcd
[ "MIT" ]
null
null
null
lpg2/src/CSharpAction.cpp
kuafuwang/LPG2
5cda43c109633d951facbeac361e060dd6d59dcd
[ "MIT" ]
null
null
null
#include "CTC.h" #include "NTC.h" #include "CSharpAction.h" #include <map> #include <string> #include "LCA.h" #include "TTC.h" // // // void CSharpAction::ExpandExportMacro(TextBuffer *buffer, SimpleMacroSymbol *simple_macro) { buffer -> Put(option -> exp_type); buffer -> Put("."); buffer -> Put(option -> exp_prefix); buffer -> Put(simple_macro -> Name() + 2); // skip initial escape and '_' characters buffer -> Put(option -> exp_suffix); } // // // void CSharpAction::GenerateDefaultTitle(Tuple<ActionBlockElement> &notice_actions) { // // If one or more notice blocks were specified, process and // print the notice at the beginning of each action file. // if (notice_actions.Length() > 0) { for (int i = 0; i < notice_actions.Length(); i++) ProcessActionBlock(notice_actions[i]); TextBuffer *buffer = notice_actions[0].buffer; // get proper buffer from first action buffer -> Put("\n"); action_blocks -> PutNotice(*buffer); } // // Issue the package state // TextBuffer *buffer = (option -> DefaultBlock() -> Buffer() ? option -> DefaultBlock() -> Buffer() : option -> DefaultBlock() -> ActionfileSymbol() -> InitialHeadersBuffer()); if (*option -> package != '\0') { buffer -> Put("namespace "); buffer -> Put(option -> package); buffer -> Put("\n{\n\n"); } if (option -> automatic_ast && strcmp(option -> package, option -> ast_package) != 0 && *option -> ast_package != '\0') { buffer -> Put("using "); buffer -> Put(option -> ast_package); buffer -> Put(";\n"); } return; } // // First construct a file for this type. Write the title information to its header // buffer and return the file. // ActionFileSymbol *CSharpAction::GenerateTitle(ActionFileLookupTable &ast_filename_table, Tuple<ActionBlockElement> &notice_actions, const char *type_name, bool needs_environment) { const char* filetype = option->GetFileTypeWithLanguage(); int filename_length = strlen(option -> ast_directory_prefix) + strlen(type_name) + strlen(filetype); char *filename = new char[filename_length + 1]; strcpy(filename, option -> ast_directory_prefix); strcat(filename, type_name); strcat(filename, filetype); ActionFileSymbol *file_symbol = ast_filename_table.FindOrInsertName(filename, filename_length); TextBuffer *buffer = file_symbol -> InitialHeadersBuffer(); if (notice_actions.Length() > 0) { // // Copy each notice action block, in turn, into a new // ActionBLockElement; redirect its output to this buffer // and process it. // for (int i = 0; i < notice_actions.Length(); i++) { ActionBlockElement action = notice_actions[i]; action.buffer = buffer; ProcessActionBlock(action); } buffer -> Put("\n"); } if (*option -> ast_package != '\0') { buffer -> Put("namespace "); buffer -> Put(option -> ast_package); buffer -> Put("\n{\n\n"); } if (needs_environment && strcmp(option -> ast_package, option -> package) != 0 && *option -> package != '\0') { buffer -> Put("using "); buffer -> Put(option -> package); buffer -> Put(";\n"); } delete [] filename; return file_symbol; } ActionFileSymbol *CSharpAction::GenerateTitleAndGlobals(ActionFileLookupTable &ast_filename_table, Tuple<ActionBlockElement> &notice_actions, const char *type_name, bool needs_environment) { ActionFileSymbol *file_symbol = GenerateTitle(ast_filename_table, notice_actions, type_name, needs_environment); for (int i = 0; i < grammar -> parser.global_blocks.Length(); i++) { LexStream::TokenIndex block_token = grammar -> parser.global_blocks[i]; BlockSymbol *block = lex_stream -> GetBlockSymbol(block_token); if (! option -> ActionBlocks().IsIgnoredBlock(block -> BlockBegin(), block -> BlockBeginLength())) { ActionBlockElement action; action.rule_number = 0; action.location = ActionBlockElement::INITIALIZE; // does not matter - block must be default block... action.block_token = block_token; action.buffer = file_symbol -> InitialHeadersBuffer(); ProcessActionBlock(action); action.buffer -> Put("\n"); } } return file_symbol; } // // // void CSharpAction::GenerateEnvironmentDeclaration(TextBuffer &ast_buffer, const char *indentation) { ast_buffer.Put(indentation); ast_buffer.Put(" private "); ast_buffer.Put(option -> action_type); ast_buffer.Put(" environment;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(option -> action_type); ast_buffer.Put(" getEnvironment() { return environment; }\n\n"); } void CSharpAction::ProcessCodeActionEnd() { if (*option->package != '\0') { auto ast_filename_symbol = option->DefaultBlock()->ActionfileSymbol(); TextBuffer& ast_buffer = *(ast_filename_symbol->FinalTrailersBuffer()); ast_buffer.Put("}"); } } void CSharpAction::ProcessAstActions(Tuple<ActionBlockElement>& actions, Tuple<ActionBlockElement>& notice_actions, Tuple<ActionBlockElement>& initial_actions, Array<const char*>& typestring, Tuple< Tuple<ProcessedRuleElement> >& processed_rule_map, SymbolLookupTable& classname_set, Tuple<ClassnameElement>& classname) { ActionFileLookupTable ast_filename_table(4096); auto ast_filename_symbol = option->DefaultBlock()->ActionfileSymbol(); TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); Array<RuleAllocationElement> rule_allocation_map(grammar->num_rules + 1); // // Map each rule into the set of action blocks that is associated with it. // Array< Tuple<ActionBlockElement> > rule_action_map(grammar->num_rules + 1); { for (int i = 0; i < actions.Length(); i++) rule_action_map[actions[i].rule_number].Next() = actions[i]; } // // For each nonterminal A, compute the set of rules that A produces. // BoundedArray< Tuple<int> > global_map(grammar->num_terminals + 1, grammar->num_symbols); { for (int rule_no = grammar->FirstRule(); rule_no <= grammar->LastRule(); rule_no++) { int lhs = grammar->rules[rule_no].lhs; global_map[lhs].Next() = rule_no; } } TTC ttc(global_map, processed_rule_map); // // Compute the interface depences. // assert(grammar->Get_ast_token_interface() == grammar->num_symbols + 1); BoundedArray< Tuple<int> > extension_of(grammar->num_terminals + 1, grammar->Get_ast_token_interface()); BoundedArray<BitSetWithOffset> extension_set(grammar->num_terminals + 1, grammar->Get_ast_token_interface()); for (int nt = extension_set.Lbound(); nt <= extension_set.Ubound(); nt++) extension_set[nt].Initialize(extension_set.Size() + 1, extension_set.Lbound() - 1); for (int rule_no = grammar->FirstRule(); rule_no <= grammar->LastRule(); rule_no++) { int lhs = grammar->rules[rule_no].lhs; if (grammar->RhsSize(rule_no) == 1) { if (lhs != grammar->accept_image) { int symbol = grammar->rhs_sym[grammar->FirstRhsIndex(rule_no)]; if (grammar->IsNonTerminal(symbol)) { if (!extension_set[symbol][lhs]) { int source_index = grammar->rules[rule_no].source_index, array_index = grammar->parser.rules[source_index].array_element_type_index; // // If the left-hand side is not an array(list) then it // may extend the right-hand side // if (array_index == 0) { extension_set[symbol].AddElement(lhs); extension_of[symbol].Next() = lhs; } } } else { if (!extension_set[lhs][grammar->Get_ast_token_interface()]) { int source_index = grammar->rules[rule_no].source_index, array_index = grammar->parser.rules[source_index].array_element_type_index; // // If the left-hand side is not an array(list) then it // may extend the right-hand side // if (array_index == 0) { extension_set[lhs].AddElement(grammar->Get_ast_token_interface()); extension_of[lhs].Next() = grammar->Get_ast_token_interface(); } } } } } } LCA lca(extension_of); CompleteClassnameInfo(lca, ttc, global_map, typestring, processed_rule_map, classname_set, classname, rule_allocation_map); // // Compute a map from each interface into the (transitive closure) // of the set of classes that can implement in. // (CTC: class transitive closure) // CTC ctc(classname, typestring, extension_of); BoundedArray< Tuple<int> >& interface_map = ctc.GetInterfaceMap(); // // (NTC: Nonterminals that can generate null ASTs.) // // A (user-specified) NULL ast is generated for a rule that the user explicitly // associates with the null classname. For example: // // A$ ::= x y z // // Note that in order to qualify the rule in question must have either a single // terminal on its right-hand side or contain more than one symbol on its right-hand // side. When the right-hand side of a rule contain no symbol then the null ast must // be generated for that rule. When the right-hand side of a rule consist of a single // nonterminal then no AST needs be generated for it. Instead, the left-hand side // nonterminal must inherit the ast that was produced for the right-hand side nonterminal. // (Otherwise, we would end up with a dangling pointer.) // Array< bool > user_specified_null_ast(grammar->num_rules + 1, false); { for (int rule_no = grammar->FirstRule(); rule_no <= grammar->LastRule(); rule_no++) { int source_index = grammar->rules[rule_no].source_index, classname_index = grammar->parser.rules[source_index].classname_index; if (lex_stream->NameStringLength(classname_index) == 1) // The classname is the null macro? { user_specified_null_ast[rule_no] = (grammar->RhsSize(rule_no) > 1 || (grammar->RhsSize(rule_no) == 1 && grammar->IsTerminal(grammar->rhs_sym[grammar->FirstRhsIndex(rule_no)]))); } } } NTC ntc(global_map, user_specified_null_ast, grammar); // // First process the root class, the list class, and the Token class. // { if (option->automatic_ast == Option::NESTED) { GenerateAstType(ast_filename_symbol, " ", option->ast_type); GenerateAbstractAstListType(ast_filename_symbol, " ", abstract_ast_list_classname); GenerateAstTokenType(ntc, ast_filename_symbol, " ", grammar->Get_ast_token_classname()); } else { assert(option->automatic_ast == Option::TOPLEVEL); ActionFileSymbol* file_symbol = GenerateTitleAndGlobals(ast_filename_table, notice_actions, option->ast_type, (grammar->parser.ast_blocks.Length() > 0)); GenerateAstType(file_symbol, "", option->ast_type); file_symbol->Flush(); file_symbol = GenerateTitleAndGlobals(ast_filename_table, notice_actions, abstract_ast_list_classname, false); GenerateAbstractAstListType(file_symbol, "", abstract_ast_list_classname); file_symbol->Flush(); file_symbol = GenerateTitleAndGlobals(ast_filename_table, notice_actions, grammar->Get_ast_token_classname(), false); GenerateAstTokenType(ntc, file_symbol, "", grammar->Get_ast_token_classname()); file_symbol->Flush(); } } // // Generate the token interface // { astRootInterfaceName.append("IRootFor"); astRootInterfaceName += option->action_type; if (option->automatic_ast == Option::NESTED) GenerateAstRootInterface( ast_filename_symbol, (char*)" "); else { ActionFileSymbol* file_symbol = GenerateTitleAndGlobals(ast_filename_table, notice_actions, astRootInterfaceName.c_str(), false); GenerateAstRootInterface( file_symbol, (char*)" "); file_symbol->Flush(); } } // // Generate the token interface // { char* ast_token_interfacename = new char[strlen(grammar->Get_ast_token_classname()) + 2]; strcpy(ast_token_interfacename, "I"); strcat(ast_token_interfacename, grammar->Get_ast_token_classname()); if (option->automatic_ast == Option::NESTED) GenerateInterface(true /* is token */, ast_filename_symbol, (char*)" ", ast_token_interfacename, extension_of[grammar->Get_ast_token_interface()], interface_map[grammar->Get_ast_token_interface()], classname); else { ActionFileSymbol* file_symbol = GenerateTitleAndGlobals(ast_filename_table, notice_actions, ast_token_interfacename, false); GenerateInterface(true /* is token */, file_symbol, (char*)"", ast_token_interfacename, extension_of[grammar->Get_ast_token_interface()], interface_map[grammar->Get_ast_token_interface()], classname); file_symbol->Flush(); } delete[] ast_token_interfacename; } // // Generate the nonterminal interfaces. // for (int symbol = grammar->num_terminals + 1; symbol <= grammar->num_symbols; symbol++) { if (symbol != grammar->accept_image) { char* interface_name = new char[strlen(grammar->RetrieveString(symbol)) + 2]; strcpy(interface_name, "I"); strcat(interface_name, grammar->RetrieveString(symbol)); if (option->automatic_ast == Option::NESTED) GenerateInterface(ctc.IsTerminalClass(symbol), ast_filename_symbol, (char*)" ", interface_name, extension_of[symbol], interface_map[symbol], classname); else { ActionFileSymbol* file_symbol = extension_of[symbol].Length() > 0 ? GenerateTitle(ast_filename_table, notice_actions, interface_name, false) : GenerateTitleAndGlobals(ast_filename_table, notice_actions, interface_name, false); GenerateInterface(ctc.IsTerminalClass(symbol), file_symbol, (char*)"", interface_name, extension_of[symbol], interface_map[symbol], classname); file_symbol->Flush(); } delete[] interface_name; } } // // generate the rule classes. // for (int i = 0; i < classname.Length(); i++) { // // No class is generated for rules that are asoociated with the null classname. // if (IsNullClassname(classname[i])) continue; // // Figure out whether or not, classname[i] needs the environment // and process it if it is a List class. // Tuple<int>& rule = classname[i].rule; if (classname[i].array_element_type_symbol != NULL) { for (int k = 0; k < rule.Length(); k++) { int rule_no = rule[k]; classname[i].rhs_type_index.Reset(); // expected by ProcessAstRule classname[i].symbol_set.Reset(); // expected by ProcessAstRule ProcessAstRule(classname[i], rule_no, processed_rule_map[rule_no]); classname[i].needs_environment = false; } } else { if (rule.Length() == 1) { int rule_no = rule[0]; Tuple<ActionBlockElement>& actions = rule_action_map[rule_no]; classname[i].needs_environment = (actions.Length() > 0); } else { assert(classname[i].specified_name != classname[i].real_name); // a classname was specified? for (int k = 0; k < rule.Length(); k++) { int rule_no = rule[k]; rule_allocation_map[rule_no].name = classname[i].real_name; Tuple<ActionBlockElement>& actions = rule_action_map[rule_no]; classname[i].needs_environment = classname[i].needs_environment || (actions.Length() > 0); } } } // // If the classes are to be generated as top-level classes, we first obtain // a file for this class. // ActionFileSymbol* file_symbol = (option->automatic_ast == Option::NESTED ? NULL : GenerateTitleAndGlobals(ast_filename_table, notice_actions, classname[i].real_name, classname[i].needs_environment)); // // // if (classname[i].array_element_type_symbol != NULL) { // // Generate the class // GenerateListClass(ctc, ntc, (option->automatic_ast == Option::NESTED ? ast_filename_symbol : file_symbol), (option->automatic_ast == Option::NESTED ? (char*)" " : (char*)""), classname[i], typestring); for (int j = 0; j < classname[i].special_arrays.Length(); j++) { // // Finish up the previous class we were procesing // if (option->automatic_ast == Option::NESTED) // Generate Class Closer ast_buffer.Put(" }\n\n"); else { file_symbol->BodyBuffer()->Put("}\n\n"); file_symbol->Flush(); } // // Process the new special array class. // file_symbol = (option->automatic_ast == Option::NESTED ? NULL : GenerateTitleAndGlobals(ast_filename_table, notice_actions, classname[i].special_arrays[j].name, true)); // needs_environment GenerateListExtensionClass(ctc, ntc, (option->automatic_ast == Option::NESTED ? ast_filename_symbol : file_symbol), (option->automatic_ast == Option::NESTED ? (char*)" " : (char*)""), classname[i].special_arrays[j], classname[i], typestring); // // Generate info for the allocation of rules associated with this class // Tuple<int>& special_rule = classname[i].special_arrays[j].rules; for (int k = 0; k < special_rule.Length(); k++) { int rule_no = special_rule[k]; Tuple<ActionBlockElement>& actions = rule_action_map[rule_no]; if (file_symbol != NULL) // possible when option -> automatic_ast == Option::TOPLEVEL { for (int l = 0; l < actions.Length(); l++) actions[l].buffer = file_symbol->BodyBuffer(); } rule_allocation_map[rule_no].needs_environment = true; ProcessCodeActions(actions, typestring, processed_rule_map); } } } else { if (rule.Length() == 1) { int rule_no = rule[0]; Tuple<ActionBlockElement>& actions = rule_action_map[rule_no]; rule_allocation_map[rule_no].needs_environment = classname[i].needs_environment; GenerateRuleClass(ctc, ntc, (option->automatic_ast == Option::NESTED ? ast_filename_symbol : file_symbol), (option->automatic_ast == Option::NESTED ? (char*)" " : (char*)""), classname[i], typestring); if (file_symbol != NULL) // option -> automatic_ast == Option::TOPLEVEL { for (int j = 0; j < actions.Length(); j++) actions[j].buffer = file_symbol->BodyBuffer(); } ProcessCodeActions(actions, typestring, processed_rule_map); } else { assert(classname[i].specified_name != classname[i].real_name); // a classname was specified? if (classname[i].is_terminal_class) GenerateTerminalMergedClass(ntc, (option->automatic_ast == Option::NESTED ? ast_filename_symbol : file_symbol), (option->automatic_ast == Option::NESTED ? (char*)" " : (char*)""), classname[i], typestring); else GenerateMergedClass(ctc, ntc, (option->automatic_ast == Option::NESTED ? ast_filename_symbol : file_symbol), (option->automatic_ast == Option::NESTED ? (char*)" " : (char*)""), classname[i], processed_rule_map, typestring); for (int k = 0; k < rule.Length(); k++) { int rule_no = rule[k]; rule_allocation_map[rule_no].needs_environment = classname[i].needs_environment; Tuple<ActionBlockElement>& actions = rule_action_map[rule_no]; if (file_symbol != NULL) // possible when option -> automatic_ast == Option::TOPLEVEL { for (int j = 0; j < actions.Length(); j++) actions[j].buffer = file_symbol->BodyBuffer(); } ProcessCodeActions(actions, typestring, processed_rule_map); } } } if (option->automatic_ast == Option::NESTED) // Generate Class Closer ast_buffer.Put(" }\n\n"); else { file_symbol->BodyBuffer()->Put("}\n\n"); file_symbol->Flush(); } } // // // SymbolLookupTable type_set; type_set.FindOrInsertName(grammar->Get_ast_token_classname(), strlen(grammar->Get_ast_token_classname())); { for (int i = 0; i < classname.Length(); i++) { // // No class is generated for rules that are associated with the null classname. // if (!IsNullClassname(classname[i])) { // // Note that it is CRUCIAL that the special array names be added // to the type_set prior to the base array. Since they are subclasses // of the base array, when visiting a generic AST node, we need to check // first whether or not it is a special array before we check if it the base. // for (int k = 0; k < classname[i].special_arrays.Length(); k++) type_set.FindOrInsertName(classname[i].special_arrays[k].name, strlen(classname[i].special_arrays[k].name)); type_set.FindOrInsertName(classname[i].real_name, strlen(classname[i].real_name)); } } } // // Generate the visitor interfaces and Abstract classes that implements // the visitors. // { const char* visitor_type = option->visitor_type, * argument = "Argument", * result = "Result", * abstract = "Abstract"; char* argument_visitor_type = new char[strlen(argument) + strlen(visitor_type) + 1], * result_visitor_type = new char[strlen(result) + strlen(visitor_type) + 1], * result_argument_visitor_type = new char[strlen(result) + strlen(argument) + strlen(visitor_type) + 1], * abstract_visitor_type = new char[strlen(abstract) + strlen(visitor_type) + 1], * abstract_result_visitor_type = new char[strlen(abstract) + strlen(result) + strlen(visitor_type) + 1]; strcpy(argument_visitor_type, argument); strcat(argument_visitor_type, visitor_type); strcpy(result_visitor_type, result); strcat(result_visitor_type, visitor_type); strcpy(result_argument_visitor_type, result); strcat(result_argument_visitor_type, argument); strcat(result_argument_visitor_type, visitor_type); strcpy(abstract_visitor_type, abstract); strcat(abstract_visitor_type, visitor_type); strcpy(abstract_result_visitor_type, abstract); strcat(abstract_result_visitor_type, result); strcat(abstract_result_visitor_type, visitor_type); if (option->visitor == Option::DEFAULT) { if (option->automatic_ast == Option::NESTED) { GenerateSimpleVisitorInterface(ast_filename_symbol, " ", visitor_type, type_set); GenerateArgumentVisitorInterface(ast_filename_symbol, " ", argument_visitor_type, type_set); GenerateResultVisitorInterface(ast_filename_symbol, " ", result_visitor_type, type_set); GenerateResultArgumentVisitorInterface(ast_filename_symbol, " ", result_argument_visitor_type, type_set); GenerateNoResultVisitorAbstractClass(ast_filename_symbol, " ", abstract_visitor_type, type_set); GenerateResultVisitorAbstractClass(ast_filename_symbol, " ", abstract_result_visitor_type, type_set); } else { ActionFileSymbol* file_symbol = GenerateTitle(ast_filename_table, notice_actions, visitor_type, false); GenerateSimpleVisitorInterface(file_symbol, "", visitor_type, type_set); file_symbol->Flush(); file_symbol = GenerateTitle(ast_filename_table, notice_actions, argument_visitor_type, false); GenerateArgumentVisitorInterface(file_symbol, "", argument_visitor_type, type_set); file_symbol->Flush(); file_symbol = GenerateTitle(ast_filename_table, notice_actions, result_visitor_type, false); GenerateResultVisitorInterface(file_symbol, "", result_visitor_type, type_set); file_symbol->Flush(); file_symbol = GenerateTitle(ast_filename_table, notice_actions, result_argument_visitor_type, false); GenerateResultArgumentVisitorInterface(file_symbol, "", result_argument_visitor_type, type_set); file_symbol->Flush(); file_symbol = GenerateTitle(ast_filename_table, notice_actions, abstract_visitor_type, false); GenerateNoResultVisitorAbstractClass(file_symbol, "", abstract_visitor_type, type_set); file_symbol->Flush(); file_symbol = GenerateTitle(ast_filename_table, notice_actions, abstract_result_visitor_type, false); GenerateResultVisitorAbstractClass(file_symbol, "", abstract_result_visitor_type, type_set); file_symbol->Flush(); } } else if (option->visitor == Option::PREORDER) { if (option->automatic_ast == Option::NESTED) { GeneratePreorderVisitorInterface(ast_filename_symbol, " ", visitor_type, type_set); GeneratePreorderVisitorAbstractClass(ast_filename_symbol, " ", abstract_visitor_type, type_set); } else { ActionFileSymbol* file_symbol = GenerateTitleAndGlobals(ast_filename_table, notice_actions, visitor_type, false); GeneratePreorderVisitorInterface(file_symbol, "", visitor_type, type_set); file_symbol->Flush(); file_symbol = GenerateTitleAndGlobals(ast_filename_table, notice_actions, abstract_visitor_type, false); GeneratePreorderVisitorAbstractClass(file_symbol, "", abstract_visitor_type, type_set); file_symbol->Flush(); } } delete[] argument_visitor_type; delete[] result_visitor_type; delete[] result_argument_visitor_type; delete[] abstract_visitor_type; delete[] abstract_result_visitor_type; } ProcessCodeActions(initial_actions, typestring, processed_rule_map); int count = 0; { // // Note that the start rules are skipped as no AST node is allocated for them. // for (int rule_no = grammar->GetStartSymbol().Length(); rule_no < rule_allocation_map.Size(); rule_no++) { if ((user_specified_null_ast[rule_no]) || ((rule_allocation_map[rule_no].name != NULL || grammar->RhsSize(rule_no) == 0) && (rule_allocation_map[rule_no].list_kind != RuleAllocationElement::COPY_LIST || rule_allocation_map[rule_no].list_position != 1))) { count++; // // Check whether or not the rule is a single production // and if so, issue an error and stop. // if (grammar->IsUnitProduction(rule_no)) { int source_index = grammar->rules[rule_no].source_index; option->EmitError(grammar->parser.rules[source_index].separator_index, "Unable to generate Ast allocation for single production"); return_code = 12; } if (count % option->max_cases == 0) { ProcessMacro(&ast_buffer, "SplitActions", rule_no); count++; } ProcessMacro(&ast_buffer, "BeginAction", rule_no); if (rule_allocation_map[rule_no].list_kind != RuleAllocationElement::NOT_A_LIST) { GenerateListAllocation(ctc, ast_buffer, rule_no, rule_allocation_map[rule_no]); } else { if (user_specified_null_ast[rule_no] || (grammar->RhsSize(rule_no) == 0 && rule_allocation_map[rule_no].name == NULL)) GenerateNullAstAllocation(ast_buffer, rule_no); else GenerateAstAllocation(ctc, ast_buffer, rule_allocation_map[rule_no], processed_rule_map[rule_no], typestring, rule_no); } GenerateCode(&ast_buffer, "\n ", rule_no); ProcessMacro(&ast_buffer, "EndAction", rule_no); } else { // // Make sure that no action block is associated with a rule for // which no class is allocated when it is reduced. // for (int k = 0; k < rule_action_map[rule_no].Length(); k++) { ActionBlockElement& action = rule_action_map[rule_no][k]; option->EmitError(action.block_token, "Since no class is associated with this production, the information in this block is unreachable"); return_code = 12; } ProcessMacro(&ast_buffer, "NoAction", rule_no); } } } return; } // // // void CSharpAction::GenerateVisitorHeaders(TextBuffer &ast_buffer, const char *indentation, const char *modifiers) { if (option -> visitor != Option::NONE) { char *header = new char[strlen(indentation) + strlen(modifiers) + 9]; strcpy(header, indentation); strcat(header, modifiers); ast_buffer.Put(header); if (option -> visitor == Option::PREORDER) { ast_buffer.Put("void accept(IAstVisitor v);"); } else if (option -> visitor == Option::DEFAULT) { ast_buffer.Put("void accept("); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v);"); ast_buffer.Put("\n"); ast_buffer.Put(header); ast_buffer.Put("void accept(Argument"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v, object o);\n"); ast_buffer.Put(header); ast_buffer.Put("object accept(Result"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v);\n"); ast_buffer.Put(header); ast_buffer.Put("object accept(ResultArgument"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v, object o);"); } ast_buffer.Put("\n"); delete [] header; } return; } // // // void CSharpAction::GenerateVisitorMethods(NTC &ntc, TextBuffer &ast_buffer, const char *indentation, ClassnameElement &element, BitSet &optimizable_symbol_set) { if (option -> visitor == Option::DEFAULT) { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override void accept("); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v) { v.visit(this); }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override void accept(Argument"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v, object o) { v.visit(this, o); }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override object accept(Result"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v) { return v.visit(this); }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override object accept(ResultArgument"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v, object o) { return v.visit(this, o); }\n"); } else if (option -> visitor == Option::PREORDER) { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override void accept(IAstVisitor v)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! v.preVisit(this)) return;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" enter(("); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(") v);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" v.postVisit(this);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override void enter("); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); SymbolLookupTable &symbol_set = element.symbol_set; Tuple<int> &rhs_type_index = element.rhs_type_index; if (element.is_terminal_class || symbol_set.Size() == 0) { ast_buffer.Put(indentation); ast_buffer.Put(" v.visit(this);\n"); } else { ast_buffer.Put(indentation); ast_buffer.Put(" bool checkChildren = v.visit(this);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (checkChildren)\n"); if (symbol_set.Size() > 1) { ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); } for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" "); if ((! optimizable_symbol_set[i]) || ntc.CanProduceNullAst(rhs_type_index[i])) { ast_buffer.Put("if (_"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(" != null) "); } ast_buffer.Put("_"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(".accept(v);\n"); } if (symbol_set.Size() > 1) { ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" v.endVisit(this);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } return; } // // // void CSharpAction::GenerateGetAllChildrenMethod(TextBuffer &ast_buffer, const char *indentation, ClassnameElement &element) { if (! element.is_terminal_class) { SymbolLookupTable &symbol_set = element.symbol_set; ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * A list of all children of this node,don't including the null ones.\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override System.Collections.ArrayList getAllChildren()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" System.Collections.ArrayList list = new System.Collections.ArrayList();\n"); for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" if(_");ast_buffer.Put(symbol_set[i]->Name());ast_buffer.Put(" != null) "); ast_buffer.Put("list.Add(_");ast_buffer.Put(symbol_set[i] -> Name());ast_buffer.Put(");\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" return list;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } return; } // // // void CSharpAction::GenerateEqualsMethod(NTC &ntc, TextBuffer &ast_buffer, const char *indentation, ClassnameElement &element, BitSet &optimizable_symbol_set) { SymbolLookupTable &symbol_set = element.symbol_set; // // Note that if an AST node does not contain any field (symbol_set.Size() == 0), // we do not generate an "Equals" function for it. // if ((! element.is_terminal_class) && symbol_set.Size() > 0) { Tuple<int> &rhs_type_index = element.rhs_type_index; ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override bool Equals(object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (o == this) return true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! (o is "); ast_buffer.Put(element.real_name); ast_buffer.Put(")) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! base.Equals(o)) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(element.real_name); ast_buffer.Put(" other = ("); ast_buffer.Put(element.real_name); ast_buffer.Put(") o;\n"); for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" "); if ((! optimizable_symbol_set[i]) || ntc.CanProduceNullAst(rhs_type_index[i])) { ast_buffer.Put("if (_"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(" == null)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (other._"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(" != null) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" else{}// continue\n"); ast_buffer.Put(indentation); ast_buffer.Put(" else "); } ast_buffer.Put("if (! _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(".Equals(other._"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(")) return false;\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" return true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } return; } // // // void CSharpAction::GenerateHashcodeMethod(NTC &ntc, TextBuffer &ast_buffer, const char *indentation, ClassnameElement &element, BitSet &optimizable_symbol_set) { SymbolLookupTable &symbol_set = element.symbol_set; // // Note that if an AST node does not contain any field (symbol_set.Size() == 0), // we do not generate an "Equals" function for it. // if ((! element.is_terminal_class) && symbol_set.Size() > 0) { Tuple<int> &rhs_type_index = element.rhs_type_index; ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override int GetHashCode()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" int hash = base.GetHashCode();\n"); for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" hash = hash * 31 + (_"); ast_buffer.Put(symbol_set[i] -> Name()); if ((! optimizable_symbol_set[i]) || ntc.CanProduceNullAst(rhs_type_index[i])) { ast_buffer.Put(" == null ? 0 : _"); ast_buffer.Put(symbol_set[i] -> Name()); } ast_buffer.Put(".GetHashCode());\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" return hash;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } return; } // // // void CSharpAction::GenerateSimpleVisitorInterface(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *interface_name, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("public interface "); ast_buffer.Put(interface_name); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" void visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n);\n"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" void visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n);\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n"); if(option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } } // // // void CSharpAction::GenerateArgumentVisitorInterface(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *interface_name, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("public interface "); ast_buffer.Put(interface_name); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" void visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n, object o);\n"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" void visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n, object o);\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n"); if (ast_filename_symbol != option->DefaultBlock()->ActionfileSymbol()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } } // // // void CSharpAction::GenerateResultVisitorInterface(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *interface_name, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("public interface "); ast_buffer.Put(interface_name); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" object visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n);\n"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" object visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n);\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } } // // // void CSharpAction::GenerateResultArgumentVisitorInterface(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *interface_name, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("public interface "); ast_buffer.Put(interface_name); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" object visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n, object o);\n"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" object visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n, object o);\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } } // // // void CSharpAction::GeneratePreorderVisitorInterface(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *interface_name, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); assert(option -> visitor == Option::PREORDER); ast_buffer.Put(indentation); ast_buffer.Put("public interface "); ast_buffer.Put(interface_name); ast_buffer.Put(" : IAstVisitor\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); // ast_buffer.Put(indentation); ast_buffer.Put(" bool preVisit("); // ast_buffer.Put(option -> ast_type); // ast_buffer.Put(" element);\n"); // // ast_buffer.Put(indentation); ast_buffer.Put(" void postVisit("); // ast_buffer.Put(option -> ast_type); // ast_buffer.Put(" element);\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" bool visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" void endVisit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n);\n\n"); for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" bool visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" void endVisit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n);\n"); ast_buffer.Put("\n"); } ast_buffer.Put(indentation); ast_buffer.Put("}\n\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // // void CSharpAction::GenerateNoResultVisitorAbstractClass(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *classname, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("public abstract class "); ast_buffer.Put(classname); ast_buffer.Put(" : "); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(", Argument"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public abstract void unimplementedVisitor(string s);\n\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" public void visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n) { unimplementedVisitor(\"visit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(")\"); }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n, object o) { unimplementedVisitor(\"visit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(", object)\"); }\n"); ast_buffer.Put("\n"); } } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(i == 0 ? "" : "else "); ast_buffer.Put("if (n is "); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") visit(("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") n);\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"visit(\" + n.GetType().ToString() + \")\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n, object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(i == 0 ? "" : "else "); ast_buffer.Put("if (n is "); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") visit(("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") n, o);\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"visit(\" + n.GetType().ToString() + \")\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } } // // // void CSharpAction::GenerateResultVisitorAbstractClass(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *classname, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("public abstract class "); ast_buffer.Put(classname); ast_buffer.Put(" : Result"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(", ResultArgument"); ast_buffer.Put(option -> visitor_type); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public abstract object unimplementedVisitor(string s);\n\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" public object visit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n) { return unimplementedVisitor(\"visit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(")\"); }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public object visit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n, object o) { return unimplementedVisitor(\"visit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(", object)\"); }\n"); ast_buffer.Put("\n"); } } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public object visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(i == 0 ? "" : "else "); ast_buffer.Put("if (n is "); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") return visit(("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") n);\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"visit(\" + n.GetType().ToString() + \")\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public object visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n, object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(i == 0 ? "" : "else "); ast_buffer.Put("if (n is "); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") return visit(("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") n, o);\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"visit(\" + n.GetType().ToString() + \")\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } } // // // void CSharpAction::GeneratePreorderVisitorAbstractClass(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *classname, SymbolLookupTable &type_set) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); assert(option -> visitor == Option::PREORDER); ast_buffer.Put(indentation); ast_buffer.Put("public abstract class "); ast_buffer.Put(classname); ast_buffer.Put(" : "); ast_buffer.Put(option -> visitor_type); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public abstract void unimplementedVisitor(string s);\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public bool preVisit(IAst element) { return true; }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void postVisit(IAst element) {}\n\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" public bool visit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n) { unimplementedVisitor(\"visit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(")\"); return true; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void endVisit"); ast_buffer.Put("("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(" n) { unimplementedVisitor(\"endVisit("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(")\"); }\n"); ast_buffer.Put("\n"); } } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public bool visit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(i == 0 ? "" : "else "); ast_buffer.Put("if (n is "); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") return visit(("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") n);\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"visit(\" + n.GetType().ToString() + \")\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void endVisit"); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" n)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); { for (int i = 0; i < type_set.Size(); i++) { Symbol *symbol = type_set[i]; ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(i == 0 ? "" : "else "); ast_buffer.Put("if (n is "); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") endVisit(("); ast_buffer.Put(symbol -> Name()); ast_buffer.Put(") n);\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"visit(\" + n.GetType().ToString() + \")\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // Generate the the Ast root classes // void CSharpAction::GenerateAstType(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *classname) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); /* * First, generate the main root class */ ast_buffer.Put(indentation); ast_buffer.Put("public abstract class "); ast_buffer.Put(classname); ast_buffer.Put(" : IAst\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); if (option -> glr) { ast_buffer.Put(indentation); ast_buffer.Put(" private Ast nextAst = null;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IAst getNextAst() { return nextAst; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void setNextAst(IAst n) { nextAst = n; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void resetNextAst() { nextAst = null; }\n"); } else ast_buffer.Put(indentation); ast_buffer.Put(" public IAst getNextAst() { return null; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" protected IToken leftIToken,\n"); ast_buffer.Put(indentation); ast_buffer.Put(" rightIToken;\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" protected IAst parent = null;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void setParent(IAst parent) { this.parent = parent; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IAst getParent() { return parent; }\n");\ } else { ast_buffer.Put(indentation); ast_buffer.Put(" public IAst getParent()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"noparent-saved option in effect\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IToken getLeftIToken() { return leftIToken; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IToken getRightIToken() { return rightIToken; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IToken[] getPrecedingAdjuncts() { return leftIToken.getPrecedingAdjuncts(); }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IToken[] getFollowingAdjuncts() { return rightIToken.getFollowingAdjuncts(); }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override string ToString()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return leftIToken.getILexStream().ToString(leftIToken.getStartOffset(), rightIToken.getEndOffset());\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("(IToken token) { this.leftIToken = this.rightIToken = token; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("(IToken leftIToken, IToken rightIToken)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" this.leftIToken = leftIToken;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" this.rightIToken = rightIToken;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void initialize() {}\n"); for (int i = 0; i < grammar -> parser.ast_blocks.Length(); i++) { LexStream::TokenIndex block_token = grammar -> parser.ast_blocks[i]; BlockSymbol *block = lex_stream -> GetBlockSymbol(block_token); if (! option -> ActionBlocks().IsIgnoredBlock(block -> BlockBegin(), block -> BlockBeginLength())) { ActionBlockElement action; action.rule_number = 0; action.location = ActionBlockElement::INITIALIZE; // does not matter - block must be default block... action.block_token = block_token; action.buffer = &ast_buffer; ProcessActionBlock(action); } } ast_buffer.Put("\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * A list of all children of this node, excluding the null ones.\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public System.Collections.ArrayList getChildren()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" ArrayListEx<object> list = new ArrayListEx<object>(getAllChildren()) ;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" int k = -1;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < list.Count; i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" object element = list.get(i);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (element != null)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (++k != i)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" list.set(k, element);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = list.Count - 1; i > k; i--) // remove extraneous elements\n"); ast_buffer.Put(indentation); ast_buffer.Put(" list.remove(i);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return list;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * A list of all children of this node, including the null ones.\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public abstract System.Collections.ArrayList getAllChildren();\n"); } else { ast_buffer.Put(indentation); ast_buffer.Put(" public System.Collections.ArrayList getChildren()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" throw new System.NotSupportedException(\"noparent-saved option in effect\");\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override System.Collections.ArrayList getAllChildren() { return getChildren(); }\n"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override bool Equals(object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (o == this) return true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! (o is "); ast_buffer.Put(classname); ast_buffer.Put(")) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(classname); ast_buffer.Put(" other = ("); ast_buffer.Put(classname); ast_buffer.Put(") o;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return getLeftIToken().getILexStream() == other.getLeftIToken().getILexStream() &&\n"); ast_buffer.Put(indentation); ast_buffer.Put(" getLeftIToken().getTokenIndex() == other.getLeftIToken().getTokenIndex() &&\n"); ast_buffer.Put(indentation); ast_buffer.Put(" getRightIToken().getILexStream() == other.getRightIToken().getILexStream() &&\n"); ast_buffer.Put(indentation); ast_buffer.Put(" getRightIToken().getTokenIndex() == other.getRightIToken().getTokenIndex();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override int GetHashCode()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" int hash = 7;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (getLeftIToken().getILexStream() != null) hash = hash * 31 + getLeftIToken().getILexStream().GetHashCode();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" hash = hash * 31 + getLeftIToken().getTokenIndex();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (getRightIToken().getILexStream() != null) hash = hash * 31 + getRightIToken().getILexStream().GetHashCode();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" hash = hash * 31 + getRightIToken().getTokenIndex();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return hash;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); GenerateVisitorHeaders(ast_buffer, indentation, " public abstract "); // // Not Preorder visitor? generate dummy accept method to satisfy IAst abstract declaration of accept(IAstVisitor); // TODO: Should IAstVisitor be used for default visitors also? If (when) yes then we should remove it from the test below // if (option -> visitor == Option::NONE || option -> visitor == Option::DEFAULT) // ??? Don't need this for DEFAULT case after upgrade { ast_buffer.Put(indentation); ast_buffer.Put(" public virtual void accept(IAstVisitor v) {}\n"); } ast_buffer.Put(indentation); ast_buffer.Put("}\n\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } typedef std::map<std::string, std::string> Substitutions; // // Generate the the Ast list class // void CSharpAction::GenerateAbstractAstListType(ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *classname) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); /* * Generate the List root class */ ast_buffer.Put(indentation); ast_buffer.Put("public abstract class "); ast_buffer.Put(this -> abstract_ast_list_classname); ast_buffer.Put(" : "); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" , IAbstractArrayList<"); ast_buffer.Put(option -> ast_type); ast_buffer.Put(">\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); ast_buffer.Put(indentation); ast_buffer.Put(" private bool leftRecursive;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" private ArrayListEx<"); ast_buffer.Put(option->ast_type); ast_buffer.Put("> list=new ArrayListEx<"); ast_buffer.Put(option->ast_type); ast_buffer.Put(">();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public int size() { return list.Count; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public System.Collections.ArrayList getList() { return list; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" getElementAt(int i) { return ("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") list.get(leftRecursive ? i : list.Count - 1 - i); }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public System.Collections.ArrayList getArrayList()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! leftRecursive) // reverse the list \n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0, n = list.Count - 1; i < n; i++, n--)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" dynamic ith = list.get(i),\n"); ast_buffer.Put(indentation); ast_buffer.Put(" nth = list.get(n);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" list.set(i, nth);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" list.set(n, ith);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" leftRecursive = true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return list;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * @deprecated replaced by {@link #addElement()}\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public bool add("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" element)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" addElement(element);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void addElement("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" element)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" list.Add(element);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" rightIToken = element.getRightIToken();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" else leftIToken = element.getLeftIToken();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); // generate constructors for list class ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("(IToken leftIToken, IToken rightIToken, bool leftRecursive):base(leftIToken, rightIToken)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" this.leftRecursive = leftRecursive;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" \n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" element, bool leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" :this(element.getLeftIToken(), element.getRightIToken(), leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" list.Add(element);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * Make a copy of the list and return it. Note that we obtain the local list by\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * invoking getArrayList so as to make sure that the list we return is in proper order.\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override System.Collections.ArrayList getAllChildren()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return (System.Collections.ArrayList) getArrayList().Clone();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); } // // Implementation for functions in System.Collections.ArrayList // Substitutions subs; subs["%%AstType%%"] = option->ast_type; subs["%%ListClassName%%"] = classname; ast_buffer.Put(indentation); ast_buffer.Put("}\n\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // Generate the the Ast token class // void CSharpAction::GenerateAstTokenType(NTC &ntc, ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *classname) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); /* * Generate the Token root class */ ast_buffer.Put(indentation); ast_buffer.Put(option -> automatic_ast == Option::NESTED ? " " : ""); ast_buffer.Put("public class "); ast_buffer.Put(classname); ast_buffer.Put(" : "); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" , I"); ast_buffer.Put(classname); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("(IToken token) :base(token){ }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IToken getIToken() { return leftIToken; }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override string ToString() { return leftIToken.ToString(); }\n\n"); ClassnameElement element; // generate a temporary element with no symbols in its symbol set. element.real_name = (char *) classname; BitSet optimizable_symbol_set(element.symbol_set.Size(), BitSet::UNIVERSE); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * A token class has no children. So, we return the empty list.\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override System.Collections.ArrayList getAllChildren() { return new System.Collections.ArrayList(); }\n\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" public override bool Equals(object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (o == this) return true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! (o is "); ast_buffer.Put(classname); ast_buffer.Put(")) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(classname); ast_buffer.Put(" other = ("); ast_buffer.Put(classname); ast_buffer.Put(") o;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return getIToken().getILexStream() == other.getIToken().getILexStream() &&\n"); ast_buffer.Put(indentation); ast_buffer.Put(" getIToken().getTokenIndex() == other.getIToken().getTokenIndex();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override int GetHashCode()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" int hash = 7;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (getIToken().getILexStream() != null) hash = hash * 31 + getIToken().getILexStream().GetHashCode();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" hash = hash * 31 + getIToken().getTokenIndex();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return hash;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); GenerateVisitorMethods(ntc, ast_buffer, indentation, element, optimizable_symbol_set); ast_buffer.Put(indentation); ast_buffer.Put("}\n\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // // void CSharpAction::GenerateCommentHeader(TextBuffer &ast_buffer, const char *indentation, Tuple<int> &ungenerated_rule, Tuple<int> &generated_rule) { BlockSymbol* scope_block = nullptr; const char* rule_info = rule_info_holder.c_str(); ast_buffer.Put(indentation); ast_buffer.Put("/**"); if (ungenerated_rule.Length() > 0) { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *<em>"); for (int i = 0; i < ungenerated_rule.Length(); i++) { int rule_no = ungenerated_rule[i]; LexStream::TokenIndex separator_token = grammar -> parser.rules[grammar -> rules[rule_no].source_index].separator_index; int line_no = lex_stream -> Line(separator_token), start = lex_stream -> StartLocation(separator_token), end = lex_stream -> EndLocation(separator_token) + 1; const char *start_cursor_location = &(lex_stream -> InputBuffer(separator_token)[start]), *end_cursor_location = &(lex_stream -> InputBuffer(separator_token)[end]); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ProcessActionLine(scope_block, ActionBlockElement::BODY, &ast_buffer, lex_stream -> FileName(separator_token), rule_info, &rule_info[strlen(rule_info)], rule_no, lex_stream -> FileName(separator_token), line_no, start_cursor_location, end_cursor_location); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *</em>\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *<p>"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *<b>"); for (int i = 0; i < generated_rule.Length(); i++) { int rule_no = generated_rule[i]; LexStream::TokenIndex separator_token = grammar -> parser.rules[grammar -> rules[rule_no].source_index].separator_index; int line_no = lex_stream -> Line(separator_token), start = lex_stream -> StartLocation(separator_token), end = lex_stream -> EndLocation(separator_token) + 1; const char *start_cursor_location = &(lex_stream -> InputBuffer(separator_token)[start]), *end_cursor_location = &(lex_stream -> InputBuffer(separator_token)[end]); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ProcessActionLine(scope_block, ActionBlockElement::BODY, &ast_buffer, lex_stream -> FileName(separator_token), // option -> DefaultBlock() -> ActionfileSymbol() -> Name(), rule_info, &rule_info[strlen(rule_info)], rule_no, lex_stream -> FileName(separator_token), line_no, start_cursor_location, end_cursor_location); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *</b>\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); } void CSharpAction::GenerateListMethods(CTC &ctc, NTC &ntc, TextBuffer &ast_buffer, const char *indentation, const char *classname, ClassnameElement &element, Array<const char *> &typestring) { const char *element_name = element.array_element_type_symbol -> Name(), *element_type = ctc.FindBestTypeFor(element.array_element_type_symbol -> SymbolIndex()); // // Generate ADD method // ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put("void addElement("); ast_buffer.Put(element_type); ast_buffer.Put(" _"); ast_buffer.Put(element_name); ast_buffer.Put(")\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" base.addElement(("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") _"); ast_buffer.Put(element_name); ast_buffer.Put(");\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" "); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) { ast_buffer.Put("if (_"); ast_buffer.Put(element_name); ast_buffer.Put(" != null) "); } ast_buffer.Put("(("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") _"); ast_buffer.Put(element_name); ast_buffer.Put(").setParent(this);\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); // // Generate the "Equals" method for this list // ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override bool Equals(object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (o == this) return true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! (o is "); ast_buffer.Put(classname); ast_buffer.Put(")) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! base.Equals(o)) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); ast_buffer.Put(classname); ast_buffer.Put(" other = ("); ast_buffer.Put(classname); ast_buffer.Put(indentation); ast_buffer.Put(") o;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (size() != other.size()) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < size(); i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); const char *element_typename = ctc.FindUniqueTypeFor(element.array_element_type_symbol -> SymbolIndex()); if (element_typename != NULL) ast_buffer.Put(element_typename); else ast_buffer.Put(typestring[element.array_element_type_symbol -> SymbolIndex()]); ast_buffer.Put(" element = get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) { ast_buffer.Put("if (element == null && other.get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i) != null) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" else "); } ast_buffer.Put(indentation); ast_buffer.Put("if (! element.Equals(other.get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i))) return false;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return true;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); // // Generate the "hashCode" method for a list node // ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override int GetHashCode()\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" int hash = base.GetHashCode();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < size(); i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" hash = hash * 31 + (get"); ast_buffer.Put(element_name); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) { ast_buffer.Put("At(i) == null ? 0 : get"); ast_buffer.Put(element_name); } ast_buffer.Put("At(i).GetHashCode());\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return hash;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); // // Generate visitor methods. // if (option -> visitor == Option::DEFAULT) { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override void accept("); ast_buffer.Put(option -> visitor_type); if (ctc.FindUniqueTypeFor(element.array_element_type_symbol -> SymbolIndex()) != NULL) { ast_buffer.Put(" v) { for (int i = 0; i < size(); i++) v.visit" "(" "get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i)" "); }\n"); } else { ast_buffer.Put(" v) { for (int i = 0; i < size(); i++) get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i).accept(v); }\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" public override void accept(Argument"); ast_buffer.Put(option -> visitor_type); if (ctc.FindUniqueTypeFor(element.array_element_type_symbol -> SymbolIndex()) != NULL) { ast_buffer.Put(" v, object o) { for (int i = 0; i < size(); i++) v.visit" "(" "get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i), o"); ast_buffer.Put("); }\n"); } else { ast_buffer.Put(" v, object o) { for (int i = 0; i < size(); i++) get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i).accept(v, o); }\n"); } // // Code cannot be generated to automatically visit a node that // can return a value. These cases are left up to the user. // ast_buffer.Put(indentation); ast_buffer.Put(" public override object accept(Result"); ast_buffer.Put(option -> visitor_type); if (ctc.FindUniqueTypeFor(element.array_element_type_symbol -> SymbolIndex()) != NULL) { ast_buffer.Put(" v)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" System.Collections.ArrayList result = new System.Collections.ArrayList();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < size(); i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" result.Add(v.visit(get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i)));\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return result;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } else { ast_buffer.Put(" v)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" System.Collections.ArrayList result = new System.Collections.ArrayList();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < size(); i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" result.Add(get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i).accept(v));\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return result;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" public override object accept(ResultArgument"); ast_buffer.Put(option -> visitor_type); if (ctc.FindUniqueTypeFor(element.array_element_type_symbol -> SymbolIndex()) != NULL) { ast_buffer.Put(" v, object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" System.Collections.ArrayList result = new System.Collections.ArrayList();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < size(); i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" result.Add(v.visit(get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i), o));\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return result;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } else { ast_buffer.Put(" v, object o)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" System.Collections.ArrayList result = new System.Collections.ArrayList();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < size(); i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" result.Add(get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i).accept(v, o));\n"); ast_buffer.Put(indentation); ast_buffer.Put(" return result;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } } else if (option -> visitor == Option::PREORDER) { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public override void accept(IAstVisitor v)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! v.preVisit(this)) return;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" enter(("); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(") v);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" v.postVisit(this);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public void enter("); ast_buffer.Put(option -> visitor_type); ast_buffer.Put(" v)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" bool checkChildren = v.visit(this);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (checkChildren)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" for (int i = 0; i < size(); i++)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); const char *element_typename = ctc.FindUniqueTypeFor(element.array_element_type_symbol -> SymbolIndex()); if (element_typename != NULL) { ast_buffer.Put(element_typename); ast_buffer.Put(" element = get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i);\n"); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) { ast_buffer.Put(indentation); ast_buffer.Put(" if (element != null)"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" if (! v.preVisit(element)) continue;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" element.enter(v);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" v.postVisit(element);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } else { ast_buffer.Put(indentation); ast_buffer.Put(" if (! v.preVisit(element)) continue;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" element.enter(v);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" v.postVisit(element);\n"); } } else { ast_buffer.Put(typestring[element.array_element_type_symbol -> SymbolIndex()]); ast_buffer.Put(" element = get"); ast_buffer.Put(element_name); ast_buffer.Put("At(i);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" "); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) ast_buffer.Put("if (element != null) "); ast_buffer.Put("element.accept(v);\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put(indentation); ast_buffer.Put(" v.endVisit(this);\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } return; } // // // void CSharpAction::GenerateListClass(CTC &ctc, NTC &ntc, ActionFileSymbol* ast_filename_symbol, const char *indentation, ClassnameElement &element, Array<const char *> &typestring) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); Tuple<int> &interface = element.interface_; assert(element.array_element_type_symbol != NULL); const char *classname = element.real_name, *element_name = element.array_element_type_symbol -> Name(), *element_type = ctc.FindBestTypeFor(element.array_element_type_symbol -> SymbolIndex()); GenerateCommentHeader(ast_buffer, indentation, element.ungenerated_rule, element.rule); ast_buffer.Put(indentation); ast_buffer.Put("public class "); ast_buffer.Put(classname); ast_buffer.Put(" : "); ast_buffer.Put(this -> abstract_ast_list_classname); ast_buffer.Put(" , "); for (int i = 0; i < interface.Length() - 1; i++) { ast_buffer.Put(typestring[element.interface_[i]]); ast_buffer.Put(", "); } ast_buffer.Put(typestring[element.interface_[interface.Length() - 1]]); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) { ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * The value returned by <b>get"); ast_buffer.Put(element_name); ast_buffer.Put("At</b> may be <b>null</b>\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(element_type); ast_buffer.Put(" get"); ast_buffer.Put(element_name); ast_buffer.Put("At(int i) { return ("); ast_buffer.Put(element_type); ast_buffer.Put(") getElementAt(i); }\n\n"); // // generate constructors // ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("("); ast_buffer.Put("IToken leftIToken, IToken rightIToken, bool leftRecursive):base(leftIToken, rightIToken, leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("("); ast_buffer.Put(element_type); ast_buffer.Put(" _"); ast_buffer.Put(element_name); ast_buffer.Put(", bool leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" :base(("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") _"); ast_buffer.Put(element_name); ast_buffer.Put(", leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" "); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) { ast_buffer.Put("if (_"); ast_buffer.Put(element_name); ast_buffer.Put(" != null) "); } ast_buffer.Put("(("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") _"); ast_buffer.Put(element_name); ast_buffer.Put(").setParent(this);\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); ast_buffer.Put("\n"); GenerateListMethods(ctc, ntc, ast_buffer, indentation, classname, element, typestring); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // Generate a class that : a basic list class. This is necessary when the user // specifies action blocks to be associated with a generic list class - in which case, // we have to generate a (new) unique class (that : the generic class) to hold the content // of the action blocks. // void CSharpAction::GenerateListExtensionClass(CTC &ctc, NTC &ntc, ActionFileSymbol* ast_filename_symbol, const char *indentation, SpecialArrayElement &special_array, ClassnameElement &element, Array<const char *> &typestring) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); const char *classname = element.real_name, *element_name = element.array_element_type_symbol -> Name(), *element_type = ctc.FindBestTypeFor(element.array_element_type_symbol -> SymbolIndex()); GenerateCommentHeader(ast_buffer, indentation, element.ungenerated_rule, special_array.rules); ast_buffer.Put(indentation); ast_buffer.Put("public class "); ast_buffer.Put(special_array.name); ast_buffer.Put(" : "); ast_buffer.Put(classname); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); GenerateEnvironmentDeclaration(ast_buffer, indentation); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(special_array.name); ast_buffer.Put("("); ast_buffer.Put(option -> action_type); ast_buffer.Put(" environment, "); ast_buffer.Put("IToken leftIToken, IToken rightIToken, bool leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" :base(leftIToken, rightIToken, leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" this.environment = environment;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" initialize();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(special_array.name); ast_buffer.Put("("); ast_buffer.Put(option -> action_type); ast_buffer.Put(" environment, "); ast_buffer.Put(element_type); ast_buffer.Put(" _"); ast_buffer.Put(element_name); ast_buffer.Put(", bool leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" :base(_"); ast_buffer.Put(element_name); ast_buffer.Put(", leftRecursive)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" this.environment = environment;\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" "); if (ntc.CanProduceNullAst(element.array_element_type_symbol -> SymbolIndex())) { ast_buffer.Put("if (_"); ast_buffer.Put(element_name); ast_buffer.Put(" != null) "); } ast_buffer.Put("(("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") _"); ast_buffer.Put(element_name); ast_buffer.Put(").setParent(this);\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" initialize();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n\n"); GenerateListMethods(ctc, ntc, ast_buffer, indentation, special_array.name, element, typestring); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // Generate a generic rule class // void CSharpAction::GenerateRuleClass(CTC &ctc, NTC &ntc, ActionFileSymbol* ast_filename_symbol, const char *indentation, ClassnameElement &element, Array<const char *> &typestring) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); char *classname = element.real_name; SymbolLookupTable &symbol_set = element.symbol_set; Tuple<int> &rhs_type_index = element.rhs_type_index; BitSet optimizable_symbol_set(element.symbol_set.Size(), BitSet::UNIVERSE); GenerateCommentHeader(ast_buffer, indentation, element.ungenerated_rule, element.rule); assert(element.rule.Length() == 1); int rule_no = element.rule[0]; ast_buffer.Put(indentation); ast_buffer.Put("public class "); ast_buffer.Put(classname); ast_buffer.Put(" : "); if (element.is_terminal_class) { ast_buffer.Put(grammar -> Get_ast_token_classname()); ast_buffer.Put(" , "); ast_buffer.Put(typestring[grammar -> rules[rule_no].lhs]); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); if (element.needs_environment) GenerateEnvironmentDeclaration(ast_buffer, indentation); if (symbol_set.Size() == 1) // if the right-hand side contains a symbol ... { ast_buffer.Put(indentation); ast_buffer.Put(" public IToken get"); ast_buffer.Put(symbol_set[0] -> Name()); ast_buffer.Put("() { return leftIToken; }\n\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("("); if (element.needs_environment) { ast_buffer.Put(option -> action_type); ast_buffer.Put(" environment, IToken token)"); ast_buffer.Put(indentation); ast_buffer.Put(" :base(token)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" this.environment = environment;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" initialize();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } else ast_buffer.Put("IToken token):base(token) { initialize(); }\n"); } else { ast_buffer.Put(option -> ast_type); ast_buffer.Put(" , "); ast_buffer.Put(typestring[grammar -> rules[rule_no].lhs]); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); if (element.needs_environment) GenerateEnvironmentDeclaration(ast_buffer, indentation); if (symbol_set.Size() > 0) { { for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" private "); ast_buffer.Put(ctc.FindBestTypeFor(rhs_type_index[i])); ast_buffer.Put(" _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(";\n"); } } ast_buffer.Put("\n"); { for (int i = 0; i < symbol_set.Size(); i++) { const char *symbolName = symbol_set[i] -> Name(); const char *bestType = ctc.FindBestTypeFor(rhs_type_index[i]); if (ntc.CanProduceNullAst(rhs_type_index[i])) { ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * The value returned by <b>get"); ast_buffer.Put(symbolName); ast_buffer.Put("</b> may be <b>null</b>\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); } // Generate getter method ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(bestType); ast_buffer.Put(" get"); ast_buffer.Put(symbolName); ast_buffer.Put("() { return _"); ast_buffer.Put(symbolName); ast_buffer.Put("; }\n"); // Generate setter method ast_buffer.Put(indentation); ast_buffer.Put(" public void set"); ast_buffer.Put(symbolName); ast_buffer.Put("("); ast_buffer.Put(bestType); ast_buffer.Put(" _"); // add "_" prefix to arg name in case symbol happens to be a Java keyword ast_buffer.Put(symbolName); ast_buffer.Put(")"); ast_buffer.Put(" { this._"); ast_buffer.Put(symbolName); ast_buffer.Put(" = _"); ast_buffer.Put(symbolName); ast_buffer.Put("; }\n"); } } ast_buffer.Put("\n"); } // // generate constructor // const char *header = " public "; ast_buffer.Put(indentation); ast_buffer.Put(header); ast_buffer.Put(classname); int length = strlen(indentation) + strlen(header) + strlen(classname); ast_buffer.Put("("); if (element.needs_environment) { ast_buffer.Put(option -> action_type); ast_buffer.Put(" environment, "); } ast_buffer.Put("IToken leftIToken, IToken rightIToken"); ast_buffer.Put(symbol_set.Size() == 0 ? ")\n" : ",\n"); { for (int i = 0; i < symbol_set.Size(); i++) { for (int k = 0; k <= length; k++) ast_buffer.PutChar(' '); ast_buffer.Put(ctc.FindBestTypeFor(rhs_type_index[i])); ast_buffer.Put(" _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(i == symbol_set.Size() - 1 ? ")\n" : ",\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" :base(leftIToken, rightIToken)\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); if (element.needs_environment) { ast_buffer.Put(indentation); ast_buffer.Put(" this.environment = environment;\n"); } { for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" this._"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(" = _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(";\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" "); if ((! optimizable_symbol_set[i]) || ntc.CanProduceNullAst(rhs_type_index[i])) { ast_buffer.Put("if (_"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(" != null) "); } ast_buffer.Put("(("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(").setParent(this);\n"); } } } ast_buffer.Put(indentation); ast_buffer.Put(" initialize();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } if (option -> parent_saved) GenerateGetAllChildrenMethod(ast_buffer, indentation, element); GenerateEqualsMethod(ntc, ast_buffer, indentation, element, optimizable_symbol_set); GenerateHashcodeMethod(ntc, ast_buffer, indentation, element, optimizable_symbol_set); GenerateVisitorMethods(ntc, ast_buffer, indentation, element, optimizable_symbol_set); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // Generate Ast class // void CSharpAction::GenerateTerminalMergedClass(NTC &ntc, ActionFileSymbol* ast_filename_symbol, const char *indentation, ClassnameElement &element, Array<const char *> &typestring) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); char *classname = element.real_name; GenerateCommentHeader(ast_buffer, indentation, element.ungenerated_rule, element.rule); ast_buffer.Put(indentation); ast_buffer.Put("public class "); ast_buffer.Put(classname); ast_buffer.Put(" : "); ast_buffer.Put(grammar -> Get_ast_token_classname()); ast_buffer.Put(" , "); for (int i = 0; i < element.interface_.Length() - 1; i++) { ast_buffer.Put(typestring[element.interface_[i]]); ast_buffer.Put(", "); } ast_buffer.Put(typestring[element.interface_[element.interface_.Length() - 1]]); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); if (element.needs_environment) GenerateEnvironmentDeclaration(ast_buffer, indentation); SymbolLookupTable &symbol_set = element.symbol_set; if (symbol_set.Size() == 1) // if the right-hand side contains a symbol ... { ast_buffer.Put(indentation); ast_buffer.Put(" public IToken get"); ast_buffer.Put(symbol_set[0] -> Name()); ast_buffer.Put("() { return leftIToken; }\n\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(classname); ast_buffer.Put("("); if (element.needs_environment) { ast_buffer.Put(option -> action_type); ast_buffer.Put(" environment, IToken token)"); ast_buffer.Put(indentation); ast_buffer.Put(" :base(token)\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); ast_buffer.Put(indentation); ast_buffer.Put(" this.environment = environment;\n"); ast_buffer.Put(indentation); ast_buffer.Put(" initialize();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); } else ast_buffer.Put("IToken token): base(token){ initialize(); }\n"); BitSet optimizable_symbol_set(element.symbol_set.Size(), BitSet::UNIVERSE); GenerateHashcodeMethod(ntc, ast_buffer, indentation, element, optimizable_symbol_set); GenerateVisitorMethods(ntc, ast_buffer, indentation, element, optimizable_symbol_set); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // Generate Ast class // void CSharpAction::GenerateMergedClass(CTC &ctc, NTC &ntc, ActionFileSymbol* ast_filename_symbol, const char *indentation, ClassnameElement &element, Tuple< Tuple<ProcessedRuleElement> > &processed_rule_map, Array<const char *> &typestring) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); char *classname = element.real_name; SymbolLookupTable &symbol_set = element.symbol_set; Tuple<int> &rhs_type_index = element.rhs_type_index; GenerateCommentHeader(ast_buffer, indentation, element.ungenerated_rule, element.rule); ast_buffer.Put(indentation); ast_buffer.Put("public class "); ast_buffer.Put(classname); ast_buffer.Put(" : "); ast_buffer.Put(option -> ast_type); ast_buffer.Put(" , "); { for (int i = 0; i < element.interface_.Length() - 1; i++) { ast_buffer.Put(typestring[element.interface_[i]]); ast_buffer.Put(", "); } } ast_buffer.Put(typestring[element.interface_[element.interface_.Length() - 1]]); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); if (element.needs_environment) GenerateEnvironmentDeclaration(ast_buffer, indentation); { for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" private "); ast_buffer.Put(ctc.FindBestTypeFor(rhs_type_index[i])); ast_buffer.Put(" _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(";\n"); } } ast_buffer.Put("\n"); // // Compute the set of symbols that always appear in an instance creation // of this merged class for which a null instance allocation will never occur. // BitSet optimizable_symbol_set(element.symbol_set.Size(), BitSet::UNIVERSE); Tuple<int> &rule = element.rule; { for (int i = 0; i < rule.Length(); i++) { int rule_no = rule[i]; Tuple<ProcessedRuleElement> &processed_rule_elements = processed_rule_map[rule_no]; for (int k = 0; k < processed_rule_elements.Length(); k++) { if (processed_rule_elements[k].position == 0 || ntc.CanProduceNullAst(grammar -> rhs_sym[processed_rule_elements[k].position])) optimizable_symbol_set.RemoveElement(k); } } } { for (int i = 0; i < symbol_set.Size(); i++) { if ((! optimizable_symbol_set[i]) || ntc.CanProduceNullAst(rhs_type_index[i])) { ast_buffer.Put(indentation); ast_buffer.Put(" /**\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * The value returned by <b>get"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put("</b> may be <b>null</b>\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); } ast_buffer.Put(indentation); ast_buffer.Put(" public "); ast_buffer.Put(ctc.FindBestTypeFor(rhs_type_index[i])); ast_buffer.Put(" get"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put("() { return _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put("; }\n"); } } ast_buffer.Put("\n"); // // generate merged constructor // const char *header = " public "; ast_buffer.Put(indentation); ast_buffer.Put(header); ast_buffer.Put(classname); int length = strlen(indentation) + strlen(header) + strlen(classname); ast_buffer.Put("("); if (element.needs_environment) { ast_buffer.Put(option -> action_type); ast_buffer.Put(" environment, "); } ast_buffer.Put("IToken leftIToken, IToken rightIToken"); ast_buffer.Put(symbol_set.Size() == 0 ? ")\n" : ",\n"); { for (int i = 0; i < symbol_set.Size(); i++) { for (int k = 0; k <= length; k++) ast_buffer.PutChar(' '); ast_buffer.Put(ctc.FindBestTypeFor(rhs_type_index[i])); ast_buffer.Put(" _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(i == symbol_set.Size() - 1 ? ")\n" : ",\n"); } } ast_buffer.Put(indentation); ast_buffer.Put(" :base(leftIToken, rightIToken)\n\n"); ast_buffer.Put(indentation); ast_buffer.Put(" {\n"); if (element.needs_environment) { ast_buffer.Put(indentation); ast_buffer.Put(" this.environment = environment;\n"); } { for (int i = 0; i < symbol_set.Size(); i++) { ast_buffer.Put(indentation); ast_buffer.Put(" this._"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(" = _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(";\n"); if (option -> parent_saved) { ast_buffer.Put(indentation); ast_buffer.Put(" "); if ((! optimizable_symbol_set[i]) || ntc.CanProduceNullAst(rhs_type_index[i])) { ast_buffer.Put("if (_"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(" != null) "); } ast_buffer.Put("(("); ast_buffer.Put(option -> ast_type); ast_buffer.Put(") _"); ast_buffer.Put(symbol_set[i] -> Name()); ast_buffer.Put(").setParent(this);\n"); } } } ast_buffer.Put(indentation); ast_buffer.Put(" initialize();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" }\n"); if (option -> parent_saved) GenerateGetAllChildrenMethod(ast_buffer, indentation, element); GenerateEqualsMethod(ntc, ast_buffer, indentation, element, optimizable_symbol_set); GenerateHashcodeMethod(ntc, ast_buffer, indentation, element, optimizable_symbol_set); GenerateVisitorMethods(ntc, ast_buffer, indentation, element, optimizable_symbol_set); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } void CSharpAction::GenerateAstRootInterface( ActionFileSymbol* ast_filename_symbol, const char* indentation) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("public interface "); ast_buffer.Put(astRootInterfaceName.c_str()); ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IToken getLeftIToken();\n"); ast_buffer.Put(indentation); ast_buffer.Put(" public IToken getRightIToken();\n"); ast_buffer.Put("\n"); GenerateVisitorHeaders(ast_buffer, indentation, " "); ast_buffer.Put(indentation); ast_buffer.Put("}\n\n"); if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } void CSharpAction::GenerateInterface(bool is_terminal, ActionFileSymbol* ast_filename_symbol, const char *indentation, const char *interface_name, Tuple<int> &extension, Tuple<int> &classes, Tuple<ClassnameElement> &classname) { TextBuffer& ast_buffer = *(ast_filename_symbol->BodyBuffer()); ast_buffer.Put(indentation); ast_buffer.Put("/**"); if (is_terminal) { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * is always implemented by <b>"); ast_buffer.Put(grammar -> Get_ast_token_classname()); ast_buffer.Put("</b>. It is also implemented by"); } else { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" * is implemented by"); } if (classes.Length() == 1) { ast_buffer.Put(" <b>"); ast_buffer.Put(classname[classes[0]].real_name); ast_buffer.Put("</b>"); } else { ast_buffer.Put(":\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *<b>\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *<ul>"); for (int i = 0; i < classes.Length(); i++) { ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *<li>"); ast_buffer.Put(classname[classes[i]].real_name); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *</ul>\n"); ast_buffer.Put(indentation); ast_buffer.Put(" *</b>"); } ast_buffer.Put("\n"); ast_buffer.Put(indentation); ast_buffer.Put(" */\n"); ast_buffer.Put(indentation); ast_buffer.Put("public interface "); ast_buffer.Put(interface_name); if (extension.Length() > 0) { ast_buffer.Put(" : "); for (int k = 0; k < extension.Length() - 1; k++) { ast_buffer.PutChar('I'); ast_buffer.Put(extension[k] == grammar -> Get_ast_token_interface() ? grammar -> Get_ast_token_classname() : grammar -> RetrieveString(extension[k])); ast_buffer.Put(", "); } ast_buffer.PutChar('I'); ast_buffer.Put(extension[extension.Length() - 1] == grammar -> Get_ast_token_interface() ? grammar -> Get_ast_token_classname() : grammar -> RetrieveString(extension[extension.Length() - 1])); ast_buffer.Put(" {}\n\n"); } else { ast_buffer.Put(":"); ast_buffer.Put(astRootInterfaceName.c_str()); ast_buffer.Put(indentation); ast_buffer.Put("{\n"); ast_buffer.Put(indentation); ast_buffer.Put("}\n\n"); } if (option->IsTopLevel() && option->IsPackage()) { ast_buffer.Put(indentation); ast_buffer.Put("}\n");// for namespace } return; } // // // void CSharpAction::GenerateNullAstAllocation(TextBuffer &ast_buffer, int rule_no) { const char *code = "\n setResult(null);"; GenerateCode(&ast_buffer, code, rule_no); return; } // // // void CSharpAction::GenerateAstAllocation(CTC &ctc, TextBuffer &ast_buffer, RuleAllocationElement &allocation_element, Tuple<ProcessedRuleElement> &processed_rule_elements, Array<const char *> &typestring, int rule_no) { const char *classname = allocation_element.name; // // Copy these two arrays into a local tuple for CONVENIENCE. // Tuple<int> position, type_index; for (int i = 0; i < processed_rule_elements.Length(); i++) { position.Next() = processed_rule_elements[i].position; type_index.Next() = processed_rule_elements[i].type_index; } // // Convenient constant declarations. // const char *space = "\n ", *space4 = " ", *newkey = option -> factory, *lparen = "(", *comma = ",", *rparen = ")", *trailer = ");"; int extra_space_length = strlen(space) + strlen(space4) + strlen(newkey) + strlen(classname) + 1; char *extra_space = new char[extra_space_length + 1]; extra_space[0] = '\n'; { for (int i = 1; i < extra_space_length; i++) extra_space[i] = ' '; } extra_space[extra_space_length] = '\0'; // // TODO: We simply generate a comment as a reminder that the previous nonterminal // allocated for this token should be deleted when using a language such as C/C++ // that does not have a garbage collector. // // if (allocation_element.is_terminal_class && type_index.Length() == 1 && IsNonTerminal(type_index[0])) // { // GenerateCode(&ast_buffer, space, rule_no); // GenerateCode(&ast_buffer, "// When garbage collection is not available, delete ", rule_no); // GenerateCode(&ast_buffer, "getRhsSym(", rule_no); // IntToString index(position[0]); // GenerateCode(&ast_buffer, index.string(), rule_no); // GenerateCode(&ast_buffer, rparen, rule_no); // } // if (allocation_element.is_terminal_class && (grammar -> RhsSize(rule_no) == 1 && grammar -> IsNonTerminal(grammar -> rhs_sym[grammar -> FirstRhsIndex(rule_no)]))) { GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, "//", rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, "// When garbage collection is not available, delete ", rule_no); GenerateCode(&ast_buffer, "getRhsSym(1)", rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, "//", rule_no); } GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, "setResult(", rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, space4, rule_no); GenerateCode(&ast_buffer, current_line_input_file_info.c_str(), rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, space4, rule_no); GenerateCode(&ast_buffer, newkey, rule_no); GenerateCode(&ast_buffer, classname, rule_no); GenerateCode(&ast_buffer, lparen, rule_no); if (allocation_element.needs_environment) { GenerateCode(&ast_buffer, "this, ", rule_no); } if (allocation_element.is_terminal_class) { GenerateCode(&ast_buffer, "getRhsIToken(1)", rule_no); // // TODO: Old bad idea. Remove at some point... // // // assert(position.Length() <= 1); // // GenerateCode(&ast_buffer, "getRhsIToken(", rule_no); // IntToString index(position.Length() == 0 ? 1 : position[0]); // GenerateCode(&ast_buffer, index.string(), rule_no); // GenerateCode(&ast_buffer, rparen, rule_no); // } else { GenerateCode(&ast_buffer, "getLeftIToken()", rule_no); GenerateCode(&ast_buffer, ", ", rule_no); GenerateCode(&ast_buffer, "getRightIToken()", rule_no); if (position.Length() > 0) { GenerateCode(&ast_buffer, comma, rule_no); GenerateCode(&ast_buffer, extra_space, rule_no); GenerateCode(&ast_buffer, current_line_input_file_info.c_str(), rule_no); GenerateCode(&ast_buffer, extra_space, rule_no); int offset = grammar -> FirstRhsIndex(rule_no) - 1; for (int i = 0; i < position.Length(); i++) { if (position[i] == 0) { GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, ctc.FindBestTypeFor(type_index[i]), rule_no); GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, "null", rule_no); } else { int symbol = grammar -> rhs_sym[offset + position[i]]; if (grammar -> IsTerminal(symbol)) { const char *actual_type = ctc.FindBestTypeFor(type_index[i]); if (strcmp(actual_type, grammar -> Get_ast_token_classname()) != 0) { GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, actual_type, rule_no); GenerateCode(&ast_buffer, rparen, rule_no); } GenerateCode(&ast_buffer, newkey, rule_no); GenerateCode(&ast_buffer, grammar -> Get_ast_token_classname(), rule_no); GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, "getRhsIToken(", rule_no); IntToString index(position[i]); GenerateCode(&ast_buffer, index.String(), rule_no); GenerateCode(&ast_buffer, rparen, rule_no); } else { GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, ctc.FindBestTypeFor(type_index[i]), rule_no); GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, "getRhsSym(", rule_no); IntToString index(position[i]); GenerateCode(&ast_buffer, index.String(), rule_no); } GenerateCode(&ast_buffer, rparen, rule_no); } if (i != position.Length() - 1) { GenerateCode(&ast_buffer, comma, rule_no); GenerateCode(&ast_buffer, extra_space, rule_no); GenerateCode(&ast_buffer, current_line_input_file_info.c_str(), rule_no); GenerateCode(&ast_buffer, extra_space, rule_no); } } } } GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, current_line_input_file_info.c_str(), rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, trailer, rule_no); delete [] extra_space; return; } // // // void CSharpAction::GenerateListAllocation(CTC &ctc, TextBuffer &ast_buffer, int rule_no, RuleAllocationElement &allocation_element) { const char *space = "\n ", *space4 = " ", *newkey = option -> factory, *lparen = "(", *comma = ",", *rparen = ")", *trailer = ");"; if (allocation_element.list_kind == RuleAllocationElement::LEFT_RECURSIVE_EMPTY || allocation_element.list_kind == RuleAllocationElement::RIGHT_RECURSIVE_EMPTY || allocation_element.list_kind == RuleAllocationElement::LEFT_RECURSIVE_SINGLETON || allocation_element.list_kind == RuleAllocationElement::RIGHT_RECURSIVE_SINGLETON) { GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, "setResult(", rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, space4, rule_no); GenerateCode(&ast_buffer, current_line_input_file_info.c_str(), rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, space4, rule_no); GenerateCode(&ast_buffer, newkey, rule_no); GenerateCode(&ast_buffer, allocation_element.name, rule_no); GenerateCode(&ast_buffer, lparen, rule_no); if (allocation_element.needs_environment) { GenerateCode(&ast_buffer, "this, ", rule_no); } if (allocation_element.list_kind == RuleAllocationElement::LEFT_RECURSIVE_EMPTY || allocation_element.list_kind == RuleAllocationElement::RIGHT_RECURSIVE_EMPTY) { GenerateCode(&ast_buffer, "getLeftIToken()", rule_no); GenerateCode(&ast_buffer, ", ", rule_no); GenerateCode(&ast_buffer, "getRightIToken()", rule_no); GenerateCode(&ast_buffer, comma, rule_no); if (allocation_element.list_kind == RuleAllocationElement::LEFT_RECURSIVE_EMPTY) GenerateCode(&ast_buffer, " true /* left recursive */", rule_no); else GenerateCode(&ast_buffer, " false /* not left recursive */", rule_no); } else { assert(allocation_element.list_kind == RuleAllocationElement::LEFT_RECURSIVE_SINGLETON || allocation_element.list_kind == RuleAllocationElement::RIGHT_RECURSIVE_SINGLETON); if (grammar -> IsTerminal(allocation_element.element_symbol)) { GenerateCode(&ast_buffer, newkey, rule_no); GenerateCode(&ast_buffer, grammar -> Get_ast_token_classname(), rule_no); GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, "getRhsIToken(", rule_no); IntToString index(allocation_element.element_position); GenerateCode(&ast_buffer, index.String(), rule_no); GenerateCode(&ast_buffer, rparen, rule_no); } else { GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, ctc.FindBestTypeFor(allocation_element.element_type_symbol_index), rule_no); GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, "getRhsSym(", rule_no); IntToString index(allocation_element.element_position); GenerateCode(&ast_buffer, index.String(), rule_no); } GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, comma, rule_no); if (allocation_element.list_kind == RuleAllocationElement::LEFT_RECURSIVE_SINGLETON) GenerateCode(&ast_buffer, " true /* left recursive */", rule_no); else GenerateCode(&ast_buffer, " false /* not left recursive */", rule_no); } GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, current_line_input_file_info.c_str(), rule_no); GenerateCode(&ast_buffer, space, rule_no); } else { // // Add new element to list // if (allocation_element.list_kind == RuleAllocationElement::ADD_ELEMENT) { GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, allocation_element.name, rule_no); GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, "getRhsSym(", rule_no); IntToString index(allocation_element.list_position); GenerateCode(&ast_buffer, index.String(), rule_no); GenerateCode(&ast_buffer, ")).addElement(", rule_no); if (grammar -> IsTerminal(allocation_element.element_symbol)) { GenerateCode(&ast_buffer, newkey, rule_no); GenerateCode(&ast_buffer, grammar -> Get_ast_token_classname(), rule_no); GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, "getRhsIToken(", rule_no); IntToString index(allocation_element.element_position); GenerateCode(&ast_buffer, index.String(), rule_no); GenerateCode(&ast_buffer, rparen, rule_no); } else { GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, ctc.FindBestTypeFor(allocation_element.element_type_symbol_index), rule_no); GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, "getRhsSym(", rule_no); IntToString index(allocation_element.element_position); GenerateCode(&ast_buffer, index.String(), rule_no); } if (allocation_element.list_position != 1) // a right-recursive rule? set the list as result { GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, trailer, rule_no); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, "setResult(", rule_no); GenerateCode(&ast_buffer, "getRhsSym(", rule_no); IntToString index(allocation_element.list_position); GenerateCode(&ast_buffer, index.String(), rule_no); } } // // Copy a list that is not the first element on the right-hand side of the rule // else { assert(allocation_element.list_kind == RuleAllocationElement::COPY_LIST); GenerateCode(&ast_buffer, space, rule_no); GenerateCode(&ast_buffer, "setResult(", rule_no); GenerateCode(&ast_buffer, lparen, rule_no); GenerateCode(&ast_buffer, allocation_element.name, rule_no); GenerateCode(&ast_buffer, rparen, rule_no); GenerateCode(&ast_buffer, "getRhsSym(", rule_no); IntToString index(allocation_element.list_position); GenerateCode(&ast_buffer, index.String(), rule_no); } GenerateCode(&ast_buffer, rparen, rule_no); } GenerateCode(&ast_buffer, trailer, rule_no); return; }
46.511065
174
0.525599
[ "object" ]
2d054f932a2addb7499ce08da081e90c78be02fc
2,790
cpp
C++
chap18/drill.cpp
ksvbka/pppuc
840962dd612ab4f2b2c638409089cd889c417c8f
[ "MIT" ]
2
2016-05-06T02:08:38.000Z
2016-05-10T02:19:05.000Z
chap18/drill.cpp
ksvbka/pppuc
840962dd612ab4f2b2c638409089cd889c417c8f
[ "MIT" ]
null
null
null
chap18/drill.cpp
ksvbka/pppuc
840962dd612ab4f2b2c638409089cd889c417c8f
[ "MIT" ]
1
2020-11-01T13:06:15.000Z
2020-11-01T13:06:15.000Z
#include <iostream> #include <vector> #include <stdexcept> using namespace std; /* Array drill: 1. Define a global int array ga of ten ints initialized to 1, 2, 4, 8, 16, etc. */ int ga[10] = {1,2,4,8,16}; /* 2. Define a function f() taking an int array argument and an int argument indicating the number of elements in the array. 3. In f(): a. Define a local int array la of ten ints. b. Copy the values from ga into la. c. Print out the elements of la. d. Define a pointer p to int and initialize it with an array allocated on the free store with the same number of elements as the argument array. e. Copy the values from the argument array into the free-store array. f. Print out the elements of the free-store array. g. Deallocate the free-store array. */ void f(int a[], int size){ int la[10]; int elements_count = size < 10 ? size : 10; for(int i = 0; i < elements_count; ++i) la[i] = a[i]; cout << "\n Elements of local array" << endl; for(auto i : la) cout << " " << i; int* p = new int[size]; for(int i = 0; i < size; ++i) p[i] = a[i]; cout << "\n Elements of free-store: " << endl; for(int i = 0; i < size; ++i) cout << " " << p[i]; delete[] p; } /* 4. In main(): a. Call f() with ga as its argument. b. Define an array aa with ten elements, and initialize it with the first ten factorial values (1, 2*1, 3*2*1, 4*3*2*1,etc.). c. Call f() with aa as its argument. */ /* Standard library vector drill: 1. Define a global vector<int> gv; initialize it with ten ints, 1, 2, 4, 8, 16, etc. 2. Define a function f() taking a vector<int> argument. 3. In f(): a. Define a local vector<int> lv with the same number of elements as the argument vector. b. Copy the values from gv into lv. c. Print out the elements of lv. d. Define a local vector<int> lv2; initialize it to be a copy of the argument vector. e. Print out the elements of lv2. */ vector<int> gv{1,2,4,8,16}; void fv(vector<int> v){ vector<int> lv = v; cout << "\nElements of vector lv: " << endl; for(auto elem : lv) cout << " " << elem; } /* 4. In main(): a. Call f() with gv as its argument. b. Define a vector<int> vv, and initialize it with the first ten factorial values (1, 2*1, 3*2*1, 4*3*2*1, etc.). c. Call f() with vv as its argument. */ int main(int argc, char const *argv[]) { try{ /*No-std version:D*/ f(ga,10); int factorial_arr[10]; factorial_arr[0] = 1; for(int i = 1; i < 10; ++i) factorial_arr[i] = factorial_arr[i-1] * i; f(factorial_arr,10); /*std lib version*/ fv(gv); }catch(runtime_error &e){ cout << e.what() << endl; }catch(...){ cout << "Exiting...!" << endl; } }
26.320755
79
0.605376
[ "vector" ]
2d0819b3f021763ca3c867954f901f66e5c762e8
8,314
cxx
C++
Remoting/ServerManager/Testing/Cxx/TestMultiplexerSourceProxy.cxx
xj361685640/ParaView
0a27eef5abc5a0c0472ab0bc806c4db881156e64
[ "Apache-2.0", "BSD-3-Clause" ]
815
2015-01-03T02:14:04.000Z
2022-03-26T07:48:07.000Z
Remoting/ServerManager/Testing/Cxx/TestMultiplexerSourceProxy.cxx
xj361685640/ParaView
0a27eef5abc5a0c0472ab0bc806c4db881156e64
[ "Apache-2.0", "BSD-3-Clause" ]
9
2015-04-28T20:10:37.000Z
2021-08-20T18:19:01.000Z
Remoting/ServerManager/Testing/Cxx/TestMultiplexerSourceProxy.cxx
xj361685640/ParaView
0a27eef5abc5a0c0472ab0bc806c4db881156e64
[ "Apache-2.0", "BSD-3-Clause" ]
328
2015-01-22T23:11:46.000Z
2022-03-14T06:07:52.000Z
/*========================================================================= Program: ParaView Module: TestMultiplexerSourceProxy.cxx Copyright (c) Kitware, Inc. All rights reserved. See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkInitializationHelper.h" #include "vtkLogger.h" #include "vtkNew.h" #include "vtkPVTestUtilities.h" #include "vtkProcessModule.h" #include "vtkSMMultiplexerSourceProxy.h" #include "vtkSMParaViewPipelineController.h" #include "vtkSMPropertyHelper.h" #include "vtkSMSession.h" #include "vtkSMSessionProxyManager.h" #include "vtkSmartPointer.h" #include "vtkSphereSource.h" #include "vtkWeakPointer.h" static const char* testMultiplexerSourceProxyXML = R"==( <ServerManagerConfiguration> <ProxyGroup name="filters"> <MultiplexerSourceProxy name="Multiplexer"> <InputProperty name="Input"> <Documentation> Specify the input to this filter. </Documentation> <MultiplexerInputDomain name="input" /> </InputProperty> </MultiplexerSourceProxy> <SourceProxy name="TypeSphere" class="vtkSphereSource"> <InputProperty name="Input"> <DataTypeDomain name="input_type"> <DataType value="vtkPolyData" /> </DataTypeDomain> </InputProperty> <DoubleVectorProperty animateable="1" command="SetCenter" default_values="0.0 0.0 0.0" name="Center" number_of_elements="3" panel_visibility="default"> <DoubleRangeDomain name="range" /> <Documentation>This property specifies the 3D coordinates for the center of the sphere.</Documentation> </DoubleVectorProperty> <Hints> <!-- not adding optional <LinkProperties/> element --> <MultiplexerSourceProxy proxygroup="filters" proxyname="Multiplexer" /> </Hints> </SourceProxy> <SourceProxy name="TypeWavelet" class="vtkRTAnalyticSource"> <InputProperty name="Input0"> <DataTypeDomain name="input_type"> <DataType value="vtkImageData" /> </DataTypeDomain> </InputProperty> <IntVectorProperty command="SetWholeExtent" default_values="-10 10 -10 10 -10 10" label="Whole Extent" name="WholeExtent" number_of_elements="6" panel_visibility="default"> <IntRangeDomain name="range" /> </IntVectorProperty> <DoubleVectorProperty animateable="1" command="SetXFreq" default_values="60.0" name="XFreq" number_of_elements="1" panel_visibility="advanced"> <DoubleRangeDomain name="range" /> <Documentation>This property specifies the natural frequency in X (XF in the equation).</Documentation> </DoubleVectorProperty> <DoubleVectorProperty animateable="1" command="SetYFreq" default_values="30.0" name="YFreq" number_of_elements="1" panel_visibility="advanced"> <DoubleRangeDomain name="range" /> <Documentation>This property specifies the natural frequency in Y (YF in the equation).</Documentation> </DoubleVectorProperty> <DoubleVectorProperty animateable="1" command="SetZFreq" default_values="40.0" name="ZFreq" number_of_elements="1" panel_visibility="advanced"> <DoubleRangeDomain name="range" /> <Documentation>This property specifies the natural frequency in Z (ZF in the equation).</Documentation> </DoubleVectorProperty> <PropertyGroup label="Frequency"> <Property name="XFreq" /> <Property name="YFreq" /> <Property name="ZFreq" /> </PropertyGroup> <Hints> <MultiplexerSourceProxy proxygroup="filters" proxyname="Multiplexer"> <LinkProperties> <!-- adding custom property linking --> <Property name="Input0" with_property="Input" /> </LinkProperties> </MultiplexerSourceProxy> </Hints> </SourceProxy> </ProxyGroup> </ServerManagerConfiguration> )=="; static bool ValidateSphere(vtkSMProxy* mux) { if (mux->GetProperty("Center") != nullptr) { vtkSMPropertyHelper(mux, "Center").Set(0, 12); mux->UpdateVTKObjects(); } else { vtkLogF(ERROR, "Missing 'Center' property!"); return false; } if (mux->GetProperty("ZFreq") != nullptr) { vtkLogF(ERROR, "Unexpected property 'ZFreq!"); return false; } return true; } static bool ValidateWavelet(vtkSMProxy* mux) { if (mux->GetProperty("ZFreq") != nullptr) { vtkSMPropertyHelper(mux, "ZFreq").Set(12); mux->UpdateVTKObjects(); } else { vtkLogF(ERROR, "Missing 'ZFreq' property!"); return false; } if (mux->GetProperty("Center") != nullptr) { vtkLogF(ERROR, "Unexpected property 'Center'!"); return false; } if (mux->GetNumberOfPropertyGroups() != 1 || mux->GetPropertyGroup(0) == nullptr) { vtkLogF(ERROR, "Missing property group!"); return false; } return true; } int TestMultiplexerSourceProxy(int argc, char* argv[]) { vtkNew<vtkPVTestUtilities> testing; testing->Initialize(argc, argv); vtkInitializationHelper::Initialize(argv[0], vtkProcessModule::PROCESS_CLIENT); vtkNew<vtkSMParaViewPipelineController> controller; // Create a new session. vtkNew<vtkSMSession> session; controller->InitializeSession(session); auto pxm = session->GetSessionProxyManager(); pxm->LoadConfigurationXML(testMultiplexerSourceProxyXML); auto pdsource = vtkSmartPointer<vtkSMProxy>::Take(pxm->NewProxy("sources", "ConeSource")); controller->InitializeProxy(pdsource); controller->RegisterPipelineProxy(pdsource); auto mux = vtkSmartPointer<vtkSMSourceProxy>::Take( vtkSMSourceProxy::SafeDownCast(pxm->NewProxy("filters", "Multiplexer"))); controller->PreInitializeProxy(mux); vtkSMPropertyHelper(mux, "Input").Set(pdsource); controller->PostInitializeProxy(mux); controller->RegisterPipelineProxy(mux, "mux0"); if (!ValidateSphere(mux)) { vtkInitializationHelper::Finalize(); return EXIT_FAILURE; } // now try the img input. auto imgsource = vtkSmartPointer<vtkSMProxy>::Take(pxm->NewProxy("sources", "RTAnalyticSource")); controller->InitializeProxy(imgsource); controller->RegisterPipelineProxy(imgsource); mux = vtkSmartPointer<vtkSMSourceProxy>::Take( vtkSMSourceProxy::SafeDownCast(pxm->NewProxy("filters", "Multiplexer"))); controller->PreInitializeProxy(mux); vtkSMPropertyHelper(mux, "Input").Set(imgsource); controller->PostInitializeProxy(mux); controller->RegisterPipelineProxy(mux, "mux1"); if (!ValidateWavelet(mux)) { vtkInitializationHelper::Finalize(); return EXIT_FAILURE; } auto cstr = testing->GetTempFilePath("TestMultiplexerSourceProxy-state.pvsm"); const std::string filename(cstr); delete[] cstr; pxm->SaveXMLState(filename.c_str()); pxm->UnRegisterProxies(); pdsource = nullptr; imgsource = nullptr; mux = nullptr; pxm->LoadXMLState(filename.c_str()); auto mux0 = pxm->GetProxy("sources", "mux0"); if (!mux0 || !ValidateSphere(mux0)) { vtkLogF(ERROR, "State loading failed!"); vtkInitializationHelper::Finalize(); return EXIT_FAILURE; } auto mux1 = pxm->GetProxy("sources", "mux1"); if (!mux1 || !ValidateWavelet(mux1)) { vtkLogF(ERROR, "State loading failed!"); vtkInitializationHelper::Finalize(); return EXIT_FAILURE; } vtkInitializationHelper::Finalize(); return EXIT_SUCCESS; }
32.603922
99
0.631706
[ "3d" ]
2d0882443b51fc0639e19811f311e785a8cc9ea1
6,252
cpp
C++
core/src/cpic/data/easy.cpp
emanuelmch/cpic
d31b977710865d28b87e66a419964200de197067
[ "MIT" ]
null
null
null
core/src/cpic/data/easy.cpp
emanuelmch/cpic
d31b977710865d28b87e66a419964200de197067
[ "MIT" ]
2
2021-05-06T15:08:44.000Z
2022-02-09T00:51:11.000Z
core/src/cpic/data/easy.cpp
emanuelmch/cpic
d31b977710865d28b87e66a419964200de197067
[ "MIT" ]
null
null
null
/* * Copyright (c) 2019 Emanuel Machado da Silva * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "board_data.h" #include "../model/board_builder.h" using std::vector; using namespace CPic; BoardData createBoardEasy1_1() { auto board = BoardBuilder(2) .column({2, 3}, {true, true}) ->column({2, 3}, {true, true}) ->column({2, 3}, {true, true}) ->column({5}, {true}) ->column({5}, {true}) ->row({5}, {true}) ->row({5}, {true}) ->row({2, 3}, {true, true}) ->row({2, 3}, {true, true}) ->row({2, 3}, {true, true}) ->build(); BoardState solution = BoardState({{C0, C0, C0, C0, C0}, // {C0, C0, C0, C0, C0}, {C1, C1, C1, C0, C0}, {C1, C1, C1, C0, C0}, {C1, C1, C1, C0, C0}}); return BoardData("easy1_1", board, solution); } BoardData createBoardEasy1_2() { auto board = BoardBuilder(2) .column({0, 5}, {false, true}) ->column({2, 3}) ->column({5}, {true}) ->column({1, 4}, {false, true}) ->column({0, 5}, {false, true}) ->row({1, 4}) ->row({2, 3}, {true, false}) ->row({1, 4}) ->row({1, 4}) ->row({3, 2}, {true}) ->build(); BoardState solution = BoardState({{C1, C1, C0, C1, C1}, // {C1, C0, C0, C1, C1}, {C1, C1, C0, C1, C1}, {C1, C1, C0, C1, C1}, {C1, C0, C0, C0, C1}}); return BoardData("easy1_2", board, solution); } BoardData createBoardEasy1_3() { auto board = BoardBuilder(2) .column({2, 3}, {true, true}) ->column({5}, {true}) ->column({1, 4}, {false, true}) ->column({3, 2}, {false, true}) ->column({5}, {true}) ->row({4, 1}, {true}) ->row({2, 3}) ->row({2, 3}) ->row({4, 1}) ->row({4, 1}) ->build(); BoardState solution = BoardState({{C1, C0, C0, C0, C0}, // {C1, C0, C1, C1, C0}, {C1, C0, C1, C1, C0}, {C0, C0, C1, C0, C0}, {C0, C0, C1, C0, C0}}); return BoardData("easy1_3", board, solution); } BoardData createBoardEasy1_4() { auto board = BoardBuilder(3) .column({2, 3}, {true, true}) ->column({2, 1, 2}, {true, false, true}) ->column({2, 3}, {true, true}) ->column({2, 2, 1}, {true}) ->column({2, 3}, {true, true}) ->row({5}, {true}) ->row({5}, {true}) ->row({0, 5}, {false, true}) ->row({0, 3, 2}) ->row({0, 4, 1}) ->build(); BoardState solution = BoardState({{C0, C0, C0, C0, C0}, // {C0, C0, C0, C0, C0}, {C1, C1, C1, C1, C1}, {C1, C2, C1, C2, C1}, {C1, C2, C1, C1, C1}}); return BoardData("easy1_4", board, solution); } BoardData createBoardEasy1_20() { auto board = BoardBuilder(4) .column({1, 0, 1, 8}) ->column({5, 0, 0, 5}) ->column({8, 2}) ->column({5, 0, 0, 5}) ->column({1, 0, 1, 8}) ->row({1, 0, 0, 4}) ->row({3, 0, 0, 2}, {true}) ->row({5}, {true}) ->row({0, 1, 0, 4}) ->row({1, 0, 0, 4}) ->row({3, 0, 0, 2}, {true}) ->row({0, 1, 0, 4}) ->row({1, 0, 0, 4}) ->row({3, 0, 0, 2}, {true}) ->row({3, 0, 2}, {true}) ->build(); BoardState solution = BoardState({{C3, C3, C0, C3, C3}, {C3, C0, C0, C0, C3}, {C0, C0, C0, C0, C0}, {C3, C3, C1, C3, C3}, {C3, C3, C0, C3, C3}, {C3, C0, C0, C0, C3}, {C3, C3, C1, C3, C3}, {C3, C3, C0, C3, C3}, {C3, C0, C0, C0, C3}, {C2, C0, C0, C0, C2}}); return BoardData("easy1_20", board, solution); } vector<BoardData> CPic::createEasyBoards() { return {createBoardEasy1_1(), createBoardEasy1_2(), createBoardEasy1_3(), createBoardEasy1_4(), createBoardEasy1_20()}; }
40.335484
97
0.40771
[ "vector", "model" ]
2d11c9633e2e54c97590c18dc8413163e7efc121
1,233
hpp
C++
render-test/manifest_parser.hpp
kair8m/mapbox-gl-native
68516e1c6964c41a2c7fe9305cabf5a058012568
[ "BSD-2-Clause", "BSD-3-Clause" ]
4,234
2015-01-09T08:10:16.000Z
2022-03-30T14:13:55.000Z
render-test/manifest_parser.hpp
kair8m/mapbox-gl-native
68516e1c6964c41a2c7fe9305cabf5a058012568
[ "BSD-2-Clause", "BSD-3-Clause" ]
12,771
2015-01-01T20:27:42.000Z
2022-03-24T18:14:44.000Z
render-test/manifest_parser.hpp
kair8m/mapbox-gl-native
68516e1c6964c41a2c7fe9305cabf5a058012568
[ "BSD-2-Clause", "BSD-3-Clause" ]
1,571
2015-01-08T08:24:53.000Z
2022-03-28T06:30:53.000Z
#pragma once #include "metadata.hpp" #include <mbgl/util/optional.hpp> #include <mbgl/util/rapidjson.hpp> #include <cstdlib> #include <regex> #include <string> #include <utility> #include <vector> class Manifest { public: Manifest(); ~Manifest(); const std::vector<std::pair<std::string, std::string>>& getIgnores() const; const std::vector<TestPaths>& getTestPaths() const; const std::string& getTestRootPath() const; const std::string& getManifestPath() const; const std::string& getResultPath() const; const std::string& getCachePath() const; const std::string& getAccessToken() const; const std::set<std::string>& getProbes() const; void doShuffle(uint32_t seed); private: friend class ManifestParser; std::string manifestPath; std::string testRootPath; std::string resultPath; std::string cachePath; std::string accessToken; std::vector<std::pair<std::string, std::string>> ignores; std::vector<TestPaths> testPaths; std::set<std::string> probes; }; class ManifestParser { public: static mbgl::optional<Manifest> parseManifest(const std::string& manifestPath, std::string testFilter); };
27.4
82
0.671533
[ "vector" ]
2d1d21e5ebbc41db70c60df9746673428d3f946a
1,723
cpp
C++
comments.cpp
tanveerbadar/CppCodeProvider
e1279c59dd5199e4447d00124d6a4358e27b4315
[ "MIT" ]
null
null
null
comments.cpp
tanveerbadar/CppCodeProvider
e1279c59dd5199e4447d00124d6a4358e27b4315
[ "MIT" ]
null
null
null
comments.cpp
tanveerbadar/CppCodeProvider
e1279c59dd5199e4447d00124d6a4358e27b4315
[ "MIT" ]
null
null
null
#include "cppcodeprovider.h" #include <sstream> namespace CPlusPlusCodeProvider { using std::wstring; using std::wostream; Comment& Comment::Assign( const CodeObject& object ) { const Comment& ref = cast< Comment >( object ); text = ref.text; return *this; } Comment& Comment::Duplicate( ) const { return *new Comment( text ); } Comment::Comment( const wstring& comment ) : text( comment ) , object_source( false ) , multiline( false ) { } Comment::Comment( const CodeObject& other ) : object( &other ) , object_source( true ) , multiline( false ) { } bool Comment::IsEmpty( ) const { return !text.length( ) && !object_source; } bool Comment::MultiLine( ) const { return multiline; } Comment& Comment::MultiLine( bool flag ) { multiline = flag; return *this; } wstring Comment::Text( ) const { return text; } void Comment::writetext( wostream& os , unsigned long tabs ) const { if( object_source ) { std::wstringstream ws; object -> write( ws , tabs ); text = ws.str( ); multiline = text.find_first_of( L'\n' ) != wstring::npos; } if( !text.size( ) ) return; if( !MultiLine( ) ) os << L"/*" << text << L"*/"; else { os << L"//"; wstring result = text; wstring::size_type n = result.find( L'\n' ); while( n != wstring::npos ) result.replace( n , 1 , L'\n' + wstring( tabs , FormattingData::IndentationCharacter ) + L"//" ) , n = result.find( L'\n' , ++n ); os << result; } } void Comment::writetext( wostream& declos , wostream& , unsigned long decltabs , unsigned long ) const { Comment::writetext( declos , decltabs ); } }
21.5375
135
0.59141
[ "object" ]
2d21f371f35705a1b45ec06858b89ed2530ebcfe
6,721
hh
C++
include/aleph/topology/io/TikZ.hh
eudoxos/Aleph
874882c33a0e8429c74e567eb01525613fee0616
[ "MIT" ]
56
2019-04-24T22:11:15.000Z
2022-03-22T11:37:47.000Z
include/aleph/topology/io/TikZ.hh
eudoxos/Aleph
874882c33a0e8429c74e567eb01525613fee0616
[ "MIT" ]
48
2016-11-30T09:37:13.000Z
2019-01-30T21:43:39.000Z
include/aleph/topology/io/TikZ.hh
eudoxos/Aleph
874882c33a0e8429c74e567eb01525613fee0616
[ "MIT" ]
11
2019-05-02T11:54:31.000Z
2020-12-10T14:05:40.000Z
#ifndef ALEPH_TOPOLOGY_IO_TIKZ_HH__ #define ALEPH_TOPOLOGY_IO_TIKZ_HH__ #include <fstream> #include <ostream> #include <stdexcept> #include <string> namespace aleph { namespace topology { namespace io { /** @class TikZ @brief Writes files as a TikZ picture This writer class uses coordinate information of a simplicial complex to represent its 1-skeleton, i.e. its vertices and edges. All data is stored as a picture for the TikZ LaTeX toolkit, resulting in a clean, modern output for publications. The output is configurable and permits the following adjustments: - point size - line width */ class TikZ { public: /** Writes the simplicial complex to a new file. */ template <class SimplicialComplex, class Container> void operator()( const std::string& filename, const SimplicialComplex& K, const Container& container ) { std::ofstream out( filename ); if( !out ) throw std::runtime_error( "Unable to open output file" ); this->operator()( out, K, container ); } /** Writes the simplicial complex to a new output stream. */ template <class SimplicialComplex, class Container> void operator()( std::ostream& out, const SimplicialComplex& K, const Container& container ) { out << "\\begin{tikzpicture}\n"; // Render vertices as points --------------------------------------- out << "% 0-simplices\n"; for( auto&& s : K ) { if( s.dimension() != 0 ) continue; auto u = s[0]; // vertex auto p = container[u]; // coordinate if( p.size() >= 2 ) writePoint( out, u, p ); else throw std::runtime_error( "Insufficient number of dimensions for storing coordinates" ); } // Render 2-simplices as triangles ---------------------------------- if( _showTriangles ) { out << "% 2-simplices\n"; for( auto&& s : K ) { if( s.dimension() != 2 ) continue; auto u = s[0]; auto v = s[1]; auto w = s[2]; writeTriangle(out, u, v, w); } } // Render edges as lines ------------------------------------------- out << "% 1-simplices\n"; for( auto&& s : K ) { if( s.dimension() != 1 ) continue; auto u = s[0]; // vertex auto v = s[1]; // vertex writeEdge(out, u, v); } out << "\\end{tikzpicture}\n"; } bool showVertexLabels() const noexcept { return _showVertexLabels; } void showVertexLabels( bool value ) noexcept { _showVertexLabels = value; } void pointSize( double value ) noexcept { _pointSize = value; } void pointColour( const std::string& value ) noexcept { _pointColour = value; } void lineColour( const std::string& value ) noexcept { _lineColour = value; } bool showBalls() const noexcept { return _showBalls; } void showBalls( bool value ) noexcept { _showBalls = value; } double ballRadius() const noexcept { return _ballRadius; } void ballRadius( double radius ) { _ballRadius = radius; } bool showTriangles() const noexcept { return _showTriangles; } void showTriangles( bool value ) noexcept { _showTriangles = value; } void triangleColour( const std::string& value ) noexcept { _triangleColour = value; } void triangleOpacity( double value ) noexcept { _triangleOpacity = value; } private: /** Auxiliary function for creating a point in TikZ format. The point will be shown as a circle of a given size. @param out Output stream to which the point will be appended @param v Vertex index @param p Coordinates for the vertex (only two dimensions will be used) */ template <class Coordinate, class Index> void writePoint( std::ostream& out, Index v, Coordinate& p ) { auto x = p[0]; auto y = p[1]; out << "\\coordinate"; if( _showVertexLabels ) out << "[label=" << _labelPosition << ":" << std::to_string(v) << "] "; out << "(" << v << ") at (" << x << "," << y << ");\n"; out << "\\filldraw[" << _pointColour << "]" << " " << "(" << v << ") circle (" << _pointSize << _pointSizeUnit << ");\n"; if( _showBalls ) { out << "\\fill[" << _ballColour << "," << " fill opacity=" << _ballOpacity << "]" << " " << "(" << v << ") circle (" << _ballRadius << "cm" << ");\n"; } } /** Auxiliary function for creating an edge in TikZ format. The edge will be shown as a line connecting the two vertices. @param out Output stream to which the edge will be appended @param u Source vertex index @param v Target vertex index */ template <class Index> void writeEdge( std::ostream& out, Index u, Index v ) { out << "\\draw[" << _lineColour << "," << " line width=" << _lineWidth << _lineWidthUnit <<"]" << " " << "(" << u << ") -- (" << v << ");\n"; } /** Auxiliary function for creating a triangle in TikZ format. It is supposed to represent a 2-simplex. @param out Output stream to which the triangle will be appended @param u First vertex index @param v Second vertex index @param w Third vertex index */ template <class Index> void writeTriangle( std::ostream& out, Index u, Index v, Index w ) { out << "\\fill[" << _triangleColour << "," << " fill opacity=" << _triangleOpacity <<"]" << " " << "(" << u << ") -- (" << v << ") -- (" << w << ") -- cycle;\n"; } bool _showBalls = false; double _ballOpacity = 0.1; double _ballRadius = 0.0; std::string _ballColour = "black"; bool _showVertexLabels = false; std::string _labelPosition = "above"; // Node/vertex configuration options --------------------------------- std::string _pointColour = "black"; std::string _pointSizeUnit = "pt"; double _pointSize = 1; // Line/edge configuration options ----------------------------------- std::string _lineColour = "black"; std::string _lineWidthUnit = "mm"; double _lineWidth = 0.50; // Triangles --------------------------------------------------------- bool _showTriangles = false; std::string _triangleColour = "black"; double _triangleOpacity = 0.20; }; } // namespace io } // namespace topology } // namespace aleph #endif
23.918149
103
0.543372
[ "render" ]
2d288bf69b095afa157f54e706388e72c67c3d1a
529
cpp
C++
challenge/leet.gcc/q658/q658/main.cpp
odys-z/hello
39ca67cae34eb4bc4cbd848a06b3c0d65a995954
[ "MIT" ]
null
null
null
challenge/leet.gcc/q658/q658/main.cpp
odys-z/hello
39ca67cae34eb4bc4cbd848a06b3c0d65a995954
[ "MIT" ]
3
2021-04-17T18:36:24.000Z
2022-03-04T20:30:09.000Z
challenge/leet.gcc/q658/q658/main.cpp
odys-z/hello
39ca67cae34eb4bc4cbd848a06b3c0d65a995954
[ "MIT" ]
null
null
null
#include <QCoreApplication> #include <iostream> #include "coutvectors.h" #include "q658.h" using namespace std; int main(int argc, char *argv[]) { // QCoreApplication a(argc, argv); Q658* q = new Q658(); vector<int> arr {1, 2, 3}; vector<int> reslt = q->findClosestElements(arr, 3, 2); CoutVectors::ints(reslt); // expect [1, 2, 3] arr = vector<int>{1, 2}; reslt = q->findClosestElements(arr, 1, 2); CoutVectors::ints(reslt); // expect [1] cout << endl << "OK!" << endl; return 0; }
21.16
58
0.604915
[ "vector" ]
2d297311cd31a2cca6cf661df07b5fbec82033c8
1,667
cpp
C++
src/mlpack/bindings/tests/clean_memory.cpp
oblanchet/mlpack
e02ab3be544694294d2f73bd12a98d0d162ef3af
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
4,216
2015-01-01T02:06:12.000Z
2022-03-31T19:12:06.000Z
src/mlpack/bindings/tests/clean_memory.cpp
oblanchet/mlpack
e02ab3be544694294d2f73bd12a98d0d162ef3af
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2,621
2015-01-01T01:41:47.000Z
2022-03-31T19:01:26.000Z
src/mlpack/bindings/tests/clean_memory.cpp
oblanchet/mlpack
e02ab3be544694294d2f73bd12a98d0d162ef3af
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1,972
2015-01-01T23:37:13.000Z
2022-03-28T06:03:41.000Z
/** * @file bindings/tests/clean_memory.cpp * @author Ryan Curtin * * Delete any pointers held by the IO object. * * mlpack is free software; you may redistribute it and/or modify it under the * terms of the 3-clause BSD license. You should have received a copy of the * 3-clause BSD license along with mlpack. If not, see * http://www.opensource.org/licenses/BSD-3-Clause for more information. */ #include "clean_memory.hpp" #include <mlpack/core.hpp> #include <mlpack/core/util/params.hpp> namespace mlpack { namespace bindings { namespace tests { /** * Delete any pointers held by the IO object. */ void CleanMemory(util::Params& params) { // If we are holding any pointers, then we "own" them. But we may hold the // same pointer twice, so we have to be careful to not delete it multiple // times. std::unordered_map<void*, util::ParamData*> memoryAddresses; auto it = params.Parameters().begin(); while (it != params.Parameters().end()) { util::ParamData& data = it->second; void* result; params.functionMap[data.tname]["GetAllocatedMemory"](data, NULL, (void*) &result); if (result != NULL && memoryAddresses.count(result) == 0) memoryAddresses[result] = &data; ++it; } // Now we have all the unique addresses that need to be deleted. std::unordered_map<void*, util::ParamData*>::const_iterator it2; it2 = memoryAddresses.begin(); while (it2 != memoryAddresses.end()) { util::ParamData& data = *(it2->second); params.functionMap[data.tname]["DeleteAllocatedMemory"](data, NULL, NULL); ++it2; } } } // namespace tests } // namespace bindings } // namespace mlpack
27.783333
78
0.683863
[ "object" ]
2d2a4a65645e413659611c87b90dc81709b5d4cb
2,721
hpp
C++
log4cxx/string_utility.hpp
wangzhicheng2013/log_system
69787cb10d30f36b2ff532b2db96106c272eafd4
[ "MIT" ]
null
null
null
log4cxx/string_utility.hpp
wangzhicheng2013/log_system
69787cb10d30f36b2ff532b2db96106c272eafd4
[ "MIT" ]
null
null
null
log4cxx/string_utility.hpp
wangzhicheng2013/log_system
69787cb10d30f36b2ff532b2db96106c272eafd4
[ "MIT" ]
null
null
null
#pragma once #include <stdio.h> #include <string.h> #include <stdarg.h> #include <string> #include <vector> #include <unordered_map> #include "single_instance.hpp" class string_utility { public: void replace_all(std::string &origin_str, const char *pattern, const char *val) { size_t size = strlen(val); std::string::size_type pos = 0; while (pos != std::string::npos) { pos = origin_str.find(pattern, pos); if (std::string::npos == pos) { break; } origin_str.replace(pos, size, val); pos += size; } } void get_url_args(const char *url, std::unordered_map<std::string, std::string>&args) { const char *p = url; std::vector<std::string>keys; std::vector<std::string>values; while(*p) { if('?' == *p) { break; } p++; } if (0 == *p) { return; } char tmp[1024] = ""; int loop = 0; bool Get = false; while (*p) { if (*(p + 1) && !Get) { sscanf(p + 1, "%[^= | &]", tmp); if (strcmp(tmp, "")) { Get = true; if (!loop) { keys.emplace_back(tmp); } else { values.emplace_back(tmp); } } } p++; if (0 == *p) { break; } if (('=' == *p) || ('&' == *p)) { if ('=' == *p) { loop = 1; } else { loop = 0; } Get = false; } } if (keys.size() != values.size()) { return; } int size = keys.size(); for (int i = 0;i < size;i++) { args[keys[i]] = values[i]; } } void get_special_sub_str(const std::string &original_str, char ch, std::string &sub_str) { auto pos = original_str.find(ch); if (std::string::npos == pos) { sub_str = original_str; return; } sub_str.assign(original_str, 0, pos); } inline std::string get_format_str(const char *format_str, ...) { va_list args; va_start(args, format_str); char buf[1024] = ""; vsnprintf(buf, sizeof(buf), format_str, args); va_end(args); return buf; } }; #define G_STRING_UTILITY single_instance<string_utility>::instance()
29.576087
95
0.408306
[ "vector" ]
2d2b21b7ed1304df0fa1256c0361f7dd294061e7
1,081
cpp
C++
Graph/detect_cycle.cpp
Nilesh-Das/dsalgo
2454f272a5de47e7b9cfbde73bf7c01d0d1492a2
[ "MIT" ]
null
null
null
Graph/detect_cycle.cpp
Nilesh-Das/dsalgo
2454f272a5de47e7b9cfbde73bf7c01d0d1492a2
[ "MIT" ]
null
null
null
Graph/detect_cycle.cpp
Nilesh-Das/dsalgo
2454f272a5de47e7b9cfbde73bf7c01d0d1492a2
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; // https://codeforces.com/contest/510/problem/B vector<vector<int>> grid, vis; vector<vector<int>> dir = {{1,0},{-1,0},{0,1},{0,-1}}; int n, m; void fuckingyes() { cout << "Yes\n"; exit(0); } void dfs(int x, int y, int px, int py, int c) { if(vis[x][y]) fuckingyes(); vis[x][y] = 1; for(auto d : dir) { int nx = x + d[0]; int ny = y + d[1]; if(nx==px && ny==py) continue; if(nx<0 || nx>=n || ny<0 || ny>=m) continue; if(grid[nx][ny] != c) continue; dfs(nx, ny, x, y, c); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; grid.resize(n, vector<int>(m)); vis.resize(n, vector<int>(m)); for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { char c; cin >> c; grid[i][j] = c-'A'; } } for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { if(!vis[i][j]) dfs(i, j, -1, -1, grid[i][j]); } } cout << "No\n"; return 0; }
21.196078
57
0.440333
[ "vector" ]
2d3480fd11461e8f3f968a6a16d7e2373aa55c85
1,557
cc
C++
src/goesproc/lrit_processor.cc
codient/goestools
862600960681a1a1f3942f18f40b1f17dcdffc40
[ "BSD-2-Clause" ]
244
2017-11-07T12:12:23.000Z
2022-03-24T07:24:53.000Z
src/goesproc/lrit_processor.cc
codient/goestools
862600960681a1a1f3942f18f40b1f17dcdffc40
[ "BSD-2-Clause" ]
116
2018-03-07T04:02:26.000Z
2022-03-27T12:08:01.000Z
src/goesproc/lrit_processor.cc
codient/goestools
862600960681a1a1f3942f18f40b1f17dcdffc40
[ "BSD-2-Clause" ]
65
2018-05-28T02:44:21.000Z
2022-03-18T12:27:58.000Z
#include "lrit_processor.h" #include <sys/stat.h> #include <algorithm> #include "lib/dir.h" #include "lrit/file.h" LRITProcessor::LRITProcessor(std::vector<std::unique_ptr<Handler> > handlers) : handlers_(std::move(handlers)) { } void LRITProcessor::run(int argc, char** argv) { std::vector<std::shared_ptr<lrit::File>> files; std::map<std::string, int64_t> time; // Gather files from arguments (globs *.lrit* in directories). for (int i = 0; i < argc; i++) { struct stat st; auto rv = stat(argv[i], &st); if (rv < 0) { perror("stat"); exit(1); } if (S_ISDIR(st.st_mode)) { Dir dir(argv[i]); auto result = dir.matchFiles("*.lrit*"); for (const auto& path : result) { files.push_back(std::make_shared<lrit::File>(path)); } } else { files.push_back(std::make_shared<lrit::File>(argv[i])); } } // Gather time stamps (per-second granularity is plenty) for (const auto& file : files) { if (file->hasHeader<lrit::TimeStampHeader>()) { auto ts = file->getHeader<lrit::TimeStampHeader>().getUnix(); time[file->getName()] = ts.tv_sec; } else { time[file->getName()] = 0; } } // Sort files by their LRIT time std::sort( files.begin(), files.end(), [&time](const auto& a, const auto& b) -> bool { return time[a->getName()] < time[b->getName()]; }); // Process files in chronological order for (const auto& file : files) { for (auto& handler : handlers_) { handler->handle(file); } } }
25.112903
77
0.594091
[ "vector" ]
2d3646e1cfb3d220a746892d3a5390548c9a3d75
3,819
cpp
C++
app/src/viewmanager.cpp
DaveeFTW/infinity
6a4f269f8abcf65696064cad94ba9ac8b845bd74
[ "MIT" ]
137
2019-11-10T16:12:16.000Z
2022-03-27T23:32:15.000Z
app/src/viewmanager.cpp
DaveeFTW/infinity
6a4f269f8abcf65696064cad94ba9ac8b845bd74
[ "MIT" ]
12
2019-11-11T20:37:05.000Z
2021-11-14T17:18:56.000Z
app/src/viewmanager.cpp
DaveeFTW/infinity
6a4f269f8abcf65696064cad94ba9ac8b845bd74
[ "MIT" ]
49
2019-11-15T02:37:05.000Z
2022-03-28T20:04:49.000Z
/* Copyright (C) 2015, David "Davee" Morgan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "viewmanager.h" #include "application.h" #include "buttonarbiter.h" #include "buttontransition.h" #include "event.h" #include "graphicsdevice.h" #include "numberanimation.h" #include "scene.h" #include "state.h" #include "statemachine.h" #include "timer.h" #include "view.h" #include <pspdisplay.h> #include <pspgu.h> #include <pspgum.h> #include <psputils.h> #include <algorithm> #include "vertextype.h" #include <pspdebug.h> #include <string.h> namespace { void sceGumOrtho2(float left, float right, float bottom, float top, float near, float far) { ScePspFMatrix4* t; ScePspFMatrix4 t2; t = &t2; float dx = right - left, dy = top - bottom, dz = far - near; memset(t, 0, sizeof(ScePspFMatrix4)); t->x.x = 2.0f / dx; t->w.x = -(right + left) / dx; t->y.y = 2.0f / dy; t->w.y = -(top + bottom) / dy; t->z.z = -2.0f / dz; t->w.z = -(far + near) / dz; t->w.w = 1.0f; sceGumMultMatrix(t); } } ViewManager::ViewManager(void) : m_graphicsDevice(new GraphicsDevice()) , m_buttonArbiter(new ButtonArbiter()) , m_stateMachine(nullptr) , m_scene(nullptr) { } void ViewManager::addView(View* view) { m_views.push_back(view); } void ViewManager::removeView(View* view) { auto it = std::find(m_views.begin(), m_views.end(), view); if (it != m_views.end()) { m_views.erase(it); } } void ViewManager::setStateMachine(StateMachine* machine) { m_stateMachine = machine; } GraphicsDevice* ViewManager::graphics(void) { return m_graphicsDevice; } void ViewManager::exec(void) { m_graphicsDevice->initialise(); Timer* timer = Timer::instance(); timer->start(); while (true) { // process all events Application::instance()->processEvents(); sceGuStart(GU_DIRECT, m_graphicsDevice->displayList()); sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT); // disable depth test sceGuDepthMask(GU_TRUE); // setup ortho projection sceGumMatrixMode(GU_PROJECTION); sceGumLoadIdentity(); sceGumOrtho2(0, 480, 272, 0, -1, 1); sceGumMatrixMode(GU_VIEW); sceGumLoadIdentity(); auto elapsedTime = timer->elapsed(true); for (auto it = m_views.begin(); it != m_views.end(); ++it) { // update our scene (*it)->update(elapsedTime); sceGumMatrixMode(GU_MODEL); sceGumLoadMatrix((*it)->model()); sceGumUpdateMatrix(); (*it)->render(); } sceGuFinish(); sceGuSync(0, 0); sceDisplayWaitVblankStart(); sceGuSwapBuffers(); } }
25.125
94
0.653836
[ "render", "model" ]
2d37d8b6e31edfdf73cebc6ea12ce0c85fb6c0d2
5,366
cc
C++
src/tint/resolver/is_storeable_test.cc
encounter/dawn-cmake
64a23ce0ede5f232cc209b69d64164ede6810b65
[ "Apache-2.0" ]
null
null
null
src/tint/resolver/is_storeable_test.cc
encounter/dawn-cmake
64a23ce0ede5f232cc209b69d64164ede6810b65
[ "Apache-2.0" ]
null
null
null
src/tint/resolver/is_storeable_test.cc
encounter/dawn-cmake
64a23ce0ede5f232cc209b69d64164ede6810b65
[ "Apache-2.0" ]
null
null
null
// Copyright 2021 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "src/tint/resolver/resolver.h" #include "gmock/gmock.h" #include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/sem/atomic.h" namespace tint::resolver { namespace { using ResolverIsStorableTest = ResolverTest; TEST_F(ResolverIsStorableTest, Void) { EXPECT_FALSE(r()->IsStorable(create<sem::Void>())); } TEST_F(ResolverIsStorableTest, Scalar) { EXPECT_TRUE(r()->IsStorable(create<sem::Bool>())); EXPECT_TRUE(r()->IsStorable(create<sem::I32>())); EXPECT_TRUE(r()->IsStorable(create<sem::U32>())); EXPECT_TRUE(r()->IsStorable(create<sem::F32>())); } TEST_F(ResolverIsStorableTest, Vector) { EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::I32>(), 2u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::I32>(), 3u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::I32>(), 4u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::U32>(), 2u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::U32>(), 3u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::U32>(), 4u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F32>(), 2u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F32>(), 3u))); EXPECT_TRUE(r()->IsStorable(create<sem::Vector>(create<sem::F32>(), 4u))); } TEST_F(ResolverIsStorableTest, Matrix) { auto* vec2 = create<sem::Vector>(create<sem::F32>(), 2u); auto* vec3 = create<sem::Vector>(create<sem::F32>(), 3u); auto* vec4 = create<sem::Vector>(create<sem::F32>(), 4u); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2, 2u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2, 3u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec2, 4u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec3, 2u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec3, 3u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec3, 4u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec4, 2u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec4, 3u))); EXPECT_TRUE(r()->IsStorable(create<sem::Matrix>(vec4, 4u))); } TEST_F(ResolverIsStorableTest, Pointer) { auto* ptr = create<sem::Pointer>(create<sem::I32>(), ast::StorageClass::kPrivate, ast::Access::kReadWrite); EXPECT_FALSE(r()->IsStorable(ptr)); } TEST_F(ResolverIsStorableTest, Atomic) { EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<sem::I32>()))); EXPECT_TRUE(r()->IsStorable(create<sem::Atomic>(create<sem::U32>()))); } TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) { auto* arr = create<sem::Array>(create<sem::I32>(), 5u, 4u, 20u, 4u, 4u); EXPECT_TRUE(r()->IsStorable(arr)); } TEST_F(ResolverIsStorableTest, ArrayUnsizedOfStorable) { auto* arr = create<sem::Array>(create<sem::I32>(), 0u, 4u, 4u, 4u, 4u); EXPECT_TRUE(r()->IsStorable(arr)); } TEST_F(ResolverIsStorableTest, Struct_AllMembersStorable) { Structure("S", { Member("a", ty.i32()), Member("b", ty.f32()), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverIsStorableTest, Struct_SomeMembersNonStorable) { Structure("S", { Member("a", ty.i32()), Member("b", ty.pointer<i32>(ast::StorageClass::kPrivate)), }); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( r()->error(), R"(error: ptr<private, i32, read_write> cannot be used as the type of a structure member)"); } TEST_F(ResolverIsStorableTest, Struct_NestedStorable) { auto* storable = Structure("Storable", { Member("a", ty.i32()), Member("b", ty.f32()), }); Structure("S", { Member("a", ty.i32()), Member("b", ty.Of(storable)), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverIsStorableTest, Struct_NestedNonStorable) { auto* non_storable = Structure("nonstorable", { Member("a", ty.i32()), Member("b", ty.pointer<i32>(ast::StorageClass::kPrivate)), }); Structure("S", { Member("a", ty.i32()), Member("b", ty.Of(non_storable)), }); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( r()->error(), R"(error: ptr<private, i32, read_write> cannot be used as the type of a structure member)"); } } // namespace } // namespace tint::resolver
38.884058
100
0.600261
[ "vector" ]
2d407f7d1e599cc865669ff9bcf814efadbf91ac
10,067
cpp
C++
tests/std/tests/P0608R3_improved_variant_converting_constructor/test.cpp
isra-fel/STL
6ae9a578b4f52193dc523922c943a2214a873577
[ "Apache-2.0" ]
1
2021-02-22T00:19:50.000Z
2021-02-22T00:19:50.000Z
tests/std/tests/P0608R3_improved_variant_converting_constructor/test.cpp
isra-fel/STL
6ae9a578b4f52193dc523922c943a2214a873577
[ "Apache-2.0" ]
null
null
null
tests/std/tests/P0608R3_improved_variant_converting_constructor/test.cpp
isra-fel/STL
6ae9a578b4f52193dc523922c943a2214a873577
[ "Apache-2.0" ]
null
null
null
// Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // Also tests for P1957R2: Converting from T* to bool should be considered narrowing #include <assert.h> #include <bitset> #include <functional> #include <optional> #include <string> #include <type_traits> #include <variant> #include <vector> using namespace std; struct double_double { double_double(double x) : x_(x) {} double x_; }; struct convertible_bool { convertible_bool(bool x) : x_(x) {} ~convertible_bool() = default; operator bool() const noexcept { return x_; } bool x_; }; struct default_struct {}; void assert_P0608R3() { // P0608R3 examples static_assert(is_constructible_v<variant<string, bool>, const char*>); static_assert(is_constructible_v<variant<string, bool>, string>); static_assert(is_constructible_v<variant<char, optional<char16_t>>, char16_t>); static_assert(is_constructible_v<variant<int, reference_wrapper<double>>, double&>); static_assert(is_constructible_v<variant<float, int>, char>); #ifndef __EDG__ // TRANSITION, DevCom-1337958 static_assert(is_constructible_v<variant<float, long>, int>); static_assert(is_constructible_v<variant<float, long long>, int>); static_assert(is_constructible_v<variant<float, long, double>, int>); static_assert(is_constructible_v<variant<float, vector<int>, long long>, int>); #endif // !__EDG__ static_assert(is_constructible_v<variant<float, int, long long>, char>); #ifndef __EDG__ // TRANSITION, DevCom-1337958 static_assert(!is_constructible_v<variant<float>, int>); static_assert(!is_constructible_v<variant<float, vector<int>>, int>); #endif // !__EDG__ static_assert(!is_constructible_v<variant<float, char>, int>); static_assert(is_assignable_v<variant<string, bool>, const char*>); static_assert(is_assignable_v<variant<string, bool>, string>); static_assert(is_assignable_v<variant<char, optional<char16_t>>, char16_t>); static_assert(is_assignable_v<variant<int, reference_wrapper<double>>, double&>); static_assert(is_assignable_v<variant<float, int>, char>); #ifndef __EDG__ // TRANSITION, DevCom-1337958 static_assert(is_assignable_v<variant<float, long>, int>); static_assert(is_assignable_v<variant<float, long long>, int>); static_assert(is_assignable_v<variant<float, long, double>, int>); static_assert(is_assignable_v<variant<float, vector<int>, long long>, int>); #endif // !__EDG__ static_assert(is_assignable_v<variant<float, int, long long>, char>); #ifndef __EDG__ // TRANSITION, DevCom-1337958 static_assert(!is_assignable_v<variant<float>, int>); static_assert(!is_assignable_v<variant<float, vector<int>>, int>); #endif // !__EDG__ static_assert(!is_assignable_v<variant<float, char>, int>); } void assert_P1957R2() { // P1957R2 examples static_assert(is_constructible_v<variant<bool, int>, bool>); static_assert(is_constructible_v<variant<bool, int>, bitset<4>::reference>); static_assert(is_constructible_v<variant<bool>, bitset<4>::reference>); static_assert(is_assignable_v<variant<bool, int>, bool>); static_assert(is_assignable_v<variant<bool, int>, bitset<4>::reference>); static_assert(is_assignable_v<variant<bool>, bitset<4>::reference>); } void assert_more_examples() { // More examples static_assert(is_constructible_v<variant<double_double>, double>); static_assert(is_constructible_v<variant<vector<vector<int>>, optional<int>, int>, int>); static_assert(is_constructible_v<variant<vector<vector<int>>, optional<int>>, int>); static_assert(is_constructible_v<variant<vector<int>, optional<int>, float>, int>); static_assert(is_constructible_v<variant<bool>, convertible_bool>); static_assert(is_constructible_v<variant<bool, int>, convertible_bool>); static_assert(is_constructible_v<variant<convertible_bool>, bool>); static_assert(is_constructible_v<variant<float, bool, convertible_bool>, convertible_bool>); static_assert(is_constructible_v<variant<float, bool, convertible_bool>, bool>); static_assert(is_constructible_v<variant<char, int>, bool>); #ifndef __EDG__ // TRANSITION, DevCom-1337958 #ifdef __clang__ // TRANSITION, DevCom-1338628 static_assert(is_constructible_v<variant<double_double>, int>); #endif // __clang__ static_assert(!is_constructible_v<variant<float>, unsigned int>); static_assert(!is_constructible_v<variant<char, default_struct>, int>); #endif // !__EDG__ static_assert(!is_constructible_v<variant<float, long, long long>, int>); static_assert(is_assignable_v<variant<double_double>, double>); static_assert(is_assignable_v<variant<vector<vector<int>>, optional<int>, int>, int>); static_assert(is_assignable_v<variant<vector<vector<int>>, optional<int>>, int>); static_assert(is_assignable_v<variant<vector<int>, optional<int>, float>, int>); static_assert(is_assignable_v<variant<bool>, convertible_bool>); static_assert(is_assignable_v<variant<bool, int>, convertible_bool>); static_assert(is_assignable_v<variant<convertible_bool>, bool>); static_assert(is_assignable_v<variant<float, bool, convertible_bool>, convertible_bool>); static_assert(is_assignable_v<variant<float, bool, convertible_bool>, bool>); static_assert(is_assignable_v<variant<char, int>, bool>); #ifndef __EDG__ // TRANSITION, DevCom-1337958 #ifdef __clang__ // TRANSITION, DevCom-1338628 static_assert(is_assignable_v<variant<double_double>, int>); #endif // __clang__ static_assert(!is_assignable_v<variant<float>, unsigned int>); static_assert(!is_assignable_v<variant<char, default_struct>, int>); #endif // !__EDG__ static_assert(!is_assignable_v<variant<float, long, long long>, int>); } void test_variant_constructor_P0608R3() { // P0608R3 runtime checks variant<string, bool> a = "abc"; // string assert(a.index() == 0); assert(get<0>(a) == "abc"); variant<char, optional<char16_t>> b = u'\u2043'; // optional<char16_t> assert(b.index() == 1); assert(get<optional<char16_t>>(b) == u'\u2043'); double c_data = 3.14; variant<int, reference_wrapper<double>> c = c_data; // reference_wrapper<double> assert(c.index() == 1); assert(get<1>(c) == c_data); variant<float, int> d; assert(d.index() == 0); d = 0; // int assert(d.index() == 1); variant<float, long> e; assert(e.index() == 0); #ifndef __EDG__ // TRANSITION, DevCom-1337958 e = 0; // long assert(e.index() == 1); #endif // !__EDG__ variant<float, int> f = 'a'; // int assert(f.index() == 1); assert(get<int>(f) == 97); #ifndef __EDG__ // TRANSITION, DevCom-1337958 variant<float, long> g = 0; // long assert(g.index() == 1); variant<float, long, double> h = 0; // long assert(h.index() == 1); variant<float, vector<int>, long long> i = 0; // long long assert(i.index() == 2); #endif // !__EDG__ variant<float, int, long long> j = 'a'; // int assert(j.index() == 1); assert(get<int>(j) == 97); } void test_variant_constructor_P1957R2() { bitset<4> a_bitset("0101"); bool a_data = a_bitset[2]; variant<bool, int> a = a_data; // bool assert(a.index() == 0); assert(get<0>(a)); bitset<4> b_bitset("0101"); variant<bool, int> b = b_bitset[2]; // bool variant<bool, int> b2 = b_bitset[1]; // bool assert(b.index() == 0); assert(get<0>(b)); assert(b2.index() == 0); assert(!get<0>(b2)); } void test_variant_constructor_more_examples() { variant<char, int, float, bool, vector<bool>> a = true; // bool assert(a.index() == 3); variant<bool, int> b = convertible_bool{true}; // bool assert(b.index() == 0); assert(get<0>(b)); variant<char, int, bool> c = false; // bool assert(c.index() == 2); variant<float, bool, convertible_bool> d = convertible_bool{true}; // convertible_bool assert(d.index() == 2); variant<float, bool, convertible_bool> e = bool{}; // bool assert(e.index() == 1); assert(!get<1>(e)); variant<float, bool> f = convertible_bool{false}; // bool assert(f.index() == 1); assert(!get<1>(f)); variant<bool, int> g = true_type{}; // bool assert(g.index() == 0); assert(get<0>(g)); } void test_assignment_operator() { variant<string, bool, int> a; // string assert(a.index() == 0); assert(get<string>(a) == ""); a = 3; // int assert(a.index() == 2); assert(get<int>(a) == 3); a = true; // bool assert(a.index() == 1); assert(get<bool>(a) == true); #ifndef __EDG__ // TRANSITION, DevCom-1337958 bool b_data = true; variant<bool, int, double_double> b = b_data; // bool assert(b.index() == 0); assert(get<0>(b) == b_data); b = 12; // int assert(b.index() == 1); assert(get<1>(b) == 12); b = 12.5; // double_double assert(b.index() == 2); assert(get<2>(b).x_ == 12.5); #endif // !__EDG__ #ifdef __clang__ // TRANSITION, DevCom-1338628 variant<void*, bool, double_double> c; assert(c.index() == 0); c = false; // bool assert(c.index() == 1); assert(get<1>(c) == false); c = 5.12; // double_double assert(c.index() == 2); assert(get<2>(c).x_ == 5.12); double_double c_data{1.2}; c = static_cast<void*>(&c_data); // void* assert(c.index() == 0); assert(static_cast<double_double*>(get<0>(c))->x_ == 1.2); #endif // __clang__ } int main() { assert_P0608R3(); assert_P1957R2(); assert_more_examples(); test_variant_constructor_P0608R3(); test_variant_constructor_P1957R2(); test_variant_constructor_more_examples(); test_assignment_operator(); }
38.132576
97
0.659481
[ "vector" ]
2d413ce481a73a15e2c5cd34c3cf87d3201bacc7
2,468
cpp
C++
src/field.cpp
ihtiandr9/AMQP-CPP
7b671fa637863ec65948d7dc7585ff802b4f0407
[ "Apache-2.0" ]
713
2015-01-16T07:53:09.000Z
2022-03-26T07:13:25.000Z
src/field.cpp
ihtiandr9/AMQP-CPP
7b671fa637863ec65948d7dc7585ff802b4f0407
[ "Apache-2.0" ]
335
2015-01-07T10:14:41.000Z
2022-03-28T19:39:33.000Z
src/field.cpp
ihtiandr9/AMQP-CPP
7b671fa637863ec65948d7dc7585ff802b4f0407
[ "Apache-2.0" ]
345
2015-01-25T12:24:29.000Z
2022-03-15T12:53:13.000Z
/** * Field.cpp * * @copyright 2014 - 2020 Copernica BV */ #include "includes.h" /** * Set up namespace */ namespace AMQP { /** * Decode a field by fetching a type and full field from a frame * The returned field is allocated on the heap! * @param frame * @return std::unique_ptr<Field> */ std::unique_ptr<Field> Field::decode(InBuffer &frame) { // get the type uint8_t type = frame.nextUint8(); // create field based on type switch (type) { // @todo: use std::make_unique when switching to C++14/17/20 case 't': return std::unique_ptr<Field>(new BooleanSet(frame)); case 'b': return std::unique_ptr<Field>(new Octet(frame)); case 'B': return std::unique_ptr<Field>(new UOctet(frame)); case 'U': return std::unique_ptr<Field>(new Short(frame)); case 'u': return std::unique_ptr<Field>(new UShort(frame)); case 'I': return std::unique_ptr<Field>(new Long(frame)); case 'i': return std::unique_ptr<Field>(new ULong(frame)); case 'L': return std::unique_ptr<Field>(new LongLong(frame)); case 'l': return std::unique_ptr<Field>(new ULongLong(frame)); case 'f': return std::unique_ptr<Field>(new Float(frame)); case 'd': return std::unique_ptr<Field>(new Double(frame)); case 'D': return std::unique_ptr<Field>(new DecimalField(frame)); case 's': return std::unique_ptr<Field>(new ShortString(frame)); case 'S': return std::unique_ptr<Field>(new LongString(frame)); case 'A': return std::unique_ptr<Field>(new Array(frame)); case 'T': return std::unique_ptr<Field>(new Timestamp(frame)); case 'F': return std::unique_ptr<Field>(new Table(frame)); case 'V': return std::unique_ptr<Field>(new VoidField(frame)); default: return nullptr; } } /** * Cast to string * @return std::string */ Field::operator const std::string& () const { // static empty string static std::string empty; // return it return empty; } /** * Cast to array * @return Array */ Field::operator const Array& () const { // static empty array static Array empty; // return it return empty; } /** * Cast to object * @return Array */ Field::operator const Table& () const { // static empty table static Table empty; // return it return empty; } /** * End of namespace */ }
26.255319
75
0.606969
[ "object" ]
2d4635935e710fb04ff1ded027340ee109754cee
2,830
cpp
C++
C++Server/Test_Tools/main.cpp
IncompleteWorlds/01_gs4cubesat
4386a3a8b984e96cab364bab83fc2fb49aa5cc3d
[ "RSA-MD" ]
null
null
null
C++Server/Test_Tools/main.cpp
IncompleteWorlds/01_gs4cubesat
4386a3a8b984e96cab364bab83fc2fb49aa5cc3d
[ "RSA-MD" ]
null
null
null
C++Server/Test_Tools/main.cpp
IncompleteWorlds/01_gs4cubesat
4386a3a8b984e96cab364bab83fc2fb49aa5cc3d
[ "RSA-MD" ]
null
null
null
/** * CubeGS * An online Ground Segment for Cubesats and Small Sats * (c) 2017 Incomplete Worlds * */ /* * THIS TOOL IS INCOMPLETE * A GENERIC JSON CANNOT BE CREATED WITHOUT CREATING A MESSAGE * STRUCTURE BEFOREHAND. THUS, IT DOES NOT WORK * */ #include <iostream> #include <string> #include <vector> #include <string> using namespace std; #include <avro/Decoder.hh> #include <avro/Encoder.hh> #include <zmq.hpp> void readFile(const string& inFileName, string& textMessage) { // Open file ifstream inputFile(inFileName.c_str(), ios:: text); if(inputFile.is_open() == false) { // Error cout << "ERROR: Opening input message file: " << inFileName << endl; } else { // Read the whole file as a string string tmpLine; while(inputFile.eof() == false) { getline(inputFile, tmpLine); textMessage += tmpLine; // cout << tmpLine << endl; } // Close the file inputFile.close(); } } int main(int argc, char* argv[]) { cout << "SendMessage" << endl; cout << "Incomplete Worlds (c) 2017 " << endl; cout << endl; if(argc < 4) { cout << "ERROR: Incorrect number of parameters" << endl; cout << endl; cout << "Usage: SendMessage message_file.json IP_address:port" << endl; cout << endl; } else { // Read the input file. Message coded in JSON string messageFileName{ argv[1] }; string ipAddress{ argv[2] }; // Read the file and store in a string string textMessage; readFile(messageFileName, textMessage); // Read schema //avro::ValidSchema inputSchema; // Encode in Avro unique_ptr<avro::OutputStream> avroOutput = avro::memoryOutputStream(); // Create a binary encoder avro::EncoderPtr avroEncoder = avro::binaryEncoder(); // Encode the message - AVRO avroEncoder->init(*avroOutput); avro::encode(*avroEncoder, inAvroMsg); avroEncoder->flush(); // Create a ZMQ socket zmq::context_t context_{ 1 }; zmq::socket_t socket_(context_, ZMQ_REQ); socket_.connect(ipAddress); // Create message zmq::message_t outputMessage; AVRO_DECL DecoderPtr jsonDecoder(const ValidSchema& schema); vector<uint8_t> outData(textMessage.size()); for(uint32_t i = 0; i < textMessage.size(); i++) { outData[i] = textMessage[i]; // printf(" %02x %02x \n", textMessage[i], outData[i]); } // Send the message socket_.send(outputMessage); // Wait for reply zmq::message_t replyMessage; socket_.recv(replyMessage); // Show the answer } return 0; }
23.38843
81
0.584099
[ "vector" ]
2d46b755df449b6b3dec9777065c4e4d8a346186
26,168
cpp
C++
lib/src/test/metadataToneCurveTest.cpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
182
2019-04-19T12:38:30.000Z
2022-03-20T16:48:20.000Z
lib/src/test/metadataToneCurveTest.cpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
107
2019-04-23T10:49:35.000Z
2022-03-02T18:12:28.000Z
lib/src/test/metadataToneCurveTest.cpp
tlalexander/stitchEm
cdff821ad2c500703e6cb237ec61139fce7bf11c
[ "MIT" ]
59
2019-06-04T11:27:25.000Z
2022-03-17T23:49:49.000Z
// Copyright (c) 2012-2017 VideoStitch SAS // Copyright (c) 2018 stitchEm #include "gpu/testing.hpp" #include "libvideostitch/parse.hpp" #include "libvideostitch/panoDef.hpp" #include "exposure/metadataProcessor.hpp" namespace VideoStitch { namespace Testing { static const int NUM_INPUTS{4}; std::unique_ptr<Core::PanoDefinition> getTestPanoDef() { Potential<Ptv::Parser> parser(Ptv::Parser::create()); if (!parser->parseData("{" " \"width\": 513, " " \"height\": 315, " " \"hfov\": 90.0, " " \"proj\": \"rectilinear\", " " \"inputs\": [ " " { " " \"width\": 17, " " \"height\": 13, " " \"hfov\": 90.0, " " \"yaw\": 0.0, " " \"pitch\": 0.0, " " \"roll\": 0.0, " " \"proj\": \"rectilinear\", " " \"viewpoint_model\": \"ptgui\", " " \"response\": \"linear\", " " \"filename\": \"\" " " }, " " { " " \"width\": 17, " " \"height\": 13, " " \"hfov\": 90.0, " " \"yaw\": 0.0, " " \"pitch\": 0.0, " " \"roll\": 0.0, " " \"proj\": \"rectilinear\", " " \"viewpoint_model\": \"ptgui\", " " \"response\": \"linear\", " " \"filename\": \"\" " " }, " " { " " \"width\": 17, " " \"height\": 13, " " \"hfov\": 90.0, " " \"yaw\": 0.0, " " \"pitch\": 0.0, " " \"roll\": 0.0, " " \"proj\": \"rectilinear\", " " \"viewpoint_model\": \"ptgui\", " " \"response\": \"linear\", " " \"filename\": \"\" " " }, " " { " " \"width\": 17, " " \"height\": 13, " " \"hfov\": 90.0, " " \"yaw\": 0.0, " " \"pitch\": 0.0, " " \"roll\": 0.0, " " \"proj\": \"rectilinear\", " " \"viewpoint_model\": \"ptgui\", " " \"response\": \"linear\", " " \"filename\": \"\" " " } " " ]" "}")) { std::cerr << parser->getErrorMessage() << std::endl; ENSURE(false, "could not parse"); return NULL; } std::unique_ptr<Core::PanoDefinition> panoDef(Core::PanoDefinition::create(parser->getRoot())); ENSURE((bool)panoDef); return panoDef; } const std::array<uint16_t, 256>& getLinearToneCurve() { static std::array<uint16_t, 256> linear = []() -> std::array<uint16_t, 256> { std::array<uint16_t, 256> values; for (uint16_t i = 0; i < 256; i++) { values[i] = i; } return values; }(); return linear; } // a linear metadata uint16_t tone curve applied on top the Orah 4i camera response const std::array<uint16_t, 256>& getOrahLinearCurve() { static std::array<uint16_t, 256> values = { {0, 4, 7, 11, 15, 18, 21, 25, 28, 31, 35, 38, 41, 44, 47, 50, 53, 56, 58, 61, 64, 66, 69, 72, 74, 77, 79, 82, 84, 86, 89, 91, 93, 95, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 121, 123, 125, 127, 128, 130, 132, 133, 135, 137, 138, 140, 141, 143, 144, 146, 147, 149, 150, 152, 153, 154, 156, 157, 158, 160, 161, 162, 163, 164, 166, 167, 168, 169, 170, 171, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 188, 189, 190, 191, 192, 193, 194, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 202, 203, 204, 204, 205, 206, 206, 207, 208, 208, 209, 210, 210, 211, 212, 212, 213, 213, 214, 215, 215, 216, 216, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, 225, 225, 226, 226, 227, 227, 227, 228, 228, 229, 229, 230, 230, 230, 231, 231, 232, 232, 232, 233, 233, 234, 234, 234, 235, 235, 236, 236, 236, 237, 237, 237, 238, 238, 238, 239, 239, 239, 240, 240, 240, 241, 241, 241, 241, 242, 242, 242, 243, 243, 243, 244, 244, 244, 244, 245, 245, 245, 245, 246, 246, 246, 246, 247, 247, 247, 247, 248, 248, 248, 248, 249, 249, 249, 249, 250, 250, 250, 250, 250, 251, 251, 251, 251, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 255, 255, 255}}; return values; } std::array<uint16_t, 256> getGammaToneCurve(double gamma) { std::array<uint16_t, 256> values; for (uint16_t i = 0; i < 256; i++) { values[i] = static_cast<uint16_t>(round(pow(i / 255.f, gamma) * 255.f)); } return values; } // a gamma metadata uint16_t tone curve applied on top the Orah 4i camera response template <int gamma10> std::array<uint16_t, 256>& getOrahGammaToneCurve(); template <> std::array<uint16_t, 256>& getOrahGammaToneCurve<12>() { // libvideostitch has Orah 4i curve as float values // curve = np.array([ ... values from Gamma.gma.mpg ...]) / 1023 * 255 // // The gamma 1.2 metadata tone curve is passed in uint16_t values --> round // gamma_1_2_u16 = np.rint((np.arange(256) / 255.) ** 1.2 * 255) // Result should be interpolated properly, then rounded to uint16_t again // values = np.round(np.interp(curve, np.arange(256), gamma_1_2_u16)) static std::array<uint16_t, 256> values = { {0, 2, 3, 6, 9, 11, 13, 16, 18, 20, 24, 26, 28, 31, 34, 36, 39, 41, 43, 46, 49, 50, 53, 56, 58, 61, 62, 65, 67, 69, 72, 74, 76, 78, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 104, 106, 108, 110, 112, 114, 116, 117, 119, 121, 122, 124, 125, 127, 129, 131, 132, 134, 135, 137, 138, 139, 141, 142, 144, 146, 147, 148, 149, 150, 152, 153, 155, 156, 157, 158, 160, 161, 162, 163, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 176, 177, 177, 178, 179, 180, 181, 183, 184, 184, 185, 186, 187, 188, 188, 190, 191, 192, 193, 193, 194, 195, 195, 196, 197, 198, 199, 200, 200, 201, 202, 202, 203, 204, 204, 205, 206, 207, 208, 208, 209, 209, 210, 211, 211, 212, 212, 213, 214, 215, 215, 216, 216, 217, 217, 218, 218, 219, 219, 220, 221, 222, 222, 222, 223, 223, 224, 224, 225, 225, 225, 226, 227, 227, 228, 228, 229, 229, 230, 230, 230, 231, 231, 232, 232, 232, 233, 234, 234, 235, 235, 235, 236, 236, 236, 237, 237, 237, 238, 238, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242, 242, 242, 243, 243, 243, 243, 244, 244, 244, 244, 245, 245, 245, 246, 246, 247, 247, 247, 248, 248, 248, 248, 249, 249, 249, 249, 249, 250, 250, 250, 250, 251, 251, 251, 251, 252, 252, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 255, 255, 255}}; return values; } template <> std::array<uint16_t, 256>& getOrahGammaToneCurve<15>() { // as getOrahGammaToneCurve<12>(), but with ** 1.5 static std::array<uint16_t, 256> values = { {0, 1, 1, 2, 4, 5, 6, 8, 9, 11, 13, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 53, 54, 56, 58, 61, 63, 65, 66, 68, 70, 72, 74, 76, 78, 80, 82, 83, 85, 88, 90, 91, 93, 95, 96, 98, 100, 102, 104, 105, 107, 108, 110, 112, 114, 115, 117, 119, 120, 122, 123, 124, 127, 128, 129, 130, 132, 134, 135, 136, 138, 139, 140, 142, 143, 145, 146, 147, 149, 150, 151, 152, 154, 155, 156, 158, 159, 160, 161, 162, 163, 164, 165, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 188, 189, 191, 191, 192, 193, 194, 195, 195, 196, 197, 198, 199, 199, 200, 201, 202, 203, 203, 204, 204, 205, 206, 207, 208, 209, 209, 210, 210, 211, 211, 212, 213, 214, 214, 215, 216, 216, 217, 217, 218, 218, 219, 220, 220, 221, 221, 222, 223, 223, 224, 224, 225, 226, 226, 227, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 234, 235, 236, 236, 236, 237, 237, 237, 238, 239, 239, 239, 240, 240, 240, 241, 241, 242, 242, 242, 243, 243, 243, 244, 244, 245, 245, 245, 246, 246, 246, 247, 247, 248, 248, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 252, 252, 252, 252, 253, 253, 253, 254, 254, 254, 254, 255, 255, 255}}; return values; } template <> std::array<uint16_t, 256>& getOrahGammaToneCurve<9>() { // as getOrahGammaToneCurve<12>(), but with ** 0.9 static std::array<uint16_t, 256> values = { {0, 6, 10, 15, 20, 23, 27, 32, 35, 38, 43, 46, 49, 52, 56, 59, 62, 65, 67, 70, 73, 76, 79, 82, 84, 87, 89, 92, 94, 96, 99, 101, 103, 105, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 127, 129, 130, 132, 134, 136, 137, 139, 141, 142, 144, 146, 147, 149, 150, 152, 152, 154, 155, 157, 158, 160, 161, 162, 164, 165, 166, 168, 169, 170, 170, 171, 173, 174, 175, 176, 177, 178, 180, 181, 182, 183, 184, 185, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 194, 195, 196, 197, 198, 198, 199, 199, 200, 201, 202, 203, 203, 204, 205, 206, 207, 207, 208, 209, 209, 210, 210, 210, 211, 212, 212, 213, 214, 214, 215, 216, 216, 217, 217, 218, 219, 219, 220, 220, 221, 221, 221, 222, 222, 223, 223, 224, 224, 225, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 230, 231, 231, 231, 231, 232, 232, 232, 233, 233, 234, 234, 234, 235, 235, 236, 236, 236, 237, 237, 238, 238, 238, 239, 239, 239, 240, 240, 240, 241, 241, 241, 241, 241, 241, 242, 242, 242, 242, 243, 243, 243, 244, 244, 244, 245, 245, 245, 245, 246, 246, 246, 246, 247, 247, 247, 247, 248, 248, 248, 248, 249, 249, 249, 249, 250, 250, 250, 250, 250, 250, 250, 250, 250, 251, 251, 251, 251, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 255, 255, 255}}; return values; } void testAppendToneCurve() { std::unique_ptr<Core::PanoDefinition> panoDef = getTestPanoDef(); ENSURE(panoDef->numVideoInputs() == NUM_INPUTS); FrameRate frameRate{30, 1}; std::vector<std::pair<int, GPU::Buffer<const uint32_t>>> frames{{0, {}}}; // ensure inputs are currently linear response for (const auto& videoInput : panoDef->getVideoInputs()) { ENSURE(videoInput.get().getPhotoResponse() == Core::InputDefinition::PhotoResponse::LinearResponse); } Exposure::MetadataProcessor mp; auto applyToneCurveToPanoAtFrame = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame, const Input::MetadataChunk& metadata) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano(metadata, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; auto updatePanoNoNewData = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano({}, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; // ensure inputs are still linear response (tone curve arrives at frame 1000) for (const auto& videoInput : panoDef->getVideoInputs()) { ENSURE(videoInput.get().getPhotoResponse() == Core::InputDefinition::PhotoResponse::LinearResponse); } { frameid_t toneCurveDataFrame{1000}; mtime_t toneCurveDataTime = frameRate.frameToTimestamp(toneCurveDataFrame); Metadata::ToneCurve toneCurve{toneCurveDataTime, getLinearToneCurve()}; Input::MetadataChunk metadata; metadata.toneCurve.push_back({{0, toneCurve}}); applyToneCurveToPanoAtFrame(999, metadata); } // ensure inputs are still linear response (tone curve arrives at frame 1000) for (const auto& videoInput : panoDef->getVideoInputs()) { ENSURE(videoInput.get().getPhotoResponse() == Core::InputDefinition::PhotoResponse::LinearResponse); } updatePanoNoNewData(999); // ensure inputs are still linear response (tone curve arrives at frame 1000) for (const auto& videoInput : panoDef->getVideoInputs()) { ENSURE(videoInput.get().getPhotoResponse() == Core::InputDefinition::PhotoResponse::LinearResponse); } updatePanoNoNewData(1000); // ensure input are now in curve response { videoreaderid_t videoInputID = 0; for (const auto& videoInput : panoDef->getVideoInputs()) { auto expectedResponse = videoInputID == 0 ? Core::InputDefinition::PhotoResponse::CurveResponse : Core::InputDefinition::PhotoResponse::LinearResponse; ENSURE(videoInput.get().getPhotoResponse() == expectedResponse); videoInputID++; } } ENSURE(panoDef->getVideoInput(0).getValueBasedResponseCurve() != nullptr, "Should have value based tone curve"); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahLinearCurve(), "Tone curve was set with linear values"); } void testAppendToneCurveMoreSensors() { std::unique_ptr<Core::PanoDefinition> panoDef = getTestPanoDef(); FrameRate frameRate{50, 1}; std::vector<std::pair<int, GPU::Buffer<const uint32_t>>> frames{{0, {}}}; Exposure::MetadataProcessor mp; auto applyToneCurveToPanoAtFrame = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame, const Input::MetadataChunk& metadata) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano(metadata, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; auto updatePanoNoNewData = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano({}, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; // add tone curves for several sensors at once { Input::MetadataChunk metadata; metadata.toneCurve.push_back({{0, {frameRate.frameToTimestamp(1000), getGammaToneCurve(1.2)}}, {1, {frameRate.frameToTimestamp(1001), getGammaToneCurve(1.5)}}, {2, {frameRate.frameToTimestamp(1500), getGammaToneCurve(0.9)}}, {3, {frameRate.frameToTimestamp(2000), getLinearToneCurve()}}}); applyToneCurveToPanoAtFrame(0, metadata); } ENSURE(panoDef->getVideoInput(0).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(1).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(2).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(3).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); updatePanoNoNewData(1000); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE(panoDef->getVideoInput(1).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(2).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(3).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); updatePanoNoNewData(1001); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE(panoDef->getVideoInput(2).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(3).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); updatePanoNoNewData(1500); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE(panoDef->getVideoInput(3).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); updatePanoNoNewData(2000); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahLinearCurve(), "Tone curve data"); updatePanoNoNewData(9999); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahLinearCurve(), "Tone curve data"); } void testPruning() { std::unique_ptr<Core::PanoDefinition> panoDef = getTestPanoDef(); FrameRate frameRate{1001, 1000}; std::vector<std::pair<int, GPU::Buffer<const uint32_t>>> frames{{0, {}}}; Exposure::MetadataProcessor mp; auto applyToneCurveToPanoAtFrame = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame, const Input::MetadataChunk& metadata) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano(metadata, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; auto updatePanoNoNewData = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano({}, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; // add tone curves for several sensors at once { Input::MetadataChunk metadata; metadata.toneCurve.push_back({{0, {frameRate.frameToTimestamp(1000), getGammaToneCurve(1.2)}}, {1, {frameRate.frameToTimestamp(1000), getGammaToneCurve(1.2)}}, {2, {frameRate.frameToTimestamp(1000), getGammaToneCurve(1.2)}}, {3, {frameRate.frameToTimestamp(1000), getGammaToneCurve(1.2)}}}); applyToneCurveToPanoAtFrame(0, metadata); } ENSURE(panoDef->getVideoInput(0).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(1).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(2).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); ENSURE(panoDef->getVideoInput(3).getValueBasedResponseCurve() == nullptr, "Frame of tone curve not reached yet"); updatePanoNoNewData(1000); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); { Input::MetadataChunk metadata; metadata.toneCurve.push_back({{0, {frameRate.frameToTimestamp(2000), getGammaToneCurve(1.5)}}, {1, {frameRate.frameToTimestamp(2000), getGammaToneCurve(1.5)}}, {2, {frameRate.frameToTimestamp(2000), getGammaToneCurve(1.5)}}, {3, {frameRate.frameToTimestamp(2000), getGammaToneCurve(1.5)}}}); applyToneCurveToPanoAtFrame(1001, metadata); } ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahGammaToneCurve<12>(), "Tone curve data"); updatePanoNoNewData(2000); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); { Input::MetadataChunk metadata; metadata.toneCurve.push_back({{0, {frameRate.frameToTimestamp(3000), getGammaToneCurve(0.9)}}, {1, {frameRate.frameToTimestamp(3000), getGammaToneCurve(0.9)}}, {2, {frameRate.frameToTimestamp(3000), getGammaToneCurve(0.9)}}, {3, {frameRate.frameToTimestamp(3000), getGammaToneCurve(0.9)}}}); applyToneCurveToPanoAtFrame(2500, metadata); } ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahGammaToneCurve<15>(), "Tone curve data"); updatePanoNoNewData(3000); ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); updatePanoNoNewData(1000); // do we drop data at some point? // // tests somewhat undefined behavior, may need to adapt test to implementation details // we expect that the metadata for time 1000 has been dropped at this point // and thus the tone curves are not updated when requesting pano def at frame 1000 // if they were still available, gamma should be 1.2 ENSURE_EQ(*panoDef->getVideoInput(0).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(1).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(2).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); ENSURE_EQ(*panoDef->getVideoInput(3).getValueBasedResponseCurve(), getOrahGammaToneCurve<9>(), "Tone curve data"); } void benchmarkAddingData(int iterations) { std::unique_ptr<Core::PanoDefinition> panoDef = getTestPanoDef(); FrameRate frameRate{25, 1}; std::vector<std::pair<int, GPU::Buffer<const uint32_t>>> frames{{0, {}}}; Exposure::MetadataProcessor mp; auto applyToneCurveToPanoAtFrame = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame, const Input::MetadataChunk& metadata) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano(metadata, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; auto updatePanoNoNewData = [&mp, &frameRate, &panoDef](frameid_t currentStitchingFrame) { std::unique_ptr<Core::PanoDefinition> updated = mp.createUpdatedPano({}, *panoDef, frameRate, currentStitchingFrame); if (updated) { panoDef.reset(updated.release()); } }; for (int i = 0; i < iterations; i++) { Input::MetadataChunk metadata; metadata.toneCurve.push_back({{0, {frameRate.frameToTimestamp(i * 2), getGammaToneCurve(1.2)}}, {1, {frameRate.frameToTimestamp(i * 2), getGammaToneCurve(1.5)}}, {2, {frameRate.frameToTimestamp(i * 2), getGammaToneCurve(0.9)}}, {3, {frameRate.frameToTimestamp(i * 2), getLinearToneCurve()}}}); applyToneCurveToPanoAtFrame(i * 2, metadata); updatePanoNoNewData(i * 2 + 1); } } } // namespace Testing } // namespace VideoStitch int main() { VideoStitch::Testing::initTest(); VideoStitch::Testing::testAppendToneCurve(); VideoStitch::Testing::testAppendToneCurveMoreSensors(); VideoStitch::Testing::testPruning(); VideoStitch::Testing::benchmarkAddingData(10); return 0; }
52.023857
117
0.61258
[ "vector" ]
2d4d3a23c9dde0d23c17a1ea67bce17167def6c7
1,390
cpp
C++
LeetCode/01315.cpp
vdshk/algos
8896c9edd30225acbdb51fa2e9760c0cc4adf307
[ "MIT" ]
null
null
null
LeetCode/01315.cpp
vdshk/algos
8896c9edd30225acbdb51fa2e9760c0cc4adf307
[ "MIT" ]
null
null
null
LeetCode/01315.cpp
vdshk/algos
8896c9edd30225acbdb51fa2e9760c0cc4adf307
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define len(a) (int)a.size() using namespace std; typedef vector<int> vint; typedef long double ld; typedef long long ll; typedef string str; /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} * }; */ class Solution { public: int sumEvenGrandparent(TreeNode* root) { if (root == nullptr) { return 0; } int res = 0; if (root->val % 2 == 0) { if (root->left != nullptr) { res += getVal(root->left->left); res += getVal(root->left->right); } if (root->right != nullptr) { res += getVal(root->right->left); res += getVal(root->right->right); } } return res + sumEvenGrandparent(root->left) + sumEvenGrandparent(root->right); } int getVal(TreeNode* node) { if (node == nullptr) { return 0; } return node->val; } };
26.226415
93
0.535971
[ "vector" ]
2d50e665fd269f04f57f2422cda15ea06c0f9221
2,163
cpp
C++
common/gl/threadedSwapchainRenderer.cpp
kwahoo2/sdl2oxr
a3e765fddffe66e67fd3c64e1339f2ad752e20f8
[ "Apache-2.0" ]
32
2019-10-01T04:08:22.000Z
2022-03-05T14:11:38.000Z
common/gl/threadedSwapchainRenderer.cpp
kwahoo2/sdl2oxr
a3e765fddffe66e67fd3c64e1339f2ad752e20f8
[ "Apache-2.0" ]
7
2019-09-30T21:07:49.000Z
2021-01-14T23:24:58.000Z
common/gl/threadedSwapchainRenderer.cpp
kwahoo2/sdl2oxr
a3e765fddffe66e67fd3c64e1339f2ad752e20f8
[ "Apache-2.0" ]
7
2019-10-15T01:26:32.000Z
2022-03-05T14:11:54.000Z
#include "threadedSwapchainRenderer.hpp" #include <gl/debug.hpp> #include <glad/glad.h> using namespace xr_examples; using namespace xr_examples::gl; void ThreadedSwapchainRenderer::create(const xr::Extent2Di& size, const xr::Session& session, Window& window) { auto swapchain = session.createSwapchain(xr::SwapchainCreateInfo{ {}, xr::SwapchainUsageFlagBits::TransferDst, GL_RGBA8, 1, (uint32_t)size.width, (uint32_t)size.height, 1, 1, 1 }); framebuffer.setSwapchain(swapchain); auto glContext = window.createOffscreenContext(); glContext->makeCurrent(); gl::enableDebugLogging(); // Framebuffers are not shared between contexts, so we have to create ours AFTER creating and making the offscreen context current framebuffer.create(size); // Always make sure the first entry in the swapchain is valid for submission in a layer BEFORE we return on the main thread { framebuffer.bind(); framebuffer.clear(); framebuffer.bindDefault(); framebuffer.advance(); } // Let derived class do any one-time GL context setup required initContext(); // Release offscreen context on the main thread glContext->doneCurrent(); // Launch the rendering thread. The offscreen context will remain current on that thread for the duration thread = std::make_unique<std::thread>([=] { glContext->makeCurrent(); run(); glContext->doneCurrent(); glContext->destroy(); }); window.makeCurrent(); } void ThreadedSwapchainRenderer::requestNewFrame() { Lock lock{ mutex }; frameRequested = true; conditional.notify_one(); } void ThreadedSwapchainRenderer::run() { using namespace std::chrono_literals; while (!quit) { Lock lock(mutex); if (!conditional.wait_for(lock, 100ms, [this] { return frameRequested; })) { continue; } frameRequested = false; framebuffer.bind(); render(); framebuffer.bindDefault(); framebuffer.advance(); } } const xr::Swapchain& ThreadedSwapchainRenderer::getSwapchain() const { return framebuffer.swapchain; }
32.772727
134
0.680999
[ "render" ]
2d591d30118193bfd0c59a47f973b6bf78ff91b1
9,195
hpp
C++
modules/mcc/include/opencv2/mcc/distance.hpp
riskiest/opencv_contrib
47c716db455c1b9aaff0fe4cafba2c283132fb39
[ "Apache-2.0" ]
null
null
null
modules/mcc/include/opencv2/mcc/distance.hpp
riskiest/opencv_contrib
47c716db455c1b9aaff0fe4cafba2c283132fb39
[ "Apache-2.0" ]
null
null
null
modules/mcc/include/opencv2/mcc/distance.hpp
riskiest/opencv_contrib
47c716db455c1b9aaff0fe4cafba2c283132fb39
[ "Apache-2.0" ]
2
2020-08-07T07:12:11.000Z
2020-08-07T08:35:45.000Z
// This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // // // License Agreement // For Open Source Computer Vision Library // // Copyright(C) 2020, Huawei Technologies Co.,Ltd. All rights reserved. // Third party copyrights are property of their respective owners. // // 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. // // Author: Longbu Wang <wanglongbu@huawei.com.com> // Jinheng Zhang <zhangjinheng1@huawei.com> // Chenqi Shan <shanchenqi@huawei.com> #ifndef __OPENCV_MCC_DISTANCE_HPP__ #define __OPENCV_MCC_DISTANCE_HPP__ #include "opencv2/mcc/utils.hpp" namespace cv { namespace ccm { /* *\brief Enum of possibale functions to calculate the distance between * colors.see https://en.wikipedia.org/wiki/Color_difference for details;*/ enum DISTANCE_TYPE { CIE76, CIE94_GRAPHIC_ARTS, CIE94_TEXTILES, CIE2000, CMC_1TO1, CMC_2TO1, RGB, RGBL }; double deltaCIE76(cv::Vec3d lab1, cv::Vec3d lab2); double deltaCIE94(cv::Vec3d lab1, cv::Vec3d lab2, double kH = 1.0, double kC = 1.0, double kL = 1.0, double k1 = 0.045, double k2 = 0.015); double deltaCIE94GraphicArts(cv::Vec3d lab1, cv::Vec3d lab2); double toRad(double degree); double deltaCIE94Textiles(cv::Vec3d lab1, cv::Vec3d lab2); double deltaCIEDE2000_(cv::Vec3d lab1, cv::Vec3d lab2, double kL = 1.0, double kC = 1.0, double kH = 1.0); double deltaCIEDE2000(cv::Vec3d lab1, cv::Vec3d lab2); double deltaCMC(cv::Vec3d lab1, cv::Vec3d lab2, double kL = 1, double kC = 1); double deltaCMC1To1(cv::Vec3d lab1, cv::Vec3d lab2); double deltaCMC2To1(cv::Vec3d lab1, cv::Vec3d lab2); Mat distance(Mat src, Mat ref, DISTANCE_TYPE distance_type); /* *\ brief distance between two points in formula CIE76 *\ param lab1 a 3D vector *\ param lab2 a 3D vector *\ return distance between lab1 and lab2 */ double deltaCIE76(cv::Vec3d lab1, cv::Vec3d lab2) { return norm(lab1 - lab2); }; /* *\ brief distance between two points in formula CIE94 *\ param lab1 a 3D vector *\ param lab2 a 3D vector *\ param kH Hue scale *\ param kC Chroma scale *\ param kL Lightness scale *\ param k1 first scale parameter *\ param k2 second scale parameter *\ return distance between lab1 and lab2 */ double deltaCIE94(cv::Vec3d lab1, cv::Vec3d lab2, double kH, double kC, double kL, double k1, double k2) { double dl = lab1[0] - lab2[0]; double c1 = sqrt(pow(lab1[1], 2) + pow(lab1[2], 2)); double c2 = sqrt(pow(lab2[1], 2) + pow(lab2[2], 2)); double dc = c1 - c2; double da = lab1[1] - lab2[1]; double db = lab1[2] - lab2[2]; double dh = pow(da, 2) + pow(db, 2) - pow(dc, 2); double sc = 1.0 + k1 * c1; double sh = 1.0 + k2 * c1; double sl = 1.0; double res = pow(dl / (kL * sl), 2) + pow(dc / (kC * sc), 2) + dh / pow(kH * sh, 2); return res > 0 ? sqrt(res) : 0; } double deltaCIE94GraphicArts(cv::Vec3d lab1, cv::Vec3d lab2) { return deltaCIE94(lab1, lab2); } double toRad(double degree) { return degree / 180 * CV_PI; }; double deltaCIE94Textiles(cv::Vec3d lab1, cv::Vec3d lab2) { return deltaCIE94(lab1, lab2, 1.0, 1.0, 2.0, 0.048, 0.014); } /* *\ brief distance between two points in formula CIE2000 *\ param lab1 a 3D vector *\ param lab2 a 3D vector *\ param kL Lightness scale *\ param kC Chroma scale *\ param kH Hue scale *\ return distance between lab1 and lab2 */ double deltaCIEDE2000_(cv::Vec3d lab1, cv::Vec3d lab2, double kL, double kC, double kH) { double delta_L_apo = lab2[0] - lab1[0]; double l_bar_apo = (lab1[0] + lab2[0]) / 2.0; double C1 = sqrt(pow(lab1[1], 2) + pow(lab1[2], 2)); double C2 = sqrt(pow(lab2[1], 2) + pow(lab2[2], 2)); double C_bar = (C1 + C2) / 2.0; double G = sqrt(pow(C_bar, 7) / (pow(C_bar, 7) + pow(25, 7))); double a1_apo = lab1[1] + lab1[1] / 2.0 * (1.0 - G); double a2_apo = lab2[1] + lab2[1] / 2.0 * (1.0 - G); double C1_apo = sqrt(pow(a1_apo, 2) + pow(lab1[2], 2)); double C2_apo = sqrt(pow(a2_apo, 2) + pow(lab2[2], 2)); double C_bar_apo = (C1_apo + C2_apo) / 2.0; double delta_C_apo = C2_apo - C1_apo; double h1_apo; if (C1_apo == 0) { h1_apo = 0.0; } else { h1_apo = atan2(lab1[2], a1_apo); if (h1_apo < 0.0) h1_apo += 2. * CV_PI; } double h2_apo; if (C2_apo == 0) { h2_apo = 0.0; } else { h2_apo = atan2(lab2[2], a2_apo); if (h2_apo < 0.0) h2_apo += 2. * CV_PI; } double delta_h_apo; if (abs(h2_apo - h1_apo) <= CV_PI) { delta_h_apo = h2_apo - h1_apo; } else if (h2_apo <= h1_apo) { delta_h_apo = h2_apo - h1_apo + 2. * CV_PI; } else { delta_h_apo = h2_apo - h1_apo - 2. * CV_PI; } double H_bar_apo; if (C1_apo == 0 || C2_apo == 0) { H_bar_apo = h1_apo + h2_apo; } else if (abs(h1_apo - h2_apo) <= CV_PI) { H_bar_apo = (h1_apo + h2_apo) / 2.0; } else if (h1_apo + h2_apo < 2. * CV_PI) { H_bar_apo = (h1_apo + h2_apo + 2. * CV_PI) / 2.0; } else { H_bar_apo = (h1_apo + h2_apo - 2. * CV_PI) / 2.0; } double delta_H_apo = 2.0 * sqrt(C1_apo * C2_apo) * sin(delta_h_apo / 2.0); double T = 1.0 - 0.17 * cos(H_bar_apo - toRad(30.)) + 0.24 * cos(2.0 * H_bar_apo) + 0.32 * cos(3.0 * H_bar_apo + toRad(6.0)) - 0.2 * cos(4.0 * H_bar_apo - toRad(63.0)); double sC = 1.0 + 0.045 * C_bar_apo; double sH = 1.0 + 0.015 * C_bar_apo * T; double sL = 1.0 + ((0.015 * pow(l_bar_apo - 50.0, 2.0)) / sqrt(20.0 + pow(l_bar_apo - 50.0, 2.0))); double RT = -2.0 * G * sin(toRad(60.0) * exp(-pow((H_bar_apo - toRad(275.0)) / toRad(25.0), 2.0))); double res = (pow(delta_L_apo / (kL * sL), 2.0) + pow(delta_C_apo / (kC * sC), 2.0) + pow(delta_H_apo / (kH * sH), 2.0) + RT * (delta_C_apo / (kC * sC)) * (delta_H_apo / (kH * sH))); return res > 0 ? sqrt(res) : 0; } double deltaCIEDE2000(cv::Vec3d lab1, cv::Vec3d lab2) { return deltaCIEDE2000_(lab1, lab2); } /* *\ brief distance between two points in formula CMC *\ param lab1 a 3D vector *\ param lab2 a 3D vector *\ param kL Lightness scale *\ param kC Chroma scale *\ return distance between lab1 and lab2 */ double deltaCMC(cv::Vec3d lab1, cv::Vec3d lab2, double kL, double kC) { double dL = lab2[0] - lab1[0]; double da = lab2[1] - lab1[1]; double db = lab2[2] - lab1[2]; double C1 = sqrt(pow(lab1[1], 2.0) + pow(lab1[2], 2.0)); double C2 = sqrt(pow(lab2[1], 2.0) + pow(lab2[2], 2.0)); double dC = C2 - C1; double dH = sqrt(pow(da, 2) + pow(db, 2) - pow(dC, 2)); double H1; if (C1 == 0.) { H1 = 0.0; } else { H1 = atan2(lab1[2], lab1[1]); if (H1 < 0.0) H1 += 2. * CV_PI; } double F = pow(C1, 2) / sqrt(pow(C1, 4) + 1900); double T = (H1 > toRad(164) && H1 <= toRad(345)) ? 0.56 + abs(0.2 * cos(H1 + toRad(168))) : 0.36 + abs(0.4 * cos(H1 + toRad(35))); double sL = lab1[0] < 16. ? 0.511 : (0.040975 * lab1[0]) / (1.0 + 0.01765 * lab1[0]); double sC = (0.0638 * C1) / (1.0 + 0.0131 * C1) + 0.638; double sH = sC * (F * T + 1.0 - F); return sqrt(pow(dL / (kL * sL), 2.0) + pow(dC / (kC * sC), 2.0) + pow(dH / sH, 2.0)); } double deltaCMC1To1(cv::Vec3d lab1, cv::Vec3d lab2) { return deltaCMC(lab1, lab2); } double deltaCMC2To1(cv::Vec3d lab1, cv::Vec3d lab2) { return deltaCMC(lab1, lab2, 2, 1); } Mat distance(Mat src, Mat ref, DISTANCE_TYPE distance_type) { switch (distance_type) { case cv::ccm::CIE76: return distanceWise(src, ref, deltaCIE76); case cv::ccm::CIE94_GRAPHIC_ARTS: return distanceWise(src, ref, deltaCIE94GraphicArts); case cv::ccm::CIE94_TEXTILES: return distanceWise(src, ref, deltaCIE94Textiles); case cv::ccm::CIE2000: return distanceWise(src, ref, deltaCIEDE2000); case cv::ccm::CMC_1TO1: return distanceWise(src, ref, deltaCMC1To1); case cv::ccm::CMC_2TO1: return distanceWise(src, ref, deltaCMC2To1); case cv::ccm::RGB: return distanceWise(src, ref, deltaCIE76); case cv::ccm::RGBL: return distanceWise(src, ref, deltaCIE76); default: throw std::invalid_argument{ "Wrong distance_type!" }; break; } }; } // namespace ccm } // namespace cv #endif
30.855705
90
0.59826
[ "vector", "3d" ]
062bb371e5cd91e0dd089a4e40ba1db07da9e805
2,403
cpp
C++
c++/CMakeProject1/query/TextQuery.cpp
Minyi1750/test
08409df49fb576114c8b70677face827023d9cb5
[ "Apache-2.0" ]
1
2018-03-03T21:04:45.000Z
2018-03-03T21:04:45.000Z
c++/CMakeProject1/query/TextQuery.cpp
Minyi1750/test
08409df49fb576114c8b70677face827023d9cb5
[ "Apache-2.0" ]
null
null
null
c++/CMakeProject1/query/TextQuery.cpp
Minyi1750/test
08409df49fb576114c8b70677face827023d9cb5
[ "Apache-2.0" ]
null
null
null
#include<iostream> using std::cout; using std::endl; using std::cin; #include<fstream> using std::ifstream; using std::ostream; #include<sstream> using std::istringstream; #include<vector> using std::vector; #include<string> using std::string; using std::getline; #include<memory> using std::shared_ptr; #include<map> using std::map; #include<set> using std::set; class TextQuery { public: using line_no = vector<string>::size_type; TextQuery(ifstream&); //QueryResult query(const string&) const; QueryResult query(const string&) const; private: shared_ptr<vector<string>> file; map<string, shared_ptr<set<line_no>>> wm; }; TextQuery::TextQuery(ifstream& is): file(new vector<string>) { string text; while (getline(is, text)) { file->push_back(text); int n = file->size() - 1; istringstream line(text); string word; while (line >> word) { auto& lines = wm[word]; if (!lines) lines.reset(new set<line_no>); lines->insert(n); } } } //QueryResult query(const string&) const; QueryResult TextQuery::query(const string& sought) const { static shared_ptr<set<line_no>> nodata(new set<line_no>); auto loc = wm.find(sought); if (loc == wm.end()) return QueryResult(sought, nodata, file); else return QueryResult(sought, loc->second, file); } class QueryResult { friend ostream& print(ostream&, const QueryResult&); public: typedef std::vector<std::string>::size_type line_no; QueryResult(string s, shared_ptr<set<line_no>> p, shared_ptr<vector<string>> f) : sought(s), lines(p), file(f) { } private: string sought; shared_ptr<set<line_no>> lines; shared_ptr<vector<string>> file; }; string make_plural(size_t ctr, const string& word, const string& ending) { return (ctr > 1) ? word + ending : word; } ostream& print(ostream& os, const QueryResult& qr) { os << qr.sought << " occurs " << qr.lines->size() << " " << make_plural(qr.lines->size(), "times", "s") << endl; for (auto num : *qr.lines) { os << "\t(line " << num + 1 << ") " << *(qr.lines->begin() + num) << endl; } return os; } void runQueries(ifstream& infile) { TextQuery tq(infile); while (true) { cout << "enter word to look for, or q to quit: "; string s; if (!(cin >> s) || s == "q") break; print(cout, tq.query(s)) << endl; } } int test() { string filename = "E:/tmp/test.text"; ifstream ifs(filename); //runQueries(ifs); return 0; }
19.224
74
0.661257
[ "vector" ]
062ca448927926f3bd69bd8b2b32a6f2a3e007f2
7,127
hpp
C++
http.hpp
sjk7/xpsockets
28388c5a88a612b7bae8199bfe4dd43062ee2826
[ "MIT" ]
null
null
null
http.hpp
sjk7/xpsockets
28388c5a88a612b7bae8199bfe4dd43062ee2826
[ "MIT" ]
null
null
null
http.hpp
sjk7/xpsockets
28388c5a88a612b7bae8199bfe4dd43062ee2826
[ "MIT" ]
null
null
null
#pragma once // HTTP_HPP #include <vector> #include "strings.hpp" #include <string_view> #include <cassert> namespace http { struct header; struct name_value_pair_type { std::string name; std::string value; }; struct request_line_type { friend struct header; private: std::string m_method; // GET std::string m_path; // /index.html std::string m_protocol; // HTTP/1.0 std::vector<std::string_view> m_request_line_components{ m_method, m_path, m_protocol}; public: const std::string& method() const noexcept { return m_method; } const std::string& path() const noexcept { return m_path; } const std::string& protocol() const noexcept { return m_protocol; } const auto& request_line_components() const noexcept { return m_request_line_components; } void clear() { m_method.clear(); m_path.clear(); m_protocol.clear(); m_last_error.clear(); } bool parse(std::string_view data) { clear(); auto splut_space = strings::splitSV(data, strings::SPACE); if (splut_space.size() != 3) { m_last_error = "request line does not consist of 3 components, as expected"; return false; } m_method = splut_space[0]; m_path = splut_space[1]; m_protocol = splut_space[2]; m_request_line_components[0] = m_method; m_request_line_components[1] = m_path; m_request_line_components[2] = m_protocol; return true; } private: std::string m_last_error; }; struct header { header(std::string_view data, bool have_dbl_newline_already = false) { parse(data, have_dbl_newline_already); } header(const header& rhs) { m_fields = rhs.m_fields; this->m_request_line = rhs.m_request_line; this->m_is_valid = rhs.m_is_valid; } header& operator=(const header& rhs) { m_fields = rhs.m_fields; this->m_request_line = rhs.m_request_line; this->m_is_valid = rhs.m_is_valid; return *this; } bool parse(std::string_view data, bool have_dbl_newline_already = false) { clear(); auto nlfound = have_dbl_newline_already ? data.size() : data.find(strings::DBLNEWLINE); if (nlfound == std::string::npos) { m_last_error = "Double newline not found"; m_is_valid = false; return false; } std::string_view header_data{data}; if (nlfound != data.size()) { auto splutbydblnewline = strings::splitSV(data, strings::DBLNEWLINE); if (splutbydblnewline.empty()) { m_is_valid = false; m_last_error = "no double newline found"; } else { header_data = splutbydblnewline[0]; if (splutbydblnewline.size() > 1) { this->m_data_after_header = splutbydblnewline[1]; } } } if (header_data.empty()) { m_last_error = "header data empty"; m_is_valid = false; } else { auto splutnewline = strings::splitSV(header_data, strings::NEWLINE); if (splutnewline.empty()) { splutnewline = strings::splitSV(header_data, strings::UNIX_NEWLINE); if (splutnewline.size() > 1) { m_last_error = "Possibly bad header, no proper new lines " "found, only unix newlines"; } else { m_last_error = "No new lines in header"; m_is_valid = false; } } else { bool ok = this->m_request_line.parse(splutnewline[0]); if (!ok) { m_last_error = "Unable to parse request line into 3 components"; m_is_valid = false; } else { m_is_valid = true; add_fields(splutnewline); } } } return m_is_valid; } bool is_valid() const noexcept { return m_is_valid; } const std::string& last_error() const noexcept { return m_last_error; } const request_line_type& request_line() const noexcept { return m_request_line; } const std::string& data_after_header() const noexcept { return m_data_after_header; } const auto& fields() const noexcept { return m_fields; } const auto& field_by_id(std::string_view id) const { auto& v = m_fields; static name_value_pair_type nvp = name_value_pair_type{}; auto it = std::find_if(v.begin(), v.end(), [&](auto& f) { if (f.name.length() != id.length()) return false; return strings::to_lower(id) == strings::to_lower(f.name); }); if (it != v.end()) { return *it; } return nvp; } void add_field(const name_value_pair_type& nvp) { auto it = std::find_if(m_fields.begin(), m_fields.end(), [&](const auto& np) { return np.name == nvp.name; }); if (it != m_fields.end()) { *it = nvp; } else { m_fields.push_back(nvp); } } std::string serialize(size_t content_length = std::string::npos) { static constexpr const char* COLON_SPACE = ": "; if (content_length != std::string::npos) { add_field({"Content-Length: ", std::to_string(content_length)}); } std::string s; for (const auto& field : m_fields) { s += field.name + COLON_SPACE + field.value; s += strings::NEWLINE; } if (!s.empty()) { s = s.substr(s.length() - 2); } return s; } private: request_line_type m_request_line; std::vector<name_value_pair_type> m_fields; std::string m_data_after_header; bool m_is_valid = false; std::string m_last_error; void add_fields(const std::vector<std::string_view>& v) { m_fields.clear(); if (v.empty()) return; m_fields.reserve(v.size()); int i = 0; for (const auto& s : v) { if (++i > 0) { if (s.find_first_of(strings::COLON) != std::string::npos) { auto splutcolon = strings::splitSV(s, strings::COLON); if (splutcolon.size() == 2) { strings::trimSV(splutcolon[0]); strings::trimSV(splutcolon[1]); m_fields.emplace_back( name_value_pair_type{std::string{splutcolon[0]}, std::string{splutcolon[1]}}); } } } } } void clear() { this->m_fields.clear(); this->m_data_after_header.clear(); this->m_last_error.clear(); this->m_request_line.clear(); this->m_is_valid = false; } }; } // namespace http
31.258772
80
0.541462
[ "vector" ]
063090f3cb07aee029f08184e81acbefd3820617
2,145
cpp
C++
gui/mouse.cpp
n3on/revisy
f69f778563776ae463505baf9835820704e72bd4
[ "MIT" ]
1
2020-02-18T22:59:20.000Z
2020-02-18T22:59:20.000Z
gui/mouse.cpp
n3on/revisy
f69f778563776ae463505baf9835820704e72bd4
[ "MIT" ]
null
null
null
gui/mouse.cpp
n3on/revisy
f69f778563776ae463505baf9835820704e72bd4
[ "MIT" ]
null
null
null
/*************************************************************************** * This file is part of the ReViSy project * Copyright (C) 2007 by Neon ***************************************************************************/ #include "mouse.h" POINT Mouse::position = {0,0}; bool Mouse::lpressed = false; Mouse::Mouse() { } Mouse::~Mouse() { } void Mouse::init(HWND hwnd) { glEnable(GL_TEXTURE_2D); //glClearColor(0.0f,0.0f,0.0f,0.0f); //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); this->m_hwnd = hwnd; this->m_position.x = 0; this->m_position.y = 0; if(!this->m_mouseImage.loadTGA("data\\gui\\cursor.tga")) MessageBox(NULL,"couldn't load texture","error",MB_OK); } void Mouse::update() { glMatrixMode(GL_PROJECTION); GetCursorPos(&this->m_position); ScreenToClient(this->m_hwnd,&this->m_position); this->toOGLPos(this->m_position.x, this->m_position.y); glMatrixMode(GL_MODELVIEW); } void Mouse::render(int width, int height) { //glClear(GL_DEPTH_BUFFER_BIT); this->m_mouseImage.show(this->m_positionOGL.x,this->m_positionOGL.y,width/64,height/25); } void Mouse::shutdown() { //this->m_mouseImage.remove(); } void Mouse::toOGLPos(int x, int y) { int viewport[4]; double mvmatrix[16]; double projectionmatrix[16]; double pX,pY,pZ; float wX,wY,wZ; glGetIntegerv(GL_VIEWPORT,viewport); glGetDoublev(GL_MODELVIEW_MATRIX,mvmatrix); glGetDoublev(GL_PROJECTION_MATRIX,projectionmatrix); wX = (double)x; wY = viewport[3]-y; glReadPixels(wX,wY,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&wZ); gluUnProject(wX,wY,wZ,mvmatrix,projectionmatrix,viewport, &pX,&pY,&pZ); this->m_positionOGL.x = (int)pX; this->m_positionOGL.y = (int)pY; Mouse::position.x = (int)pX; Mouse::position.y = (int)pY; } POINT Mouse::getPosition() { return Mouse::position; } void Mouse::setLState(bool state) { Mouse::lpressed = state; } bool Mouse::getLState() { return Mouse::lpressed; }
22.113402
92
0.591608
[ "render" ]
0634328701a932def82619510ead97cd39c00d2a
5,850
hpp
C++
redfish-core/include/event_service_manager.hpp
ztai-goog/bmcweb
881e50b775fcccbc447fc39f40671574e0fa4157
[ "Apache-2.0" ]
null
null
null
redfish-core/include/event_service_manager.hpp
ztai-goog/bmcweb
881e50b775fcccbc447fc39f40671574e0fa4157
[ "Apache-2.0" ]
null
null
null
redfish-core/include/event_service_manager.hpp
ztai-goog/bmcweb
881e50b775fcccbc447fc39f40671574e0fa4157
[ "Apache-2.0" ]
null
null
null
/* // Copyright (c) 2020 Intel Corporation // // 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. */ #pragma once #include "node.hpp" #include <boost/container/flat_map.hpp> #include <cstdlib> #include <ctime> #include <error_messages.hpp> #include <http_client.hpp> #include <memory> #include <utils/json_utils.hpp> #include <variant> namespace redfish { class Subscription { public: std::string id; std::string destinationUrl; std::string protocol; std::string retryPolicy; std::string customText; std::string eventFormatType; std::string subscriptionType; std::vector<std::string> registryMsgIds; std::vector<std::string> registryPrefixes; std::vector<nlohmann::json> httpHeaders; // key-value pair Subscription(const Subscription&) = delete; Subscription& operator=(const Subscription&) = delete; Subscription(Subscription&&) = delete; Subscription& operator=(Subscription&&) = delete; Subscription(const std::string& inHost, const std::string& inPort, const std::string& inPath, const std::string& inUriProto) : host(inHost), port(inPort), path(inPath), uriProto(inUriProto) { conn = std::make_shared<crow::HttpClient>( crow::connections::systemBus->get_io_context(), host, port, path); } ~Subscription() { } void sendEvent(const std::string& msg) { std::vector<std::pair<std::string, std::string>> reqHeaders; for (const auto& header : httpHeaders) { for (const auto& item : header.items()) { std::string key = item.key(); std::string val = item.value(); reqHeaders.emplace_back(std::pair(key, val)); } } conn->setHeaders(reqHeaders); conn->sendData(msg); } private: std::string host; std::string port; std::string path; std::string uriProto; std::shared_ptr<crow::HttpClient> conn; }; class EventServiceManager { private: EventServiceManager(const EventServiceManager&) = delete; EventServiceManager& operator=(const EventServiceManager&) = delete; EventServiceManager(EventServiceManager&&) = delete; EventServiceManager& operator=(EventServiceManager&&) = delete; EventServiceManager() { // TODO: Read the persistent data from store and populate. // Populating with default. enabled = true; retryAttempts = 3; retryTimeoutInterval = 30; // seconds } boost::container::flat_map<std::string, std::shared_ptr<Subscription>> subscriptionsMap; public: bool enabled; uint32_t retryAttempts; uint32_t retryTimeoutInterval; static EventServiceManager& getInstance() { static EventServiceManager handler; return handler; } void updateSubscriptionData() { // Persist the config and subscription data. // TODO: subscriptionsMap & configData need to be // written to Persist store. return; } std::shared_ptr<Subscription> getSubscription(const std::string& id) { auto obj = subscriptionsMap.find(id); if (obj == subscriptionsMap.end()) { BMCWEB_LOG_ERROR << "No subscription exist with ID:" << id; return nullptr; } std::shared_ptr<Subscription> subValue = obj->second; return subValue; } std::string addSubscription(const std::shared_ptr<Subscription> subValue) { std::srand(static_cast<uint32_t>(std::time(0))); std::string id; int retry = 3; while (retry) { id = std::to_string(std::rand()); auto inserted = subscriptionsMap.insert(std::pair(id, subValue)); if (inserted.second) { break; } --retry; }; if (retry <= 0) { BMCWEB_LOG_ERROR << "Failed to generate random number"; return std::string(""); } updateSubscriptionData(); return id; } bool isSubscriptionExist(const std::string& id) { auto obj = subscriptionsMap.find(id); if (obj == subscriptionsMap.end()) { return false; } return true; } void deleteSubscription(const std::string& id) { auto obj = subscriptionsMap.find(id); if (obj != subscriptionsMap.end()) { subscriptionsMap.erase(obj); updateSubscriptionData(); } } size_t getNumberOfSubscriptions() { return subscriptionsMap.size(); } std::vector<std::string> getAllIDs() { std::vector<std::string> idList; for (const auto& it : subscriptionsMap) { idList.emplace_back(it.first); } return idList; } bool isDestinationExist(const std::string& destUrl) { for (const auto& it : subscriptionsMap) { std::shared_ptr<Subscription> entry = it.second; if (entry->destinationUrl == destUrl) { BMCWEB_LOG_ERROR << "Destination exist already" << destUrl; return true; } } return false; } }; } // namespace redfish
27.336449
78
0.605299
[ "vector" ]
063fd6b2254039fefa2cd908b0706421eb104332
963
cpp
C++
Greedy Algorithms/Activity Selection Problem/solutionBySravani.cpp
harsh9999aggarwal/Programmers-Community
511d207cb15d823012c79794fc49a77f336f670d
[ "MIT" ]
8
2020-11-07T10:29:21.000Z
2020-12-26T16:54:13.000Z
Greedy Algorithms/Activity Selection Problem/solutionBySravani.cpp
harsh9999aggarwal/Programmers-Community
511d207cb15d823012c79794fc49a77f336f670d
[ "MIT" ]
null
null
null
Greedy Algorithms/Activity Selection Problem/solutionBySravani.cpp
harsh9999aggarwal/Programmers-Community
511d207cb15d823012c79794fc49a77f336f670d
[ "MIT" ]
null
null
null
#include <iostream> #include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); } int main() { int n; cin>>n; int start[n]; int end[n]; for(int i=0;i<n;i++){ cin>>start[i]; } for(int i=0;i<n;i++){ cin>>end[i]; } vector<pair<int,int>> times; for(int i=0;i<n;i++){ times.push_back(make_pair(start[i],end[i])); } sort(times.begin(),times.end(),sortbysec); int i=0; vector<pair<int,int>> result; result.push_back(times[0]); for (int j = 1; j < n; j++) { if (times[j].first>= times[i].second) { result.push_back(times[j]); i = j; } } cout<<"Maximum activities selected are ="<<result.size()<<endl; for(int i=0;i<result.size();i++){ cout<<"("<<result[i].first<<","<<result[i].second<<")"<<endl; } return 0; }
20.934783
69
0.509865
[ "vector" ]
0642f36b0f4db874fafe99918fd84aa52edb2411
3,251
cpp
C++
etpServerExample/MyOwnCoreProtocolHandlers.cpp
Fabien-Bosquet/fesapi
73cec4d1665dba7a11864d90cb16f0205204946e
[ "Apache-2.0" ]
null
null
null
etpServerExample/MyOwnCoreProtocolHandlers.cpp
Fabien-Bosquet/fesapi
73cec4d1665dba7a11864d90cb16f0205204946e
[ "Apache-2.0" ]
null
null
null
etpServerExample/MyOwnCoreProtocolHandlers.cpp
Fabien-Bosquet/fesapi
73cec4d1665dba7a11864d90cb16f0205204946e
[ "Apache-2.0" ]
null
null
null
/*----------------------------------------------------------------------- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"; you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ #include "MyOwnCoreProtocolHandlers.h" #include <boost/uuid/random_generator.hpp> #include <boost/uuid/uuid_io.hpp> #include "MyServerInitializationParameters.h" #include "etp/AbstractSession.h" #include "etp/EtpHelpers.h" void MyOwnCoreProtocolHandlers::on_RequestSession(const Energistics::Etp::v12::Protocol::Core::RequestSession & rs, int64_t correlationId) { MyServerInitializationParameters serverInitializationParams(nullptr); auto supportedProtocols = serverInitializationParams.makeSupportedProtocols(); // Check requested protocols std::vector<Energistics::Etp::v12::Datatypes::SupportedProtocol> requestedAndSupportedProtocols; for (auto& rp : rs.requestedProtocols) { const auto validatedProtocol = std::find_if(supportedProtocols.begin(), supportedProtocols.end(), [rp](const Energistics::Etp::v12::Datatypes::SupportedProtocol & sp) -> bool { return sp.protocol == rp.protocol && sp.role == rp.role && sp.protocolVersion.major == rp.protocolVersion.major && sp.protocolVersion.minor == rp.protocolVersion.minor && sp.protocolVersion.patch == rp.protocolVersion.patch && sp.protocolVersion.revision == rp.protocolVersion.revision; } ); if (validatedProtocol != std::end(supportedProtocols)) { requestedAndSupportedProtocols.push_back(*validatedProtocol); } } if (requestedAndSupportedProtocols.empty()) { session->send(ETP_NS::EtpHelpers::buildSingleMessageProtocolException(7, "The server does not support any of the requested protocols.")); return; } // Build Open Session message Energistics::Etp::v12::Protocol::Core::OpenSession openSession; openSession.applicationName = serverInitializationParams.getApplicationName(); openSession.applicationVersion = serverInitializationParams.getApplicationVersion(); boost::uuids::random_generator gen; boost::uuids::uuid uuid = gen(); std::move(std::begin(uuid.data), std::end(uuid.data), openSession.serverInstanceId.array.begin()); openSession.supportedFormats.push_back("xml"); openSession.supportedProtocols = requestedAndSupportedProtocols; openSession.endpointCapabilities = serverInitializationParams.makeEndpointCapabilities(); openSession.supportedDataObjects = serverInitializationParams.makeSupportedDataObjects(); session->send(openSession, correlationId); std::cout << "New session" << std::endl; }
45.152778
139
0.752384
[ "vector" ]
06459956edf75e01b6c47a0dd5143862628efc7a
1,546
cpp
C++
tenets/west/default/allocation/variable_allocation.cpp
michaelneale/codelingo
ff5f93bb24d4d3424a83739a34bfce64e1dfa80a
[ "Apache-2.0" ]
2
2019-02-14T06:03:14.000Z
2021-12-07T02:33:00.000Z
tenets/west/default/allocation/variable_allocation.cpp
michaelneale/codelingo
ff5f93bb24d4d3424a83739a34bfce64e1dfa80a
[ "Apache-2.0" ]
null
null
null
tenets/west/default/allocation/variable_allocation.cpp
michaelneale/codelingo
ff5f93bb24d4d3424a83739a34bfce64e1dfa80a
[ "Apache-2.0" ]
2
2018-11-29T22:49:06.000Z
2019-08-28T15:50:02.000Z
#include <stdlib.h> // What is obtained using new must be disposed of using delete. // Also what is obtained using malloc must be disposed using free. class Obj { int x; public: Obj(); }; Obj::Obj() { x=1; } // The first function is correct: void ProperlyDeleted() { Obj * a = new Obj(); // Some code... delete a; } // But this code is wrong, and should be detected as a wrong use of free and a missing // delete: void FreedObject() { Obj * b = new Obj(); // Some code free(b); } // This is wrong too, and should be detected as a wrong use of delete. void DeletedArray(){ Int[] intArray = malloc(10); // Some code... delete(intArray); } // New objects must be deleted or passed by reference to another function that would delete them. void D () { ObjectOnHeap objectOnHeap = new ObjectOnHeap(); // use object... } // This creates a problem. After calling delete, it is very possible that the memory has been // reallocated to another variable somewhere else. Using it again will very likely cause a crash void E () { ObjectOnHeap objectOnHeap = new ObjectOnHeap(); delete objectOnHeap // some code cout << objectOnHeap } // This is more complex for a tool to detect: The function returns a reference. Func1 uses the reference and ends up deleting the object whereas Func2 does not. Therefore Func2 creates a leak. ObjectOnHeap Func () { ObjectOnHeap objectOnHeap = new ObjectOnHeap(); // use object... delete objectOnHeap // some code // use objectOnHeap... }
23.784615
192
0.6837
[ "object" ]
064ba7d9a30a801593f226bc4d001203a85ba24a
4,776
cpp
C++
apps/common/ospray_testing/builders/UnstructuredVolume.cpp
tribal-tec/ospray
31ea9d16f8551c06551a11d54fe908d9d004a767
[ "Apache-2.0" ]
1
2020-05-30T02:39:22.000Z
2020-05-30T02:39:22.000Z
apps/common/ospray_testing/builders/UnstructuredVolume.cpp
tribal-tec/ospray
31ea9d16f8551c06551a11d54fe908d9d004a767
[ "Apache-2.0" ]
null
null
null
apps/common/ospray_testing/builders/UnstructuredVolume.cpp
tribal-tec/ospray
31ea9d16f8551c06551a11d54fe908d9d004a767
[ "Apache-2.0" ]
null
null
null
// Copyright 2009-2019 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #include "Builder.h" #include "ospray_testing.h" using namespace ospcommon::math; namespace ospray { namespace testing { struct UnstructuredVolume : public detail::Builder { UnstructuredVolume() = default; ~UnstructuredVolume() override = default; void commit() override; cpp::Group buildGroup() const override; private: bool sharedVertices{true}; bool valuesPerCell{false}; }; // Inlined definitions //////////////////////////////////////////////////// void UnstructuredVolume::commit() { Builder::commit(); sharedVertices = getParam<bool>("sharedVertices", true); valuesPerCell = getParam<bool>("cellCenteredValues", false); } cpp::Group UnstructuredVolume::buildGroup() const { // define hexahedron parameters const float hSize = .4f; const float hX = -.5f, hY = -.5f, hZ = 0.f; // define wedge parameters const float wSize = .4f; const float wX = .5f, wY = -.5f, wZ = 0.f; // define tetrahedron parameters const float tSize = .4f; const float tX = .5f, tY = .5f, tZ = 0.f; // define pyramid parameters const float pSize = .4f; const float pX = -.5f, pY = .5f, pZ = 0.f; // define vertex positions std::vector<vec3f> vertices = {// hexahedron {-hSize + hX, -hSize + hY, hSize + hZ}, // bottom quad {hSize + hX, -hSize + hY, hSize + hZ}, {hSize + hX, -hSize + hY, -hSize + hZ}, {-hSize + hX, -hSize + hY, -hSize + hZ}, {-hSize + hX, hSize + hY, hSize + hZ}, // top quad {hSize + hX, hSize + hY, hSize + hZ}, {hSize + hX, hSize + hY, -hSize + hZ}, {-hSize + hX, hSize + hY, -hSize + hZ}, // wedge {-wSize + wX, -wSize + wY, wSize + wZ}, // botom triangle {wSize + wX, -wSize + wY, 0.f + wZ}, {-wSize + wX, -wSize + wY, -wSize + wZ}, {-wSize + wX, wSize + wY, wSize + wZ}, // top triangle {wSize + wX, wSize + wY, 0.f + wZ}, {-wSize + wX, wSize + wY, -wSize + wZ}, // tetrahedron {-tSize + tX, -tSize + tY, tSize + tZ}, {tSize + tX, -tSize + tY, 0.f + tZ}, {-tSize + tX, -tSize + tY, -tSize + tZ}, {-tSize + tX, tSize + tY, 0.f + tZ}, // pyramid {-pSize + pX, -pSize + pY, pSize + pZ}, {pSize + pX, -pSize + pY, pSize + pZ}, {pSize + pX, -pSize + pY, -pSize + pZ}, {-pSize + pX, -pSize + pY, -pSize + pZ}, {pSize + pX, pSize + pY, 0.f + pZ}}; // define per-vertex values std::vector<float> vertexValues = {// hexahedron 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 1.f, 0.f, // wedge 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, // tetrahedron 1.f, 0.f, 1.f, 0.f, // pyramid 0.f, 1.f, 1.f, 0.f, 0.f}; // define vertex indices for both shared and separate case std::vector<uint32_t> indicesSharedVert = {// hexahedron 0, 1, 2, 3, 4, 5, 6, 7, // wedge 1, 9, 2, 5, 12, 6, // tetrahedron 5, 12, 6, 17, // pyramid 4, 5, 6, 7, 17}; std::vector<uint32_t> indicesSeparateVert = {// hexahedron 0, 1, 2, 3, 4, 5, 6, 7, // wedge 8, 9, 10, 11, 12, 13, // tetrahedron 14, 15, 16, 17, // pyramid 18, 19, 20, 21, 22}; std::vector<uint32_t> &indices = sharedVertices ? indicesSharedVert : indicesSeparateVert; // define cell offsets in indices array std::vector<uint32_t> cells = {0, 8, 14, 18}; // define cell types std::vector<uint8_t> cellTypes = { OSP_HEXAHEDRON, OSP_WEDGE, OSP_TETRAHEDRON, OSP_PYRAMID}; // define per-cell values std::vector<float> cellValues = {0.1f, .3f, .7f, 1.f}; cpp::Volume volume("unstructured"); // set data objects for volume object volume.setParam("vertex.position", cpp::Data(vertices)); if (valuesPerCell) volume.setParam("cell.data", cpp::Data(cellValues)); else volume.setParam("vertex.data", cpp::Data(vertexValues)); volume.setParam("index", cpp::Data(indices)); volume.setParam("cell.index", cpp::Data(cells)); volume.setParam("cell.type", cpp::Data(cellTypes)); volume.commit(); cpp::VolumetricModel model(volume); model.setParam("transferFunction", makeTransferFunction({0.f, 1.f})); model.commit(); cpp::Group group; group.setParam("volume", cpp::Data(model)); group.commit(); return group; } OSP_REGISTER_TESTING_BUILDER(UnstructuredVolume, unstructured_volume); } // namespace testing } // namespace ospray
21.321429
75
0.545854
[ "object", "vector", "model" ]
064c786b0a3e98d3ca7496b0d1aa5e5b01439b9d
8,466
cpp
C++
Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/EndianConversion.cpp
cypherdotXd/o3de
bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676
[ "Apache-2.0", "MIT" ]
11
2021-07-08T09:58:26.000Z
2022-03-17T17:59:26.000Z
Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/EndianConversion.cpp
RoddieKieley/o3de
e804fd2a4241b039a42d9fa54eaae17dc94a7a92
[ "Apache-2.0", "MIT" ]
29
2021-07-06T19:33:52.000Z
2022-03-22T10:27:49.000Z
Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/EndianConversion.cpp
RoddieKieley/o3de
e804fd2a4241b039a42d9fa54eaae17dc94a7a92
[ "Apache-2.0", "MIT" ]
4
2021-07-06T19:24:43.000Z
2022-03-31T12:42:27.000Z
/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include "Exporter.h" #include <AzCore/Math/Vector2.h> #include <AzCore/Math/Quaternion.h> namespace ExporterLib { void CopyVector2(EMotionFX::FileFormat::FileVector2& to, const AZ::Vector2& from) { to.m_x = from.GetX(); to.m_y = from.GetY(); } void CopyVector(EMotionFX::FileFormat::FileVector3& to, const AZ::PackedVector3f& from) { to.m_x = from.GetX(); to.m_y = from.GetY(); to.m_z = from.GetZ(); } void CopyQuaternion(EMotionFX::FileFormat::FileQuaternion& to, const AZ::Quaternion& from) { AZ::Quaternion q = from; if (q.GetW() < 0.0f) { q = -q; } to.m_x = q.GetX(); to.m_y = q.GetY(); to.m_z = q.GetZ(); to.m_w = q.GetW(); } void Copy16BitQuaternion(EMotionFX::FileFormat::File16BitQuaternion& to, const AZ::Quaternion& from) { AZ::Quaternion q = from; if (q.GetW() < 0.0f) { q = -q; } const MCore::Compressed16BitQuaternion compressedQuat(q); to.m_x = compressedQuat.m_x; to.m_y = compressedQuat.m_y; to.m_z = compressedQuat.m_z; to.m_w = compressedQuat.m_w; } void Copy16BitQuaternion(EMotionFX::FileFormat::File16BitQuaternion& to, const MCore::Compressed16BitQuaternion& from) { MCore::Compressed16BitQuaternion q = from; if (q.m_w < 0) { q.m_x = -q.m_x; q.m_y = -q.m_y; q.m_z = -q.m_z; q.m_w = -q.m_w; } to.m_x = q.m_x; to.m_y = q.m_y; to.m_z = q.m_z; to.m_w = q.m_w; } void CopyColor(const MCore::RGBAColor& from, EMotionFX::FileFormat::FileColor& to) { to.m_r = from.m_r; to.m_g = from.m_g; to.m_b = from.m_b; to.m_a = from.m_a; } void ConvertUnsignedInt(uint32* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertUnsignedInt32(value, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertUnsignedInt(uint64* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertUnsignedInt64(value, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertInt(int* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertSignedInt32(value, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertUnsignedShort(uint16* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertUnsignedInt16(value, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFloat(float* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertFloat(value, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFileChunk(EMotionFX::FileFormat::FileChunk* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertUnsignedInt32(&value->m_chunkId, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt32(&value->m_sizeInBytes, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt32(&value->m_version, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFileColor(EMotionFX::FileFormat::FileColor* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertFloat(&value->m_r, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_g, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_b, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_a, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFileVector2(EMotionFX::FileFormat::FileVector2* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertFloat(&value->m_x, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_y, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFileVector3(EMotionFX::FileFormat::FileVector3* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertFloat(&value->m_x, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_y, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_z, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFile16BitVector3(EMotionFX::FileFormat::File16BitVector3* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertUnsignedInt16(&value->m_x, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt16(&value->m_y, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt16(&value->m_z, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFileQuaternion(EMotionFX::FileFormat::FileQuaternion* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertFloat(&value->m_x, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_y, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_z, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_w, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFile16BitQuaternion(EMotionFX::FileFormat::File16BitQuaternion* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertSignedInt16(&value->m_x, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertSignedInt16(&value->m_y, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertSignedInt16(&value->m_z, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertSignedInt16(&value->m_w, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFileMotionEvent(EMotionFX::FileFormat::FileMotionEvent* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertFloat(&value->m_startTime, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_endTime, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt32(&value->m_eventTypeIndex, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt32(&value->m_mirrorTypeIndex, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt16(&value->m_paramIndex, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertFileMotionEventTable(EMotionFX::FileFormat::FileMotionEventTrack* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertUnsignedInt32(&value->m_numEvents, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt32(&value->m_numTypeStrings, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt32(&value->m_numParamStrings, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertUnsignedInt32(&value->m_numMirrorTypeStrings, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertRGBAColor(MCore::RGBAColor* value, MCore::Endian::EEndianType targetEndianType) { MCore::Endian::ConvertFloat(&value->m_r, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_g, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_b, EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&value->m_a, EXPLIB_PLATFORM_ENDIAN, targetEndianType); } void ConvertVector3(AZ::PackedVector3f* value, MCore::Endian::EEndianType targetEndianType) { float* data = reinterpret_cast<float*>(value); MCore::Endian::ConvertFloat(&data[0], EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&data[1], EXPLIB_PLATFORM_ENDIAN, targetEndianType); MCore::Endian::ConvertFloat(&data[2], EXPLIB_PLATFORM_ENDIAN, targetEndianType); } } // namespace ExporterLib
40.507177
133
0.699268
[ "3d" ]
064d31fffe566ebe1f2921b6b3446dca1de96500
1,936
hpp
C++
include/ugly/edge_directed_weighted.hpp
JoshuaSBrown/GraphCluster
d9c28204b276165cf59137c9668c4dfcfa397089
[ "MIT" ]
null
null
null
include/ugly/edge_directed_weighted.hpp
JoshuaSBrown/GraphCluster
d9c28204b276165cf59137c9668c4dfcfa397089
[ "MIT" ]
null
null
null
include/ugly/edge_directed_weighted.hpp
JoshuaSBrown/GraphCluster
d9c28204b276165cf59137c9668c4dfcfa397089
[ "MIT" ]
null
null
null
#ifndef UGLY_EDGEDIRECTEDWEIGHTED_HPP #define UGLY_EDGEDIRECTEDWEIGHTED_HPP #include <cassert> #include <iostream> #include <list> #include <utility> #include <vector> #include "../../src/libugly/edge/edge.hpp" namespace ugly { // Composed of two integers describing a link // between two vertices class EdgeDirectedWeighted : public Edge { private: static const constants::EdgeType class_type_; protected: double weight_; public: EdgeDirectedWeighted() : weight_(1.0) { object_type_ = constants::EdgeType::directed_weighted; edge_directed_ = true; } EdgeDirectedWeighted(int vertex1, int vertex2) : Edge(vertex1, vertex2) { object_type_ = constants::EdgeType::directed_weighted; weight_ = 1.0; } EdgeDirectedWeighted(int vertex1, int vertex2, double weight) : Edge(vertex1, vertex2) { object_type_ = constants::EdgeType::directed_weighted; weight_ = weight; } EdgeDirectedWeighted(const EdgeDirectedWeighted &edgedirectedweighted) : Edge() { vertex1_ = edgedirectedweighted.vertex1_; vertex2_ = edgedirectedweighted.vertex2_; weight_ = edgedirectedweighted.weight_; object_type_ = edgedirectedweighted.object_type_; edge_directed_ = true; } EdgeDirectedWeighted(const Edge &edge) { if (edge.getEdgeType() == getClassType()) { const EdgeDirectedWeighted *edw = static_cast<const EdgeDirectedWeighted *>(&edge); vertex1_ = edw->getVertex1(); vertex2_ = edw->getVertex2(); weight_ = edw->getWeight(); object_type_ = constants::EdgeType::directed_weighted; edge_directed_ = true; } } EdgeDirectedWeighted &operator=( const EdgeDirectedWeighted &EdgeDirectedWeighted); void setWeight(double weight) { weight_ = weight; } double getWeight() const { return weight_; } static constants::EdgeType getClassType(); }; } #endif // UGLY_EDGEDIRECTEDWEIGHTED_HPP
26.162162
75
0.713326
[ "vector" ]
064e73aab2c4ef0a4a78db25b0d8ec45b3ee797a
4,090
cpp
C++
src/hotspot/share/opto/intrinsicnode.cpp
siweilxy/openjdkstudy
8597674ec1d6809faf55cbee1f45f4e9149d670d
[ "Apache-2.0" ]
2
2018-06-19T05:43:32.000Z
2018-06-23T10:04:56.000Z
src/hotspot/share/opto/intrinsicnode.cpp
siweilxy/openjdkstudy
8597674ec1d6809faf55cbee1f45f4e9149d670d
[ "Apache-2.0" ]
null
null
null
src/hotspot/share/opto/intrinsicnode.cpp
siweilxy/openjdkstudy
8597674ec1d6809faf55cbee1f45f4e9149d670d
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #include "precompiled.hpp" #include "opto/intrinsicnode.hpp" #include "opto/memnode.hpp" #include "opto/phaseX.hpp" //============================================================================= // Do not match memory edge. uint StrIntrinsicNode::match_edge(uint idx) const { return idx == 2 || idx == 3; } //------------------------------Ideal------------------------------------------ // Return a node which is more "ideal" than the current node. Strip out // control copies Node* StrIntrinsicNode::Ideal(PhaseGVN* phase, bool can_reshape) { if (remove_dead_region(phase, can_reshape)) return this; // Don't bother trying to transform a dead node if (in(0) && in(0)->is_top()) return NULL; if (can_reshape) { Node* mem = phase->transform(in(MemNode::Memory)); // If transformed to a MergeMem, get the desired slice uint alias_idx = phase->C->get_alias_index(adr_type()); mem = mem->is_MergeMem() ? mem->as_MergeMem()->memory_at(alias_idx) : mem; if (mem != in(MemNode::Memory)) { set_req(MemNode::Memory, mem); return this; } } return NULL; } //------------------------------Value------------------------------------------ const Type* StrIntrinsicNode::Value(PhaseGVN* phase) const { if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP; return bottom_type(); } uint StrIntrinsicNode::size_of() const { return sizeof(*this); } //============================================================================= //------------------------------Ideal------------------------------------------ // Return a node which is more "ideal" than the current node. Strip out // control copies Node* StrCompressedCopyNode::Ideal(PhaseGVN* phase, bool can_reshape) { return remove_dead_region(phase, can_reshape) ? this : NULL; } //============================================================================= //------------------------------Ideal------------------------------------------ // Return a node which is more "ideal" than the current node. Strip out // control copies Node* StrInflatedCopyNode::Ideal(PhaseGVN* phase, bool can_reshape) { return remove_dead_region(phase, can_reshape) ? this : NULL; } //============================================================================= //------------------------------match_edge------------------------------------- // Do not match memory edge uint EncodeISOArrayNode::match_edge(uint idx) const { return idx == 2 || idx == 3; // EncodeISOArray src (Binary dst len) } //------------------------------Ideal------------------------------------------ // Return a node which is more "ideal" than the current node. Strip out // control copies Node* EncodeISOArrayNode::Ideal(PhaseGVN* phase, bool can_reshape) { return remove_dead_region(phase, can_reshape) ? this : NULL; } //------------------------------Value------------------------------------------ const Type* EncodeISOArrayNode::Value(PhaseGVN* phase) const { if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP; return bottom_type(); }
40.49505
79
0.571394
[ "transform" ]
06524dfc88149d38921c48702d7648a3de6de51e
6,294
cpp
C++
.MeshSync/Plugin/MeshSyncClientBlender/MeshSyncClientBlender.cpp
RopyTan/MeshSync
69c0aa3e953d5f9a99d8c0aaafe3f89bfb8c63cf
[ "MIT" ]
null
null
null
.MeshSync/Plugin/MeshSyncClientBlender/MeshSyncClientBlender.cpp
RopyTan/MeshSync
69c0aa3e953d5f9a99d8c0aaafe3f89bfb8c63cf
[ "MIT" ]
null
null
null
.MeshSync/Plugin/MeshSyncClientBlender/MeshSyncClientBlender.cpp
RopyTan/MeshSync
69c0aa3e953d5f9a99d8c0aaafe3f89bfb8c63cf
[ "MIT" ]
null
null
null
#include "pch.h" #include "MeshSyncClientBlender.h" using namespace mu; PYBIND11_PLUGIN(MeshSyncClientBlender) { py::module mod("MeshSyncClientBlender", "Python bindings for MeshSync"); #define BindMethod(Name) .def(#Name, &self_t::Name) #define BindMethod2(Name, ...) .def(#Name, __VA_ARGS__) #define BindProperty(Name, ...) .def_property(#Name, __VA_ARGS__) { using self_t = msbContext; py::class_<msbContext, msbContextPtr>(mod, "Context") .def(py::init<>()) BindMethod(flushPendingList) BindMethod2(setup, [](msbContext& self, py::object ctx) { bl::setup(ctx); }) BindMethod2(clear, [](msbContext& self, py::object ctx) { self.clear(); }) BindMethod2(sendSceneAll, [](msbContext& self, bool force_all) { self.sendScene(msbContext::SendScope::All, force_all); }) BindMethod2(sendSceneUpdated, [](msbContext& self) { self.sendScene(msbContext::SendScope::Updated, false); }) BindMethod2(sendSceneSelected, [](msbContext& self) { self.sendScene(msbContext::SendScope::Selected, false); }) BindMethod2(sendAnimationsAll, [](msbContext& self) { self.sendAnimations(msbContext::SendScope::All); }) BindMethod2(sendAnimationsSelected, [](msbContext& self) { self.sendAnimations(msbContext::SendScope::Selected); }) BindProperty(server_address, [](const msbContext& self) { return self.getSettings().client_settings.server; }, [](msbContext& self, const std::string& v) { self.getSettings().client_settings.server = v; }) BindProperty(server_port, [](const msbContext& self) { return self.getSettings().client_settings.port; }, [](msbContext& self, uint16_t v) { self.getSettings().client_settings.port = v; }) BindProperty(scene_name, [](const msbContext& self) { return self.getSettings().scene_settings.name; }, [](msbContext& self, const std::string& v) { self.getSettings().scene_settings.name = v; }) BindProperty(scale_factor, [](const msbContext& self) { return self.getSettings().scene_settings.scale_factor; }, [](msbContext& self, float v) { self.getSettings().scene_settings.scale_factor = v; }) BindProperty(handedness, [](const msbContext& self) { return (int)self.getSettings().scene_settings.handedness; }, [](msbContext& self, int v) { (int&)self.getSettings().scene_settings.handedness = v; }) BindProperty(sync_meshes, [](const msbContext& self) { return (int)self.getSettings().sync_meshes; }, [](msbContext& self, int v) { (int&)self.getSettings().sync_meshes = v; }) BindProperty(sync_normals, [](const msbContext& self) { return (int)self.getSettings().sync_normals; }, [](msbContext& self, bool v) { (int&)self.getSettings().sync_normals = v; }) BindProperty(sync_uvs, [](const msbContext& self) { return self.getSettings().sync_uvs; }, [](msbContext& self, bool v) { self.getSettings().sync_uvs = v; }) BindProperty(sync_colors, [](const msbContext& self) { return self.getSettings().sync_colors; }, [](msbContext& self, bool v) { self.getSettings().sync_colors = v; }) BindProperty(make_double_sided, [](const msbContext& self) { return self.getSettings().make_double_sided; }, [](msbContext& self, bool v) { self.getSettings().make_double_sided = v; }) BindProperty(bake_modifiers, [](const msbContext& self) { return self.getSettings().bake_modifiers; }, [](msbContext& self, bool v) { self.getSettings().bake_modifiers = v; }) BindProperty(convert_to_mesh, [](const msbContext& self) { return self.getSettings().convert_to_mesh; }, [](msbContext& self, bool v) { self.getSettings().convert_to_mesh = v; }) BindProperty(sync_bones, [](const msbContext& self) { return self.getSettings().sync_bones; }, [](msbContext& self, bool v) { self.getSettings().sync_bones = v; }) BindProperty(sync_blendshapes, [](const msbContext& self) { return self.getSettings().sync_blendshapes; }, [](msbContext& self, bool v) { self.getSettings().sync_blendshapes = v; }) BindProperty(sync_textures, [](const msbContext& self) { return self.getSettings().sync_textures; }, [](msbContext& self, bool v) { self.getSettings().sync_textures = v; }) BindProperty(sync_cameras, [](const msbContext& self) { return self.getSettings().sync_cameras; }, [](msbContext& self, bool v) { self.getSettings().sync_cameras = v; }) BindProperty(sync_lights, [](const msbContext& self) { return self.getSettings().sync_lights; }, [](msbContext& self, bool v) { self.getSettings().sync_lights = v; }) BindProperty(animation_ts, [](const msbContext& self) { return self.getSettings().animation_timescale; }, [](msbContext& self, float v) { self.getSettings().animation_timescale = v; }) BindProperty(animation_interval, [](const msbContext& self) { return self.getSettings().animation_frame_interval; }, [](msbContext& self, int v) { self.getSettings().animation_frame_interval = v; }) BindProperty(keyframe_reduction, [](const msbContext& self) { return self.getSettings().keyframe_reduction; }, [](msbContext& self, int v) { self.getSettings().keyframe_reduction = v; }) BindProperty(multithreaded, [](const msbContext& self) { return self.getSettings().multithreaded; }, [](msbContext& self, int v) { self.getSettings().multithreaded = v; }) .def_property_readonly("version", [](const msbContext& self) { return std::string(msReleaseDateStr); }); } #undef BindMethod #undef BindMethod2 #undef BindProperty return mod.ptr(); }
65.5625
134
0.611376
[ "object" ]
065286f97cd9ea8e0280da2e5b42d71250e87d7f
2,185
cpp
C++
plugins/G3D/VRG3D/src/VRG3DGraphicsToolkit.cpp
kmilo9999/MinVR
fc1a01b82610961c277b890a86cd6ecaabf41146
[ "BSD-3-Clause" ]
18
2016-08-04T16:09:52.000Z
2022-01-17T15:43:37.000Z
plugins/G3D/VRG3D/src/VRG3DGraphicsToolkit.cpp
kmilo9999/MinVR
fc1a01b82610961c277b890a86cd6ecaabf41146
[ "BSD-3-Clause" ]
123
2015-01-08T17:32:39.000Z
2021-12-22T00:55:00.000Z
plugins/G3D/VRG3D/src/VRG3DGraphicsToolkit.cpp
kmilo9999/MinVR
fc1a01b82610961c277b890a86cd6ecaabf41146
[ "BSD-3-Clause" ]
21
2016-11-04T18:36:29.000Z
2022-03-01T19:44:11.000Z
#include "../include/VRG3DGraphicsToolkit.h" namespace MinVR { PLUGIN_API VRG3DGraphicsToolkit::VRG3DGraphicsToolkit(VRMainInterface *vrMain) :_renderDevice(NULL), _vrMain(vrMain), isInitialized(false), _frameCounter(0) { _renderDevice = new G3D::RenderDevice(); } PLUGIN_API VRG3DGraphicsToolkit::~VRG3DGraphicsToolkit() { } PLUGIN_API void VRG3DGraphicsToolkit::setDrawBuffer(VRDRAWBUFFER buffer) { /*_frameCounter++; if (_frameCounter == 1) { _renderDevice->beginFrame(); }*/ if (buffer == VRDRAWBUFFER_BACK) { //glViewport(0, 0, 1024, 1024); _renderDevice->setDrawBuffer(G3D::RenderDevice::DRAW_BACK); //glDrawBuffer(GL_BACK); // _renderDevice->clear(true, true, true); } else if (buffer == VRDRAWBUFFER_FRONT) { _renderDevice->setDrawBuffer(G3D::RenderDevice::DRAW_FRONT); } else if (buffer == VRDRAWBUFFER_BACKLEFT) { _renderDevice->setDrawBuffer(G3D::RenderDevice::DRAW_BACK_LEFT); } else if (buffer == VRDRAWBUFFER_FRONTLEFT) { _renderDevice->setDrawBuffer(G3D::RenderDevice::DRAW_FRONT_LEFT); } else if (buffer == VRDRAWBUFFER_BACKRIGHT) { _renderDevice->setDrawBuffer(G3D::RenderDevice::DRAW_BACK_RIGHT); } else if (buffer == VRDRAWBUFFER_FRONTRIGHT) { _renderDevice->setDrawBuffer(G3D::RenderDevice::DRAW_FRONT_RIGHT); } } PLUGIN_API void VRG3DGraphicsToolkit::flushGraphics() { } PLUGIN_API void VRG3DGraphicsToolkit::finishGraphics() { } PLUGIN_API VRGraphicsToolkit* VRG3DGraphicsToolkit::create(VRMainInterface *vrMain, VRDataIndex *config, const std::string &nameSpace) { return new VRG3DGraphicsToolkit(vrMain); } void VRG3DGraphicsToolkit::InitG3DRenderDevice( G3D::OSWindow* g3dWindow) { if (!isInitialized) { std::cout << "G3D Render device init" << std::endl; _renderDevice->init(g3dWindow); std::cout << "Render device reset state" << std::endl; // _renderDevice->resetState(); isInitialized = true; } } G3D::RenderDevice* VRG3DGraphicsToolkit::getG3DRenderDevice() { return this->_renderDevice; } }
24.550562
136
0.685584
[ "render" ]
0652bd11225ca08222c9f4b184677f92b865eed1
22,617
cpp
C++
src/test/prediction_service_test.cpp
lsdace30095/model_server
43862a61935d0798ed6908ac84b20192287933f1
[ "Apache-2.0" ]
null
null
null
src/test/prediction_service_test.cpp
lsdace30095/model_server
43862a61935d0798ed6908ac84b20192287933f1
[ "Apache-2.0" ]
null
null
null
src/test/prediction_service_test.cpp
lsdace30095/model_server
43862a61935d0798ed6908ac84b20192287933f1
[ "Apache-2.0" ]
null
null
null
//***************************************************************************** // Copyright 2020 Intel Corporation // // 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 <cstdio> #include <cstring> #include <filesystem> #include <fstream> #include <future> #include <thread> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <inference_engine.hpp> #include <stdlib.h> #include "../executinstreamidguard.hpp" #include "../modelinstance.hpp" #include "../prediction_service_utils.hpp" #include "test_utils.hpp" using testing::Each; using testing::Eq; class TestPredict : public ::testing::Test { public: void SetUp() { ovms::ModelConfig config = DUMMY_MODEL_CONFIG; const int initialBatchSize = 1; config.setBatchSize(initialBatchSize); config.setNireq(2); } void TearDown() { SPDLOG_ERROR("TEAR_DOWN"); } /** * @brief This function should mimic most closely predict request to check for thread safety */ void performPredict(const std::string modelName, const ovms::model_version_t modelVersion, const tensorflow::serving::PredictRequest& request, std::unique_ptr<std::future<void>> waitBeforeGettingModelInstance = nullptr, std::unique_ptr<std::future<void>> waitBeforePerformInference = nullptr); void deserialize(const std::vector<float>& input, InferenceEngine::InferRequest& inferRequest, std::shared_ptr<ovms::ModelInstance> modelInstance) { auto blob = InferenceEngine::make_shared_blob<float>( modelInstance->getInputsInfo().at(DUMMY_MODEL_INPUT_NAME)->getTensorDesc(), const_cast<float*>(reinterpret_cast<const float*>(input.data()))); inferRequest.SetBlob(DUMMY_MODEL_INPUT_NAME, blob); } void serializeAndCheck(int outputSize, InferenceEngine::InferRequest& inferRequest) { std::vector<float> output(outputSize); ASSERT_THAT(output, Each(Eq(0.))); auto blobOutput = inferRequest.GetBlob(DUMMY_MODEL_OUTPUT_NAME); ASSERT_EQ(blobOutput->byteSize(), outputSize * sizeof(float)); std::memcpy(output.data(), blobOutput->cbuffer(), outputSize * sizeof(float)); EXPECT_THAT(output, Each(Eq(2.))); } void testConcurrentPredicts(const int initialBatchSize, const uint waitingBeforePerformInferenceCount, const uint waitingBeforeGettingModelCount) { ASSERT_GE(20, waitingBeforePerformInferenceCount); config.setNireq(20); ASSERT_EQ(manager.reloadModelWithVersions(config), ovms::StatusCode::OK); std::vector<std::promise<void>> releaseWaitBeforeGettingModelInstance(waitingBeforeGettingModelCount); std::vector<std::promise<void>> releaseWaitBeforePerformInference(waitingBeforePerformInferenceCount); std::vector<std::thread> predictsWaitingBeforeGettingModelInstance; std::vector<std::thread> predictsWaitingBeforeInference; for (auto i = 0u; i < waitingBeforeGettingModelCount; ++i) { predictsWaitingBeforeGettingModelInstance.emplace_back( std::thread( [this, initialBatchSize, &releaseWaitBeforeGettingModelInstance, i]() { tensorflow::serving::PredictRequest request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{(initialBatchSize + (i % 3)), 10}, tensorflow::DataType::DT_FLOAT}}}); performPredict(config.getName(), config.getVersion(), request, std::move(std::make_unique<std::future<void>>(releaseWaitBeforeGettingModelInstance[i].get_future()))); })); } for (auto i = 0u; i < waitingBeforePerformInferenceCount; ++i) { predictsWaitingBeforeInference.emplace_back( std::thread( [this, initialBatchSize, &releaseWaitBeforePerformInference, i]() { tensorflow::serving::PredictRequest request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{initialBatchSize, 10}, tensorflow::DataType::DT_FLOAT}}}); performPredict(config.getName(), config.getVersion(), request, nullptr, std::move(std::make_unique<std::future<void>>(releaseWaitBeforePerformInference[i].get_future()))); })); } // sleep to allow all threads to initialize std::this_thread::sleep_for(std::chrono::seconds(2)); for (auto& promise : releaseWaitBeforeGettingModelInstance) { promise.set_value(); } for (auto& promise : releaseWaitBeforePerformInference) { promise.set_value(); } for (auto& thread : predictsWaitingBeforeGettingModelInstance) { thread.join(); } for (auto& thread : predictsWaitingBeforeInference) { thread.join(); } } void testConcurrentBsChanges(const int initialBatchSize, const uint numberOfThreads) { ASSERT_GE(20, numberOfThreads); config.setNireq(20); ASSERT_EQ(manager.reloadModelWithVersions(config), ovms::StatusCode::OK); std::vector<std::promise<void>> releaseWaitBeforeGettingModelInstance(numberOfThreads); std::vector<std::thread> predictThreads; for (auto i = 0u; i < numberOfThreads; ++i) { predictThreads.emplace_back( std::thread( [this, initialBatchSize, &releaseWaitBeforeGettingModelInstance, i]() { tensorflow::serving::PredictRequest request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{(initialBatchSize + i), 10}, tensorflow::DataType::DT_FLOAT}}}); performPredict(config.getName(), config.getVersion(), request, std::move(std::make_unique<std::future<void>>(releaseWaitBeforeGettingModelInstance[i].get_future()))); })); } // sleep to allow all threads to initialize std::this_thread::sleep_for(std::chrono::seconds(2)); for (auto& promise : releaseWaitBeforeGettingModelInstance) { promise.set_value(); } for (auto& thread : predictThreads) { thread.join(); } } static void checkOutputShape(const tensorflow::serving::PredictResponse& response, const ovms::shape_t& shape) { ASSERT_EQ(response.outputs().count("a"), 1); const auto& output_tensor = response.outputs().at("a"); ASSERT_EQ(output_tensor.tensor_shape().dim_size(), shape.size()); for (size_t i = 0; i < shape.size(); i++) { EXPECT_EQ(output_tensor.tensor_shape().dim(i).size(), shape[i]); } } ovms::Status performInferenceWithRequest(const tensorflow::serving::PredictRequest& request, tensorflow::serving::PredictResponse& response) { std::shared_ptr<ovms::ModelInstance> model; std::unique_ptr<ovms::ModelInstanceUnloadGuard> unload_guard; auto status = ovms::getModelInstance(manager, "dummy", 0, model, unload_guard); if (!status.ok()) { return status; } response.Clear(); return ovms::inference(*model, &request, &response, unload_guard); } ovms::Status performInferenceWithShape(tensorflow::serving::PredictResponse& response, const ovms::shape_t& shape = {1, 10}, const tensorflow::DataType precision = tensorflow::DataType::DT_FLOAT) { auto request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{shape, precision}}}); return performInferenceWithRequest(request, response); } ovms::Status performInferenceWithBatchSize(tensorflow::serving::PredictResponse& response, int batchSize = 1, const tensorflow::DataType precision = tensorflow::DataType::DT_FLOAT) { ovms::shape_t shape = {batchSize, 10}; auto request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{shape, precision}}}); return performInferenceWithRequest(request, response); } public: ConstructorEnabledModelManager manager; ovms::ModelConfig config = DUMMY_MODEL_CONFIG; ~TestPredict() { std::cout << "Destructor of TestPredict()" << std::endl; } }; void TestPredict::performPredict(const std::string modelName, const ovms::model_version_t modelVersion, const tensorflow::serving::PredictRequest& request, std::unique_ptr<std::future<void>> waitBeforeGettingModelInstance, std::unique_ptr<std::future<void>> waitBeforePerformInference) { // only validation is skipped std::shared_ptr<ovms::ModelInstance> modelInstance; std::unique_ptr<ovms::ModelInstanceUnloadGuard> modelInstanceUnloadGuard; auto& tensorProto = request.inputs().find("b")->second; size_t batchSize = tensorProto.tensor_shape().dim(0).size(); size_t inputSize = 1; for (int i = 0; i < tensorProto.tensor_shape().dim_size(); i++) { inputSize *= tensorProto.tensor_shape().dim(i).size(); } if (waitBeforeGettingModelInstance) { std::cout << "Waiting before getModelInstance. Batch size: " << batchSize << std::endl; waitBeforeGettingModelInstance->get(); } ASSERT_EQ(getModelInstance(manager, modelName, modelVersion, modelInstance, modelInstanceUnloadGuard), ovms::StatusCode::OK); if (waitBeforePerformInference) { std::cout << "Waiting before performInfernce." << std::endl; waitBeforePerformInference->get(); } ovms::Status validationStatus = modelInstance->validate(&request); ASSERT_TRUE(validationStatus == ovms::StatusCode::OK || validationStatus == ovms::StatusCode::RESHAPE_REQUIRED || validationStatus == ovms::StatusCode::BATCHSIZE_CHANGE_REQUIRED); ASSERT_EQ(reloadModelIfRequired(validationStatus, *modelInstance, &request, modelInstanceUnloadGuard), ovms::StatusCode::OK); ovms::OVInferRequestsQueue& inferRequestsQueue = modelInstance->getInferRequestsQueue(); ovms::ExecutingStreamIdGuard executingStreamIdGuard(inferRequestsQueue); int executingInferId = executingStreamIdGuard.getId(); InferenceEngine::InferRequest& inferRequest = inferRequestsQueue.getInferRequest(executingInferId); std::vector<float> input(inputSize); std::generate(input.begin(), input.end(), []() { return 1.; }); ASSERT_THAT(input, Each(Eq(1.))); deserialize(input, inferRequest, modelInstance); auto status = performInference(inferRequestsQueue, executingInferId, inferRequest); ASSERT_EQ(status, ovms::StatusCode::OK); size_t outputSize = batchSize * DUMMY_MODEL_OUTPUT_SIZE; serializeAndCheck(outputSize, inferRequest); } TEST_F(TestPredict, SuccesfullOnDummyModel) { tensorflow::serving::PredictRequest request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{1, 10}, tensorflow::DataType::DT_FLOAT}}}); ovms::ModelConfig config = DUMMY_MODEL_CONFIG; config.setBatchSize(1); ASSERT_EQ(manager.reloadModelWithVersions(config), ovms::StatusCode::OK); performPredict(config.getName(), config.getVersion(), request); } TEST_F(TestPredict, SuccesfullReloadFromAlreadyLoadedWithNewBatchSize) { tensorflow::serving::PredictRequest request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{1, 10}, tensorflow::DataType::DT_FLOAT}}}); ovms::ModelConfig config = DUMMY_MODEL_CONFIG; const int initialBatchSize = config.getBatchSize(); config.setBatchSize(initialBatchSize); ASSERT_EQ(manager.reloadModelWithVersions(config), ovms::StatusCode::OK); performPredict(config.getName(), config.getVersion(), request); } TEST_F(TestPredict, SuccesfullReloadWhen1InferenceInProgress) { // FIRST LOAD MODEL WITH BS=1 tensorflow::serving::PredictRequest requestBs1 = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{1, 10}, tensorflow::DataType::DT_FLOAT}}}); tensorflow::serving::PredictRequest requestBs2 = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{2, 10}, tensorflow::DataType::DT_FLOAT}}}); config.setBatchingParams("auto"); config.setNireq(2); ASSERT_EQ(manager.reloadModelWithVersions(config), ovms::StatusCode::OK); std::promise<void> releaseWaitBeforePerformInferenceBs1, releaseWaitBeforeGetModelInstanceBs2; std::thread t1( [this, &requestBs1, &releaseWaitBeforePerformInferenceBs1]() { performPredict(config.getName(), config.getVersion(), requestBs1, nullptr, std::move(std::make_unique<std::future<void>>(releaseWaitBeforePerformInferenceBs1.get_future()))); }); std::thread t2( [this, &requestBs2, &releaseWaitBeforeGetModelInstanceBs2]() { performPredict(config.getName(), config.getVersion(), requestBs2, std::move(std::make_unique<std::future<void>>(releaseWaitBeforeGetModelInstanceBs2.get_future())), nullptr); }); std::this_thread::sleep_for(std::chrono::seconds(1)); releaseWaitBeforePerformInferenceBs1.set_value(); releaseWaitBeforeGetModelInstanceBs2.set_value(); t1.join(); t2.join(); } TEST_F(TestPredict, SuccesfullReloadWhen1InferenceAboutToStart) { // FIRST LOAD MODEL WITH BS=1 tensorflow::serving::PredictRequest requestBs1 = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{1, 10}, tensorflow::DataType::DT_FLOAT}}}); tensorflow::serving::PredictRequest requestBs2 = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{2, 10}, tensorflow::DataType::DT_FLOAT}}}); config.setBatchingParams("auto"); config.setNireq(2); ASSERT_EQ(manager.reloadModelWithVersions(config), ovms::StatusCode::OK); std::promise<void> releaseWaitBeforeGetModelInstanceBs1, releaseWaitBeforePerformInferenceBs2; std::thread t1( [this, &requestBs1, &releaseWaitBeforeGetModelInstanceBs1]() { performPredict(config.getName(), config.getVersion(), requestBs1, std::move(std::make_unique<std::future<void>>(releaseWaitBeforeGetModelInstanceBs1.get_future())), nullptr); }); std::thread t2( [this, &requestBs2, &releaseWaitBeforePerformInferenceBs2]() { performPredict(config.getName(), config.getVersion(), requestBs2, nullptr, std::move(std::make_unique<std::future<void>>(releaseWaitBeforePerformInferenceBs2.get_future()))); }); std::this_thread::sleep_for(std::chrono::seconds(1)); releaseWaitBeforePerformInferenceBs2.set_value(); releaseWaitBeforeGetModelInstanceBs1.set_value(); t1.join(); t2.join(); } TEST_F(TestPredict, SuccesfullReloadWhenSeveralInferRequestJustBeforeGettingModelInstance) { const int initialBatchSize = 1; config.setBatchingParams("auto"); const uint waitingBeforePerformInferenceCount = 0; const uint waitingBeforeGettingModelCount = 9; testConcurrentPredicts(initialBatchSize, waitingBeforePerformInferenceCount, waitingBeforeGettingModelCount); } TEST_F(TestPredict, SuccesfullReloadWhenSeveralInferRequestJustBeforeInference) { const int initialBatchSize = 1; config.setBatchingParams("auto"); const uint waitingBeforePerformInferenceCount = 9; const uint waitingBeforeGettingModelCount = 0; testConcurrentPredicts(initialBatchSize, waitingBeforePerformInferenceCount, waitingBeforeGettingModelCount); } TEST_F(TestPredict, SuccesfullReloadWhenSeveralInferRequestAtDifferentStages) { const int initialBatchSize = 1; config.setBatchingParams("auto"); const uint waitingBeforePerformInferenceCount = 9; const uint waitingBeforeGettingModelCount = 9; testConcurrentPredicts(initialBatchSize, waitingBeforePerformInferenceCount, waitingBeforeGettingModelCount); } TEST_F(TestPredict, SuccesfullReloadForMultipleThreadsDifferentBS) { const int initialBatchSize = 2; config.setBatchingParams("auto"); const uint numberOfThreads = 5; testConcurrentBsChanges(initialBatchSize, numberOfThreads); } TEST_F(TestPredict, SuccesfullReshapeViaRequestOnDummyModel) { // Prepare model manager with dynamic shaped dummy model, originally loaded with 1x10 shape ovms::ModelConfig config = DUMMY_MODEL_CONFIG; config.setBatchingParams("0"); config.parseShapeParameter("auto"); ASSERT_EQ(manager.reloadModelWithVersions(config), ovms::StatusCode::OK); // Get dummy model instance std::shared_ptr<ovms::ModelInstance> model; std::unique_ptr<ovms::ModelInstanceUnloadGuard> unload_guard; auto status = ovms::getModelInstance(manager, "dummy", 0, model, unload_guard); // Prepare request with 1x5 shape, expect reshape tensorflow::serving::PredictRequest request = preparePredictRequest( {{DUMMY_MODEL_INPUT_NAME, std::tuple<ovms::shape_t, tensorflow::DataType>{{1, 5}, tensorflow::DataType::DT_FLOAT}}}); tensorflow::serving::PredictResponse response; // Do the inference ASSERT_EQ(inference(*model, &request, &response, unload_guard), ovms::StatusCode::OK); // Expect reshape to 1x5 ASSERT_EQ(response.outputs().count("a"), 1); auto& output_tensor = (*response.mutable_outputs())["a"]; ASSERT_EQ(output_tensor.tensor_shape().dim_size(), 2); EXPECT_EQ(output_tensor.tensor_shape().dim(0).size(), 1); EXPECT_EQ(output_tensor.tensor_shape().dim(1).size(), 5); } /** * Scenario - perform inferences with different shapes and model reload via config.json change * * 1. Load model with shape=auto, initial internal shape (1,10) * 2. Do the inference with (1,12) shape - expect status OK and result (1,12) * 3. Reshape model to fixed=(1,11) with config.json change * 4. Do the inference with (1,12) shape - expect status INVALID_SHAPE * 5. Do the inference with (1,11) shape - expect status OK and result (1,11) * 6. Reshape model back to shape=auto, initial internal shape (1,10) * 7. Do the inference with (1,12) shape - expect status OK and result (1,12) */ TEST_F(TestPredict, ReshapeViaRequestAndConfigChange) { using namespace ovms; // Prepare model with shape=auto (initially (1,10) shape) ModelConfig config = DUMMY_MODEL_CONFIG; config.setBatchingParams("0"); config.parseShapeParameter("auto"); ASSERT_EQ(manager.reloadModelWithVersions(config), StatusCode::OK); tensorflow::serving::PredictResponse response; // Perform reshape to (1,12) using request ASSERT_EQ(performInferenceWithShape(response, {1, 12}), StatusCode::OK); checkOutputShape(response, {1, 12}); // Reshape with model reload to Fixed=(1,11) config.setBatchingParams("0"); config.parseShapeParameter("(1,11)"); ASSERT_EQ(manager.reloadModelWithVersions(config), StatusCode::OK); // Cannot do the inference with (1,12) ASSERT_EQ(performInferenceWithShape(response, {1, 12}), StatusCode::INVALID_SHAPE); // Successfull inference with (1,11) ASSERT_EQ(performInferenceWithShape(response, {1, 11}), StatusCode::OK); checkOutputShape(response, {1, 11}); // Reshape back to AUTO, internal shape is (1,10) config.setBatchingParams("0"); config.parseShapeParameter("auto"); ASSERT_EQ(manager.reloadModelWithVersions(config), StatusCode::OK); // Perform reshape to (1,12) using request ASSERT_EQ(performInferenceWithShape(response, {1, 12}), StatusCode::OK); checkOutputShape(response, {1, 12}); } /** * Scenario - perform inferences with different batch size and model reload via config.json change * * 1. Load model with bs=auto, initial internal shape (1,10) * 2. Do the inference with (3,10) shape - expect status OK and result (3,10) * 3. Change model batch size to fixed=4 with config.json change * 4. Do the inference with (3,10) shape - expect status INVALID_BATCH_SIZE * 5. Do the inference with (4,10) shape - expect status OK and result (4,10) * 6. Reshape model back to batchsize=auto, initial internal shape (1,10) * 7. Do the inference with (3,10) shape - expect status OK and result (3,10) */ TEST_F(TestPredict, ChangeBatchSizeViaRequestAndConfigChange) { using namespace ovms; // Prepare model with shape=auto (initially (1,10) shape) ModelConfig config = DUMMY_MODEL_CONFIG; config.setBatchingParams("auto"); ASSERT_EQ(manager.reloadModelWithVersions(config), StatusCode::OK); tensorflow::serving::PredictResponse response; // Perform batch size change to 3 using request ASSERT_EQ(performInferenceWithBatchSize(response, 3), StatusCode::OK); checkOutputShape(response, {3, 10}); // Change batch size with model reload to Fixed=4 config.setBatchingParams("4"); ASSERT_EQ(manager.reloadModelWithVersions(config), StatusCode::OK); // Cannot do the inference with (3,10) ASSERT_EQ(performInferenceWithBatchSize(response, 3), StatusCode::INVALID_BATCH_SIZE); // Successfull inference with (4,10) ASSERT_EQ(performInferenceWithBatchSize(response, 4), StatusCode::OK); checkOutputShape(response, {4, 10}); // Reshape back to AUTO, internal shape is (1,10) config.setBatchingParams("auto"); ASSERT_EQ(manager.reloadModelWithVersions(config), StatusCode::OK); // Perform batch change to 3 using request ASSERT_EQ(performInferenceWithBatchSize(response, 3), StatusCode::OK); checkOutputShape(response, {3, 10}); }
47.02079
201
0.694964
[ "shape", "vector", "model" ]
066619224d287b8a887241661bc715a7fa380fcd
6,735
cpp
C++
Src/SimRobotCore2/Simulation/Sensors/ApproxDistanceSensor.cpp
bhuman/SimRobot
f7b2039e7b8c801cdbd74ea25346cf86b298ab06
[ "MIT" ]
3
2021-11-05T21:09:09.000Z
2021-11-15T22:48:10.000Z
Src/SimRobotCore2/Simulation/Sensors/ApproxDistanceSensor.cpp
bhuman/SimRobot
f7b2039e7b8c801cdbd74ea25346cf86b298ab06
[ "MIT" ]
null
null
null
Src/SimRobotCore2/Simulation/Sensors/ApproxDistanceSensor.cpp
bhuman/SimRobot
f7b2039e7b8c801cdbd74ea25346cf86b298ab06
[ "MIT" ]
null
null
null
/** * @file Simulation/Sensors/ApproxDistanceSensor.cpp * Implementation of class ApproxDistanceSensor * @author Colin Graf */ #include "Platform/OpenGL.h" #include <cmath> #include "Simulation/Sensors/ApproxDistanceSensor.h" #include "Simulation/Geometries/Geometry.h" #include "Platform/Assert.h" #include "Tools/OpenGLTools.h" #include "Tools/ODETools.h" #include "CoreModule.h" #include <algorithm> ApproxDistanceSensor::ApproxDistanceSensor() { sensor.sensorType = SimRobotCore2::SensorPort::floatSensor; sensor.unit = "m"; } void ApproxDistanceSensor::createPhysics() { OpenGLTools::convertTransformation(rotation, translation, transformation); sensor.tanHalfAngleX = std::tan(angleX * 0.5f); sensor.tanHalfAngleY = std::tan(angleY * 0.5f); float width = sensor.tanHalfAngleX * max * 2.f; float height = sensor.tanHalfAngleY * max * 2.f; float depth = max; sensor.geom = dCreateBox(Simulation::simulation->rootSpace, depth, width, height); sensor.scanRayGeom = dCreateRay(Simulation::simulation->rootSpace, max); sensor.min = min; sensor.max = max; sensor.maxSqrDist = max * max; if(translation) sensor.offset.translation = *translation; if(rotation) sensor.offset.rotation = *rotation; } void ApproxDistanceSensor::registerObjects() { sensor.fullName = fullName + ".distance"; CoreModule::application->registerObject(*CoreModule::module, sensor, this); Sensor::registerObjects(); } void ApproxDistanceSensor::addParent(Element& element) { sensor.physicalObject = dynamic_cast<::PhysicalObject*>(&element); ASSERT(sensor.physicalObject); Sensor::addParent(element); } void ApproxDistanceSensor::DistanceSensor::staticCollisionCallback(ApproxDistanceSensor::DistanceSensor* sensor, dGeomID geom1, dGeomID geom2) { static_cast<void>(geom1); ASSERT(geom1 == sensor->geom); ASSERT(!dGeomIsSpace(geom2)); Geometry* geometry = static_cast<Geometry*>(dGeomGetData(geom2)); if(reinterpret_cast<::PhysicalObject*>(geometry->parentBody) == sensor->physicalObject) return; // avoid detecting the body on which the sensor is mounted const dReal* pos = dGeomGetPosition(geom2); Vector3f geomPos; ODETools::convertVector(pos, geomPos); const float approxSqrDist = (geomPos - sensor->pose.translation).squaredNorm() - geometry->innerRadiusSqr; if(approxSqrDist >= sensor->closestSqrDistance) return; // we already found another geometrie that was closer const Vector3f relPos = sensor->invertedPose * geomPos; if(relPos.x() <= 0.f) return; // center of the geometry should be in front of the distance sensor const float halfMaxY = sensor->tanHalfAngleX * relPos.x(); const float halfMaxZ = sensor->tanHalfAngleY * relPos.x(); if(std::max(std::abs(relPos.y()) - geometry->outerRadius, 0.f) >= halfMaxY || std::max(std::abs(relPos.z()) - geometry->outerRadius, 0.f) >= halfMaxZ) return; // the sphere that covers the geometry does not collide with the pyramid of the distance sensor if(std::max(std::abs(relPos.y()) - geometry->innerRadius, 0.f) < halfMaxY && std::max(std::abs(relPos.z()) - geometry->innerRadius, 0.f) < halfMaxZ) goto hit; // the sphere enclosed by the geometry collides with the pyramid of the distance sensor // geom2 might collide with the pyramid of the distance sensor. let us perform a hit scan along one of the pyramid's sides to find out.. { const Vector3f scanDir = sensor->pose.rotation * Vector3f(relPos.x(), std::max(std::min(relPos.y(), halfMaxY), -halfMaxY), std::max(std::min(relPos.z(), halfMaxZ), -halfMaxZ)); const Vector3f& sensorPos = sensor->pose.translation; dGeomRaySet(sensor->scanRayGeom, sensorPos.x(), sensorPos.y(), sensorPos.z(), scanDir.x(), scanDir.y(), scanDir.z()); dContactGeom contactGeom; if(dCollide(sensor->scanRayGeom, geom2, CONTACTS_UNIMPORTANT | 1, &contactGeom, sizeof(dContactGeom)) <= 0) return; } hit: sensor->closestSqrDistance = approxSqrDist; sensor->closestGeom = geom2; } void ApproxDistanceSensor::DistanceSensor::staticCollisionWithSpaceCallback(ApproxDistanceSensor::DistanceSensor* sensor, dGeomID geom1, dGeomID geom2) { ASSERT(geom1 == sensor->geom); ASSERT(dGeomIsSpace(geom2)); dSpaceCollide2(geom1, geom2, sensor, reinterpret_cast<dNearCallback*>(&staticCollisionCallback)); } void ApproxDistanceSensor::DistanceSensor::updateValue() { pose = physicalObject->pose; pose.conc(offset); invertedPose = pose.inverse(); Vector3f boxPos = pose * Vector3f(max * 0.5f, 0.f, 0.f); dGeomSetPosition(geom, boxPos.x(), boxPos.y(), boxPos.z()); dMatrix3 matrix3; ODETools::convertMatrix(pose.rotation, matrix3); dGeomSetRotation(geom, matrix3); closestGeom = 0; closestSqrDistance = maxSqrDist; dSpaceCollide2(geom, reinterpret_cast<dGeomID>(Simulation::simulation->movableSpace), this, reinterpret_cast<dNearCallback*>(&staticCollisionWithSpaceCallback)); dSpaceCollide2(geom, reinterpret_cast<dGeomID>(Simulation::simulation->staticSpace), this, reinterpret_cast<dNearCallback*>(&staticCollisionCallback)); if(closestGeom) { const dReal* pos = dGeomGetPosition(closestGeom); Geometry* geometry = static_cast<Geometry*>(dGeomGetData(closestGeom)); data.floatValue = (Vector3f(static_cast<float>(pos[0]), static_cast<float>(pos[1]), static_cast<float>(pos[2])) - pose.translation).norm() - geometry->innerRadius; if(data.floatValue < min) data.floatValue = min; } else data.floatValue = max; } bool ApproxDistanceSensor::DistanceSensor::getMinAndMax(float& min, float& max) const { min = this->min; max = this->max; return true; } void ApproxDistanceSensor::drawPhysics(unsigned int flags) const { glPushMatrix(); glMultMatrixf(transformation); if(flags & SimRobotCore2::Renderer::showSensors) { const Vector3f ml(max, -std::tan(angleX * 0.5f) * max, 0); const Vector3f mt(max, 0, std::tan(angleY * 0.5f) * max); const Vector3f tl(max, ml.y(), mt.z()); const Vector3f tr(max, -ml.y(), mt.z()); const Vector3f bl(max, ml.y(), -mt.z()); const Vector3f br(max, -ml.y(), -mt.z()); glBegin(GL_LINE_LOOP); glColor3f(0.5f, 0, 0); glNormal3f (0, 0, 1.f); glVertex3f(tl.x(), tl.y(), tl.z()); glVertex3f(tr.x(), tr.y(), tr.z()); glVertex3f(br.x(), br.y(), br.z()); glVertex3f(bl.x(), bl.y(), bl.z()); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(tl.x(), tl.y(), tl.z()); glVertex3f(0.f, 0.f, 0.f); glVertex3f(tr.x(), tr.y(), tr.z()); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(bl.x(), bl.y(), bl.z()); glVertex3f(0.f, 0.f, 0.f); glVertex3f(br.x(), br.y(), br.z()); glEnd(); } Sensor::drawPhysics(flags); glPopMatrix(); }
37.416667
180
0.708092
[ "geometry" ]
0668dc7d83b2b6a491e361f10ebe972c7cf30c0e
1,800
hpp
C++
src/core/lib/core_qt_common/models/wg_transpose_proxy.hpp
wgsyd/wgtf
d8cacb43e2c5d40080d33c18a8c2f5bd27d21bed
[ "BSD-3-Clause" ]
28
2016-06-03T05:28:25.000Z
2019-02-14T12:04:31.000Z
src/core/lib/core_qt_common/models/wg_transpose_proxy.hpp
karajensen/wgtf
740397bcfdbc02bc574231579d57d7c9cd5cc26d
[ "BSD-3-Clause" ]
null
null
null
src/core/lib/core_qt_common/models/wg_transpose_proxy.hpp
karajensen/wgtf
740397bcfdbc02bc574231579d57d7c9cd5cc26d
[ "BSD-3-Clause" ]
14
2016-06-03T05:52:27.000Z
2019-03-21T09:56:03.000Z
#ifndef WG_TRANSPOSE_PROXY_HPP #define WG_TRANSPOSE_PROXY_HPP #include <QAbstractProxyModel> #include "qt_connection_holder.hpp" #include "core_qt_common/qt_new_handler.hpp" namespace wgt { /** * Proxy layer which transposes the source model, i.e. swaps rows and columns. * * Used by the MultiEdit control to transpose the output of WGMergeProxy, which has * items as columns and properties as rows, into a layout where items are rows, which * is more suitable for presentation. */ class WGTransposeProxy : public QAbstractProxyModel { Q_OBJECT DECLARE_QT_MEMORY_HANDLER public: virtual void setSourceModel(QAbstractItemModel* sourceModel) override; Q_INVOKABLE virtual QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; Q_INVOKABLE virtual QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; Q_INVOKABLE virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; Q_INVOKABLE virtual QModelIndex parent(const QModelIndex& child) const override; Q_INVOKABLE virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override; Q_INVOKABLE virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override; Q_INVOKABLE virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const override; Q_INVOKABLE virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant& value, int role = Qt::EditRole) override; virtual QHash<int, QByteArray> roleNames() const override; private: QtConnectionHolder connections_; }; } #endif // WG_TRANSPOSE_PROXY_HPP
37.5
126
0.779444
[ "model" ]
067c44123b925fae0d6085217d62ba98e853d3b3
19,307
cc
C++
third_party/webrtc/call/rtc_event_log_unittest.cc
maidiHaitai/haitaibrowser
a232a56bcfb177913a14210e7733e0ea83a6b18d
[ "BSD-3-Clause" ]
1
2020-09-15T08:43:34.000Z
2020-09-15T08:43:34.000Z
third_party/webrtc/call/rtc_event_log_unittest.cc
maidiHaitai/haitaibrowser
a232a56bcfb177913a14210e7733e0ea83a6b18d
[ "BSD-3-Clause" ]
null
null
null
third_party/webrtc/call/rtc_event_log_unittest.cc
maidiHaitai/haitaibrowser
a232a56bcfb177913a14210e7733e0ea83a6b18d
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifdef ENABLE_RTC_EVENT_LOG #include <map> #include <memory> #include <string> #include <utility> #include <vector> #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/buffer.h" #include "webrtc/base/checks.h" #include "webrtc/base/random.h" #include "webrtc/call.h" #include "webrtc/call/rtc_event_log.h" #include "webrtc/call/rtc_event_log_parser.h" #include "webrtc/call/rtc_event_log_unittest_helper.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" #include "webrtc/system_wrappers/include/clock.h" #include "webrtc/test/test_suite.h" #include "webrtc/test/testsupport/fileutils.h" // Files generated at build-time by the protobuf compiler. #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/call/rtc_event_log.pb.h" #else #include "webrtc/call/rtc_event_log.pb.h" #endif namespace webrtc { namespace { const RTPExtensionType kExtensionTypes[] = { RTPExtensionType::kRtpExtensionTransmissionTimeOffset, RTPExtensionType::kRtpExtensionAudioLevel, RTPExtensionType::kRtpExtensionAbsoluteSendTime, RTPExtensionType::kRtpExtensionVideoRotation, RTPExtensionType::kRtpExtensionTransportSequenceNumber}; const char* kExtensionNames[] = {RtpExtension::kTOffset, RtpExtension::kAudioLevel, RtpExtension::kAbsSendTime, RtpExtension::kVideoRotation, RtpExtension::kTransportSequenceNumber}; const size_t kNumExtensions = 5; void PrintActualEvents(const ParsedRtcEventLog& parsed_log) { std::map<int, size_t> actual_event_counts; for (size_t i = 0; i < parsed_log.GetNumberOfEvents(); i++) { actual_event_counts[parsed_log.GetEventType(i)]++; } printf("Actual events: "); for (auto kv : actual_event_counts) { printf("%d_count = %zu, ", kv.first, kv.second); } printf("\n"); for (size_t i = 0; i < parsed_log.GetNumberOfEvents(); i++) { printf("%4d ", parsed_log.GetEventType(i)); } printf("\n"); } void PrintExpectedEvents(size_t rtp_count, size_t rtcp_count, size_t playout_count, size_t bwe_loss_count) { printf( "Expected events: rtp_count = %zu, rtcp_count = %zu," "playout_count = %zu, bwe_loss_count = %zu\n", rtp_count, rtcp_count, playout_count, bwe_loss_count); size_t rtcp_index = 1, playout_index = 1, bwe_loss_index = 1; printf("strt cfg cfg "); for (size_t i = 1; i <= rtp_count; i++) { printf(" rtp "); if (i * rtcp_count >= rtcp_index * rtp_count) { printf("rtcp "); rtcp_index++; } if (i * playout_count >= playout_index * rtp_count) { printf("play "); playout_index++; } if (i * bwe_loss_count >= bwe_loss_index * rtp_count) { printf("loss "); bwe_loss_index++; } } printf("end \n"); } } // namespace /* * Bit number i of extension_bitvector is set to indicate the * presence of extension number i from kExtensionTypes / kExtensionNames. * The least significant bit extension_bitvector has number 0. */ size_t GenerateRtpPacket(uint32_t extensions_bitvector, uint32_t csrcs_count, uint8_t* packet, size_t packet_size, Random* prng) { RTC_CHECK_GE(packet_size, 16 + 4 * csrcs_count + 4 * kNumExtensions); Clock* clock = Clock::GetRealTimeClock(); RTPSender rtp_sender(false, // bool audio clock, // Clock* clock nullptr, // Transport* nullptr, // PacedSender* nullptr, // PacketRouter* nullptr, // SendTimeObserver* nullptr, // BitrateStatisticsObserver* nullptr, // FrameCountObserver* nullptr, // SendSideDelayObserver* nullptr, // RtcEventLog* nullptr); // SendPacketObserver* std::vector<uint32_t> csrcs; for (unsigned i = 0; i < csrcs_count; i++) { csrcs.push_back(prng->Rand<uint32_t>()); } rtp_sender.SetCsrcs(csrcs); rtp_sender.SetSSRC(prng->Rand<uint32_t>()); rtp_sender.SetStartTimestamp(prng->Rand<uint32_t>(), true); rtp_sender.SetSequenceNumber(prng->Rand<uint16_t>()); for (unsigned i = 0; i < kNumExtensions; i++) { if (extensions_bitvector & (1u << i)) { rtp_sender.RegisterRtpHeaderExtension(kExtensionTypes[i], i + 1); } } int8_t payload_type = prng->Rand(0, 127); bool marker_bit = prng->Rand<bool>(); uint32_t capture_timestamp = prng->Rand<uint32_t>(); int64_t capture_time_ms = prng->Rand<uint32_t>(); bool timestamp_provided = prng->Rand<bool>(); bool inc_sequence_number = prng->Rand<bool>(); size_t header_size = rtp_sender.BuildRTPheader( packet, payload_type, marker_bit, capture_timestamp, capture_time_ms, timestamp_provided, inc_sequence_number); for (size_t i = header_size; i < packet_size; i++) { packet[i] = prng->Rand<uint8_t>(); } return header_size; } rtc::Buffer GenerateRtcpPacket(Random* prng) { rtcp::ReportBlock report_block; report_block.To(prng->Rand<uint32_t>()); // Remote SSRC. report_block.WithFractionLost(prng->Rand(50)); rtcp::SenderReport sender_report; sender_report.From(prng->Rand<uint32_t>()); // Sender SSRC. sender_report.WithNtp( NtpTime(prng->Rand<uint32_t>(), prng->Rand<uint32_t>())); sender_report.WithPacketCount(prng->Rand<uint32_t>()); sender_report.WithReportBlock(report_block); return sender_report.Build(); } void GenerateVideoReceiveConfig(uint32_t extensions_bitvector, VideoReceiveStream::Config* config, Random* prng) { // Create a map from a payload type to an encoder name. VideoReceiveStream::Decoder decoder; decoder.payload_type = prng->Rand(0, 127); decoder.payload_name = (prng->Rand<bool>() ? "VP8" : "H264"); config->decoders.push_back(decoder); // Add SSRCs for the stream. config->rtp.remote_ssrc = prng->Rand<uint32_t>(); config->rtp.local_ssrc = prng->Rand<uint32_t>(); // Add extensions and settings for RTCP. config->rtp.rtcp_mode = prng->Rand<bool>() ? RtcpMode::kCompound : RtcpMode::kReducedSize; config->rtp.remb = prng->Rand<bool>(); // Add a map from a payload type to a new ssrc and a new payload type for RTX. VideoReceiveStream::Config::Rtp::Rtx rtx_pair; rtx_pair.ssrc = prng->Rand<uint32_t>(); rtx_pair.payload_type = prng->Rand(0, 127); config->rtp.rtx.insert(std::make_pair(prng->Rand(0, 127), rtx_pair)); // Add header extensions. for (unsigned i = 0; i < kNumExtensions; i++) { if (extensions_bitvector & (1u << i)) { config->rtp.extensions.push_back( RtpExtension(kExtensionNames[i], prng->Rand<int>())); } } } void GenerateVideoSendConfig(uint32_t extensions_bitvector, VideoSendStream::Config* config, Random* prng) { // Create a map from a payload type to an encoder name. config->encoder_settings.payload_type = prng->Rand(0, 127); config->encoder_settings.payload_name = (prng->Rand<bool>() ? "VP8" : "H264"); // Add SSRCs for the stream. config->rtp.ssrcs.push_back(prng->Rand<uint32_t>()); // Add a map from a payload type to new ssrcs and a new payload type for RTX. config->rtp.rtx.ssrcs.push_back(prng->Rand<uint32_t>()); config->rtp.rtx.payload_type = prng->Rand(0, 127); // Add header extensions. for (unsigned i = 0; i < kNumExtensions; i++) { if (extensions_bitvector & (1u << i)) { config->rtp.extensions.push_back( RtpExtension(kExtensionNames[i], prng->Rand<int>())); } } } // Test for the RtcEventLog class. Dumps some RTP packets and other events // to disk, then reads them back to see if they match. void LogSessionAndReadBack(size_t rtp_count, size_t rtcp_count, size_t playout_count, size_t bwe_loss_count, uint32_t extensions_bitvector, uint32_t csrcs_count, unsigned int random_seed) { ASSERT_LE(rtcp_count, rtp_count); ASSERT_LE(playout_count, rtp_count); ASSERT_LE(bwe_loss_count, rtp_count); std::vector<rtc::Buffer> rtp_packets; std::vector<rtc::Buffer> rtcp_packets; std::vector<size_t> rtp_header_sizes; std::vector<uint32_t> playout_ssrcs; std::vector<std::pair<int32_t, uint8_t> > bwe_loss_updates; VideoReceiveStream::Config receiver_config(nullptr); VideoSendStream::Config sender_config(nullptr); Random prng(random_seed); // Create rtp_count RTP packets containing random data. for (size_t i = 0; i < rtp_count; i++) { size_t packet_size = prng.Rand(1000, 1100); rtp_packets.push_back(rtc::Buffer(packet_size)); size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count, rtp_packets[i].data(), packet_size, &prng); rtp_header_sizes.push_back(header_size); } // Create rtcp_count RTCP packets containing random data. for (size_t i = 0; i < rtcp_count; i++) { rtcp_packets.push_back(GenerateRtcpPacket(&prng)); } // Create playout_count random SSRCs to use when logging AudioPlayout events. for (size_t i = 0; i < playout_count; i++) { playout_ssrcs.push_back(prng.Rand<uint32_t>()); } // Create bwe_loss_count random bitrate updates for BwePacketLoss. for (size_t i = 0; i < bwe_loss_count; i++) { bwe_loss_updates.push_back( std::make_pair(prng.Rand<int32_t>(), prng.Rand<uint8_t>())); } // Create configurations for the video streams. GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config, &prng); GenerateVideoSendConfig(extensions_bitvector, &sender_config, &prng); const int config_count = 2; // Find the name of the current test, in order to use it as a temporary // filename. auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); const std::string temp_filename = test::OutputPath() + test_info->test_case_name() + test_info->name(); // When log_dumper goes out of scope, it causes the log file to be flushed // to disk. { SimulatedClock fake_clock(prng.Rand<uint32_t>()); std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create(&fake_clock)); log_dumper->LogVideoReceiveStreamConfig(receiver_config); fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); log_dumper->LogVideoSendStreamConfig(sender_config); fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); size_t rtcp_index = 1; size_t playout_index = 1; size_t bwe_loss_index = 1; for (size_t i = 1; i <= rtp_count; i++) { log_dumper->LogRtpHeader( (i % 2 == 0) ? kIncomingPacket : kOutgoingPacket, (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, rtp_packets[i - 1].data(), rtp_packets[i - 1].size()); fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); if (i * rtcp_count >= rtcp_index * rtp_count) { log_dumper->LogRtcpPacket( (rtcp_index % 2 == 0) ? kIncomingPacket : kOutgoingPacket, rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, rtcp_packets[rtcp_index - 1].data(), rtcp_packets[rtcp_index - 1].size()); rtcp_index++; fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); } if (i * playout_count >= playout_index * rtp_count) { log_dumper->LogAudioPlayout(playout_ssrcs[playout_index - 1]); playout_index++; fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); } if (i * bwe_loss_count >= bwe_loss_index * rtp_count) { log_dumper->LogBwePacketLossEvent( bwe_loss_updates[bwe_loss_index - 1].first, bwe_loss_updates[bwe_loss_index - 1].second, i); bwe_loss_index++; fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); } if (i == rtp_count / 2) { log_dumper->StartLogging(temp_filename, 10000000); fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); } } log_dumper->StopLogging(); } // Read the generated file from disk. ParsedRtcEventLog parsed_log; ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); // Verify that what we read back from the event log is the same as // what we wrote down. For RTCP we log the full packets, but for // RTP we should only log the header. const size_t event_count = config_count + playout_count + bwe_loss_count + rtcp_count + rtp_count + 2; EXPECT_GE(1000u, event_count); // The events must fit in the message queue. EXPECT_EQ(event_count, parsed_log.GetNumberOfEvents()); if (event_count != parsed_log.GetNumberOfEvents()) { // Print the expected and actual event types for easier debugging. PrintActualEvents(parsed_log); PrintExpectedEvents(rtp_count, rtcp_count, playout_count, bwe_loss_count); } RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); RtcEventLogTestHelper::VerifyReceiveStreamConfig(parsed_log, 1, receiver_config); RtcEventLogTestHelper::VerifySendStreamConfig(parsed_log, 2, sender_config); size_t event_index = config_count + 1; size_t rtcp_index = 1; size_t playout_index = 1; size_t bwe_loss_index = 1; for (size_t i = 1; i <= rtp_count; i++) { RtcEventLogTestHelper::VerifyRtpEvent( parsed_log, event_index, (i % 2 == 0) ? kIncomingPacket : kOutgoingPacket, (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, rtp_packets[i - 1].data(), rtp_header_sizes[i - 1], rtp_packets[i - 1].size()); event_index++; if (i * rtcp_count >= rtcp_index * rtp_count) { RtcEventLogTestHelper::VerifyRtcpEvent( parsed_log, event_index, rtcp_index % 2 == 0 ? kIncomingPacket : kOutgoingPacket, rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, rtcp_packets[rtcp_index - 1].data(), rtcp_packets[rtcp_index - 1].size()); event_index++; rtcp_index++; } if (i * playout_count >= playout_index * rtp_count) { RtcEventLogTestHelper::VerifyPlayoutEvent( parsed_log, event_index, playout_ssrcs[playout_index - 1]); event_index++; playout_index++; } if (i * bwe_loss_count >= bwe_loss_index * rtp_count) { RtcEventLogTestHelper::VerifyBweLossEvent( parsed_log, event_index, bwe_loss_updates[bwe_loss_index - 1].first, bwe_loss_updates[bwe_loss_index - 1].second, i); event_index++; bwe_loss_index++; } } // Clean up temporary file - can be pretty slow. remove(temp_filename.c_str()); } TEST(RtcEventLogTest, LogSessionAndReadBack) { // Log 5 RTP, 2 RTCP, 0 playout events and 0 BWE events // with no header extensions or CSRCS. LogSessionAndReadBack(5, 2, 0, 0, 0, 0, 321); // Enable AbsSendTime and TransportSequenceNumbers. uint32_t extensions = 0; for (uint32_t i = 0; i < kNumExtensions; i++) { if (kExtensionTypes[i] == RTPExtensionType::kRtpExtensionAbsoluteSendTime || kExtensionTypes[i] == RTPExtensionType::kRtpExtensionTransportSequenceNumber) { extensions |= 1u << i; } } LogSessionAndReadBack(8, 2, 0, 0, extensions, 0, 3141592653u); extensions = (1u << kNumExtensions) - 1; // Enable all header extensions. LogSessionAndReadBack(9, 2, 3, 2, extensions, 2, 2718281828u); // Try all combinations of header extensions and up to 2 CSRCS. for (extensions = 0; extensions < (1u << kNumExtensions); extensions++) { for (uint32_t csrcs_count = 0; csrcs_count < 3; csrcs_count++) { LogSessionAndReadBack(5 + extensions, // Number of RTP packets. 2 + csrcs_count, // Number of RTCP packets. 3 + csrcs_count, // Number of playout events. 1 + csrcs_count, // Number of BWE loss events. extensions, // Bit vector choosing extensions. csrcs_count, // Number of contributing sources. extensions * 3 + csrcs_count + 1); // Random seed. } } } TEST(RtcEventLogTest, LogEventAndReadBack) { Random prng(987654321); // Create one RTP and one RTCP packet containing random data. size_t packet_size = prng.Rand(1000, 1100); rtc::Buffer rtp_packet(packet_size); size_t header_size = GenerateRtpPacket(0, 0, rtp_packet.data(), packet_size, &prng); rtc::Buffer rtcp_packet = GenerateRtcpPacket(&prng); // Find the name of the current test, in order to use it as a temporary // filename. auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); const std::string temp_filename = test::OutputPath() + test_info->test_case_name() + test_info->name(); // Add RTP, start logging, add RTCP and then stop logging SimulatedClock fake_clock(prng.Rand<uint32_t>()); std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create(&fake_clock)); log_dumper->LogRtpHeader(kIncomingPacket, MediaType::VIDEO, rtp_packet.data(), rtp_packet.size()); fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); log_dumper->StartLogging(temp_filename, 10000000); fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); log_dumper->LogRtcpPacket(kOutgoingPacket, MediaType::VIDEO, rtcp_packet.data(), rtcp_packet.size()); fake_clock.AdvanceTimeMicroseconds(prng.Rand(1, 1000)); log_dumper->StopLogging(); // Read the generated file from disk. ParsedRtcEventLog parsed_log; ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); // Verify that what we read back from the event log is the same as // what we wrote down. EXPECT_EQ(4u, parsed_log.GetNumberOfEvents()); RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); RtcEventLogTestHelper::VerifyRtpEvent(parsed_log, 1, kIncomingPacket, MediaType::VIDEO, rtp_packet.data(), header_size, rtp_packet.size()); RtcEventLogTestHelper::VerifyRtcpEvent(parsed_log, 2, kOutgoingPacket, MediaType::VIDEO, rtcp_packet.data(), rtcp_packet.size()); RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); // Clean up temporary file - can be pretty slow. remove(temp_filename.c_str()); } } // namespace webrtc #endif // ENABLE_RTC_EVENT_LOG
40.056017
80
0.659191
[ "vector" ]
068ba0270693fd56d88a78e011437b9e20456750
1,576
cpp
C++
src/Enzo/enzo_EnzoRiemann.cpp
pgrete/enzo-e
43b1e33db50dbf00ea115ef35b7a4b17aa735342
[ "BSD-3-Clause" ]
null
null
null
src/Enzo/enzo_EnzoRiemann.cpp
pgrete/enzo-e
43b1e33db50dbf00ea115ef35b7a4b17aa735342
[ "BSD-3-Clause" ]
1
2019-04-18T15:39:23.000Z
2019-04-18T15:39:23.000Z
src/Enzo/enzo_EnzoRiemann.cpp
aemerick/enzo-e
5282aa38593c298a894b52f3ab38ae616aaee43c
[ "MIT", "BSD-3-Clause" ]
null
null
null
// See LICENSE_CELLO file for license and copyright information /// @file enzo_EnzoRiemann.cpp /// @author Matthew Abruzzo (matthewabruzzo@gmail.com) /// @date Thurs May 2 2019 /// @brief [\ref Enzo] Implementation of EnzoRiemann #include <string> #include <algorithm> #include "cello.hpp" #include "enzo.hpp" //---------------------------------------------------------------------- EnzoRiemann* EnzoRiemann::construct_riemann (std::vector<std::string> integrable_groups, std::vector<std::string> passive_groups, std::string solver) { // determine the type of solver to construct: // convert string to lower case (https://stackoverflow.com/a/313990) std::string formatted(solver.size(), ' '); std::transform(solver.begin(), solver.end(), formatted.begin(), ::tolower); EnzoRiemann* out; // Eventually we may want to check for non-MHD Riemann solvers if (formatted == std::string("hll")){ out = new EnzoRiemannHLLMHD(integrable_groups, passive_groups); } else if (formatted == std::string("hlle")){ out = new EnzoRiemannHLLEMHD(integrable_groups, passive_groups); } else if (formatted == std::string("hllc")){ out = new EnzoRiemannHLLC(integrable_groups, passive_groups); } else if (formatted == std::string("hlld")){ // could possibly check that MHD fields are included out = new EnzoRiemannHLLD(integrable_groups, passive_groups); } else { ERROR("EnzoRiemann::construct_riemann", "The only known solvers are HLL, HLLE, HLLC, & HLLD"); out = NULL; // Deals with compiler warning } return out; }
35.818182
72
0.672589
[ "vector", "transform" ]
06912035a8d61203153db757230e12f65cab5c9c
1,690
cpp
C++
_investigacion/contests/UTP-Regional/barking_machines_2.cpp
civilian/competitive_programing
a6ae7ad0db84240667c1dd6231c51c586ba040c7
[ "MIT" ]
1
2016-02-11T21:28:22.000Z
2016-02-11T21:28:22.000Z
_investigacion/contests/UTP-Regional/barking_machines_2.cpp
civilian/competitive_programing
a6ae7ad0db84240667c1dd6231c51c586ba040c7
[ "MIT" ]
null
null
null
_investigacion/contests/UTP-Regional/barking_machines_2.cpp
civilian/competitive_programing
a6ae7ad0db84240667c1dd6231c51c586ba040c7
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; inline int compareTo(double x, double y, double tol=EPS) { return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; } struct edge { int u; double p; edge(int u = 0, double p = 0) : u(u), p(p) { } }; typedef priority_queue< pair<double,int>, vector< pair<double,int> >, greater< pair<double,int> > > PQ; const int maxn = 510; int n, m; vector<edge> g[maxn]; double dist[maxn]; bool seen[maxn]; double dijkstra(int s, int t) { for (int i = 1; i <= n; i++) { dist[i] = 1e200; seen[i] = 0; } PQ q; dist[s] = 0; q.push(make_pair(0, s)); while (!q.empty()) { int u = q.top().second; double cost = q.top().first; q.pop(); if (u == t) return cost; if (seen[u]) continue; seen[u] = true; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i].u; double p = g[u][i].p; if (compareTo(dist[u] + p, dist[v]) < 0) { dist[v] = dist[u] + p; q.push(make_pair(dist[v], v)); } } } return 1e200; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(4); cout.setf(ios::fixed); while (cin >> n >> m) { for (int i = 1; i <= n; i++) g[i].clear(); for (int i = 0; i < m; i++) { int u, v; double p; cin >> u >> v >> p; if (compareTo(p, 0) == 0) continue; g[u].push_back(edge(v, -log10(p))); } double ans = dijkstra(1, n); if (compareTo(ans, 1e200) >= 0) { cout << "Impossible\n"; } else { if (compareTo(ans, 0) != 0) ans = -ans; cout << "10^" << ans << '\n'; } } return 0; }
17.604167
103
0.487574
[ "vector" ]
06917d36cef94edfb900ac66997114f41514ec3b
6,065
cpp
C++
MSCServer/MSCServer.cpp
faburaya/MacStatsCollection
18ab6fafc2f85c6d7130c7287b813e7d61317b15
[ "MS-PL" ]
null
null
null
MSCServer/MSCServer.cpp
faburaya/MacStatsCollection
18ab6fafc2f85c6d7130c7287b813e7d61317b15
[ "MS-PL" ]
null
null
null
MSCServer/MSCServer.cpp
faburaya/MacStatsCollection
18ab6fafc2f85c6d7130c7287b813e7d61317b15
[ "MS-PL" ]
null
null
null
// MSCServer.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <3FD\runtime.h> #include <3FD\configuration.h> #include <3FD\callstacktracer.h> #include <3FD\exceptions.h> #include <3FD\logger.h> #include "WebService.h" #include "TasksQueue.h" #include "Authenticator.h" #include "MSDStorageWriter.h" #include <iostream> #include <iomanip> #include <chrono> namespace application { using namespace _3fd::core; //////////////////////////////// // Web service implementation //////////////////////////////// /* Implements handling of received 'SendStatsSample' requests. Requests that fail to authenticate do not get processed, but do not fail either (no SOAP fault). */ HRESULT CALLBACK SendStatsSample_ServerImpl( _In_ const WS_OPERATION_CONTEXT *wsContextHandle, _In_z_ WCHAR *key, _In_ SendStatsSampleRequest *payload, _Out_ BOOL *status, _In_ const WS_ASYNC_CONTEXT *wsAsyncContext, _In_ WS_ERROR *wsErrorHandle) { CALL_STACK_TRACE; try { /* The actual processing of the request does not happen here, but actually in the main thread. Here the request is received, the pair machine & key is used for authentication, and if all goes well, a task in enqueued in a lock-free queue for later processing. This way the server can provide quick servicing for all requests. */ if (Authenticator::GetInstance().IsAuthentic(payload->machine, key)) { *status = TRUE; // authenticated: accept request TasksQueue::GetInstance().Enqueue( ExtractStatsDataFrom(*payload) ); } else *status = FALSE; // NOT authenticated: reject request return S_OK; } catch (IAppException &ex) { Logger::Write(ex, Logger::PRIO_CRITICAL); wws::SetSoapFault(ex, "SendStatsSample", wsContextHandle, wsErrorHandle); } catch (std::exception &ex) { std::ostringstream oss; oss << "Generic failure when processing service request: " << ex.what(); AppException<std::runtime_error> appEx(oss.str()); Logger::Write(appEx, Logger::PRIO_CRITICAL); wws::SetSoapFault(appEx, "SendStatsSample", wsContextHandle, wsErrorHandle); } return E_FAIL; } }// end of namespace application ///////////////////// // Entry Point ///////////////////// int main(int argc, char *argv[]) { using namespace application; using namespace _3fd::core; using namespace std::chrono; FrameworkInstance _framework; CALL_STACK_TRACE; int rc = EXIT_SUCCESS; try { // Before starting the service, prepare the authenticator Authenticator::GetInstance().LoadCredentials(); MSDStorageWriter dbWriter( AppConfig::GetSettings().application.GetString("dbConnString", "NOT SET") ); // Function tables contains the service implementation: MacStatsCollectionBindingFunctionTable funcTableSvc = { &application::SendStatsSample_ServerImpl, &application::CloseService_ServerImpl }; // Create the web service host with default configurations wws::SvcEndpointsConfig hostCfg; wws::ServiceBindings bindings; /* Map the binding used for the endpoint to the corresponding implementations: */ bindings.MapBinding( "MacStatsCollectionBinding", &funcTableSvc, &wws::CreateServiceEndpoint<WS_HTTP_BINDING_TEMPLATE, MacStatsCollectionBindingFunctionTable, MacStatsCollectionBinding_CreateServiceEndpoint> ); // Create the service host: wws::WebServiceHost host(2048); host.Setup("MacStatsCollection.wsdl", hostCfg, bindings, nullptr, false); host.Open(); // start listening Logger::Write("HTTP server is ready", Logger::PRIO_INFORMATION); std::cout << "The application will now enter the processing loop" << std::endl; std::vector<std::unique_ptr<StatsPackage>> tasks; // This is the main processing loop: bool running(true); while (running) { // Interrupt service when a request for shutdown arrives running = !ServiceCloser::GetInstance().WaitForCloseRequest( AppConfig::GetSettings().application.GetUInt("srvDbFlushCycleTimeSecs", 5) * 1000, host ); // Retrieve the tasks enqueued in parallel by client requests TasksQueue::GetInstance().Dequeue(tasks); if (!tasks.empty()) { std::cout << "Flushing to database a batch of " << tasks.size() << " package(s) of samples" << std::endl; // Process the tasks dbWriter.WriteStats(tasks); } /* Here I would place an implementation for processing the samples looking for a configured alert, but unfortunately I had not time for that. Sorry :( */ /* Refresh the credentials cached in the authenticator, for when new credentials are included in the database while the service is up */ Authenticator::GetInstance().LoadCredentials(); } } catch (IAppException &ex) { rc = EXIT_FAILURE; std::cout << "Error! See the log for details. Application is exiting now..." << std::endl; Logger::Write(ex, Logger::PRIO_FATAL); } catch (std::exception &ex) { rc = EXIT_FAILURE; std::cout << "Error! See the log for details. Application is exiting now..." << std::endl; std::ostringstream oss; oss << "Generic failure: " << ex.what(); Logger::Write(oss.str(), Logger::PRIO_FATAL); } ServiceCloser::Finalize(); Authenticator::Finalize(); return rc; }
32.433155
154
0.611212
[ "vector" ]
069e1396a9659271d81bce4bc2e930847cae6cdc
8,856
cxx
C++
code/plugins/xray_re/xr_level.cxx
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
7
2018-03-27T12:36:07.000Z
2020-06-26T11:31:52.000Z
code/plugins/xray_re/xr_level.cxx
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
2
2018-05-26T23:17:14.000Z
2019-04-14T18:33:27.000Z
code/plugins/xray_re/xr_level.cxx
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
5
2020-10-18T11:55:26.000Z
2022-03-28T07:21:35.000Z
#include "xr_level_version.h" #include "xr_level.h" #include "xr_level_ltx.h" #include "xr_level_geom.h" #include "xr_level_visuals.h" #include "xr_level_shaders.h" #include "xr_level_sectors.h" #include "xr_level_portals.h" #include "xr_level_lights.h" #include "xr_level_glows.h" #include "xr_level_cform.h" #include "xr_level_hom.h" #include "xr_level_details.h" #include "xr_level_dm.h" #include "xr_level_ai.h" #include "xr_level_game.h" #include "xr_level_spawn.h" #include "xr_level_wallmarks.h" #include "xr_level_som.h" #include "xr_level_snd_env.h" #include "xr_level_snd_static.h" #include "xr_level_ps_static.h" #include "xr_level_env_mod.h" #include "xr_level_fog_vol.h" #include "xr_build_lights.h" #include "xr_image.h" #include "xr_gamemtls_lib.h" #include "xr_entity.h" #include "xr_ogf_v4.h" #include "xr_file_system.h" #include "xr_utils.h" using namespace xray_re; xr_level::xr_level(): m_ltx(0), m_geom(0), m_geomx(0), m_visuals(0), m_shaders(0), m_sectors(0), m_portals(0), m_lights(0), m_glows(0), m_cform(0), m_hom(0), m_details(0), m_ai(0), m_game(0), m_spawn(0), m_wallmarks(0), m_som(0), m_snd_env(0), m_snd_static(0), m_ps_static(0), m_env_mod(0), m_fog_vol(0), m_build_lights(0), m_lods(0), m_lods_nm(0), m_gamemtls_lib(0) {} xr_level::~xr_level() { delete m_ltx; delete m_geom; delete m_geomx; delete m_visuals; delete m_shaders; delete m_sectors; delete m_portals; delete m_lights; delete m_glows; delete m_hom; delete m_cform; delete m_details; delete m_ai; delete m_game; delete m_spawn; delete m_wallmarks; delete m_som; delete m_snd_env; delete m_snd_static; delete m_ps_static; delete m_env_mod; delete m_fog_vol; delete m_build_lights; delete m_lods; delete m_lods_nm; delete_elements(m_brkbl_meshes); delete m_gamemtls_lib; } bool xr_level::load(const char* game_data_path, const char* level_path) { xr_file_system& fs = xr_file_system::instance(); xr_reader* r = fs.r_open(level_path, "level"); if (r == 0) return false; bool status = false; if (r->find_chunk(FSL_HEADER)) { uint32_t xrlc_version = r->r_u16(); m_xrlc_quality = r->r_u16(); switch (xrlc_version) { case XRLC_VERSION_5: case XRLC_VERSION_8: { char buf[124]; r->r_cseq(sizeof(buf), buf); } // fall through case XRLC_VERSION_9: case XRLC_VERSION_10: case XRLC_VERSION_11: case XRLC_VERSION_12: case XRLC_VERSION_13: case XRLC_VERSION_14: r->debug_find_chunk(); load(xrlc_version, game_data_path, level_path, *r); status = true; break; default: msg("unknown xrLC version %" PRIu32, xrlc_version); break; } } fs.r_close(r); return status; } template<typename T> static T* load(const char* path, const char* name, bool required = false) { xr_file_system& fs = xr_file_system::instance(); xr_reader* r = fs.r_open(path, name); if (r) { msg("loading %s", name); T* instance = new T(*r); fs.r_close(r); return instance; } else if (required) { msg("can't load %s", name); xr_not_expected(); } return 0; } template<> xr_image* load(const char* path, const char* name, bool required) { xr_file_system& fs = xr_file_system::instance(); if (fs.file_exist(path, name)) { msg("loading %s", name); xr_image* image = new xr_image; if (!image->load_dds(path, name)) xr_not_expected(); return image; } return 0; } void xr_level::load(uint32_t xrlc_version, const char* game_data_path, const char* level_path, xr_reader& r) { m_ltx = ::load<xr_level_ltx>(level_path, "level.ltx", true); if (xrlc_version >= XRLC_VERSION_13) { m_geom = ::load<xr_level_geom>(level_path, "level.geom", true); // m_geomx = ::load<xr_level_geom>(level_path, "level.geomx"); } msg("loading %s", "level"); if (xrlc_version <= XRLC_VERSION_12) { msg("...geom"); m_geom = new xr_level_geom(xrlc_version, r); } msg("...visuals"); m_visuals = new xr_level_visuals(xrlc_version, r, m_geom); msg("...shaders/textures"); m_shaders = new xr_level_shaders(xrlc_version, r); msg("...sectors"); m_sectors = new xr_level_sectors(xrlc_version, r); msg("...portals"); m_portals = new xr_level_portals(xrlc_version, r); msg("...lights"); m_lights = new xr_level_lights(xrlc_version, r); msg("...glows"); m_glows = new xr_level_glows(xrlc_version, r); if (xrlc_version <= XRLC_VERSION_9) { msg("...cform"); m_cform = new xr_level_cform(xrlc_version, r); } else { m_cform = ::load<xr_level_cform>(level_path, "level.cform", true); } m_hom = ::load<xr_level_hom>(level_path, "level.hom"); m_details = ::load<xr_level_details>(level_path, "level.details"); if (m_details && xrlc_version >= XRLC_VERSION_12) { msg("...texture"); m_details->load_texture(level_path); } if (xrlc_version >= XRLC_VERSION_9 && xrlc_version <= XRLC_VERSION_12) { m_ai = ::load<xr_level_ai>(level_path, "level.ai"); m_game = ::load<xr_level_game>(level_path, "level.game"); m_spawn = ::load<xr_level_spawn>(level_path, "level.spawn"); //m_snd_static = ::load<xr_level_snd_static>(level_path, "level.sound_static"); m_ps_static = ::load<xr_level_ps_static>(level_path, "level.ps_static"); //unknown format old level.wallmarks //m_wallmarks = ::load<xr_level_wallmarks>(level_path, "level.wallmarks"); m_env_mod = ::load<xr_level_env_mod>(level_path, "level.env_mod"); m_snd_env = ::load<xr_level_snd_env>(level_path, "level.sound_environment"); } else if (xrlc_version >= XRLC_VERSION_13) { m_ai = ::load<xr_level_ai>(level_path, "level.ai"); m_game = ::load<xr_level_game>(level_path, "level.game"); m_spawn = ::load<xr_level_spawn>(level_path, "level.spawn"); m_wallmarks = ::load<xr_level_wallmarks>(level_path, "level.wallmarks"); m_som = ::load<xr_level_som>(level_path, "level.som"); m_snd_env = ::load<xr_level_snd_env>(level_path, "level.snd_env"); m_snd_static = ::load<xr_level_snd_static>(level_path, "level.snd_static"); m_ps_static = ::load<xr_level_ps_static>(level_path, "level.ps_static"); m_env_mod = ::load<xr_level_env_mod>(level_path, "level.env_mod"); m_fog_vol = ::load<xr_level_fog_vol>(level_path, "level.fog_vol"); if (xrlc_version >= XRLC_VERSION_14) m_build_lights = ::load<xr_build_lights>(level_path, "build.lights"); } else { m_snd_static = new xr_level_snd_static(*m_ltx->ini()); } m_lods = ::load<xr_image>(level_path, "level_lods.dds"); m_lods_nm = ::load<xr_image>(level_path, "level_lods_nm.dds"); if (m_spawn && xrlc_version >= XRLC_VERSION_13) { for (xr_entity_vec_cit it = m_spawn->spawns().begin(), end = m_spawn->spawns().end(); it != end; ++it) { const cse_abstract* entity = *it; if (entity->name() == "breakable_object") { xr_ogf_v4* ogf = new xr_ogf_v4; const char* name = entity->name_replace().c_str(); msg("loading %s", name); if (!ogf->xr_ogf::load_ogf(level_path, name)) xr_not_expected(); m_brkbl_meshes.push_back(ogf); } } } if (xrlc_version >= XRLC_VERSION_9) m_gamemtls_lib = ::load<xr_gamemtls_lib>(game_data_path, "gamemtl.xr", true); m_xrlc_version = xrlc_version; } void xr_level::clear_ltx() { delete m_ltx; m_ltx = 0; } void xr_level::clear_geom() { delete m_geom; m_geom = 0; } void xr_level::clear_geomx() { delete m_geomx; m_geomx = 0; } void xr_level::clear_visuals() { delete m_visuals; m_visuals = 0; } void xr_level::clear_shaders() { delete m_shaders; m_shaders = 0; } void xr_level::clear_sectors() { delete m_sectors; m_sectors = 0; } void xr_level::clear_portals() { delete m_portals; m_portals = 0; } void xr_level::clear_lights() { delete m_lights; m_lights = 0; } void xr_level::clear_glows() { delete m_glows; m_glows = 0; } void xr_level::clear_cform() { delete m_cform; m_cform = 0; } void xr_level::clear_hom() { delete m_hom; m_hom = 0; } void xr_level::clear_details() { delete m_details; m_details = 0; } void xr_level::clear_ai() { delete m_ai; m_ai = 0; } void xr_level::clear_game() { delete m_game; m_game = 0; } void xr_level::clear_spawn() { delete m_spawn; m_spawn = 0; } void xr_level::clear_wallmarks() { delete m_wallmarks; m_wallmarks = 0; } void xr_level::clear_som() { delete m_som; m_som = 0; } void xr_level::clear_snd_env() { delete m_snd_env; m_snd_env = 0; } void xr_level::clear_snd_static() { delete m_snd_static; m_snd_static = 0; } void xr_level::clear_ps_static() { delete m_ps_static; m_ps_static = 0; } void xr_level::clear_env_mod() { delete m_env_mod; m_env_mod = 0; } void xr_level::clear_fog_vol() { delete m_fog_vol; m_fog_vol = 0; } void xr_level::clear_build_lights() { delete m_build_lights; m_build_lights = 0; } void xr_level::clear_lods() { delete m_lods; m_lods = 0; } void xr_level::clear_lods_nm() { delete m_lods_nm; m_lods_nm = 0; } void xr_level::clear_brkbl_meshes() { std::vector<xr_ogf*>().swap(m_brkbl_meshes); } void xr_level::clear_gamemtls_lib() { delete m_gamemtls_lib; m_gamemtls_lib = 0; }
31.741935
108
0.712737
[ "vector" ]
06a139c05f97332245352d7f266916d1050905cf
2,596
cpp
C++
C++/645. Set Mismatch.cpp
WangYang-wy/LeetCode
c92fcb83f86c277de6785d5a950f16bc007ccd31
[ "MIT" ]
3
2018-07-28T15:36:18.000Z
2020-03-17T01:26:22.000Z
C++/645. Set Mismatch.cpp
WangYang-wy/LeetCode
c92fcb83f86c277de6785d5a950f16bc007ccd31
[ "MIT" ]
null
null
null
C++/645. Set Mismatch.cpp
WangYang-wy/LeetCode
c92fcb83f86c277de6785d5a950f16bc007ccd31
[ "MIT" ]
null
null
null
// // Created by 王阳 on 2018/3/29. // /* * The set S originally contains numbers from 1 to n. * But unfortunately, due to the data error, one of the numbers in the set got * duplicated to another number in the set, which results in repetition of one * number and loss of another number. * Given an array nums representing the data status of this set after the error. * Your task is to firstly find the number occurs twice and then find the number * that is missing. Return them in the form of an array. */ #include <iostream> #include <vector> using namespace std; class Solution { public: vector<int> findErrorNums_TLE(vector<int> &nums) { for (int i = 0; i < nums.size() - 1; i++) { for (int j = i + 1; j < nums.size(); j++) { if (nums[i] > nums[j]) { int tmp = nums[i]; nums[i] = nums[j]; nums[j] = tmp; } } } for (int i = 0; i < nums.size(); i++) { std::cout << nums[i] << std::endl; } // 排序完成。 vector<int> res; // 寻找重复值。 for (int i = 0; i < nums.size(); i++) { if (nums[i] == nums[i + 1]) { res.push_back(nums[i]); break; } } // 寻找缺失的值。 for (int value = 1; value <= nums.size(); value++) { if (value != nums[value] && value != nums[value - 1]) { res.push_back(value); } } return res; } /** * 利用符号位来查看。 * 参考博客:https://blog.csdn.net/woshichaoren000/article/details/76147116 * @param nums * @return */ vector<int> findErrorNums(vector<int> &nums) { vector<int> ans; // 找到重复值。 for (int i = 0; i < nums.size(); i++) { int index = abs(nums[i]) - 1; // 将数组元素值与序号同时利用。 if (nums[index] > 0) { // 变符号,变了一次就会负数,如果再遇到,那么说明就遇到了两次。 nums[index] *= -1; } else { ans.push_back(index + 1); } } // 便利一边,所有出现过(1次和2次)的,索引-1对应的元素值都是负的。 // 寻找缺失的值。 for (int i = 0; i < nums.size(); i++) { if (nums[i] > 0) { // 如果某个元素的值大于零,如果没有变化过。 ans.push_back(i + 1); } } return ans; } }; int main() { Solution *solution = new Solution(); vector<int> s; s.push_back(1); s.push_back(3); s.push_back(2); s.push_back(-1); s.push_back(10); solution->findErrorNums(s); // printf("%d\n", solution) return 0; }
25.70297
80
0.484592
[ "vector" ]
a635e1811f739d040c66f46ebd3058f7c305bb88
6,679
cc
C++
src/kde/kde.cc
Seeenman/Draco
8540aeb8bbbf467c3aa1caa9521d0910e0ca7917
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
src/kde/kde.cc
Seeenman/Draco
8540aeb8bbbf467c3aa1caa9521d0910e0ca7917
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
src/kde/kde.cc
Seeenman/Draco
8540aeb8bbbf467c3aa1caa9521d0910e0ca7917
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
//--------------------------------------------*-C++-*---------------------------------------------// /*! * \file kde/kde.cc * \author Mathew Cleveland * \date November 10th 2020 * \brief Explicitly defined KDE functions for various dimensions and coordinate * KDE or Kernel Density Estimators are unbiased statical based * reconstruction. They can significantly increase the convergence * rate of statical distributions. The KDE performs a reconstruction by * evaluating a mean over some discrete kernel shape. In this DRACO * implementation the mean is evaluated based on the sample locations * that are bound by the kernel shape. A renormalization is used to * ensure the proper mean is returned given there is no guarantee the * full kernel (which integrates exactly to 1) will be integrated fully * in space. This renormalization also avoids the need for boundary * fix-ups which are typically used in KDE applications to account for * the kernel extending beyond the bounds of the spatial domain. Other * approaches that could be considered are quadrature based approaches * that fully sample the Kernel space reducing the need for the * normalization. * \note Copyright (C) 2018-2020 Triad National Security, LLC., All rights reserved. */ //------------------------------------------------------------------------------------------------// #include "kde.hh" #include <cmath> #include <iostream> #include <numeric> namespace rtt_kde { //------------------------------------------------------------------------------------------------// /*! * \brief Cartesian geometry KDE reconstruction of a 1D distribution * * \pre The local reconstruction data is passed into this function which * includes the original data distribution, its spatial position, and the * optimal bandwidth to be used at each point. * * \param[in] distribution original data to be reconstructed * \param[in] position local of the original data * \param[in] one_over_band_width inverse bandwidth size to be used at each data location * \param[in] domain_decomposed bool flag to switch between domain replicated and decomposed data * \return final local KDE function distribution reconstruction * * \post the local reconstruction of the original data is returned. */ template <> template <> std::vector<double> kde<kde_coordinates::CART>::reconstruction<1>( const std::vector<double> &distribution, const std::vector<std::array<double, 3>> &position, const std::vector<std::array<double, 3>> &one_over_band_width, const bool domain_decomposed) const { const int64_t local_size = distribution.size(); Require(static_cast<int64_t>(position.size()) == local_size); Require(static_cast<int64_t>(one_over_band_width.size()) == local_size); // used for the zero accumulation conservation int64_t size = local_size; double global_conservation = std::accumulate(distribution.begin(), distribution.end(), 0.0); std::vector<double> result(local_size, 0.0); std::vector<double> normal(local_size, 0.0); if (domain_decomposed) { // minimize global values and only allocate them in DD problems int64_t global_lower_bound = 0; std::vector<double> global_distribution; std::vector<double> global_x_position; // calculate global off sets int n_ranks = rtt_c4::nodes(); int64_t izero(0); std::vector<int64_t> rank_size(rtt_c4::nodes(), izero); rank_size[rtt_c4::node()] = local_size; rtt_c4::global_sum(rank_size.data(), n_ranks); size = std::accumulate(rank_size.begin(), rank_size.end(), izero); std::vector<int64_t> accum_rank_size(rank_size); std::partial_sum(rank_size.begin(), rank_size.end(), accum_rank_size.begin()); if (rtt_c4::node() > 0) { global_lower_bound = accum_rank_size[rtt_c4::node() - 1]; } // set up global arrays global_distribution.resize(size, 0.0); global_x_position.resize(size, 0.0); // build up global positions for (int i = 0; i < local_size; i++) { global_x_position[i + global_lower_bound] = position[i][0]; global_distribution[i + global_lower_bound] = distribution[i]; } rtt_c4::global_sum(global_x_position.data(), size); rtt_c4::global_sum(global_distribution.data(), size); rtt_c4::global_sum(global_conservation); // now apply the kernel to the local ranks for (int i = 0; i < local_size; i++) { const double x0 = position[i][0]; const double one_over_h = one_over_band_width[i][0]; // fetch local contribution for (int j = 0; j < size; j++) { const double x = global_x_position[j]; const double u = (x0 - x) * one_over_h; const double weight = (epan_kernel(u)) * one_over_h; result[i] += global_distribution[j] * weight; normal[i] += weight; } } } else { // local reconstruction only // now apply the kernel to the local ranks for (int i = 0; i < local_size; i++) { const double x0 = position[i][0]; const double one_over_h = one_over_band_width[i][0]; // fetch local contribution for (int j = 0; j < local_size; j++) { const double x = position[j][0]; const double u = (x0 - x) * one_over_h; const double weight = (epan_kernel(u)) * one_over_h; result[i] += distribution[j] * weight; normal[i] += weight; } } } // normalize the integrated weight contributions for (int i = 0; i < local_size; i++) { Check(normal[i] > 0.0); result[i] /= normal[i]; } double reconstruction_conservation = std::accumulate(result.begin(), result.end(), 0.0); if (domain_decomposed) { // accumulate global contribution rtt_c4::global_sum(reconstruction_conservation); } if (!rtt_dsxx::soft_equiv(reconstruction_conservation, 0.0) && !rtt_dsxx::soft_equiv(global_conservation, 0.0)) { // Totals are non-zero so scale the result for conservation for (int i = 0; i < local_size; i++) result[i] *= global_conservation / reconstruction_conservation; } else { // a zero distribution is possible. If it occurs fall back to residual conservation; const double res = global_conservation - reconstruction_conservation; for (int i = 0; i < local_size; i++) result[i] += res / double(size); } return result; } } // end namespace rtt_kde //------------------------------------------------------------------------------------------------// // end of kde/kde.cc //------------------------------------------------------------------------------------------------//
42.272152
100
0.63258
[ "geometry", "shape", "vector" ]
a63636da77518d14c269be35a43326bcc63e3e11
2,923
cc
C++
content/shell/renderer/web_test/pixel_dump.cc
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
content/shell/renderer/web_test/pixel_dump.cc
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
content/shell/renderer/web_test/pixel_dump.cc
mghgroup/Glide-Browser
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2021-01-05T23:43:46.000Z
2021-01-07T23:36:34.000Z
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/shell/renderer/web_test/pixel_dump.h" #include <memory> #include <utility> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "cc/paint/paint_flags.h" #include "cc/paint/skia_paint_canvas.h" #include "content/public/renderer/render_frame.h" #include "content/shell/renderer/web_test/web_test_runtime_flags.h" #include "mojo/public/cpp/bindings/remote.h" #include "printing/metafile_skia.h" #include "printing/mojom/print.mojom.h" #include "printing/print_settings.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "skia/ext/platform_canvas.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h" #include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h" #include "third_party/blink/public/mojom/clipboard/clipboard.mojom.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/web/web_frame.h" #include "third_party/blink/public/web/web_frame_widget.h" #include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_page_popup.h" #include "third_party/blink/public/web/web_print_params.h" #include "third_party/blink/public/web/web_view.h" #include "third_party/blink/public/web/web_widget.h" #include "ui/gfx/geometry/point.h" namespace content { SkBitmap PrintFrameToBitmap(blink::WebLocalFrame* web_frame) { auto* frame_widget = web_frame->LocalRoot()->FrameWidget(); frame_widget->UpdateAllLifecyclePhases(blink::DocumentUpdateReason::kTest); blink::WebSize page_size_in_pixels = frame_widget->Size(); int page_count = web_frame->PrintBegin(page_size_in_pixels); blink::WebSize spool_size = web_frame->SpoolSizeInPixelsForTesting(page_size_in_pixels, page_count); bool is_opaque = false; SkBitmap bitmap; if (!bitmap.tryAllocN32Pixels(spool_size.width, spool_size.height, is_opaque)) { LOG(ERROR) << "Failed to create bitmap width=" << page_size_in_pixels.width << " height=" << spool_size.height; return SkBitmap(); } printing::MetafileSkia metafile(printing::mojom::SkiaDocumentType::kMSKP, printing::PrintSettings::NewCookie()); cc::SkiaPaintCanvas canvas(bitmap); canvas.SetPrintingMetafile(&metafile); web_frame->PrintPagesForTesting(&canvas, page_size_in_pixels, spool_size); web_frame->PrintEnd(); return bitmap; } } // namespace content
40.041096
96
0.770783
[ "geometry" ]
a637c5dfbf952eab8c20f583c96449dde6315f8f
7,317
hpp
C++
src/uml/src_gen/uml/impl/ExtensionImpl.hpp
MDE4CPP/MDE4CPP
9db9352dd3b1ae26a5f640e614ed3925499b93f1
[ "MIT" ]
12
2017-02-17T10:33:51.000Z
2022-03-01T02:48:10.000Z
src/uml/src_gen/uml/impl/ExtensionImpl.hpp
ndongmo/MDE4CPP
9db9352dd3b1ae26a5f640e614ed3925499b93f1
[ "MIT" ]
28
2017-10-17T20:23:52.000Z
2021-03-04T16:07:13.000Z
src/uml/src_gen/uml/impl/ExtensionImpl.hpp
ndongmo/MDE4CPP
9db9352dd3b1ae26a5f640e614ed3925499b93f1
[ "MIT" ]
22
2017-03-24T19:03:58.000Z
2022-03-31T12:10:07.000Z
//******************************************************************** //* //* Warning: This file was generated by ecore4CPP Generator //* //******************************************************************** #ifndef UML_EXTENSIONEXTENSIONIMPL_HPP #define UML_EXTENSIONEXTENSIONIMPL_HPP //********************************* // generated Includes //Model includes #include "../Extension.hpp" #include "uml/impl/AssociationImpl.hpp" //********************************* namespace uml { class ExtensionImpl : virtual public AssociationImpl, virtual public Extension { public: ExtensionImpl(const ExtensionImpl & obj); virtual std::shared_ptr<ecore::EObject> copy() const; private: ExtensionImpl& operator=(ExtensionImpl const&) = delete; protected: friend class umlFactoryImpl; ExtensionImpl(); virtual std::shared_ptr<Extension> getThisExtensionPtr() const; virtual void setThisExtensionPtr(std::weak_ptr<Extension> thisExtensionPtr); //Additional constructors for the containments back reference ExtensionImpl(std::weak_ptr<uml::Namespace > par_namespace); //Additional constructors for the containments back reference ExtensionImpl(std::weak_ptr<uml::Element > par_owner); //Additional constructors for the containments back reference ExtensionImpl(std::weak_ptr<uml::Package > par_Package, const int reference_id); //Additional constructors for the containments back reference ExtensionImpl(std::weak_ptr<uml::TemplateParameter > par_owningTemplateParameter); //Additional constructors for the containments back reference public: //destructor virtual ~ExtensionImpl(); //********************************* // Operations //********************************* /*! Retrieves the stereotype that extends a metaclass through this extension. */ virtual std::shared_ptr<uml::Stereotype> getStereotype() ; /*! Retrieves the extension end that is typed by a stereotype (as opposed to a metaclass). */ virtual std::shared_ptr<uml::Property> getStereotypeEnd() ; /*! The query isRequired() is true if the owned end has a multiplicity with the lower bound of 1. result = (ownedEnd.lowerBound() = 1) <p>From package UML::Packages.</p> */ virtual bool isRequired() ; /*! An Extension is binary, i.e., it has only two memberEnds. memberEnd->size() = 2 */ virtual bool is_binary(Any diagnostics,std::map < Any, Any > context) ; /*! The query metaclassEnd() returns the Property that is typed by a metaclass (as opposed to a stereotype). result = (memberEnd->reject(p | ownedEnd->includes(p.oclAsType(ExtensionEnd)))->any(true)) <p>From package UML::Packages.</p> */ virtual std::shared_ptr<uml::Property> metaclassEnd() ; /*! The non-owned end of an Extension is typed by a Class. metaclassEnd()->notEmpty() and metaclassEnd().type.oclIsKindOf(Class) */ virtual bool non_owned_end(Any diagnostics,std::map < Any, Any > context) ; //********************************* // Attributes Getter Setter //********************************* /*! Indicates whether an instance of the extending stereotype must be created when an instance of the extended class is created. The attribute value is derived from the value of the lower property of the ExtensionEnd referenced by Extension::ownedEnd; a lower value of 1 means that isRequired is true, but otherwise it is false. Since the default value of ExtensionEnd::lower is 0, the default value of isRequired is false. <p>From package UML::Packages.</p> */ virtual bool getIsRequired() const ; //********************************* // Reference //********************************* /*! References the Class that is extended through an Extension. The property is derived from the type of the memberEnd that is not the ownedEnd. <p>From package UML::Packages.</p> */ virtual std::shared_ptr<uml::Class > getMetaclass() const ; //********************************* // Union Getter //********************************* /*! Specifies each Feature directly defined in the classifier. Note that there may be members of the Classifier that are of the type Feature but are not included, e.g., inherited features. <p>From package UML::Classification.</p> */ virtual std::shared_ptr<SubsetUnion<uml::Feature, uml::NamedElement>> getFeature() const ;/*! A collection of NamedElements identifiable within the Namespace, either by being owned or by being introduced by importing or inheritance. <p>From package UML::CommonStructure.</p> */ virtual std::shared_ptr<Union<uml::NamedElement>> getMember() const ;/*! Specifies the Namespace that owns the NamedElement. <p>From package UML::CommonStructure.</p> */ virtual std::weak_ptr<uml::Namespace > getNamespace() const ;/*! The Elements owned by this Element. <p>From package UML::CommonStructure.</p> */ virtual std::shared_ptr<Union<uml::Element>> getOwnedElement() const ;/*! A collection of NamedElements owned by the Namespace. <p>From package UML::CommonStructure.</p> */ virtual std::shared_ptr<SubsetUnion<uml::NamedElement, uml::Element,uml::NamedElement>> getOwnedMember() const ;/*! The Element that owns this Element. <p>From package UML::CommonStructure.</p> */ virtual std::weak_ptr<uml::Element > getOwner() const ;/*! The RedefinableElement that is being redefined by this element. <p>From package UML::Classification.</p> */ virtual std::shared_ptr<Union<uml::RedefinableElement>> getRedefinedElement() const ;/*! Specifies the elements related by the Relationship. <p>From package UML::CommonStructure.</p> */ virtual std::shared_ptr<Union<uml::Element>> getRelatedElement() const ; //********************************* // Structural Feature Getter/Setter //********************************* virtual std::shared_ptr<ecore::EObject> eContainer() const ; //********************************* // Persistence Functions //********************************* virtual void load(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler) ; virtual void loadAttributes(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler, std::map<std::string, std::string> attr_list); virtual void loadNode(std::string nodeName, std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler); virtual void resolveReferences(const int featureID, std::list<std::shared_ptr<ecore::EObject> > references) ; virtual void save(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const ; virtual void saveContent(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const; protected: virtual std::shared_ptr<ecore::EClass> eStaticClass() const; virtual Any eGet(int featureID, bool resolve, bool coreType) const ; virtual bool internalEIsSet(int featureID) const ; virtual bool eSet(int featureID, Any newValue) ; private: std::weak_ptr<Extension> m_thisExtensionPtr; }; } #endif /* end of include guard: UML_EXTENSIONEXTENSIONIMPL_HPP */
34.842857
422
0.64808
[ "model" ]
a6451232c8ec5b287fd87cd0232729feccd62750
1,767
cpp
C++
benchmark/nearestNeighbor/benchmark.cpp
Tradias/contiguous
91d0e3cd150cb3515723a5b70ef030158d37e63f
[ "MIT" ]
3
2021-05-20T16:42:37.000Z
2022-03-15T22:23:23.000Z
benchmark/nearestNeighbor/benchmark.cpp
Tradias/contiguous
91d0e3cd150cb3515723a5b70ef030158d37e63f
[ "MIT" ]
1
2021-05-22T16:00:46.000Z
2021-05-22T17:50:25.000Z
benchmark/nearestNeighbor/benchmark.cpp
Tradias/contiguous
91d0e3cd150cb3515723a5b70ef030158d37e63f
[ "MIT" ]
null
null
null
// Copyright (c) 2021 Dennis Hezel // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "nearestNeighbor/graph.hpp" #include "nearestNeighbor/load.hpp" #include "nearestNeighbor/repository.hpp" #include "nearestNeighbor/search.hpp" #include <benchmark/benchmark.h> namespace cntgs::bench { template <class Container> void BM_nearest_neighbor(benchmark::State& state) { std::filesystem::path data_path{CNTGS_BENCHMARK_GRAPH_DATA_DIR}; auto repository = bench::load_static_repository(data_path / "SIFT1M" / "sift_query.fvecs"); auto graph = bench::load_graph<Container>( data_path / "k24nns_128D_L2_Path10_Rnd3+3_AddK20Eps0.2_ImproveK20Eps0.02_ImproveExtK12-1StepEps0.02.deg"); const std::vector<uint32_t> entry_node_indices{graph.get_internal_index(0)}; const auto search_radius_epsilon = 0.01f; const size_t search_results = 100; for (auto _ : state) { for (size_t i = 0; i < repository.size; i++) { auto query = reinterpret_cast<const std::byte*>(repository.get_feature(i)); auto result_queue = bench::yahoo_search(graph, entry_node_indices, query, search_radius_epsilon, search_results); benchmark::DoNotOptimize(result_queue); } } } static constexpr auto ITERATION = 7; BENCHMARK_TEMPLATE(BM_nearest_neighbor, bench::FixedSizeContainer) ->Name("nearest neighbor cntgs") ->Iterations(ITERATION); BENCHMARK_TEMPLATE(BM_nearest_neighbor, bench::VectorContainer) ->Name("nearest neighbor pmr::vector") ->Iterations(ITERATION); BENCHMARK_TEMPLATE(BM_nearest_neighbor, bench::ArrayContainer)->Name("nearest neighbor array")->Iterations(ITERATION); } // namespace cntgs::bench
36.061224
118
0.730051
[ "vector" ]
a645d5cab04aa9da089755fa2bb21c799f4dd732
166,746
hpp
C++
nmd_memory.hpp
RibShark/nmd
b2c8567138d8c4e09dfe0876723fc713757daa33
[ "Unlicense" ]
null
null
null
nmd_memory.hpp
RibShark/nmd
b2c8567138d8c4e09dfe0876723fc713757daa33
[ "Unlicense" ]
null
null
null
nmd_memory.hpp
RibShark/nmd
b2c8567138d8c4e09dfe0876723fc713757daa33
[ "Unlicense" ]
null
null
null
// This is a C++ memory library for Windows and hopefully Linux in the future. // // define the 'NMD_MEMORY_IMPLEMENTATION' macro in one and only one source file. // Example: // #include <...> // #include <...> // #define NMD_MEMORY_IMPLEMENTATION // #include "nmd_memory.hpp" // // TODO: // - Finish ValueScan(), implement string scan and some other functionalities. // - Make MemEx::Call() work in a wow64 process(target) from a 64 bit process(this process) #ifndef NMD_MEMORY_H #define NMD_MEMORY_H //Include dependencies #include <Windows.h> #include <vector> #include <map> #include <unordered_map> #include <atomic> #include <string> #include <TlHelp32.h> #include <memory> #include <thread> #include <algorithm> #define HOOK_MARK_END __asm _emit 0xD6 __asm _emit 0xD6 __asm _emit 0x0F __asm _emit 0x0F __asm _emit 0x0F __asm _emit 0x0F __asm _emit 0x0F __asm _emit 0x0F __asm _emit 0x0F __asm _emit 0x0F __asm _emit 0xD6 __asm _emit 0xD6 #define CPTR(pointerToData, sizeOfData) ArgPtr(pointerToData, sizeOfData, true, false) #define PTR(pointerToData, sizeOfData) ArgPtr(pointerToData, sizeOfData, false, false) enum class SCAN_BOUNDARIES { RANGE, MODULE, ALL_MODULES }; struct ScanBoundaries { const SCAN_BOUNDARIES scanBoundaries; union { struct { uintptr_t start, end; }; const TCHAR* const moduleName; }; ScanBoundaries(const SCAN_BOUNDARIES scanBoundaries, const uintptr_t start, const uintptr_t end); ScanBoundaries(const SCAN_BOUNDARIES scanBoundaries, const TCHAR* const moduleName); ScanBoundaries(const SCAN_BOUNDARIES scanBoundaries); }; enum class SCAN_TYPE { EXACT, BETWEEN, GREATER_THAN, LESS_THAN, UNCHANGED, CHANGED, INCREASED, INCREASED_BY, DECREASED, DECREASED_BY, UNKNOWN }; enum class VALUE_TYPE { ONE_BYTE = 0x01, TWO_BYTES = 0x02, FOUR_BYTES = 0x04, EIGTH_BYTES = 0x08, FLOAT = 0x10, DOUBLE = 0x20, ALL = (ONE_BYTE | TWO_BYTES | FOUR_BYTES | EIGTH_BYTES | FLOAT | DOUBLE) }; enum class FLOAT_ROUNDING { NONE, ROUND, TRUNCATE }; template<typename T> struct Scan { SCAN_TYPE scanType; T value, value2; FLOAT_ROUNDING floatRounding; Scan(const SCAN_TYPE scanType, T value, const FLOAT_ROUNDING floatRounding = FLOAT_ROUNDING::NONE) : scanType(scanType), value(value), value2(T()), floatRounding(floatRounding) {} Scan(const SCAN_TYPE scanType, T value, T value2, const FLOAT_ROUNDING floatRounding = FLOAT_ROUNDING::NONE) : scanType(scanType), value(value), value2(value2), floatRounding(floatRounding) {} Scan(const SCAN_TYPE scanType) : scanType(scanType), value(T()), value2(T()), floatRounding(FLOAT_ROUNDING::NONE) {} }; template<typename T> struct Value { uintptr_t address; T value; Value(uintptr_t address, T& value) : address(address), value(value) {} //For use in std::sort() bool operator<(const Value& other) const { return address < other.address; } }; struct AOB { char* aob; size_t size; AOB() : aob(nullptr), size(0) {} AOB(const char* _aob) : aob(const_cast<char*>(_aob)), size(0) {} AOB(const AOB& other) :size(other.size) { if (size) { aob = new char[size]; memcpy(aob, other.aob, size); } else aob = other.aob; } AOB(const char* _aob, size_t size) : size(size) { aob = new char[size]; memcpy(aob, _aob, size); } ~AOB() { if (size) delete[] aob; } }; template<typename T> struct ThreadData { std::thread thread; std::vector<Value<T>> values; }; enum class INJECTION_METHOD { LOAD_LIBRARY, MANUAL_MAPPING }; typedef struct ArgPtr { const void* const data; const size_t size; const bool constant, immediate, isString; void* volatileBuffer; #ifdef _WIN64 bool isFloat = false; #endif ArgPtr(const void* pointerToData, const size_t sizeOfData, const bool isDataConstant = true, const bool isDataImmediate = false, const bool isDataString = false) :data(pointerToData), size(sizeOfData), constant(isDataConstant), immediate(isDataImmediate), isString(isDataString), volatileBuffer(nullptr) {} } Arg; //List of suported calling conventions enum class CConv { DEFAULT, THIS_PTR_RET_SIZE_OVER_8, #ifndef _WIN64 _CDECL, //_CLRCALL, Only callable from managed code. _STDCALL, _FASTCALL, _THISCALL, //_VECTORCALL, [TODO] #endif }; //CPU STATES(for use in the saveCpuStateMask parameter on the Hook() function) #define GPR 0x01 #define FLAGS 0x02 #define XMMX 0x04 size_t ldisasm(const void* const address, const bool x86_64_mode); class MemEx { struct Nop { std::unique_ptr<uint8_t[]> buffer; size_t size = 0; }; struct HookStruct { uintptr_t buffer = 0; uint8_t bufferSize = 0; uint8_t numReplacedBytes = 0; bool useCodeCaveAsMemory = true; uint8_t codeCaveNullByte = 0; }; HANDLE m_hProcess; // A handle to the target process. DWORD m_dwProcessId; // The process id of the target process. HANDLE m_hFileMapping; // A handle to the file mapping object. HANDLE m_hFileMappingDuplicate; // A handle to the file mapping object valid on the target process. In case the system doesn't support MapViewOfFile2. uint8_t* m_thisMappedView; // Starting address of the mapped view on this process. uint8_t* m_targetMappedView; // Starting address of the mapped view on the target process. size_t m_numPages; //Event objects to perform synchronization with our thread on the target process. HANDLE m_hEvent1, m_hEventDuplicate1; HANDLE m_hEvent2, m_hEventDuplicate2; HANDLE m_hThread; // A handle to our thread on the target process. //Store addresses/bytes which the user nopped so they can be restored later with Patch() std::unordered_map<uintptr_t, Nop> m_Nops; //Key(uintptr_t) stores the address of the hooked function std::map<uintptr_t, HookStruct> m_Hooks; std::unordered_map<uintptr_t, size_t> m_Pages; bool m_isWow64; public: const static DWORD dwPageSize; const static DWORD dwDesiredAccess; MemEx(); ~MemEx(); //Returns true if a handle is opened(i.e. Open() was called and Close() was not called after that), false otherwise. bool IsOpened() const; //Returns true if the attached process is running, false otherwise. bool IsRunning() const; //Opens to a process using a handle. //Parameters: // hProcess [in] A handle to the process. The handle must have the following permissions: // PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION. If Hook() or // Call() is used, the handle must also have the following permissions: // PROCESS_DUP_HANDLE | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION. bool Open(const HANDLE hProcess); //Opens to a process using a PID. //Parameters: // dwProcessId [in] The process's id. // dwDesiredAccess [in] The access for the process handle. bool Open(const DWORD dwProcessId, const DWORD dwDesiredAccess = MemEx::dwDesiredAccess); //Opens to a process using its name. //Parameters: // processName [in] The process's name. // dwDesiredAccess [in] The access for the process handle. bool Open(const TCHAR* const processName, const DWORD dwDesiredAccess = MemEx::dwDesiredAccess); //Opens to a process using a window and class name. //Parameters: // windowName [in] The window's title. If NULL, all window // names match. // className [in] The class name. If NULL, any window title // matching windowName is considered. // dwDesiredAccess [in] The access for the process handle. bool OpenByWindow(const TCHAR* const windowName, const TCHAR* const className = nullptr, const DWORD dwDesiredAccess = MemEx::dwDesiredAccess); //Opens to a process using its name. The functions does not return until a process that matches processName is found. //Parameters: // processName [in] The process's name. // dwDesiredAccess [in] The access for the process handle. // dwMilliseconds [in] The number of milliseconds the // thread sleeps every iteration. void WaitOpen(const TCHAR* const processName, const DWORD dwDesiredAccess = MemEx::dwDesiredAccess, const DWORD dwMilliseconds = 500); //Opens to a process using a window and class name. The functions does not return until a process that matches processName is found. //Parameters: // windowName [in] The window's title. If NULL, all window // names match. // className [in] The class name. If NULL, any window title // matching windowName is considered. // dwDesiredAccess [in] The access for the process handle. // dwMilliseconds [in] The number of milliseconds the thread // sleeps every iteration. void WaitOpenByWindow(const TCHAR* const windowName, const TCHAR* const className = nullptr, const DWORD dwDesiredAccess = MemEx::dwDesiredAccess, const DWORD dwMilliseconds = 500); //Terminates any remote threads and memory allocations created by this library on the process. void Close(); //Retuns a handle to the opened process. HANDLE GetProcess() const; //Returns the PID of the opened process. DWORD GetPid() const; //Returns a copy of the data at 'address'. //Parameters: // address [in] The address where the bytes will be read from. template <typename T> inline T Read(const uintptr_t address) const { T t; if (!Read(address, &t, sizeof(T))) memset(&t, 0x00, sizeof(T)); return t; } //Copies 'size' bytes from 'address' to 'buffer'. //Parameters: // address [in] The address where the bytes will be copied from. // buffer [out] The buffer where the bytes will be copied to. // size [in] The number of bytes to be copied. bool Read(const uintptr_t address, void* const buffer, const SIZE_T size) const; //Copies 'value' to 'address'. //Parameters: // address [in] The address where the bytes will be copied to. // value [in] The value where the bytes will be copied from. template <typename T> inline bool Write(uintptr_t address, const T& value) const { return Write(address, &value, sizeof(T)); } //Copies 'size' bytes from 'buffer' to 'address'. //Parameters: // address [in] The address where the bytes will be copied to. // buffer [in] The buffer where the bytes will be copied from. // size [in] The number of bytes to be copied. bool Write(uintptr_t address, const void* const buffer, const SIZE_T size) const; //Patches 'address' with 'size' bytes stored on 'buffer'. //Parameters: // address [in] The address where the bytes will be copied to. // buffer [in] The buffer where the bytes will be copied from. // size [in] The number of bytes to be copied. bool Patch(const uintptr_t address, const char* const bytes, const size_t size) const; //Writes 'size' 0x90(opcode for the NOP(no operation) instruction) bytes at address. //Parameters: // address [in] The address where the bytes will be nopped. // size [in] The number of bytes to be written. // saveBytes [in] If true, save the original bytes located at 'address' // where they can be later restored by calling Restore(). bool Nop(const uintptr_t address, const size_t size, const bool saveBytes = true); //Restores the bytes that were nopped at 'address'. //Parameters: // address [in] The address where the bytes will be restored. bool Restore(const uintptr_t address); //Copies 'size' bytes from 'sourceAddress' to 'destinationAddress'. //Parameters: // destinationAddress [in] The destination buffer's address. // sourceAddress [in] The souce buffer's address. // size [in] The number of bytes to be copied. bool Copy(const uintptr_t destinationAddress, const uintptr_t sourceAddress, const size_t size) const; //Sets 'size' 'value' bytes at 'address'. //Parameters: // address [in] The address where the bytes will be written to. // value [in] The byte to be set. // size [in] The nmber of bytes to be set. bool Set(const uintptr_t address, const int value, const size_t size) const; //Compares the first 'size' bytes of 'address1' and 'address2'. //Parameters: // address1 [in] the address where the first buffer is located. // address2 [in] the address where the second buffer is located. // size [in] The number of bytes to be compared. bool Compare(const uintptr_t address1, const uintptr_t address2, const size_t size) const; //Calculates the MD5 hash of a memory region of the opened process. //Parameters: // address [in] The address where the hash will be calculated. // size [in] The size of the region. // outHash [out] A buffer capable of holding a MD5 hash which is 16 bytes. bool HashMD5(const uintptr_t address, const size_t size, uint8_t* const outHash) const; //Scans the address space according to 'scanBoundaries' for a pattern & mask. //Parameters: // pattern [in] A buffer containing the pattern. An example of a // pattern is "\x68\xAB\x00\x00\x00\x00\x4F\x90\x00\x08". // mask [in] A string that specifies how the pattern should be // interpreted. If mask[i] is equal to '?', then the // byte pattern[i] is ignored. A example of a mask is // "xx????xxxx". // scanBoundaries [in] See definition of the ScanBoundaries class. // protect [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. uintptr_t PatternScan(const char* const pattern, const char* const mask, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), const DWORD protect = -1, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false) const; //Scans the address space according to 'scanBoundaries' for an AOB. //Parameters: // AOB [in] The array of bytes(AOB) in string form. To specify // a byte that should be ignore use the '?' character. // An example of AOB is "68 AB ?? ?? ?? ?? 4F 90 00 08". // scanBoundaries [in] See definition of the ScanBoundaries class. // protect [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // patternSize [out] A pointer to a variable that receives the size of the // size of the pattern in bytes. This parameter can be NULL. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. uintptr_t AOBScan(const char* const AOB, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), const DWORD protect = -1, size_t* const patternSize = nullptr, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false) const; //Reads a multilevel pointer. //Parameters: // base [in] The base address. // offsets [in] A vector specifying the offsets. uintptr_t ReadMultiLevelPointer(const uintptr_t base, const std::vector<uint32_t>& offsets) const; //Do not use 'void' as return type, use any other type instead. template<typename TyRet = int, CConv cConv = CConv::DEFAULT, typename ... Args> TyRet Call(const uintptr_t address, Args&& ... arguments) { if ((!m_hThread && !SetupRemoteThread()) || (cConv == CConv::THIS_PTR_RET_SIZE_OVER_8 && sizeof(TyRet) <= 8)) return TyRet(); //Parse arguments std::vector<Arg> args; GetArguments(args, arguments...); return *static_cast<TyRet*>(CallImpl(cConv, std::is_same<TyRet, float>::value, std::is_same<TyRet, double>::value, sizeof(TyRet), address, args)); } //Hooks an address. You must use the HOOK_MARK_END macro. //Parameters: // address [in] The address to be hooked. // callback [in] The callback to be executed when the CPU executes 'address'. // trampoline [out] An optional pointer to a variable that receives the address // of the trampoline. The trampoline contains the original replaced // instructions of the 'address' and a jump back to 'address'. // saveCpuStateMask [in] A mask containing a bitwise OR combination of one or more of // the following macros: GPR(general purpose registers), // FLAGS(eflags/rflags), XMMX(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5). // Push the CPU above states to the stack before executing callback. // You should use this parameter if you perform a mid function hook. // By default no CPU state is saved. bool Hook(const uintptr_t address, const void* const callback, uintptr_t* const trampoline = nullptr, const DWORD saveCpuStateMask = 0); //Hooks an address by passing a buffer with known size at compile time as the callback. //Parameters: // address [in] The address to be hooked. // callback[callbackSize] [in] The callback to be executed when the CPU executes 'address'. // trampoline [out] An optional pointer to a variable that receives the address // of the trampoline. The trampoline contains the original replaced // instructions of the 'address' and a jump back to 'address'. // saveCpuStateMask [in] A mask containing a bitwise OR combination of one or more of // the following macros: GPR(general purpose registers), // FLAGS(eflags/rflags), XMMX(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5). // Push the CPU above states to the stack before executing callback. // You should use this parameter if you perform a mid function hook. // By default no CPU state is saved. template <class _Ty, size_t callbackSize> bool HookBuffer(const uintptr_t address, _Ty(&callback)[callbackSize], uintptr_t* const trampoline = nullptr, const DWORD saveCpuStateMask = 0) { return Hook(address, callback, callbackSize, trampoline, saveCpuStateMask); }; //Hooks an address by passing a buffer as the callback. //Parameters: // address [in] The address to be hooked. // callback [in] The callback to be executed when the CPU executes 'address'. // callbackSize [in] The size of the callback in bytes. // trampoline [out] An optional pointer to a variable that receives the address // of the trampoline. The trampoline contains the original replaced // instructions of the 'address' and a jump back to 'address'. // saveCpuStateMask [in] A mask containing a bitwise OR combination of one or more of // the following macros: GPR(general purpose registers), // FLAGS(eflags/rflags), XMMX(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5). // Push the CPU above states to the stack before executing callback. // You should use this parameter if you perform a mid function hook. // By default no CPU state is saved. bool HookBuffer(const uintptr_t address, const void* const callback, const size_t callbackSize, uintptr_t* const trampoline = nullptr, const DWORD saveCpuStateMask = 0); //Removes a previously placed hook at 'address'. //Parameters: // address [in] The address to be unhooked. bool Unhook(const uintptr_t address); //Scans the address space according to 'scanBoundaries' for a nullByte. //Parameters: // size [in] The size of the code cave. // nullByte [in] The byte of the code cave. If -1 is specified, // the null byte is any byte, that is, FindCodeCave() // will return any sequence of the same byte. // scanBoundaries [in] See definition of the ScanBoundaries class. // codeCaveSize [out] If not NULL, the variable pointed by this argument // receives the size of the code cave found. If no code // cave is found, 0(zero) is set. // protection [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. uintptr_t FindCodeCave(const size_t size, const uint32_t nullByte = 0x00, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), size_t* const codeCaveSize = nullptr, const DWORD protection = PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false) const; //Scans the address space according to 'scanBoundaries' for nullBytes. //Parameters: // size [in] The size of the code cave. // nullBytes [in] The byte of the code cave. // pNullByte [in] If a codecave is found and pNullByte is not NULL, // the byte that the codecave contains is written to // the variable pointed by pNullByte. // scanBoundaries [in] See definition of the ScanBoundaries class. // codeCaveSize [out] If not NULL, the variable pointed by this argument // receives the size of the code cave found. If no code // cave is found, 0(zero) is set. // protection [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. uintptr_t FindCodeCaveBatch(const size_t size, const std::vector<uint8_t>& nullBytes, uint8_t* const pNullByte = nullptr, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), size_t* const codeCaveSize = nullptr, const DWORD protection = PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false) const; //TODO: add string as type. // values [in/out] The values. If there're no elements on the set it's // considered to be the 'first scan', otherwise it's a // 'next scan'. // scan [in] A reference to a Scan struct which specifies how the // scan should be performed. // alignment [in] The address will only be scanned if it's divisible // by the alignment value. // scanBoundaries [in] See definition of the ScanBoundaries class. // protection [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. template<typename T> bool ValueScan(std::vector<Value<T>>& values, Scan<T>& scan, const size_t alignment = 4, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), const DWORD protect = PAGE_READONLY | PAGE_READWRITE, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency())) { if (alignment == 0) return false; uintptr_t start = 0, end = 0; if (values.empty()) { switch (scanBoundaries.scanBoundaries) { case SCAN_BOUNDARIES::RANGE: start = scanBoundaries.start, end = scanBoundaries.end; break; case SCAN_BOUNDARIES::MODULE: DWORD moduleSize; if (!(start = GetModuleBase(scanBoundaries.moduleName, &moduleSize))) return 0; end = start + moduleSize; break; case SCAN_BOUNDARIES::ALL_MODULES: { struct ValueScanInfo { std::vector<Value<T>>& values; Scan<T>& scan; const size_t alignment; const DWORD protection; const size_t numThreads; bool success; MemEx* memex; }; ValueScanInfo vsi = { values, scan, alignment, protect, numThreads, true, this }; EnumModules(GetCurrentProcessId(), [](MODULEENTRY32& me, void* param) { ValueScanInfo* vsi = static_cast<ValueScanInfo*>(param); std::vector<Value<T>> values; if (!(vsi->success = vsi->memex->ValueScan(values, vsi->scan, vsi->alignment, ScanBoundaries(SCAN_BOUNDARIES::RANGE, reinterpret_cast<uintptr_t>(me.modBaseAddr), reinterpret_cast<uintptr_t>(me.modBaseAddr) + me.modBaseSize), vsi->protection, vsi->numThreads))) return false; vsi->values.insert(vsi->values.end(), values.begin(), values.end()); return true; }, &vsi); return vsi.success; } default: return 0; } } size_t chunkSize = (end - start) / numThreads; std::vector<ThreadData<T>> threads(numThreads); if (!values.empty()) { size_t quota = values.size() / numThreads; for (size_t i = 0; i < threads.size(); i++) threads[i].values.insert(threads[i].values.end(), values.begin() + i * quota, values.begin() + (i + 1) * quota); values.clear(); } for (size_t i = 0; i < numThreads; i++) threads[i].thread = std::thread(&MemEx::ValueScanImpl<T>, this, std::ref(threads[i].values), std::ref(scan), alignment, start + chunkSize * i, start + chunkSize * (static_cast<size_t>(i) + 1), protect); for (auto& thread : threads) thread.thread.join(); size_t newCapacity = 0; for (auto& thread : threads) newCapacity += thread.values.size(); values.reserve(newCapacity); for (auto& thread : threads) values.insert(values.end(), thread.values.begin(), thread.values.end()); return true; } //Creates and returns a handle to an unnamed file-mapping object backed by the system's //paging system. It basically represents a page which can be shared with other processes. //Additionaly, maps a view of the file locally and remotely. //Parameters: // size [in] The size of the file-mapping object. // localView [out] A reference to a variable that will receive the locally mapped view. // remoteView [out] A reference to a variable that will receive the remotely mapped view. HANDLE AllocateSharedMemory(const size_t size, PVOID& localView, PVOID& remoteView) const; //Unmaps the views previously mapped views and deletes the file-mapping object. //Parameters: // hFileMapping [in] A handle to a file-mapping object. // localView [in] The local view. // remoteView [in] The remote view. bool FreeSharedMemory(HANDLE hFileMapping, LPCVOID localView, LPCVOID remoteView) const; //Maps a view of a file-mapping object on the address space of the current process. //Internally, it's a wrapper around MapViewOfFile(). //Parameters: // hFileMapping [in] A handle to a file-mapping object created by // AllocateSharedMemory() or CreateSharedMemory(). static PVOID MapLocalViewOfFile(const HANDLE hFileMapping); //Unmaps a view of a file-mapping object on the address space of the current process. //Internally it's a wrapper around UnmapViewOfFile(). //Parameters: // localAddress [in] The address of the view on the address space of the current process. static bool UnmapLocalViewOfFile(LPCVOID localAddress); //Maps a view of a file-mapping object on the address space of the opened process. //Internally, it's a wrapper around MapViewOfFileNuma2() if available, otherwise //perform a workaround. //Parameters: // hFileMapping [in] A handle to a file-mapping object created by // AllocateSharedMemory() or CreateSharedMemory(). PVOID MapRemoteViewOfFile(const HANDLE hFileMapping) const; //Unmaps a view of a file-mapping object on the address space of the opened process. //Internally it's a wrapper around UnmapViewOfFile2() if available, otherwise //perform a workaround. //Parameters: // localAddress [in] The address of the view on the address space of the opened process. bool UnmapRemoteViewOfFile(LPCVOID remoteAddress) const; //Returns the PID of the specified process. //Parameters: // processName [in] The name of the process. static DWORD GetProcessIdByName(const TCHAR* const processName); //Returns the PID of the window's owner. //Parameters: // windowName [in] The window's title. If NULL, all window // names match. // className [in] The class name. If NULL, any window title // matching windowName is considered. static DWORD GetProcessIdByWindow(const TCHAR* const windowName, const TCHAR* const className = nullptr); //If moduleName is NULL, GetModuleBase() returns the base of the module created by the file used to create the process specified (.exe file) //Returns a module's base address on the opened process. //Parameters: // moduleName [in] The name of the module. // pModuleSize [out] An optional pointer that if provided, receives the size of the module. uintptr_t GetModuleBase(const TCHAR* const moduleName = nullptr, DWORD* const pModuleSize = nullptr) const; //Returns a module's base address on the process specified by dwProcessId. //Parameters: // dwProcessId [in] The PID of the process where the module base is retried. // moduleName [in] The name of the module. // pModuleSize [out] An optional pointer that if provided, receives the size of the module. static uintptr_t GetModuleBase(const DWORD dwProcessId, const TCHAR* const moduleName = nullptr, DWORD* const pModuleSize = nullptr); //Loops through all modules of a process passing its information to a callback function. //Parameters: // processId [in] The PID of the process which the modules will be looped. // callback [in] A function pointer to a callback function. // param [in] An optional pointer to be passed to the callback. static void EnumModules(const DWORD processId, bool (*callback)(MODULEENTRY32& me, void* param), void* param); //Converts an AOB in string form into pattern & mask form. //Parameters: // AOB [in] The array of bytes(AOB) in string form. // pattern [out] The string that will receive the pattern. // mask [out] The string that will receive th mask. static void AOBToPattern(const char* const AOB, std::string& pattern, std::string& mask); //Converts a pattern and mask into an AOB. //Parameters: // pattern [in] The pattern. // mask [in] The mask. // AOB [out] The array of bytes(AOB) in string form. static void PatternToAOB(const char* const pattern, const char* const mask, std::string& AOB); //Returns the size of a page on the system. static DWORD GetPageSize(); //Creates and returns a handle to an unnamed file-mapping object backed by the system's //paging system. It basically represents a page which can be shared with other processes. //Parameters: // size [in] The size of the file-mapping object. static HANDLE CreateSharedMemory(const size_t size); //Injects a dll into the opened process. If you choose to use //manual mapping, it's recommended to compile in release mode. //The function fails if 'injectionMethod' is LOAD_LIBRARY and //'isPath' is false. The base of the injected module is returned //Parameters: // dll [in] See the 'isPath' parameter. // injectionMethod [in] The injection method. // isPath [in] If true, 'dll' specifies the path to the dll, //otherwise 'dll' is a pointer to the dll in memory. uintptr_t Inject(const void* dll, INJECTION_METHOD injectionMethod = INJECTION_METHOD::LOAD_LIBRARY, bool isPath = true); //Retrieves the address of a function from the opened process. // moduleBase [in] The module's base on the opened process. // procedureName [in] The procedure's name on the opened process. // pOrdinal [out] A pointer to a variable that receives the procedure's ordinal. uintptr_t GetProcAddressEx(uintptr_t moduleBase, const char* procedureName, uint16_t* const pOrdinal = nullptr); private: void PatternScanImpl(std::atomic<uintptr_t>& address, const uint8_t* const pattern, const char* const mask, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch) const; void* CallImpl(const CConv cConv, const bool isReturnFloat, const bool isReturnDouble, const size_t returnSize, const uintptr_t functionAddress, std::vector<Arg>& args); void FindCodeCaveImpl(std::atomic<uintptr_t>& returnValue, const size_t size, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch) const; template<typename T> Arg GetArgument(T& t) { return Arg(&t, sizeof(t), true, true); } Arg GetArgument(const char t[]) { return Arg(t, strlen(t) + 1, true, false, true); } Arg GetArgument(const wchar_t t[]) { return Arg(t, (static_cast<size_t>(lstrlenW(t)) + 1) * 2, true, false, true); } Arg GetArgument(Arg& t) { return t; } #ifdef _WIN64 Arg GetArgument(float& t) { Arg arg(&t, sizeof(float), true, true); arg.isFloat = true; return arg; } Arg GetArgument(double& t) { Arg arg(&t, sizeof(double), true, true); arg.isFloat = true; return arg; } #endif void GetArguments(std::vector<Arg>& args) {} template<typename T, typename ... Args> void GetArguments(std::vector<Arg>& args, T& first, Args&& ... arguments) { args.emplace_back(GetArgument(first)); GetArguments(args, arguments...); } bool SetupRemoteThread(); void DeleteRemoteThread(); template<typename T> struct ValueScanRegionData { std::vector<Value<T>>& values; Scan<T>& scan; size_t alignment; uintptr_t start, end; Value<T>* value; uintptr_t localBuffer; uintptr_t targetBuffer; ValueScanRegionData(std::vector<Value<T>>& values, Scan<T>& scan, size_t alignment, uintptr_t start, uintptr_t end, uintptr_t localBuffer, Value<T>* value = nullptr, uintptr_t targetBuffer = NULL) : values(values), scan(scan), alignment(alignment), start(start), end(end), value(value), localBuffer(localBuffer), targetBuffer(targetBuffer) {} }; template<typename T> static T ProcessValue(ValueScanRegionData<T>& vsrd) { return *reinterpret_cast<const T*>(vsrd.start); } template<> static float ProcessValue(ValueScanRegionData<float>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return roundf(*reinterpret_cast<float*>(vsrd.start)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return truncf(*reinterpret_cast<float*>(vsrd.start)); else return *reinterpret_cast<float*>(vsrd.start); } template<> static double ProcessValue(ValueScanRegionData<double>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return round(*reinterpret_cast<double*>(vsrd.start)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return trunc(*reinterpret_cast<double*>(vsrd.start)); else return *reinterpret_cast<double*>(vsrd.start); } template<typename T> static void ValueScanRegionEquals(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) == vsrd.scan.value) vsrd.values.emplace_back(vsrd.targetBuffer + (vsrd.start - vsrd.localBuffer), *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionGreater(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) > vsrd.scan.value) vsrd.values.emplace_back(vsrd.targetBuffer + (vsrd.start - vsrd.localBuffer), *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionLess(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) < vsrd.scan.value) vsrd.values.emplace_back(vsrd.targetBuffer + (vsrd.start - vsrd.localBuffer), *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionBetween(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) > vsrd.scan.value && *reinterpret_cast<T*>(vsrd.start) < vsrd.scan.value2) vsrd.values.emplace_back(vsrd.targetBuffer + (vsrd.start - vsrd.localBuffer), *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionUnknown(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) vsrd.values.emplace_back(vsrd.targetBuffer + (vsrd.start - vsrd.localBuffer), *reinterpret_cast<T*>(vsrd.start)); } template<typename T> static T NextScanProcessValue(ValueScanRegionData<T>& vsrd) { return *reinterpret_cast<const T*>(vsrd.localBuffer); } template<> static float NextScanProcessValue(ValueScanRegionData<float>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return roundf(*reinterpret_cast<float*>(vsrd.localBuffer)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return truncf(*reinterpret_cast<float*>(vsrd.localBuffer)); else return *reinterpret_cast<float*>(vsrd.localBuffer); } template<> static double NextScanProcessValue(ValueScanRegionData<double>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return round(*reinterpret_cast<double*>(vsrd.localBuffer)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return trunc(*reinterpret_cast<double*>(vsrd.localBuffer)); else return *reinterpret_cast<double*>(vsrd.localBuffer); } template<typename T> static bool NextValueScanEquals(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) == vsrd.scan.value; } template<typename T> static bool NextValueScanGreater(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) > vsrd.scan.value; } template<typename T> static bool NextValueScanLess(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) < vsrd.scan.value; } template<typename T> static bool NextValueScanBetween(ValueScanRegionData<T>& vsrd) { T value = NextScanProcessValue(vsrd); return value > vsrd.scan.value && value < vsrd.scan.value2; } template<typename T> static bool NextValueScanIncreased(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) > vsrd.value->value; } template<typename T> static bool NextValueScanIncreasedBy(ValueScanRegionData<T>& vsrd) { T value = NextScanProcessValue(vsrd); return value == value + vsrd.scan.value; } template<typename T> static bool NextValueScanDecreased(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) < vsrd.value->value; } template<typename T> static bool NextValueScanDecreasedBy(ValueScanRegionData<T>& vsrd) { T value = NextScanProcessValue(vsrd); return value == value - vsrd.scan.value; } template<typename T> static bool NextValueScanChanged(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) != vsrd.value->value; } template<typename T> static bool NextValueScanUnchanged(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) == vsrd.value->value; } template<typename T> static void PerformFloatRounding(Scan<T>& scan) {} template<> static void PerformFloatRounding(Scan<float>& scan) { if (scan.floatRounding == FLOAT_ROUNDING::ROUND) scan.value = roundf(scan.value), scan.value2 = roundf(scan.value2); else if (scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) scan.value = truncf(scan.value), scan.value2 = truncf(scan.value2); } template<> static void PerformFloatRounding(Scan<double>& scan) { if (scan.floatRounding == FLOAT_ROUNDING::ROUND) scan.value = round(scan.value), scan.value2 = round(scan.value2); else if (scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) scan.value = trunc(scan.value), scan.value2 = trunc(scan.value2); } template<typename T> void ValueScanImpl(std::vector<Value<T>>& values, Scan<T>& scan, const size_t alignment, uintptr_t start, const uintptr_t end, const DWORD protect) { PerformFloatRounding<T>(scan); char buffer[4096]; SIZE_T nBytesRead; ValueScanRegionData<T> vsrd(values, scan, alignment, 0, end, reinterpret_cast<uintptr_t>(buffer)); MEMORY_BASIC_INFORMATION mbi; if (values.empty()) { void(*firstScan)(ValueScanRegionData<T>&); switch (scan.scanType) { case SCAN_TYPE::EXACT: firstScan = ValueScanRegionEquals; break; case SCAN_TYPE::GREATER_THAN: firstScan = ValueScanRegionGreater; break; case SCAN_TYPE::LESS_THAN: firstScan = ValueScanRegionLess; break; case SCAN_TYPE::BETWEEN: firstScan = ValueScanRegionBetween; break; case SCAN_TYPE::UNKNOWN: firstScan = ValueScanRegionUnknown; break; default: return; } while (start < end && VirtualQueryEx(m_hProcess, reinterpret_cast<LPCVOID>(start), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) { if (mbi.Protect & protect) { const uintptr_t regionEnd = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; for (; start < regionEnd; start += 4096) { vsrd.targetBuffer = start; vsrd.start = reinterpret_cast<uintptr_t>(buffer); if (!ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(start), buffer, 4096, &nBytesRead)) break; vsrd.end = reinterpret_cast<uintptr_t>(buffer) + nBytesRead; if (((vsrd.end - vsrd.start) % sizeof(T)) > 0) vsrd.end -= ((vsrd.end - vsrd.start) % sizeof(T)); firstScan(vsrd); } } start = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } } else { bool(*nextScan)(ValueScanRegionData<T>&); switch (scan.scanType) { case SCAN_TYPE::EXACT: nextScan = NextValueScanEquals; break; case SCAN_TYPE::GREATER_THAN: nextScan = NextValueScanGreater; break; case SCAN_TYPE::LESS_THAN: nextScan = NextValueScanLess; break; case SCAN_TYPE::BETWEEN: nextScan = NextValueScanBetween; break; case SCAN_TYPE::INCREASED: nextScan = NextValueScanIncreased; break; case SCAN_TYPE::INCREASED_BY: nextScan = NextValueScanIncreasedBy; break; case SCAN_TYPE::DECREASED: nextScan = NextValueScanDecreased; break; case SCAN_TYPE::DECREASED_BY: nextScan = NextValueScanDecreasedBy; break; case SCAN_TYPE::CHANGED: nextScan = NextValueScanChanged; break; case SCAN_TYPE::UNCHANGED: nextScan = NextValueScanUnchanged; break; default: return; } std::sort(values.begin(), values.end()); vsrd.start = reinterpret_cast<uintptr_t>(buffer); for (size_t i = 0; i < values.size();) { if (values[i].address > vsrd.end) { VirtualQueryEx(m_hProcess, reinterpret_cast<LPCVOID>(values[i].address), &mbi, sizeof(MEMORY_BASIC_INFORMATION)); ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(values[i].address), buffer, static_cast<SIZE_T>(reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize - values[i].address), &nBytesRead); vsrd.start = values[i].address, vsrd.end = values[i].address + nBytesRead; } vsrd.localBuffer = reinterpret_cast<uintptr_t>(buffer) + values[i].address - vsrd.start; vsrd.value = &values[i]; if (nextScan(vsrd)) { i++; continue; } values.erase(values.begin() + i); } } } template<> void ValueScanImpl(std::vector<Value<AOB>>& values, Scan<AOB>& scan, const size_t alignment, uintptr_t start, const uintptr_t end, const DWORD protect) { if (values.empty()) { uintptr_t aobStart = start; size_t patternSize; while ((aobStart = AOBScan(scan.value.aob, ScanBoundaries(SCAN_BOUNDARIES::RANGE, aobStart, end), protect, &patternSize, 1))) { if (std::find_if(std::begin(values), std::end(values), [aobStart](Value<AOB>& value) { return aobStart == value.address; }) == std::end(values)) { AOB aob(reinterpret_cast<const char*>(aobStart), patternSize); Value<AOB> value(aobStart++, aob); values.push_back(value); } } } else { std::sort(values.begin(), values.end()); uintptr_t regionEnd = 0; MEMORY_BASIC_INFORMATION mbi; for (size_t i = 0; i < values.size();) { if (values[i].address < regionEnd || VirtualQueryEx(m_hProcess, reinterpret_cast<void*>(values[i].address), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) && !(mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) && (regionEnd = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize)) { bool unchanged = true; for (size_t j = 0; j < values[i].value.size; j++) { if (reinterpret_cast<uint8_t*>(values[i].address)[j] != values[i].value.aob[j]) { unchanged = false; break; } } if (unchanged) { i++; continue; } } values.erase(values.begin() + i); } } } }; class MemIn { class ProtectRegion { uintptr_t m_Address; const size_t m_Size; DWORD m_Protection; BOOL m_Success; public: ProtectRegion(const uintptr_t address, const SIZE_T size, const bool m_Protect = true); ~ProtectRegion(); inline bool Success() { return m_Success; } }; struct NopStruct { std::unique_ptr<uint8_t[]> buffer; SIZE_T size = 0; }; struct HookStruct { uintptr_t buffer = 0; uint8_t bufferSize = 0; uint8_t numReplacedBytes = 0; bool useCodeCaveAsMemory = true; uint8_t codeCaveNullByte = 0; }; //Store addresses/bytes which the user nopped so they can be restored later with Patch() static std::unordered_map<uintptr_t, NopStruct> m_Nops; static std::unordered_map<uintptr_t, HookStruct> m_Hooks; static std::unordered_map<uintptr_t, size_t> m_Pages; public: //Returns a copy of the data at 'address'. //Parameters: // address [in] The address where the bytes will be read from. template <typename T> static inline T Read(const uintptr_t address) { T t; return Read(address, &t, sizeof(T)) ? t : T(); } //Copies 'size' bytes from 'address' to 'buffer'. //Parameters: // address [in] The address where the bytes will be copied from. // buffer [out] The buffer where the bytes will be copied to. // size [in] The number of bytes to be copied. static bool Read(const uintptr_t address, void* const buffer, const SIZE_T size); //Copies 'value' to 'address'. //Parameters: // address [in] The address where the bytes will be copied to. // value [in] The value where the bytes will be copied from. template <typename T> static inline bool Write(const uintptr_t address, const T& value) { return Write(address, &value, sizeof(T)); } //Copies 'size' bytes from 'buffer' to 'address'. //Parameters: // address [in] The address where the bytes will be copied to. // buffer [in] The buffer where the bytes will be copied from. // size [in] The number of bytes to be copied. static bool Write(const uintptr_t address, const void* const buffer, const SIZE_T size); //Patches 'address' with 'size' bytes stored on 'buffer'. //Parameters: // address [in] The address where the bytes will be copied to. // buffer [in] The buffer where the bytes will be copied from. // size [in] The number of bytes to be copied. static bool Patch(const uintptr_t address, const char* bytes, const size_t size); //Writes 'size' 0x90 bytes at address. //Parameters: // address [in] The address where the bytes will be nopped. // size [in] The number of bytes to be written. // saveBytes [in] If true, save the original bytes located at 'address' // where they can be later restored by calling Restore(). static bool Nop(const uintptr_t address, const size_t size, const bool saveBytes = true); //Restores the bytes that were nopped at 'address'. //Parameters: // address [in] The address where the bytes will be restored. static bool Restore(const uintptr_t address); //Copies 'size' bytes from 'sourceAddress' to 'destinationAddress'. //Parameters: // destinationAddress [in] The destination buffer's address. // sourceAddress [in] The souce buffer's address. // size [in] The number of bytes to be copied. static bool Copy(const uintptr_t destinationAddress, const uintptr_t sourceAddress, const size_t size); //Sets 'size' 'value' bytes at 'address'. //Parameters: // address [in] The address where the bytes will be written to. // value [in] The byte to be set. // size [in] The nmber of bytes to be set. static bool Set(const uintptr_t address, const int value, const size_t size); //Compares the first 'size' bytes of 'address1' and 'address2'. //Parameters: // address1 [in] the address where the first buffer is located. // address2 [in] the address where the second buffer is located. // size [in] The number of bytes to be compared. static bool Compare(const uintptr_t address1, const uintptr_t address2, const size_t size); //Calculates the MD5 hash of a memory region of the attached process. //Parameters: // address [in] The address where the hash will be calculated. // size [in] The size of the region. // outHash [out] A buffer capable of holding a MD5 hash which is 16 bytes. static bool HashMD5(const uintptr_t address, const size_t size, uint8_t* const outHash); //Scans the address space according to 'scanBoundaries' for a pattern & mask. //Parameters: // pattern [in] A buffer containing the pattern. An example of a // pattern is "\x68\xAB\x00\x00\x00\x00\x4F\x90\x00\x08". // mask [in] A string that specifies how the pattern should be // interpreted. If mask[i] is equal to '?', then the // byte pattern[i] is ignored. A example of a mask is // "xx????xxxx". // scanBoundaries [in] See definition of the ScanBoundaries class. // protect [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. static uintptr_t PatternScan(const char* const pattern, const char* const mask, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), const DWORD protect = -1, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false); //Scans the address space according to 'scanBoundaries' for an AOB. //Parameters: // AOB [in] The array of bytes(AOB) in string form. To specify // a byte that should be ignore use the '?' character. // An example of AOB is "68 AB ?? ?? ?? ?? 4F 90 00 08". // scanBoundaries [in] See definition of the ScanBoundaries class. // protect [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // patternSize [out] A pointer to a variable that receives the size of the // size of the pattern in bytes. This parameter can be NULL. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. static uintptr_t AOBScan(const char* const AOB, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), const DWORD protect = -1, size_t* const patternSize = nullptr, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false); //Reads a multilevel pointer. //Parameters: // base [in] The base address. // offsets [in] A vector specifying the offsets. static uintptr_t ReadMultiLevelPointer(const uintptr_t base, const std::vector<uint32_t>& offsets); //Hooks an address. //Parameters: // address [in] The address to be hooked. // callback [in] The callback to be executed when the CPU executes 'address'. // trampoline [out] An optional pointer to a variable that receives the address // of the trampoline. The trampoline contains the original replaced // instructions of the 'address' and a jump back to 'address'. // saveCpuStateMask [in] A mask containing a bitwise OR combination of one or more of // the following macros: GPR(general purpose registers), // FLAGS(eflags/rflags), XMMX(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5). // Push the CPU above states to the stack before executing callback. // You should use this parameter if you perform a mid function hook. // By default no CPU state is saved. static bool Hook(const uintptr_t address, const void* const callback, uintptr_t* const trampoline = nullptr, const DWORD saveCpuStateMask = 0); //Removes a previously placed hook at 'address'. //Parameters: // address [in] The address to be unhooked. static bool Unhook(const uintptr_t address); //Scans the address space according to 'scanBoundaries' for a nullByte. //Parameters: // size [in] The size of the code cave. // nullByte [in] The byte of the code cave. If -1 is specified, // the null byte is any byte, that is, FindCodeCave() // will return any sequence of the same byte. // scanBoundaries [in] See definition of the ScanBoundaries class. // codeCaveSize [out] If not NULL, the variable pointed by this argument // receives the size of the code cave found. If no code // cave is found, 0(zero) is set. // protection [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. static uintptr_t FindCodeCave(const size_t size, const uint32_t nullByte = 0x00, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), size_t* const codeCaveSize = nullptr, const DWORD protection = PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false); //Scans the address space according to 'scanBoundaries' for nullBytes. //Parameters: // size [in] The size of the code cave. // nullBytes [in] The byte of the code cave. // pNullByte [in] If a codecave is found and pNullByte is not NULL, // the byte that the codecave contains is written to // the variable pointed by pNullByte. // scanBoundaries [in] See definition of the ScanBoundaries class. // codeCaveSize [out] If not NULL, the variable pointed by this argument // receives the size of the code cave found. If no code // cave is found, 0(zero) is set. // protection [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. // firstMatch [in] If true, the address returned(if any) is guaranteed to // be the first match(i.e. the lowest address on the virtual // address space that is a match) according to scanBoundaries. static uintptr_t FindCodeCaveBatch(const size_t size, const std::vector<uint8_t>& nullBytes, uint8_t* const pNullByte = nullptr, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), size_t* const codeCaveSize = nullptr, const DWORD protection = PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency()), const bool firstMatch = false); //TODO: add string as type. // values [in/out] The values. If there're no elements on the set it's // considered to be the 'first scan', otherwise it's a // 'next scan'. // scan [in] A reference to a Scan struct which specifies how the // scan should be performed. // alignment [in] The address will only be scanned if it's divisible // by the alignment value. // scanBoundaries [in] See definition of the ScanBoundaries class. // protection [in] Specifies a mask of memory protection constants // which defines what memory regions will be scanned. // The default value(-1) specifies that pages with any // protection between 'start' and 'end' should be scanned. // numThreads [in] The number of threads to be used. Thr default argument // uses the number of CPU cores as the number of threads. template<typename T> static bool ValueScan(std::vector<Value<T>>& values, Scan<T>& scan, const size_t alignment = 4, const ScanBoundaries& scanBoundaries = ScanBoundaries(SCAN_BOUNDARIES::RANGE, 0, -1), const DWORD protect = PAGE_READONLY | PAGE_READWRITE, const size_t numThreads = static_cast<size_t>(std::thread::hardware_concurrency())) { if (alignment == 0) return false; uintptr_t start = 0, end = 0; if (values.empty()) { switch (scanBoundaries.scanBoundaries) { case SCAN_BOUNDARIES::RANGE: start = scanBoundaries.start, end = scanBoundaries.end; break; case SCAN_BOUNDARIES::MODULE: DWORD moduleSize; if (!(start = GetModuleBase(scanBoundaries.moduleName, &moduleSize))) return 0; end = start + moduleSize; break; case SCAN_BOUNDARIES::ALL_MODULES: { struct ValueScanInfo { std::vector<Value<T>>& values; Scan<T>& scan; const size_t alignment; const DWORD protection; const size_t numThreads; bool success; }; ValueScanInfo vsi = { values, scan, alignment, protect, numThreads, true }; EnumModules(GetCurrentProcessId(), [](MODULEENTRY32& me, void* param) { ValueScanInfo* vsi = static_cast<ValueScanInfo*>(param); std::vector<Value<T>> values; if (!(vsi->success = MemIn::ValueScan(values, vsi->scan, vsi->alignment, ScanBoundaries(SCAN_BOUNDARIES::RANGE, reinterpret_cast<uintptr_t>(me.modBaseAddr), reinterpret_cast<uintptr_t>(me.modBaseAddr) + me.modBaseSize), vsi->protection, vsi->numThreads))) return false; vsi->values.insert(vsi->values.end(), values.begin(), values.end()); return true; }, &vsi); return vsi.success; } default: return 0; } } size_t chunkSize = (end - start) / numThreads; std::vector<ThreadData<T>> threads(numThreads); if (!values.empty()) { size_t quota = values.size() / numThreads; for (size_t i = 0; i < threads.size(); i++) threads[i].values.insert(threads[i].values.end(), values.begin() + i * quota, values.begin() + (i + 1) * quota); values.clear(); } for (size_t i = 0; i < numThreads; i++) threads[i].thread = std::thread(&MemIn::ValueScanImpl<T>, std::ref(threads[i].values), std::ref(scan), alignment, start + chunkSize * i, start + chunkSize * (static_cast<size_t>(i) + 1), protect); for (auto& thread : threads) thread.thread.join(); size_t newCapacity = 0; for (auto& thread : threads) newCapacity += thread.values.size(); values.reserve(newCapacity); for (auto& thread : threads) values.insert(values.end(), thread.values.begin(), thread.values.end()); return true; } //Returns the PID of the specified process. //Parameters: // processName [in] The name of the process. static DWORD GetProcessIdByName(const TCHAR* const processName); //Returns the PID of the window's owner. //Parameters: // windowName [in] The window's title. If NULL, all window // names match. // className [in] The class name. If NULL, any window title // matching windowName is considered. static DWORD GetProcessIdByWindow(const TCHAR* const windowName, const TCHAR* const className = nullptr); //If moduleName is NULL, GetModuleBase() returns the base of the module created by the file used to create the process specified (.exe file) //Returns a module's base address on the attached process. //Parameters: // moduleName [in] The name of the module. // pModuleSize [out] An optional pointer that if provided, receives the size of the module. static uintptr_t GetModuleBase(const TCHAR* const moduleName = nullptr, DWORD* const pModuleSize = nullptr); //Loops through all modules of a process passing its information to a callback function. //Parameters: // processId [in] The PID of the process which the modules will be looped. // callback [in] A function pointer to a callback function. // param [in] An optional pointer to be passed to the callback. static void EnumModules(const DWORD processId, bool (*callback)(MODULEENTRY32& me, void* param), void* param); //Converts an AOB in string form into pattern & mask form. //Parameters: // AOB [in] The array of bytes(AOB) in string form. // pattern [out] The string that will receive the pattern. // mask [out] The string that will receive th mask. static void AOBToPattern(const char* const AOB, std::string& pattern, std::string& mask); //Converts a pattern and mask into an AOB. //Parameters: // pattern [in] The pattern. // mask [in] The mask. // AOB [out] The array of bytes(AOB) in string form. static void PatternToAOB(const char* const pattern, const char* const mask, std::string& AOB); private: static void PatternScanImpl(std::atomic<uintptr_t>& returnValue, const uint8_t* const pattern, const char* const mask, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch); static void FindCodeCaveImpl(std::atomic<uintptr_t>& returnValue, const size_t size, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch); template<typename T> struct ValueScanRegionData { std::vector<Value<T>>& values; Scan<T>& scan; size_t alignment; uintptr_t start, end; Value<T>* value; ValueScanRegionData(std::vector<Value<T>>& values, Scan<T>& scan, size_t alignment, uintptr_t start, uintptr_t end, Value<T>* value = nullptr) : values(values), scan(scan), alignment(alignment), start(start), end(end), value(value) {} }; template<typename T> static T ProcessValue(ValueScanRegionData<T>& vsrd) { return *reinterpret_cast<const T*>(vsrd.start); } template<> static float ProcessValue(ValueScanRegionData<float>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return roundf(*reinterpret_cast<float*>(vsrd.start)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return truncf(*reinterpret_cast<float*>(vsrd.start)); else return *reinterpret_cast<float*>(vsrd.start); } template<> static double ProcessValue(ValueScanRegionData<double>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return round(*reinterpret_cast<double*>(vsrd.start)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return trunc(*reinterpret_cast<double*>(vsrd.start)); else return *reinterpret_cast<double*>(vsrd.start); } template<typename T> static void ValueScanRegionEquals(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) == vsrd.scan.value) vsrd.values.emplace_back(vsrd.start, *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionGreater(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) > vsrd.scan.value) vsrd.values.emplace_back(vsrd.start, *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionLess(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) < vsrd.scan.value) vsrd.values.emplace_back(vsrd.start, *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionBetween(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) { if (ProcessValue(vsrd) > vsrd.scan.value && *reinterpret_cast<T*>(vsrd.start) < vsrd.scan.value2) vsrd.values.emplace_back(vsrd.start, *reinterpret_cast<T*>(vsrd.start)); } } template<typename T> static void ValueScanRegionUnknown(ValueScanRegionData<T>& vsrd) { for (; vsrd.start < vsrd.end; vsrd.start += vsrd.alignment) vsrd.values.emplace_back(vsrd.start, *reinterpret_cast<T*>(vsrd.start)); } template<typename T> static T NextScanProcessValue(ValueScanRegionData<T>& vsrd) { return *reinterpret_cast<const T*>(vsrd.value->address); } template<> static float NextScanProcessValue(ValueScanRegionData<float>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return roundf(*reinterpret_cast<float*>(vsrd.value->address)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return truncf(*reinterpret_cast<float*>(vsrd.value->address)); else return *reinterpret_cast<float*>(vsrd.value->address); } template<> static double NextScanProcessValue(ValueScanRegionData<double>& vsrd) { if (vsrd.scan.floatRounding == FLOAT_ROUNDING::ROUND) return round(*reinterpret_cast<double*>(vsrd.value->address)); else if (vsrd.scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) return trunc(*reinterpret_cast<double*>(vsrd.value->address)); else return *reinterpret_cast<double*>(vsrd.value->address); } template<typename T> static bool NextValueScanEquals(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) == vsrd.scan.value; } template<typename T> static bool NextValueScanGreater(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) > vsrd.scan.value; } template<typename T> static bool NextValueScanLess(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) < vsrd.scan.value; } template<typename T> static bool NextValueScanBetween(ValueScanRegionData<T>& vsrd) { T value = NextScanProcessValue(vsrd); return value > vsrd.scan.value && value < vsrd.scan.value2; } template<typename T> static bool NextValueScanIncreased(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) > vsrd.value->value; } template<typename T> static bool NextValueScanIncreasedBy(ValueScanRegionData<T>& vsrd) { T value = NextScanProcessValue(vsrd); return value == value + vsrd.scan.value; } template<typename T> static bool NextValueScanDecreased(ValueScanRegionData<T>& vsrd) { return *reinterpret_cast<T*>(vsrd.value->address) < vsrd.value->value; } template<typename T> static bool NextValueScanDecreasedBy(ValueScanRegionData<T>& vsrd) { T value = NextScanProcessValue(vsrd); return value == value - vsrd.scan.value; } template<typename T> static bool NextValueScanChanged(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) != vsrd.value->value; } template<typename T> static bool NextValueScanUnchanged(ValueScanRegionData<T>& vsrd) { return NextScanProcessValue(vsrd) == vsrd.value->value; } template<typename T> static void PerformFloatRounding(Scan<T>& scan) {} template<> static void PerformFloatRounding(Scan<float>& scan) { if (scan.floatRounding == FLOAT_ROUNDING::ROUND) scan.value = roundf(scan.value), scan.value2 = roundf(scan.value2); else if (scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) scan.value = truncf(scan.value), scan.value2 = truncf(scan.value2); } template<> static void PerformFloatRounding(Scan<double>& scan) { if (scan.floatRounding == FLOAT_ROUNDING::ROUND) scan.value = round(scan.value), scan.value2 = round(scan.value2); else if (scan.floatRounding == FLOAT_ROUNDING::TRUNCATE) scan.value = trunc(scan.value), scan.value2 = trunc(scan.value2); } template<typename T> static void ValueScanImpl(std::vector<Value<T>>& values, Scan<T>& scan, const size_t alignment, const uintptr_t start, const uintptr_t end, const DWORD protect) { PerformFloatRounding<T>(scan); ValueScanRegionData<T> vsrd(values, scan, alignment, start, end); MEMORY_BASIC_INFORMATION mbi; if (values.empty()) { void(*firstScan)(ValueScanRegionData<T>&); switch (scan.scanType) { case SCAN_TYPE::EXACT: firstScan = ValueScanRegionEquals; break; case SCAN_TYPE::GREATER_THAN: firstScan = ValueScanRegionGreater; break; case SCAN_TYPE::LESS_THAN: firstScan = ValueScanRegionLess; break; case SCAN_TYPE::BETWEEN: firstScan = ValueScanRegionBetween; break; case SCAN_TYPE::UNKNOWN: firstScan = ValueScanRegionUnknown; break; default: return; } while (vsrd.start < end&& VirtualQuery(reinterpret_cast<LPCVOID>(vsrd.start), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) { if (!(mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) && (mbi.Protect & protect)) { const uintptr_t pageEnd = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; vsrd.end = end > pageEnd ? pageEnd : end; if (((vsrd.end - vsrd.start) % sizeof(T)) > 0) vsrd.end -= ((vsrd.end - vsrd.start) % sizeof(T)); firstScan(vsrd); } vsrd.start = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } } else { bool(*nextScan)(ValueScanRegionData<T>&); switch (scan.scanType) { case SCAN_TYPE::EXACT: nextScan = NextValueScanEquals; break; case SCAN_TYPE::GREATER_THAN: nextScan = NextValueScanGreater; break; case SCAN_TYPE::LESS_THAN: nextScan = NextValueScanLess; break; case SCAN_TYPE::BETWEEN: nextScan = NextValueScanBetween; break; case SCAN_TYPE::INCREASED: nextScan = NextValueScanIncreased; break; case SCAN_TYPE::INCREASED_BY: nextScan = NextValueScanIncreasedBy; break; case SCAN_TYPE::DECREASED: nextScan = NextValueScanDecreased; break; case SCAN_TYPE::DECREASED_BY: nextScan = NextValueScanDecreasedBy; break; case SCAN_TYPE::CHANGED: nextScan = NextValueScanChanged; break; case SCAN_TYPE::UNCHANGED: nextScan = NextValueScanUnchanged; break; default: return; } std::sort(values.begin(), values.end()); uintptr_t regionEnd = 0; for (size_t i = 0; i < values.size();) { if (values[i].address < regionEnd || VirtualQuery(reinterpret_cast<void*>(values[i].address), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) && !(mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) && (regionEnd = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize)) { vsrd.value = &values[i]; if (nextScan(vsrd)) { i++; continue; } } values.erase(values.begin() + i); } } } template<> static void ValueScanImpl(std::vector<Value<AOB>>& values, Scan<AOB>& scan, const size_t alignment, const uintptr_t start, const uintptr_t end, const DWORD protect) { if (values.empty()) { uintptr_t aobStart = start; size_t patternSize; while ((aobStart = AOBScan(scan.value.aob, ScanBoundaries(SCAN_BOUNDARIES::RANGE, aobStart, end), protect, &patternSize, 1))) { if (std::find_if(std::begin(values), std::end(values), [aobStart](Value<AOB>& value) { return aobStart == value.address; }) == std::end(values)) { AOB aob(reinterpret_cast<const char*>(aobStart), patternSize); Value<AOB> value(aobStart++, aob); values.push_back(value); } } } else { std::sort(values.begin(), values.end()); uintptr_t regionEnd = 0; MEMORY_BASIC_INFORMATION mbi; for (size_t i = 0; i < values.size();) { if (values[i].address < regionEnd || VirtualQuery(reinterpret_cast<void*>(values[i].address), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) && !(mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) && (regionEnd = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize)) { bool unchanged = true; for (size_t j = 0; j < values[i].value.size; j++) { if (reinterpret_cast<uint8_t*>(values[i].address)[j] != values[i].value.aob[j]) { unchanged = false; break; } } if (unchanged) { i++; continue; } } values.erase(values.begin() + i); } } } }; #ifdef NMD_MEMORY_IMPLEMENTATION #ifdef UNICODE #define lstrstr wcsstr #define lstring wstring #else #define lstrstr strstr #define lstring string #endif #define PLACE(type, value) *reinterpret_cast<type*>(buffer) = (type)(value); buffer += sizeof(type) #define PLACE1(value) *buffer++ = static_cast<uint8_t>(value) #define PLACE2(value) PLACE(uint16_t, value) #define PLACE4(value) PLACE(uint32_t, value) #define PLACE8(value) PLACE(uint64_t, value) #define PUSH1(value) PLACE1(0x6A); PLACE(uint8_t, value) #define PUSH4(value) PLACE1(0x68); PLACE(uint32_t, value) #define CALL_RELATIVE(sourceAddress, functionAddress) PLACE1(0xE8); PLACE(ptrdiff_t, (ptrdiff_t)(functionAddress) - reinterpret_cast<ptrdiff_t>(sourceAddress + 4)) #define CALL_ABSOLUTE(address) PLACE2(0xB848); PLACE8(address); PLACE2(0xD0FF); #define HOOK_MAX_NUM_REPLACED_BYTES 19 #define NMD_R(b) (b >> 4) // Four high-order bits of an opcode to index a row of the opcode table #define NMD_C(b) (b & 0xF) // Four low-order bits to index a column of the table bool nmd_ldisasm_findByte(const uint8_t* arr, const size_t N, const uint8_t x) { for (size_t i = 0; i < N; i++) { if (arr[i] == x) { return true; } }; return false; } void nmd_ldisasm_parseModRM(const uint8_t** b, const bool addressPrefix, const bool x86_64) { uint8_t modrm = *++ * b; const uint8_t mod = (modrm & 0b11000000) >> 6; const uint8_t reg = (modrm & 0b111000) >> 3; const uint8_t rm = (modrm & 0b111); if (addressPrefix && !x86_64) { if ((mod == 0b00 && rm == 0b110) || mod == 0b10) *b += 2; else if (mod == 0b01) (*b)++; } else if (!addressPrefix || (addressPrefix && **b >= 0x40)) { //Check for SIB byte bool hasSIB = false; if (**b < 0xC0 && (**b & 0b111) == 0b100 && !addressPrefix) hasSIB = true, (*b)++; if (modrm >= 0x40 && modrm <= 0x7F) // disp8 (ModR/M) (*b)++; else if ((modrm <= 0x3F && rm == 0b101) || (modrm >= 0x80 && modrm <= 0xBF)) //disp16,32 (ModR/M) *b += (addressPrefix ? 2 : 4); else if (hasSIB && (**b & 0b111) == 0b101) //disp8,32 (SIB) *b += (modrm & 0b01000000 ? 1 : 4); } else if (addressPrefix && modrm == 0x26) *b += 2; }; size_t ldisasm(const void* const buffer, const bool x86_64) { const uint8_t prefixes[] = { 0xF0, 0xF2, 0xF3, 0x2E, 0x36, 0x3E, 0x26, 0x64, 0x65, 0x66, 0x67 }; const uint8_t op1modrm[] = { 0x62, 0x63, 0x69, 0x6B, 0xC0, 0xC1, 0xC4, 0xC5, 0xC6, 0xC7, 0xD0, 0xD1, 0xD2, 0xD3, 0xF6, 0xF7, 0xFE, 0xFF }; const uint8_t op1imm8[] = { 0x6A, 0x6B, 0x80, 0x82, 0x83, 0xA8, 0xC0, 0xC1, 0xC6, 0xCD, 0xD4, 0xD5, 0xEB }; const uint8_t op1imm32[] = { 0x68, 0x69, 0x81, 0xA9, 0xC7, 0xE8, 0xE9 }; const uint8_t op2modrm[] = { 0x0D, 0xA3, 0xA4, 0xA5, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF }; size_t offset = 0; bool operandPrefix = false, addressPrefix = false, repeatPrefix = false, repeatNotZeroPrefix = false, rexW = false; const uint8_t* b = (uint8_t*)(buffer); //Parse legacy prefixes & REX prefixes for (int i = 0; i < 14 && nmd_ldisasm_findByte(prefixes, sizeof(prefixes), *b) || (x86_64 ? (NMD_R(*b) == 4) : false); i++, b++) { if (*b == 0x66) operandPrefix = true; else if (*b == 0x67) addressPrefix = true; else if (*b == 0xf2) repeatNotZeroPrefix = true; else if (*b == 0xf3) repeatPrefix = true; else if (NMD_R(*b) == 4 && NMD_C(*b) >= 8) rexW = true; } //Parse opcode(s) if (*b == 0x0F) // 2,3 bytes { if (*b == 0x38 || *b == 0x3A) // 3 bytes { if (*b == 0x38) { } else { if (((operandPrefix || repeatPrefix || repeatNotZeroPrefix) && (*b == 0x0f || *b == 0xcc)) || operandPrefix && *b != 0x44 && *b != 0xdf && !(*b >= 0x08 && *b <= 0x0f) && !(*b >= 0x14 && *b <= 0x17) && !(*b >= 0x20 && *b <= 0x22) && !(*b >= 0x40 && *b <= 0x42) && !(*b >= 0x60 && *b <= 0x63)) return false; } nmd_ldisasm_parseModRM(&b, addressPrefix, x86_64); } else // 2 bytes { const uint8_t modrm = *(b + 1); const uint8_t mod = (modrm & 0b11000000) >> 6; const uint8_t reg = (modrm & 0b111000) >> 3; const uint8_t rm = (modrm & 0b111); const uint8_t invalid2op[] = { 0x04, 0x0a, 0x0c, 0x0f }; if (nmd_ldisasm_findByte(invalid2op, sizeof(invalid2op), *b) || (*b == 0x78 || *b == 0x79) && !(operandPrefix && repeatPrefix && repeatNotZeroPrefix) || (*b == 0xc7 && ((reg < 0b110 && !(reg == 0b001 && mod != 0b11)) || ((modrm & 0b11110000) && repeatPrefix) || (reg == 0b111 && mod != 0b11 && (operandPrefix || repeatPrefix || repeatNotZeroPrefix)))) || (*b == 0x00 && reg >= 0b110) || (*b == 0x01 && (mod == 0b11 ? ((reg == 0b000 && rm >= 0b110) || (reg == 0b001 && rm >= 0b100 && rm <= 0b110) || (reg == 0b010 && (rm == 0b010 || rm == 0b011)) || (reg == 0b101 && rm < 0b110) || (reg == 0b111 && (rm > 0b101 || (!x86_64 && rm == 0b000)))) : reg == 0b101))) return false; if (NMD_R(*b) == 8) //disp32 offset += 4; else if ((NMD_R(*b) == 7 && NMD_C(*b) < 4) || *b == 0xA4 || *b == 0xC2 || (*b > 0xC3 && *b <= 0xC6) || *b == 0xBA || *b == 0xAC) //imm8 offset++; //Check for ModR/M, SIB and displacement if (nmd_ldisasm_findByte(op2modrm, sizeof(op2modrm), *b) || (NMD_R(*b) != 3 && NMD_R(*b) > 0 && NMD_R(*b) < 7) || *b >= 0xD0 || (NMD_R(*b) == 7 && NMD_C(*b) != 7) || NMD_R(*b) == 9 || NMD_R(*b) == 0xB || (NMD_R(*b) == 0xC && NMD_C(*b) < 8) || (NMD_R(*b) == 0 && NMD_C(*b) < 4)) nmd_ldisasm_parseModRM(&b, addressPrefix, x86_64); } } else // 1 byte { //Check for potential invalid instructions const uint8_t modrm = *(b + 1); const uint8_t mod = (modrm & 0b11000000) >> 6; const uint8_t reg = (modrm & 0b111000) >> 3; const uint8_t rm = (modrm & 0b111); if (*b == 0xC6 || *b == 0xC7) { if ((reg != 0b000 && reg != 0b111) || (reg == 0b111 && (mod != 0b11 || rm != 0b000))) return false; } else if (*b == 0x8f && reg) return false; else if (*b == 0xfe && reg >= 0b010) return false; else if (*b == 0xff && (reg == 0b111 || (mod == 0b11 && (reg == 0b011 || reg == 0b101)))) return false; else if (*b >= 0xd8 && *b <= 0xdf) { switch (*b) { case 0xd9: if ((reg == 0b001 && mod != 0b11) || (modrm > 0xd0 && modrm < 0xd8) || modrm == 0xe2 || modrm == 0xe3 || modrm == 0xe6 || modrm == 0xe7 || modrm == 0xef) return false; break; case 0xda: if (modrm >= 0xe0 && modrm != 0xe9) return false; break; case 0xdb: if (((reg == 0b100 || reg == 0b110) && mod != 0b11) || (modrm >= 0xe5 && modrm <= 0xe7) || modrm >= 0xf8) return false; break; case 0xdd: if ((reg == 0b101 && mod != 0b11) || NMD_R(modrm) == 0xf) return false; break; case 0xde: if (modrm == 0xd8 || (modrm >= 0xda && modrm <= 0xdf)) return false; break; case 0xdf: if ((modrm >= 0xe1 && modrm <= 0xe7) || modrm >= 0xf8) return false; break; } } else if ((*b == 0x8c || *b == 0x8e) && reg >= 6) return false; else if (*b == 0x8e && reg == 0b001) return false; else if (mod == 0b11 && (*b == 0x62 || *b == 0x8d || *b == 0xc4 || *b == 0xc5)) return false; //Check for immediate field if ((NMD_R(*b) == 0xE && NMD_C(*b) < 8) || (NMD_R(*b) == 0xB && NMD_C(*b) < 8) || NMD_R(*b) == 7 || (NMD_R(*b) < 4 && (NMD_C(*b) == 4 || NMD_C(*b) == 0xC)) || (*b == 0xF6 && !(*(b + 1) & 48)) || nmd_ldisasm_findByte(op1imm8, sizeof(op1imm8), *b)) //imm8 offset++; else if (*b == 0xC2 || *b == 0xCA) //imm16 offset += 2; else if (*b == 0xC8) //imm16 + imm8 offset += 3; else if ((NMD_R(*b) < 4 && (NMD_C(*b) == 5 || NMD_C(*b) == 0xD)) || (NMD_R(*b) == 0xB && NMD_C(*b) >= 8) || (*b == 0xF7 && !(*(b + 1) & 48)) || nmd_ldisasm_findByte(op1imm32, sizeof(op1imm32), *b)) //imm32,16 offset += ((NMD_R(*b) == 0xB && NMD_C(*b) >= 8) && rexW) ? 8 : (operandPrefix ? 2 : 4); else if (*b == 0xEA || *b == 0x9A) //imm32,48 { if (x86_64) return false; offset += (operandPrefix ? 4 : 6); } else if (NMD_R(*b) == 0xA && NMD_C(*b) < 4) offset += x86_64 ? (addressPrefix ? 4 : 8) : (addressPrefix ? 2 : 4); //Check for ModR/M, SIB and displacement if (nmd_ldisasm_findByte(op1modrm, sizeof(op1modrm), *b) || (NMD_R(*b) < 4 && (NMD_C(*b) < 4 || (NMD_C(*b) >= 8 && NMD_C(*b) < 0xC))) || NMD_R(*b) == 8 || (NMD_R(*b) == 0xD && NMD_C(*b) >= 8)) nmd_ldisasm_parseModRM(&b, addressPrefix, x86_64); } return (size_t)((ptrdiff_t)(++b + offset) - (ptrdiff_t)(buffer)); } //MD5 #define ROL(x,s)((x<<s)|x>>(32-s)) static const uint32_t r[] = { 7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21 }; static const uint32_t k[] = { 0xd76aa478,0xe8c7b756,0x242070db,0xc1bdceee,0xf57c0faf,0x4787c62a,0xa8304613,0xfd469501,0x698098d8,0x8b44f7af,0xffff5bb1,0x895cd7be,0x6b901122,0xfd987193,0xa679438e,0x49b40821,0xf61e2562,0xc040b340,0x265e5a51,0xe9b6c7aa,0xd62f105d,0x02441453,0xd8a1e681,0xe7d3fbc8,0x21e1cde6,0xc33707d6,0xf4d50d87,0x455a14ed,0xa9e3e905,0xfcefa3f8,0x676f02d9,0x8d2a4c8a,0xfffa3942,0x8771f681,0x6d9d6122,0xfde5380c,0xa4beea44,0x4bdecfa9,0xf6bb4b60,0xbebfbc70,0x289b7ec6,0xeaa127fa,0xd4ef3085,0x04881d05,0xd9d4d039,0xe6db99e5,0x1fa27cf8,0xc4ac5665,0xf4292244,0x432aff97,0xab9423a7,0xfc93a039,0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,0x6fa87e4f,0xfe2ce6e0,0xa3014314,0x4e0811a1,0xf7537e82,0xbd3af235,0x2ad7d2bb,0xeb86d391 }; ScanBoundaries::ScanBoundaries(const SCAN_BOUNDARIES scanBoundaries, const uintptr_t start, const uintptr_t end) : scanBoundaries(scanBoundaries), start(start), end(end) {} ScanBoundaries::ScanBoundaries(const SCAN_BOUNDARIES scanBoundaries, const TCHAR* const moduleName) : scanBoundaries(scanBoundaries), moduleName(moduleName) { end = 0; } ScanBoundaries::ScanBoundaries(const SCAN_BOUNDARIES scanBoundaries) : scanBoundaries(scanBoundaries), start(0), end(0) {} typedef PVOID(__stdcall* _MapViewOfFileNuma2)(HANDLE FileMappingHandle, HANDLE ProcessHandle, ULONG64 Offset, PVOID BaseAddress, SIZE_T ViewSize, ULONG AllocationType, ULONG PageProtection, ULONG PreferredNode); typedef BOOL(__stdcall* _UnmapViewOfFile2)(HANDLE Process, LPCVOID BaseAddress, ULONG UnmapFlags); const DWORD MemEx::dwPageSize = MemEx::GetPageSize(); const DWORD MemEx::dwDesiredAccess = PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION | PROCESS_DUP_HANDLE | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION; MemEx::MemEx() : m_hProcess(NULL), m_dwProcessId(0), m_hFileMapping(NULL), m_hFileMappingDuplicate(NULL), m_hThread(NULL), m_hEvent1(NULL), m_hEvent2(NULL), m_hEventDuplicate1(NULL), m_hEventDuplicate2(NULL), m_targetMappedView(NULL), m_thisMappedView(NULL), m_numPages(0), m_isWow64(false) {} MemEx::~MemEx() { Close(); } bool MemEx::IsOpened() const { return m_hProcess != NULL; } bool MemEx::IsRunning() const { return GetProcessVersion(m_dwProcessId) != 0; } bool MemEx::Open(const HANDLE hProcess) { DWORD tmp; m_numPages = 1; return !m_hProcess && GetHandleInformation((m_hProcess = hProcess), &tmp) && (m_dwProcessId = GetProcessId(hProcess)) && IsWow64Process(m_hProcess, reinterpret_cast<PBOOL>(&m_isWow64)); } bool MemEx::Open(const DWORD dwProcessId, const DWORD dwDesiredAccess) { return Open(OpenProcess(dwDesiredAccess, FALSE, dwProcessId)); } bool MemEx::Open(const TCHAR* const processName, const DWORD dwDesiredAccess) { return Open(MemEx::GetProcessIdByName(processName), dwDesiredAccess); } bool MemEx::OpenByWindow(const TCHAR* const windowName, const TCHAR* const className, const DWORD dwDesiredAccess) { return Open(MemEx::GetProcessIdByWindow(windowName, className), dwDesiredAccess); } void MemEx::WaitOpen(const TCHAR* const processName, const DWORD dwDesiredAccess, const DWORD dwMilliseconds) { while (!Open(processName, dwDesiredAccess)) Sleep(dwMilliseconds); } void MemEx::WaitOpenByWindow(const TCHAR* const windowName, const TCHAR* const className, const DWORD dwDesiredAccess, const DWORD dwMilliseconds) { while (!OpenByWindow(windowName, className, dwDesiredAccess)) Sleep(dwMilliseconds); } void MemEx::Close() { if (!m_hProcess) return; DeleteRemoteThread(); FreeSharedMemory(m_hFileMapping, m_thisMappedView, m_targetMappedView); m_hFileMapping = NULL; CloseHandle(m_hProcess); m_hProcess = NULL; m_dwProcessId = 0; } HANDLE MemEx::GetProcess() const { return m_hProcess; } DWORD MemEx::GetPid() const { return m_dwProcessId; } bool MemEx::Read(const uintptr_t address, void* const buffer, const SIZE_T size) const { return ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(address), buffer, size, NULL); } bool MemEx::Write(uintptr_t address, const void* const buffer, const SIZE_T size) const { MEMORY_BASIC_INFORMATION mbi; if (!VirtualQueryEx(m_hProcess, reinterpret_cast<LPCVOID>(address), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) return false; DWORD oldProtect = 0; if (mbi.Protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_READONLY | PAGE_GUARD)) VirtualProtectEx(m_hProcess, reinterpret_cast<LPVOID>(address), size, PAGE_EXECUTE_READWRITE, &oldProtect); bool ret = static_cast<bool>(WriteProcessMemory(m_hProcess, reinterpret_cast<LPVOID>(address), buffer, size, NULL)); if (oldProtect) VirtualProtectEx(m_hProcess, reinterpret_cast<LPVOID>(address), size, oldProtect, &oldProtect); return ret; } bool MemEx::Patch(const uintptr_t address, const char* const bytes, const size_t size) const { return Write(address, bytes, size) && static_cast<bool>(FlushInstructionCache(m_hProcess, reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(size))); } bool MemEx::Nop(const uintptr_t address, const size_t size, const bool saveBytes) { if (saveBytes) { m_Nops[address].buffer = std::make_unique<uint8_t[]>(size); m_Nops[address].size = size; if (!Read(address, m_Nops[address].buffer.get(), size)) { m_Nops.erase(address); return false; } } return Set(address, 0x90, size) && static_cast<bool>(FlushInstructionCache(m_hProcess, reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(size))); } bool MemEx::Restore(const uintptr_t address) { bool bRet = Patch(address, reinterpret_cast<const char*>(m_Nops[address].buffer.get()), m_Nops[address].size); m_Nops.erase(address); return bRet && static_cast<bool>(FlushInstructionCache(m_hProcess, reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(m_Nops[address].size))); } bool MemEx::Copy(const uintptr_t destinationAddress, const uintptr_t sourceAddress, const size_t size) const { std::unique_ptr<uint8_t[]> buffer = std::make_unique<uint8_t[]>(size); return !Read(sourceAddress, buffer.get(), size) || !Write(destinationAddress, buffer.get(), size); } bool MemEx::Set(const uintptr_t address, const int value, const size_t size) const { std::unique_ptr<uint8_t[]> buffer = std::make_unique<uint8_t[]>(size); memset(buffer.get(), value, size); return Write(address, buffer.get(), size); } bool MemEx::Compare(const uintptr_t address1, const uintptr_t address2, const size_t size) const { std::unique_ptr<uint8_t[]> buffer1 = std::make_unique<uint8_t[]>(size), buffer2 = std::make_unique<uint8_t[]>(size); if (!Read(address1, buffer1.get(), size) || !Read(address2, buffer2.get(), size)) return false; return memcmp(buffer1.get(), buffer2.get(), size) == 0; } //Credits to: https://gist.github.com/creationix/4710780 bool MemEx::HashMD5(const uintptr_t address, const size_t size, uint8_t* const outHash) const { size_t N = ((((size + 8) / 64) + 1) * 64) - 8; std::unique_ptr<uint8_t[]> buffer = std::make_unique<uint8_t[]>(N + 64); if (!Read(address, buffer.get(), size)) return false; buffer[size] = static_cast<uint8_t>(0x80); // 0b10000000 *reinterpret_cast<uint32_t*>(buffer.get() + N) = static_cast<uint32_t>(size * 8); uint32_t X[4] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }; for (uint32_t i = 0, AA = X[0], BB = X[1], CC = X[2], DD = X[3]; i < N; i += 64) { for (uint32_t j = 0, f, g; j < 64; j++) { if (j < 16) { f = (BB & CC) | ((~BB) & DD); g = j; } else if (j < 32) { f = (DD & BB) | ((~DD) & CC); g = (5 * j + 1) % 16; } else if (j < 48) { f = BB ^ CC ^ DD; g = (3 * j + 5) % 16; } else { f = CC ^ (BB | (~DD)); g = (7 * j) % 16; } uint32_t temp = DD; DD = CC; CC = BB; BB += ROL((AA + f + k[j] + reinterpret_cast<uint32_t*>(buffer.get() + i)[g]), r[j]); AA = temp; } X[0] += AA, X[1] += BB, X[2] += CC, X[3] += DD; } for (int i = 0; i < 4; i++) reinterpret_cast<uint32_t*>(outHash)[i] = X[i]; return true; } uintptr_t MemEx::PatternScan(const char* const pattern, const char* const mask, const ScanBoundaries& scanBoundaries, const DWORD protect, const size_t numThreads, const bool firstMatch) const { std::atomic<uintptr_t> address = -1; uintptr_t start = 0, end = 0; switch (scanBoundaries.scanBoundaries) { case SCAN_BOUNDARIES::RANGE: start = scanBoundaries.start, end = scanBoundaries.end; break; case SCAN_BOUNDARIES::MODULE: DWORD moduleSize; if (!(start = GetModuleBase(scanBoundaries.moduleName, &moduleSize))) return 0; end = start + moduleSize; break; case SCAN_BOUNDARIES::ALL_MODULES: { struct PatternInfo { const char* const pattern, * const mask; const MemEx* mem; DWORD protect; size_t numThreads; bool firstMatch; uintptr_t address; }; PatternInfo pi = { pattern, mask, this, protect, numThreads, firstMatch, 0 }; EnumModules(m_dwProcessId, [](MODULEENTRY32& me, void* param) { PatternInfo* pi = static_cast<PatternInfo*>(param); return !(pi->address = pi->mem->PatternScan(pi->pattern, pi->mask, ScanBoundaries(SCAN_BOUNDARIES::RANGE, reinterpret_cast<uintptr_t>(me.modBaseAddr), reinterpret_cast<uintptr_t>(me.modBaseAddr + me.modBaseSize)), pi->protect, pi->numThreads, pi->firstMatch)); }, &pi); return pi.address; } default: return 0; } size_t chunkSize = (end - start) / numThreads; std::vector<std::thread> threads; for (size_t i = 0; i < numThreads; i++) threads.emplace_back(std::thread(&MemEx::PatternScanImpl, this, std::ref(address), reinterpret_cast<const uint8_t* const>(pattern), mask, start + chunkSize * i, start + chunkSize * (i + 1), protect, firstMatch)); for (auto& thread : threads) thread.join(); return (address.load() != -1) ? address.load() : 0; } uintptr_t MemEx::AOBScan(const char* const AOB, const ScanBoundaries& scanBoundaries, const DWORD protect, size_t* const patternSize, const size_t numThreads, const bool firstMatch) const { std::string pattern, mask; AOBToPattern(AOB, pattern, mask); if (patternSize) *patternSize = pattern.size(); return PatternScan(pattern.c_str(), mask.c_str(), scanBoundaries, protect, numThreads, firstMatch); } //Based on https://guidedhacking.com/threads/finddmaaddy-c-multilevel-pointer-function.6292/ uintptr_t MemEx::ReadMultiLevelPointer(uintptr_t base, const std::vector<uint32_t>& offsets) const { for (auto& offset : offsets) { if (!Read(base, &base, sizeof(uintptr_t))) return 0; base += offset; } return base; } bool MemEx::Hook(const uintptr_t address, const void* const callback, uintptr_t* const trampoline, const DWORD saveCpuStateMask) { size_t size = 0; constexpr uint8_t hookMark[12] = { 0xD6, 0xD6, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0xD6, 0xD6 }; const uint8_t* tmp = static_cast<const uint8_t*>(callback); while (memcmp(tmp, hookMark, sizeof(hookMark)) != 0) tmp++; return HookBuffer(address, callback, static_cast<const size_t>(reinterpret_cast<ptrdiff_t>(tmp) - reinterpret_cast<ptrdiff_t>(callback)), trampoline, saveCpuStateMask); } bool MemEx::HookBuffer(const uintptr_t address, const void* const callback, const size_t callbackSize, uintptr_t* const trampoline, const DWORD saveCpuStateMask) { uint8_t originalCode[HOOK_MAX_NUM_REPLACED_BYTES]; if (!m_hProcess || !Read(address, originalCode, sizeof(originalCode))) return false; size_t numReplacedBytes = 0; while (numReplacedBytes < 5) numReplacedBytes += ldisasm(originalCode + numReplacedBytes, !m_isWow64); #ifdef _WIN64 const bool callbackNearHook = (reinterpret_cast<ptrdiff_t>(callback) - static_cast<ptrdiff_t>(address + 5)) < 0x80000000; const size_t saveCpuStateBufferSize = static_cast<size_t>(saveCpuStateMask || (!saveCpuStateMask && !callbackNearHook) ? 14 : 0) + (saveCpuStateMask ? 8 : 0) + (saveCpuStateMask & FLAGS ? 2 : 0) + (saveCpuStateMask & GPR ? 22 : 0) + (saveCpuStateMask & XMMX ? 78 : 0); #else const size_t saveCpuStateBufferSize = (saveCpuStateMask ? 5 : 0) + (saveCpuStateMask & FLAGS ? 2 : 0) + (saveCpuStateMask & GPR ? 2 : 0) + (saveCpuStateMask & XMMX ? 76 : 0); #endif const size_t trampolineSize = numReplacedBytes + 5; const size_t bufferSize = saveCpuStateBufferSize + trampolineSize; HookStruct hook; uintptr_t bufferAddress = NULL; uint8_t codeCaveNullByte = 0; if (!(bufferAddress = FindCodeCaveBatch(bufferSize, { 0x00, 0xCC }, &codeCaveNullByte, ScanBoundaries(SCAN_BOUNDARIES::RANGE, address > 0x7ffff000 ? address - 0x7ffff000 : 0, address + 0x7ffff000)))) { hook.useCodeCaveAsMemory = false; for (auto page : m_Pages) { if (0x1000 - page.second > bufferSize) { bufferAddress = page.second; page.second += bufferSize; break; } } if (!bufferAddress) { MEMORY_BASIC_INFORMATION mbi; uintptr_t newBufferAddress = address > 0x7ffff000 ? address - 0x7ffff000 : 0; if (!VirtualQueryEx(m_hProcess, reinterpret_cast<LPVOID>(newBufferAddress), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) return false; if (reinterpret_cast<uintptr_t>(mbi.BaseAddress) < (address > 0x7ffff000 ? address - 0x7ffff000 : 0)) newBufferAddress = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; do { if (mbi.State == MEM_FREE) { do { if ((bufferAddress = reinterpret_cast<uintptr_t>(VirtualAllocEx(m_hProcess, reinterpret_cast<LPVOID>(newBufferAddress), 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE)))) break; else newBufferAddress += 0x1000; } while (newBufferAddress < reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize); } else newBufferAddress = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } while (VirtualQueryEx(m_hProcess, reinterpret_cast<LPVOID>(newBufferAddress), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) && newBufferAddress < address + 0x7ffff000 && !bufferAddress); if (bufferAddress) m_Pages[bufferAddress] = bufferSize; } } if (!bufferAddress) return false; std::unique_ptr<uint8_t[]> bufferPtr = std::make_unique<uint8_t[]>(bufferSize); uint8_t* buffer = bufferPtr.get(); if (saveCpuStateMask) { #ifdef _WIN64 PLACE8(callback); #endif if (saveCpuStateMask & GPR) { #ifdef _WIN64 // push rax, rcx, rdx, r8, r9, r10, r11 PLACE8(0x4151415041525150); PLACE1(0x52); PLACE2(0x5341); #else PLACE1(0x60); // pushad #endif } if (saveCpuStateMask & XMMX) { #ifdef _WIN64 PLACE4(0x60EC8348); // sub rsp, 0x60 #else PLACE1(0x83); PLACE2(0x60EC); // sub esp, 0x60 #endif PLACE1(0xF3); PLACE4(0x246C7F0F); PLACE1(0x50); // movdqu xmmword ptr ss:[r/esp+0x50], xmm5 PLACE1(0xF3); PLACE4(0x24647F0F); PLACE1(0x40); // movdqu xmmword ptr ss:[r/esp+0x40], xmm4 PLACE1(0xF3); PLACE4(0x245C7F0F); PLACE1(0x30); // movdqu xmmword ptr ss:[r/esp+0x30], xmm3 PLACE1(0xF3); PLACE4(0x24547F0F); PLACE1(0x20); // movdqu xmmword ptr ss:[r/esp+0x20], xmm2 PLACE1(0xF3); PLACE4(0x244C7F0F); PLACE1(0x10); // movdqu xmmword ptr ss:[r/esp+0x10], xmm1 PLACE1(0xF3); PLACE4(0x24047F0F); // movdqu xmmword ptr ss:[r/esp], xmm0 } if (saveCpuStateMask & FLAGS) { PLACE1(0x9C); } // pushfd/q #ifdef _WIN64 PLACE4(0x28EC8348); // sub rsp, 0x28 PLACE2(0x15FF); PLACE4((saveCpuStateMask & GPR ? -11 : 0) + (saveCpuStateMask & XMMX ? -39 : 0) + (saveCpuStateMask & FLAGS ? -1 : 0) - 18); PLACE4(0x28C48348); // add rsp, 0x28 #else PLACE1(0xE8); PLACE4(reinterpret_cast<ptrdiff_t>(callback) - reinterpret_cast<ptrdiff_t>(buffer + 4)); #endif if (saveCpuStateMask & FLAGS) { PLACE1(0x9D); } // popfd/q if (saveCpuStateMask & XMMX) { PLACE1(0xF3); PLACE4(0x24046F0F); // movdqu xmm0, xmmword ptr ss:[r/esp] PLACE1(0xF3); PLACE4(0x244C6F0F); PLACE1(0x10); // movdqu xmm1, xmmword ptr ss:[r/esp+0x10] PLACE1(0xF3); PLACE4(0x24546F0F); PLACE1(0x20); // movdqu xmm2, xmmword ptr ss:[r/esp+0x20] PLACE1(0xF3); PLACE4(0x245C6F0F); PLACE1(0x30); // movdqu xmm3, xmmword ptr ss:[r/esp+0x30] PLACE1(0xF3); PLACE4(0x24646F0F); PLACE1(0x40); // movdqu xmm4, xmmword ptr ss:[r/esp+0x40] PLACE1(0xF3); PLACE4(0x246C6F0F); PLACE1(0x50); // movdqu xmm5, xmmword ptr ss:[r/esp+0x50] #ifdef _WIN64 PLACE4(0x60C48348); // add rsp, 0x60 #else PLACE1(0x83); PLACE2(0x60C4); // add esp, 0x60 #endif } if (saveCpuStateMask & GPR) { #ifdef _WIN64 // pop r11, r10, r9, r8, rdx, rcx, rax PLACE8(0x584159415A415B41); PLACE1(0x5A); PLACE2(0x5859); #else PLACE1(0x61); // popad #endif } } #ifdef _WIN64 else if (!callbackNearHook) { PLACE2(0x25FF); PLACE4(0); PLACE8(callback); } #endif //Copy original instructions memcpy(reinterpret_cast<void*>(buffer), reinterpret_cast<const void*>(address), numReplacedBytes); if (*buffer == 0xE9) *reinterpret_cast<uint32_t*>(buffer + 1) = static_cast<uint32_t>(static_cast<ptrdiff_t>(*reinterpret_cast<uint32_t*>(buffer + 1) + address + 5) - static_cast<ptrdiff_t>(bufferAddress + (bufferPtr.get() - buffer) + 5)); buffer += numReplacedBytes; //Jump back to original function PLACE1(0xE9); PLACE4(static_cast<ptrdiff_t>(address + numReplacedBytes) - reinterpret_cast<ptrdiff_t>(buffer + 4)); if (!Write(bufferAddress, bufferPtr.get(), bufferSize)) return false; //Jump from hooked function to callback(x32 && !saveCpuStateMask) / buffer(x64) uint8_t jump[5]; buffer = jump; #ifdef _WIN64 PLACE1(0xE9); PLACE4(((!saveCpuStateMask && callbackNearHook) ? reinterpret_cast<ptrdiff_t>(callback) : static_cast<ptrdiff_t>(bufferAddress + 8)) - reinterpret_cast<ptrdiff_t>(buffer + 4)); #else PLACE1(0xE9); PLACE4((saveCpuStateMask ? static_cast<ptrdiff_t>(bufferAddress) : reinterpret_cast<ptrdiff_t>(callback)) - reinterpret_cast<ptrdiff_t>(buffer + 4)); #endif if (!Write(address, jump, 5)) return false; hook.buffer = bufferAddress; hook.bufferSize = static_cast<uint8_t>(bufferSize); hook.codeCaveNullByte = codeCaveNullByte; hook.numReplacedBytes = static_cast<uint8_t>(numReplacedBytes); m_Hooks[bufferAddress] = hook; return static_cast<bool>(FlushInstructionCache(m_hProcess, reinterpret_cast<LPCVOID>(address), numReplacedBytes)); } bool MemEx::Unhook(const uintptr_t address) { //Restore original instruction(s) std::unique_ptr<uint8_t[]> replacedBytes = std::make_unique<uint8_t[]>(m_Hooks[address].numReplacedBytes); if (!Read(m_Hooks[address].buffer + m_Hooks[address].bufferSize - 5 - m_Hooks[address].numReplacedBytes, replacedBytes.get(), m_Hooks[address].numReplacedBytes)) return false; if (*(replacedBytes.get() + 1) == 0xE9) *reinterpret_cast<uint32_t*>(replacedBytes.get() + 1) = static_cast<uint32_t>(static_cast<ptrdiff_t>(*reinterpret_cast<uint32_t*>(replacedBytes.get() + 1) + (m_Hooks[address].buffer + m_Hooks[address].bufferSize)) - static_cast<ptrdiff_t>(address + 5)); if (!Write(address, replacedBytes.get(), m_Hooks[address].numReplacedBytes)) return false; //Free memory used to store the buffer if (m_Hooks[address].useCodeCaveAsMemory && !Set(m_Hooks[address].buffer, m_Hooks[address].codeCaveNullByte, m_Hooks[address].bufferSize)) return false; else { for (auto page : m_Pages) { if (page.first == m_Hooks[address].buffer && !(page.second -= m_Hooks[address].bufferSize)) { VirtualFreeEx(m_hProcess, reinterpret_cast<LPVOID>(page.first), 0x1000, MEM_FREE); m_Pages.erase(m_Hooks[address].buffer); } } } m_Hooks.erase(address); return static_cast<bool>(FlushInstructionCache(m_hProcess, reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(m_Hooks[address].numReplacedBytes))); } uintptr_t MemEx::FindCodeCave(const size_t size, const uint32_t nullByte, const ScanBoundaries& scanBoundaries, size_t* const codeCaveSize, const DWORD protection, const size_t numThreads, const bool firstMatch) const { uintptr_t address = NULL; if (nullByte != -1) { auto pattern = std::make_unique<char[]>(size), mask = std::make_unique<char[]>(size + 1); memset(pattern.get(), static_cast<int>(nullByte), size); memset(mask.get(), static_cast<int>('x'), size); mask.get()[size] = '\0'; address = PatternScan(pattern.get(), mask.get(), scanBoundaries, protection, numThreads, firstMatch); } else { std::atomic<uintptr_t> atomicAddress = -1; uintptr_t start = 0, end = 0; switch (scanBoundaries.scanBoundaries) { case SCAN_BOUNDARIES::RANGE: start = scanBoundaries.start, end = scanBoundaries.end; break; case SCAN_BOUNDARIES::MODULE: DWORD moduleSize; if (!(start = GetModuleBase(scanBoundaries.moduleName, &moduleSize))) return 0; end = start + moduleSize; break; case SCAN_BOUNDARIES::ALL_MODULES: { struct CodeCaveInfo { size_t size; size_t* const codeCaveSize; const MemEx* memex; DWORD protect; size_t numThreads; bool firstMatch; uintptr_t address; }; CodeCaveInfo cci = { size, codeCaveSize, this, protection, numThreads, firstMatch, 0 }; EnumModules(GetCurrentProcessId(), [](MODULEENTRY32& me, void* param) { CodeCaveInfo* cci = static_cast<CodeCaveInfo*>(param); return !(cci->address = cci->memex->FindCodeCave(cci->size, -1, ScanBoundaries(SCAN_BOUNDARIES::RANGE, reinterpret_cast<uintptr_t>(me.modBaseAddr), reinterpret_cast<uintptr_t>(me.modBaseAddr + me.modBaseSize)), cci->codeCaveSize, cci->protect, cci->numThreads, cci->firstMatch)); }, &cci); return cci.address; } default: return 0; } size_t chunkSize = (end - start) / numThreads; std::vector<std::thread> threads; for (size_t i = 0; i < numThreads; i++) threads.emplace_back(std::thread(&MemEx::FindCodeCaveImpl, this, std::ref(atomicAddress), size, start + chunkSize * i, start + chunkSize * (static_cast<size_t>(i) + 1), protection, firstMatch)); for (auto& thread : threads) thread.join(); address = (atomicAddress.load() != -1) ? atomicAddress.load() : 0; } if (address && codeCaveSize) { size_t remainingSize = 0; SIZE_T nBytesRead; uint8_t buffer[4096]; uint8_t realNullByte = nullByte == -1 ? *reinterpret_cast<uint8_t*>(address) : nullByte; while (ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(address + size + remainingSize), buffer, 4096, &nBytesRead)) { for (SIZE_T i = 0; i < nBytesRead; i++) { if (buffer[i] == realNullByte) remainingSize++; else { *codeCaveSize = size + remainingSize; return address; } } } *codeCaveSize = size + remainingSize; } return address; } uintptr_t MemEx::FindCodeCaveBatch(const size_t size, const std::vector<uint8_t>& nullBytes, uint8_t* const pNullByte, const ScanBoundaries& scanBoundaries, size_t* const codeCaveSize, const DWORD protection, const size_t numThreads, const bool firstMatch) const { for (auto nullByte : nullBytes) { auto address = FindCodeCave(size, nullByte, scanBoundaries, codeCaveSize, protection, numThreads, firstMatch); if (address) { if (pNullByte) *pNullByte = nullByte; return address; } } return 0; } PVOID MemEx::MapLocalViewOfFile(const HANDLE hFileMapping) { return MapViewOfFile(hFileMapping, FILE_MAP_ALL_ACCESS | FILE_MAP_WRITE, 0, 0, 0); } bool MemEx::UnmapLocalViewOfFile(LPCVOID localAddress) { return static_cast<bool>(UnmapViewOfFile(localAddress)); } PVOID MemEx::MapRemoteViewOfFile(const HANDLE hFileMapping) const { auto lib = LoadLibrary(TEXT("Api-ms-win-core-memory-l1-1-5.dll")); _MapViewOfFileNuma2 mapViewOfFileNuma2; if (lib && (mapViewOfFileNuma2 = reinterpret_cast<_MapViewOfFileNuma2>(GetProcAddress(lib, "MapViewOfFileNuma2")))) { FreeLibrary(lib); return mapViewOfFileNuma2(hFileMapping, m_hProcess, 0, nullptr, 0, 0, PAGE_EXECUTE_READWRITE, -1); } else { LPVOID address = VirtualAllocEx(m_hProcess, NULL, 0x1000, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!address) return NULL; //Construct shellcode and copy it to the target process uint8_t shellcode[96]; uint8_t* buffer = shellcode; //Duplicate the handle to the file mapping object HANDLE hFileMappingDuplicate, hProcessDuplicate; if (!DuplicateHandle(GetCurrentProcess(), hFileMapping, m_hProcess, &hFileMappingDuplicate, NULL, FALSE, DUPLICATE_SAME_ACCESS) || !DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(), m_hProcess, &hProcessDuplicate, NULL, FALSE, DUPLICATE_SAME_ACCESS)) { VirtualFreeEx(m_hProcess, address, 0, MEM_RELEASE); return NULL; } PVOID targetAddress = nullptr; #ifdef _WIN64 PLACE1(0xB9); PLACE4(reinterpret_cast<uintptr_t>(m_hFileMappingDuplicate)); // mov ecx, m_hFileMappingDuplicate PLACE1(0xBA); PLACE4(FILE_MAP_ALL_ACCESS | FILE_MAP_EXECUTE); //mov edx, FILE_MAP_ALL_ACCESS PLACE4(0x45C03345); PLACE2(0xC933); // (xor r8d, r8d) & (xor r9d, r9d) PUSH1(0); CALL_ABSOLUTE(MapViewOfFile); PLACE1(0x50); PLACE1(0xB9); PLACE4(reinterpret_cast<uintptr_t>(hProcessDuplicate)); PLACE1(0xBA); PLACE8(&m_targetMappedView); PLACE1(0x4C); PLACE2(0xC48B); // mov r8, rax PLACE2(0xB941); PLACE4(sizeof(uintptr_t)); // mov r9d, sizeof(HANDLE) PUSH1(0); CALL_ABSOLUTE(WriteProcessMemory); PLACE2(0xC358); // pop esp & ret #else PUSH1(0); PUSH1(0); PUSH1(0); PUSH4(FILE_MAP_ALL_ACCESS | FILE_MAP_EXECUTE); PUSH4(hFileMappingDuplicate); CALL_RELATIVE(reinterpret_cast<uint8_t*>(address) + (buffer - shellcode), MapViewOfFile); PLACE1(0x50); //push eax PUSH1(0); PUSH1(sizeof(uintptr_t)); PLACE4(0x0824448D); // lea eax, dword ptr ss:[esp + 8] PLACE1(0x50); // push eax PUSH4(&targetAddress); PUSH4(hProcessDuplicate); CALL_RELATIVE(reinterpret_cast<uint8_t*>(address) + (buffer - shellcode), WriteProcessMemory); PLACE2(0xC358); // pop esp & ret #endif WriteProcessMemory(m_hProcess, address, shellcode, sizeof(shellcode), NULL); CreateRemoteThread(m_hProcess, NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(address), NULL, NULL, NULL); Sleep(2); DuplicateHandle(m_hProcess, hProcessDuplicate, NULL, NULL, NULL, FALSE, DUPLICATE_CLOSE_SOURCE); VirtualFreeEx(m_hProcess, address, 0, MEM_RELEASE); return targetAddress; } } bool MemEx::UnmapRemoteViewOfFile(LPCVOID remoteAddress) const { auto lib = LoadLibrary(TEXT("kernelbase.dll")); _UnmapViewOfFile2 unmapViewOfFile2; if (lib && (unmapViewOfFile2 = reinterpret_cast<_UnmapViewOfFile2>(GetProcAddress(lib, "UnmapViewOfFile2")))) { FreeLibrary(lib); return static_cast<bool>(unmapViewOfFile2(m_hProcess, remoteAddress, 0)); } else CreateRemoteThread(m_hProcess, NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(UnmapViewOfFile), const_cast<LPVOID>(remoteAddress), NULL, NULL); return true; } DWORD MemEx::GetProcessIdByName(const TCHAR* processName) { const HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return 0; std::lstring processNameLowercase(processName); std::transform(processNameLowercase.begin(), processNameLowercase.end(), processNameLowercase.begin(), [](TCHAR c) { return c >= 'A' && c < 'Z' ? c + 0x20 : c; }); PROCESSENTRY32 pe32; pe32.dwSize = sizeof(PROCESSENTRY32); if (Process32First(hSnapshot, &pe32)) { do { bool match = true; for (int i = 0; pe32.szExeFile[i]; i++) { TCHAR c = pe32.szExeFile[i]; if ((c >= 'A' && c <= 'Z' ? c + 0x20 : c) != processNameLowercase[i]) { match = false; break; } } if (match) { CloseHandle(hSnapshot); return pe32.th32ProcessID; } } while (Process32Next(hSnapshot, &pe32)); } CloseHandle(hSnapshot); return 0; } DWORD MemEx::GetProcessIdByWindow(const TCHAR* windowName, const TCHAR* className) { DWORD dwProcessId; GetWindowThreadProcessId(FindWindow(className, windowName), &dwProcessId); return dwProcessId; } uintptr_t MemEx::GetModuleBase(const TCHAR* const moduleName, DWORD* const pModuleSize) const { return MemEx::GetModuleBase(m_dwProcessId, moduleName, pModuleSize); } uintptr_t MemEx::GetModuleBase(const DWORD dwProcessId, const TCHAR* const moduleName, DWORD* const pModuleSize) { struct ModuleInfo { std::lstring* name; uintptr_t base; DWORD* const size; }; std::lstring moduleNameLowerCase; ModuleInfo mi = { nullptr, NULL, pModuleSize }; if (moduleName) { moduleNameLowerCase = moduleName; std::transform(moduleNameLowerCase.begin(), moduleNameLowerCase.end(), moduleNameLowerCase.begin(), [](TCHAR c) { return c >= 'A' && c < 'Z' ? c + 0x20 : c; }); mi.name = &moduleNameLowerCase; } EnumModules(dwProcessId, [](MODULEENTRY32& me, void* param) { ModuleInfo* mi = static_cast<ModuleInfo*>(param); bool match = true; if (mi->name) { for (int i = 0; me.szModule[i]; i++) { TCHAR c = me.szModule[i]; if ((c >= 'A' && c <= 'Z' ? c + 0x20 : c) != mi->name->at(i)) { match = false; break; } } } else match = lstrstr(me.szModule, TEXT(".exe")) != nullptr; if (match) { mi->base = reinterpret_cast<uintptr_t>(me.modBaseAddr); if (mi->size) *mi->size = me.modBaseSize; return false; } return true; }, &mi); return mi.base; } void MemEx::EnumModules(const DWORD processId, bool (*callback)(MODULEENTRY32& me, void* param), void* param) { const HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, processId); if (hSnapshot == INVALID_HANDLE_VALUE) return; MODULEENTRY32 me = { sizeof(MODULEENTRY32) }; if (Module32First(hSnapshot, &me)) { do { if (!callback(me, param)) break; } while (Module32Next(hSnapshot, &me)); } CloseHandle(hSnapshot); } //Credits to: https://guidedhacking.com/threads/universal-pattern-signature-parser.9588/ & https://guidedhacking.com/threads/python-script-to-convert-ces-aob-signature-to-c-s-signature-mask.14095/ void MemEx::AOBToPattern(const char* const AOB, std::string& pattern, std::string& mask) { if (!AOB) return; auto ishex = [](const char c) -> bool { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F'); }; auto hexchartoint = [](const char c) -> uint8_t { return (c >= 'A') ? (c - 'A' + 10) : (c - '0'); }; const char* bytes = AOB; for (; *bytes != '\0'; bytes++) { if (ishex(*bytes)) pattern += static_cast<char>((ishex(*(bytes + 1))) ? hexchartoint(*bytes) | (hexchartoint(*(bytes++)) << 4) : hexchartoint(*bytes)), mask += 'x'; else if (*bytes == '?') pattern += '\x00', mask += '?', (*(bytes + 1) == '?') ? (bytes++) : (bytes); } } void MemEx::PatternToAOB(const char* const pattern, const char* const mask, std::string& AOB) { for (size_t i = 0; mask[i]; i++) { if (mask[i] == '?') AOB += "??"; else AOB += static_cast<char>((pattern[i] & 0xF0) >> 4) + static_cast<char>(pattern[i] & 0x0F); AOB += ' '; } } DWORD MemEx::GetPageSize() { SYSTEM_INFO si; GetSystemInfo(&si); return si.dwPageSize; } HANDLE MemEx::CreateSharedMemory(const size_t size) { return CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_EXECUTE_READWRITE, static_cast<DWORD>(static_cast<uint64_t>(size) >> 32), static_cast<DWORD>(size & 0xFFFFFFFF), nullptr); } HANDLE MemEx::AllocateSharedMemory(const size_t size, PVOID& localView, PVOID& remoteView) const { HANDLE hFileMapping = CreateSharedMemory(size); if (hFileMapping) { localView = MapLocalViewOfFile(hFileMapping); remoteView = MapRemoteViewOfFile(hFileMapping); } return hFileMapping; } bool MemEx::FreeSharedMemory(HANDLE hFileMapping, LPCVOID localView, LPCVOID remoteView) const { return UnmapLocalViewOfFile(localView) && UnmapRemoteViewOfFile(remoteView) && static_cast<bool>(CloseHandle(hFileMapping)); } struct ManualMappingData64 { uint64_t moduleBase, loadLibraryA, getProcAddress; ManualMappingData64(uintptr_t moduleBase) : moduleBase(moduleBase), loadLibraryA(0), getProcAddress(0) {} }; struct ManualMappingData32 { uint32_t moduleBase, loadLibraryA, getProcAddress; ManualMappingData32(uint32_t moduleBase) : moduleBase(moduleBase), loadLibraryA(0), getProcAddress(0) {} }; /* bool __stdcall ManualMappingShellCode(ManualMappingData* manualMappingData) { IMAGE_NT_HEADERS* h = reinterpret_cast<IMAGE_NT_HEADERS*>(manualMappingData->moduleBase + reinterpret_cast<IMAGE_DOS_HEADER*>(manualMappingData->moduleBase)->e_lfanew); if (!h) return false; ptrdiff_t deltaBase = static_cast<ptrdiff_t>(manualMappingData->moduleBase) - static_cast<ptrdiff_t>(h->OptionalHeader.ImageBase); if (deltaBase && h->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size) { IMAGE_BASE_RELOCATION* r = reinterpret_cast<IMAGE_BASE_RELOCATION*>(manualMappingData->moduleBase + h->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress); while (r->VirtualAddress) { WORD* pRelativeInfo = reinterpret_cast<WORD*>(r + 1); for (UINT i = 0; i < ((r->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(WORD)); ++i, ++pRelativeInfo) { #ifdef _WIN64 if ((*pRelativeInfo >> 0x0C) == IMAGE_REL_BASED_DIR64) #else if ((*pRelativeInfo >> 0x0C) == IMAGE_REL_BASED_HIGHLOW) #endif { ULONG_PTR* pPatch = reinterpret_cast<ULONG_PTR*>(manualMappingData->moduleBase + r->VirtualAddress + ((*pRelativeInfo) & 0xFFF)); *pPatch += deltaBase; } } r = reinterpret_cast<IMAGE_BASE_RELOCATION*>(reinterpret_cast<uintptr_t>(r) + r->SizeOfBlock); } } if (h->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size) { for (IMAGE_IMPORT_DESCRIPTOR* d = reinterpret_cast<IMAGE_IMPORT_DESCRIPTOR*>(manualMappingData->moduleBase + h->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); d->Name; d++) { char* moduleName = reinterpret_cast<char*>(manualMappingData->moduleBase + d->Name); HMODULE hModule = manualMappingData->loadLibraryA(moduleName); if (!hModule) return false; ULONG_PTR* pThunkRef = reinterpret_cast<ULONG_PTR*>(manualMappingData->moduleBase + d->OriginalFirstThunk); ULONG_PTR* pFuncRef = reinterpret_cast<ULONG_PTR*>(manualMappingData->moduleBase + d->FirstThunk); if (!d->OriginalFirstThunk) pThunkRef = pFuncRef; for (; *pThunkRef; pThunkRef++, pFuncRef++) { if (IMAGE_SNAP_BY_ORDINAL(*pThunkRef)) *pFuncRef = reinterpret_cast<ULONG_PTR>(manualMappingData->getProcAddress(hModule, reinterpret_cast<char*>(*pThunkRef & 0xFFFF))); else { IMAGE_IMPORT_BY_NAME* pImport = reinterpret_cast<IMAGE_IMPORT_BY_NAME*>(manualMappingData->moduleBase + (*pThunkRef)); *pFuncRef = reinterpret_cast<ULONG_PTR>(manualMappingData->getProcAddress(hModule, pImport->Name)); } } } } if (h->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].Size) { IMAGE_TLS_DIRECTORY* pTLS = reinterpret_cast<IMAGE_TLS_DIRECTORY*>(manualMappingData->moduleBase + h->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress); for (PIMAGE_TLS_CALLBACK* pCallback = reinterpret_cast<PIMAGE_TLS_CALLBACK*>(pTLS->AddressOfCallBacks); *pCallback; pCallback++) (*pCallback)(reinterpret_cast<PVOID>(manualMappingData->moduleBase), DLL_PROCESS_ATTACH, nullptr); } return reinterpret_cast<BOOL(*WINAPI)(HINSTANCE, DWORD, LPVOID)>(manualMappingData->moduleBase + h->OptionalHeader.AddressOfEntryPoint)(reinterpret_cast<HINSTANCE>(manualMappingData->moduleBase), DLL_PROCESS_ATTACH, 0); } */ uintptr_t MemEx::Inject(const void* dll, INJECTION_METHOD injectionMethod, bool isPath) { HANDLE hThread; DWORD exitCode = 0; if (injectionMethod == INJECTION_METHOD::MANUAL_MAPPING) { DWORD numBytesRead; std::unique_ptr<uint8_t[]> rawImageUniquePtr; const uint8_t* rawImage = nullptr; //Load image from disk if the user specified a path. if (isPath) { HANDLE hFile; DWORD fileSize; if ((hFile = CreateFile(reinterpret_cast<const TCHAR*>(dll), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL)) == INVALID_HANDLE_VALUE || ((fileSize = GetFileSize(hFile, NULL)) == INVALID_FILE_SIZE) || !(rawImageUniquePtr = std::make_unique<uint8_t[]>(static_cast<size_t>(fileSize))) || !ReadFile(hFile, rawImageUniquePtr.get(), fileSize, &numBytesRead, NULL) || !CloseHandle(hFile) || !(rawImage = rawImageUniquePtr.get())) return false; } else if (!(rawImage = reinterpret_cast<const uint8_t*>(dll))) return false; //Do some checks to validate the image. const IMAGE_DOS_HEADER* idh = reinterpret_cast<const IMAGE_DOS_HEADER*>(rawImage); if (!idh || (isPath ? static_cast<DWORD>(idh->e_lfanew) > numBytesRead : false) || idh->e_magic != 0x5A4D) return false; const IMAGE_NT_HEADERS* inth = reinterpret_cast<const IMAGE_NT_HEADERS*>(rawImage + idh->e_lfanew); const IMAGE_OPTIONAL_HEADER32* ioh32 = reinterpret_cast<const IMAGE_OPTIONAL_HEADER32*>(&inth->OptionalHeader); if (inth->Signature != 0x00004550 || inth->FileHeader.NumberOfSections > 96 || inth->FileHeader.SizeOfOptionalHeader == 0 || !(inth->FileHeader.Characteristics & (IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL))) return false; #ifndef _WIN64 if (inth->OptionalHeader.Magic != 0x10b) return false; #endif //Try to allocate a buffer for the image. LPVOID moduleBase = VirtualAllocEx(m_hProcess, NULL, inth->OptionalHeader.SizeOfImage, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!moduleBase) return false; //Copy headers WriteProcessMemory(m_hProcess, moduleBase, rawImage, 0x1000, NULL); //Copy sections const IMAGE_SECTION_HEADER* ish = IMAGE_FIRST_SECTION(inth); for (WORD i = 0; i < inth->FileHeader.NumberOfSections; i++, ish++) { if (ish->PointerToRawData) WriteProcessMemory(m_hProcess, reinterpret_cast<LPVOID>(reinterpret_cast<uintptr_t>(moduleBase) + ish->VirtualAddress), rawImage + ish->PointerToRawData, ish->SizeOfRawData, NULL); } ManualMappingData64 manualMappingData64(reinterpret_cast<uintptr_t>(moduleBase)); ManualMappingData32 manualMappingData32(static_cast<uint32_t>(reinterpret_cast<uintptr_t>(moduleBase))); const char shellcode64[] = "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x41\x56\x41\x57\x48\x83\xEC\x20\x48\x8B\x01\x48\x8B\xD9\x4C\x63\x78\x3C\x4C\x03\xF8\x0F\x84\x78\x01\x00\x00\x4C\x8B\xD8\x4D\x2B\x5F\x30\x0F\x84\x8D\x00\x00\x00\x41\x83\xBF\xB4\x00\x00\x00\x00\x0F\x84\x7F\x00\x00\x00\x41\x8B\x97\xB0\x00\x00\x00\x48\x03\xD0\x83\x3A\x00\x74\x70\xBF\x00\xF0\x00\x00\xBE\x00\xA0\x00\x00\x90\x44\x8B\x52\x04\x4C\x8D\x42\x08\x45\x33\xC9\x49\x8D\x42\xF8\x48\xA9\xFE\xFF\xFF\xFF\x76\x43\x66\x0F\x1F\x84\x00\x00\x00\x00\x00\x41\x0F\xB7\x08\x0F\xB7\xC1\x66\x23\xC7\x66\x3B\xC6\x75\x11\x8B\x02\x81\xE1\xFF\x0F\x00\x00\x48\x03\xC8\x48\x03\x0B\x4C\x01\x19\x44\x8B\x52\x04\x41\xFF\xC1\x49\x83\xC0\x02\x41\x8B\xC1\x49\x8D\x4A\xF8\x48\xD1\xE9\x48\x3B\xC1\x72\xC6\x41\x8B\xC2\x48\x03\xD0\x83\x3A\x00\x75\x9B\x41\x83\xBF\x94\x00\x00\x00\x00\x74\x7E\x45\x8B\xB7\x90\x00\x00\x00\x4C\x03\x33\x41\x8B\x46\x0C\x85\xC0\x74\x6C\x8B\xC8\x48\x03\x0B\xFF\x53\x08\x48\x8B\xE8\x48\x85\xC0\x0F\x84\xAE\x00\x00\x00\x48\x8B\x13\x41\x8B\x4E\x10\x45\x8B\x06\x45\x85\xC0\x48\x8D\x34\x11\x41\x0F\x45\xC8\x48\x8D\x3C\x11\x48\x8B\x0C\x11\x48\x85\xC9\x74\x2A\x79\x05\x0F\xB7\xD1\xEB\x0A\x48\x8B\x13\x48\x83\xC2\x02\x48\x03\xD1\x48\x8B\xCD\xFF\x53\x10\x48\x83\xC7\x08\x48\x89\x06\x48\x83\xC6\x08\x48\x8B\x0F\x48\x85\xC9\x75\xD6\x41\x8B\x46\x20\x49\x83\xC6\x14\x85\xC0\x75\x94\x41\x83\xBF\xD4\x00\x00\x00\x00\x74\x32\x48\x8B\x03\x41\x8B\x8F\xD0\x00\x00\x00\x48\x8B\x7C\x01\x18\x48\x8B\x07\x48\x85\xC0\x74\x1B\x66\x90\x48\x8B\x0B\x45\x33\xC0\x41\x8D\x50\x01\xFF\xD0\x48\x8B\x47\x08\x48\x8D\x7F\x08\x48\x85\xC0\x75\xE7\x48\x8B\x0B\x45\x33\xC0\x41\x8B\x47\x28\x48\x03\xC1\x41\x8D\x50\x01\xFF\xD0\x85\xC0\x0F\x95\xC0\xEB\x02\x32\xC0\x48\x8B\x5C\x24\x40\x48\x8B\x6C\x24\x48\x48\x8B\x74\x24\x50\x48\x83\xC4\x20\x41\x5F\x41\x5E\x5F\xC3"; const char shellcode32[] = "\x55\x8B\xEC\x83\xEC\x08\x53\x8B\x5D\x08\x56\x57\x8B\x0B\x8B\x79\x3C\x03\xF9\x89\x7D\x08\x0F\x84\x35\x01\x00\x00\x8B\xC1\x2B\x47\x34\x89\x45\xF8\x74\x67\x83\xBF\xA4\x00\x00\x00\x00\x74\x5E\x8B\x97\xA0\x00\x00\x00\x03\xD1\x83\x3A\x00\x74\x51\x0F\x1F\x40\x00\x8B\x4A\x04\x8D\x72\x08\x33\xFF\x8D\x41\xF8\xA9\xFE\xFF\xFF\xFF\x76\x31\x0F\xB7\x06\x8B\xC8\x81\xE1\x00\xF0\x00\x00\x81\xF9\x00\x30\x00\x00\x75\x0E\x8B\x4D\xF8\x25\xFF\x0F\x00\x00\x03\x02\x03\x03\x01\x08\x8B\x4A\x04\x47\x83\xC6\x02\x8D\x41\xF8\xD1\xE8\x3B\xF8\x72\xCF\x03\xD1\x83\x3A\x00\x75\xB6\x8B\x7D\x08\x83\xBF\x84\x00\x00\x00\x00\x74\x77\x8B\xBF\x80\x00\x00\x00\x03\x3B\x89\x7D\xF8\x8B\x4F\x0C\x85\xC9\x74\x62\x8B\x03\x03\xC1\x50\x8B\x43\x04\xFF\xD0\x89\x45\xFC\x85\xC0\x0F\x84\x94\x00\x00\x00\x8B\x33\x8B\x0F\x85\xC9\x8B\x57\x10\x8D\x3C\x32\x0F\x45\xD1\x8B\x0C\x16\x03\xF2\x85\xC9\x74\x25\x79\x05\x0F\xB7\xC1\xEB\x07\x8B\x03\x83\xC0\x02\x03\xC1\x50\xFF\x75\xFC\x8B\x43\x08\xFF\xD0\x83\xC6\x04\x89\x07\x83\xC7\x04\x8B\x0E\x85\xC9\x75\xDB\x8B\x7D\xF8\x83\xC7\x14\x89\x7D\xF8\x8B\x4F\x0C\x85\xC9\x75\x9E\x8B\x7D\x08\x83\xBF\xC4\x00\x00\x00\x00\x74\x24\x8B\x03\x8B\x8F\xC0\x00\x00\x00\x8B\x74\x01\x0C\x8B\x06\x85\xC0\x74\x12\x6A\x00\x6A\x01\xFF\x33\xFF\xD0\x8B\x46\x04\x8D\x76\x04\x85\xC0\x75\xEE\x8B\x0B\x8B\x47\x28\x6A\x00\x6A\x01\x51\x03\xC1\xFF\xD0\x5F\x5E\x5B\x8B\xE5\x5D\xC2\x04\x00\x5F\x5E\x32\xC0\x5B\x8B\xE5\x5D\xC2\x04"; SIZE_T shellcodeSize, manualMappingDataSize; if (m_isWow64) { shellcodeSize = sizeof(shellcode32), manualMappingDataSize = sizeof(manualMappingData32); auto kernel32 = GetModuleBase(TEXT("kernel32.dll")); manualMappingData32.loadLibraryA = static_cast<uint32_t>(GetProcAddressEx(kernel32, "LoadLibraryA")); manualMappingData32.getProcAddress = static_cast<uint32_t>(GetProcAddressEx(kernel32, "GetProcAddress")); } else { shellcodeSize = sizeof(shellcode64), manualMappingDataSize = sizeof(manualMappingData64); manualMappingData64.loadLibraryA = reinterpret_cast<uint64_t>(LoadLibraryA); manualMappingData64.getProcAddress = reinterpret_cast<uint64_t>(GetProcAddress); } LPVOID manualMappingShellCodeAddress; bool success = (manualMappingShellCodeAddress = VirtualAllocEx(m_hProcess, NULL, shellcodeSize + manualMappingDataSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE)) && WriteProcessMemory(m_hProcess, manualMappingShellCodeAddress, reinterpret_cast<LPCVOID>(m_isWow64 ? shellcode32 : shellcode64), shellcodeSize, NULL) && WriteProcessMemory(m_hProcess, reinterpret_cast<LPVOID>(reinterpret_cast<uintptr_t>(manualMappingShellCodeAddress) + shellcodeSize), m_isWow64 ? reinterpret_cast<LPCVOID>(&manualMappingData32) : reinterpret_cast<LPCVOID>(&manualMappingData64), manualMappingDataSize, NULL) && (hThread = CreateRemoteThread(m_hProcess, NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(manualMappingShellCodeAddress), reinterpret_cast<LPVOID>(reinterpret_cast<uintptr_t>(manualMappingShellCodeAddress) + shellcodeSize), NULL, NULL)) && WaitForSingleObject(hThread, INFINITE) != WAIT_FAILED && VirtualFreeEx(m_hProcess, manualMappingShellCodeAddress, 0, MEM_RELEASE) && GetExitCodeThread(hThread, &exitCode) && exitCode && CloseHandle(hThread); return success ? reinterpret_cast<uintptr_t>(moduleBase) : VirtualFreeEx(m_hProcess, moduleBase, 0, MEM_RELEASE) && 0; } else { LPVOID lpAddress = NULL; LPVOID loadLibrary = LoadLibrary; if (m_isWow64) { loadLibrary = reinterpret_cast<LPVOID>(GetProcAddressEx(GetModuleBase(TEXT("kernel32.dll")), #ifdef UNICODE "LoadLibraryW" #else "LoadLibraryA" #endif )); } const bool success = isPath && (lpAddress = VirtualAllocEx(m_hProcess, NULL, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)) && WriteProcessMemory(m_hProcess, lpAddress, dll, (static_cast<size_t>(lstrlen(reinterpret_cast<const TCHAR*>(dll))) + 1) * sizeof(TCHAR), nullptr) && (hThread = CreateRemoteThread(m_hProcess, NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(loadLibrary), lpAddress, NULL, NULL)) && WaitForSingleObject(hThread, INFINITE) != WAIT_FAILED && VirtualFreeEx(m_hProcess, lpAddress, 0, MEM_RELEASE) && GetExitCodeThread(hThread, &exitCode) && exitCode && CloseHandle(hThread); return success ? exitCode : 0; } } uintptr_t MemEx::GetProcAddressEx(uintptr_t moduleBase, const char* procedureName, uint16_t* const pOrdinal) { char buffer[0x1000]; if (!procedureName || !Read(moduleBase, buffer, 0x1000)) return 0; PIMAGE_NT_HEADERS inth = reinterpret_cast<PIMAGE_NT_HEADERS>(buffer + *reinterpret_cast<DWORD*>(buffer + 0x3c)); bool image32 = inth->OptionalHeader.Magic == 0x10b; PIMAGE_DATA_DIRECTORY idd = reinterpret_cast<PIMAGE_DATA_DIRECTORY>(reinterpret_cast<char*>(&inth->OptionalHeader) + (image32 ? 96 : 112)); IMAGE_EXPORT_DIRECTORY ied; if (!Read(moduleBase + idd->VirtualAddress, &ied, sizeof(IMAGE_EXPORT_DIRECTORY))) return 0; std::string procedureNameLowerCase = procedureName; std::transform(procedureNameLowerCase.begin(), procedureNameLowerCase.end(), procedureNameLowerCase.begin(), [](TCHAR c) { return c >= 'A' && c < 'Z' ? c + 0x20 : c; }); SIZE_T numBytesRead; const DWORD* b; for (size_t i = 0; i < ied.NumberOfNames;) { ReadProcessMemory(m_hProcess, reinterpret_cast<LPVOID>(moduleBase + ied.AddressOfNames + i * 4), buffer, 0x1000, &numBytesRead); if (!numBytesRead) return 0; b = reinterpret_cast<DWORD*>(buffer); for (; reinterpret_cast<const char*>(b) < buffer + numBytesRead * sizeof(DWORD) && i < ied.NumberOfNames; b++, i++) { char functionName[0x100]{ 0 }; ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(moduleBase + *b), functionName, 0x100, NULL); bool match = true; for (size_t j = 0; j < procedureNameLowerCase.size(); j++) { char c = functionName[j]; if (!functionName[j] || (c >= 'A' && c <= 'Z' ? c + 0x20 : c) != procedureNameLowerCase.at(j)) { match = false; break; } } if (match) { uint16_t functionOrdinal; ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(moduleBase + ied.AddressOfNameOrdinals + i * 2), &functionOrdinal, sizeof(uint16_t), NULL); if (pOrdinal) *pOrdinal = functionOrdinal; uintptr_t functionAddress = 0; ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(moduleBase + ied.AddressOfFunctions + static_cast<size_t>(functionOrdinal) * (image32 ? 4 : 8)), &functionAddress, sizeof(uint32_t), NULL); functionAddress += moduleBase; return functionAddress; } } } return 0; } //Inspired by https://github.com/cheat-engine/cheat-engine/blob/ac072b6fae1e0541d9e54e2b86452507dde4689a/Cheat%20Engine/ceserver/native-api.c void MemEx::PatternScanImpl(std::atomic<uintptr_t>& address, const uint8_t* const pattern, const char* const mask, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch) const { MEMORY_BASIC_INFORMATION mbi; uint8_t buffer[4096]; const size_t patternSize = strlen(mask); while ((firstMatch ? true : address.load() == -1) && start < end && VirtualQueryEx(m_hProcess, reinterpret_cast<LPCVOID>(start), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) { if (mbi.Protect & protect) { for (; start < reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; start += 4096) { SIZE_T bufferSize; if (!ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(start), buffer, 4096, &bufferSize)) break; const uint8_t* bytes = buffer; for (size_t i = 0; i < bufferSize - patternSize; i++) { for (size_t j = 0; j < patternSize; j++) { if (!(mask[j] == '?' || bytes[j] == pattern[j])) goto byte_not_match; } { uintptr_t addressMatch = start + i; //Found match if (addressMatch < address.load()) address = addressMatch; return; } byte_not_match: bytes++; } } } start = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } } void MemEx::FindCodeCaveImpl(std::atomic<uintptr_t>& address, const size_t size, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch) const { MEMORY_BASIC_INFORMATION mbi; uint8_t buffer[4096]; size_t count = 0; while ((firstMatch ? true : address.load() == -1) && start < end && VirtualQueryEx(m_hProcess, reinterpret_cast<LPCVOID>(start), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) { if (mbi.Protect & protect) { while (start < reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize) { SIZE_T bufferSize; if (!ReadProcessMemory(m_hProcess, reinterpret_cast<LPCVOID>(start), buffer, 4096, &bufferSize)) break; uint8_t* b = buffer, lastByte = *b; while (b < buffer + bufferSize) { if (*b++ == lastByte) { if (++count == size) { uintptr_t addressMatch = start + (b - buffer) - count; //Found match if (addressMatch < address.load()) address = addressMatch; return; } } else count = 0; } } } start = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } } void* MemEx::CallImpl(const CConv cConv, const bool isReturnFloat, const bool isReturnDouble, const size_t returnSize, const uintptr_t functionAddress, std::vector<Arg>& args) { size_t returnOffset = 0; #ifdef _WIN64 uint8_t* buffer = m_thisMappedView + 35; size_t offset = static_cast<size_t>(62) + (isReturnFloat || isReturnDouble) ? 6 : 4 + returnSize > 8 ? 4 : 0; //Calculate offset(arguments) size_t paramCount = 0; for (auto arg : args) { if (paramCount <= 4) offset += (arg.isFloat) ? 6 : 10; else if (arg.size <= 8) offset += 11; else offset += 5; } //mov r15, m_targetMappedView PLACE2(0xBF49); PLACE8(m_targetMappedView); if (returnSize > 8) // sub rsp, ((returnSize >> 4) + 1) * 8) { PLACE1(0x48); PLACE2(0xEC81); PLACE4(((returnSize >> 4) + 1) * 8); } //Handle parameters uint16_t intMovOpcodes[4] = { 0xB948, 0xBA48, 0xB849, 0xB949 }; paramCount = 0; for (auto arg : args) { if (returnSize > 8 && cConv == CConv::THIS_PTR_RET_SIZE_OVER_8 && paramCount == 1) { PLACE1(0x49); PLACE2(0x8F8D); PLACE4(offset); returnOffset = offset; } else if (returnSize > 8 && cConv != CConv::THIS_PTR_RET_SIZE_OVER_8 && paramCount == 0) { PLACE1(0x49); PLACE2(0x978D); PLACE4(offset); returnOffset = offset; } else if (paramCount < 4) { if (arg.isFloat) { memcpy(m_thisMappedView + offset, arg.data, arg.size); PLACE4(0x7E0F41F3); PLACE1(0x47 + 0x8 * paramCount); PLACE1(offset); // movq xmm(paramCount), qword ptr ds:[r15 + offset] offset += arg.size; } else if (arg.immediate && arg.size <= 8) { PLACE2(intMovOpcodes[paramCount]); PLACE8(0); memcpy(buffer - 8, arg.data, arg.size); /*mov (rcx,rdx,r8,r9), arg.data*/ } else { memcpy(m_thisMappedView + offset, arg.data, arg.size); PLACE2(intMovOpcodes[paramCount]); PLACE8(m_targetMappedView + offset); offset += arg.size; } } else if (arg.size <= 8) { PLACE2(0xB848); PLACE8(0); memcpy(buffer - 8, arg.data, arg.size); PLACE1(0x50); } else { memcpy(m_thisMappedView + offset, arg.data, arg.size); PLACE1(0x49); PLACE2(0x478D); PLACE1(offset); PLACE1(0x50); offset += arg.size; } paramCount++; } CALL_ABSOLUTE(functionAddress); if (isReturnFloat || isReturnDouble) //movaps xmmword ptr ds:[r15 + offset], xmm0 { PLACE1(0x66); PLACE4(0x47D60F41); } else //mov qword ptr ds:[r15 + offset], rax { PLACE1(0x49); PLACE2(0x4789); } PLACE1(offset); #else uint8_t* buffer = m_thisMappedView + 19; size_t offset = 19; //Calculate offset for (auto& arg : args) offset += (arg.immediate) ? (((arg.size > 4) ? arg.size >> 2 : 1) * 5) : 5; offset += ((cConv == CConv::_CDECL || cConv == CConv::DEFAULT && args.size()) ? 6 : 0) + 5 + 5; //stack cleanup + CALL + jump if (isReturnFloat || isReturnDouble) //Return value offset += 6; //float/double else if (returnSize <= 4 || returnSize > 8) offset += 5; //0-4, 9-... else //5-8 offset += 10; //Handle parameters size_t nPushes = 0; int skipArgs[2]; skipArgs[0] = -1; skipArgs[1] = -1; auto pushArg = [&](Arg& arg) { if (arg.immediate) { size_t argNumPushes = (arg.size > 4 ? arg.size >> 2 : 1); nPushes += argNumPushes; for (size_t j = 0; j < argNumPushes; j++) { PUSH4(*reinterpret_cast<const uint32_t*>(static_cast<const uint8_t*>(arg.data) + (argNumPushes - 1) * 4 - (j * 4))); } } else { memcpy(m_thisMappedView + offset, arg.data, arg.size); arg.volatileBuffer = m_thisMappedView + offset; PUSH4(m_targetMappedView + offset); offset += arg.size; nPushes++; } }; if (cConv == CConv::_FASTCALL) { for (size_t i = 0; i < args.size(); i++) { if (args[i].size <= 4 || args[i].isString) { if (skipArgs[0] == -1) skipArgs[0] = i; else if (skipArgs[1] == -1) skipArgs[1] = i; else break; } } for (size_t i = 0; i < 2; i++) { if (skipArgs[i] != -1) { PUSH1(static_cast<uint8_t>((i == 0) ? 0xB9 : 0xBA)); // mov ecx|edx, value if (args[skipArgs[i]].isString) { memcpy(m_thisMappedView + offset, args[skipArgs[i]].data, args[skipArgs[i]].size); PLACE4(m_targetMappedView + offset); offset += args[skipArgs[i]].size; } else { PLACE4(*static_cast<const uint32_t*>(args[skipArgs[i]].data)); } } } } else if (cConv == CConv::_THISCALL) { if (args.size() < 1) return 0; skipArgs[0] = 0; PLACE1(0xB9); PLACE4(*static_cast<const uint32_t*>(args[0].data)); // mov ecx, this } for (int i = args.size() - 1; i >= 0; i--) { if (skipArgs[0] == i || skipArgs[1] == i) continue; pushArg(args[i]); } //Handle the return value greater than 8 bytes. if (returnSize > 8) //Push pointer to buffer that the return value will be copied to. { PUSH4(m_targetMappedView + offset + ((cConv == CConv::_CDECL && nPushes) ? 6 : 0)); } CALL_RELATIVE(m_targetMappedView + (buffer - m_thisMappedView), functionAddress); //Clean up the stack if the calling convention is cdecl if ((cConv == CConv::_CDECL || cConv == CConv::DEFAULT) && nPushes) { PLACE2(0xC481); PLACE4(nPushes * 4); } //Handle the return value less or equal to eight bytes if (isReturnFloat) //ST(0) ; mov dword ptr ds:[Address], ST(0) { PLACE2(0x1DD9); PLACE4(m_targetMappedView + offset); } else if (isReturnDouble) //ST(0) ; mov qword ptr ds:[Address], ST(0) { PLACE2(0x1DDD); PLACE4(m_targetMappedView + offset); } else if (returnSize <= 4) //EAX ; mov dword ptr ds:[Address], eax { PLACE1(0xA3); PLACE4(m_targetMappedView + offset); } else if (returnSize <= 8) //EAX:EDX { //mov dword ptr ds:[Address], eax PLACE1(0xA3); PLACE4(m_targetMappedView + offset); //mov dword ptr ds:[Address], edx PLACE2(0x1589); PLACE4(m_targetMappedView + offset + 5); } #endif //Place jump. When the target thread finishes its task, go into wait mode.. PLACE1(0xE9); PLACE4(m_thisMappedView - buffer - 4); //Resume execution of target thread SignalObjectAndWait(m_hEvent1, m_hEvent2, INFINITE, FALSE); for (auto& arg : args) { if (!arg.constant && !arg.immediate) memcpy(const_cast<void*>(arg.data), arg.volatileBuffer, arg.size); } return m_thisMappedView + (returnOffset ? returnOffset : offset); } bool MemEx::SetupRemoteThread() { if (m_hThread) return true; if (!m_hProcess || !m_hFileMapping && !(m_hFileMapping = CreateSharedMemory(m_numPages * dwPageSize)) || !(m_thisMappedView = reinterpret_cast<uint8_t*>(MapLocalViewOfFile(m_hFileMapping))) || !(m_targetMappedView = reinterpret_cast<uint8_t*>(MapRemoteViewOfFile(m_hFileMapping)))) return false; //Creates handles to event objects that are valid on this process if (!(m_hEvent1 = CreateEventA(nullptr, FALSE, FALSE, nullptr)) || !(m_hEvent2 = CreateEventA(nullptr, FALSE, FALSE, nullptr))) return false; //Duplicate handles to the previously created event objects that will be valid on the target process if (!DuplicateHandle(GetCurrentProcess(), m_hEvent1, m_hProcess, &m_hEventDuplicate1, NULL, FALSE, DUPLICATE_SAME_ACCESS) || !DuplicateHandle(GetCurrentProcess(), m_hEvent2, m_hProcess, &m_hEventDuplicate2, NULL, FALSE, DUPLICATE_SAME_ACCESS)) return false; uint8_t* buffer = m_thisMappedView; #ifdef _WIN64 //Theoratically the size of a HANDLE is 8 bytes but I've never seen one use more than 4 bytes. PLACE4(0x28EC8348); //Allocate shadow space & perform stack alignment ; sub rsp, 0x28 PLACE1(0xB9); PLACE4(reinterpret_cast<uintptr_t>(m_hEventDuplicate2)); // mov edx, m_hEventDuplicate2 PLACE1(0xBA); PLACE4(reinterpret_cast<uintptr_t>(m_hEventDuplicate1)); // mov ecx, m_hEventDuplicate1 PLACE2(0xB841); PLACE4(INFINITE); // mov r8d, INFINITE PLACE1(0x45); PLACE2(0xC933); // xor r9d, r9d CALL_ABSOLUTE(SignalObjectAndWait); #else PUSH1(0); PUSH1(0xFF); // INIFITE(-1) PUSH4(m_hEventDuplicate1); PUSH4(m_hEventDuplicate2); CALL_RELATIVE(m_targetMappedView + (buffer - m_thisMappedView), SignalObjectAndWait); #endif if (!(m_hThread = CreateRemoteThreadEx(m_hProcess, nullptr, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(m_targetMappedView), nullptr, 0, nullptr, nullptr))) return false; //Wait for the created thread to signal m_hEvent2, so it will be set to an unsignaled state. if (WaitForSingleObject(m_hEvent2, INFINITE) == WAIT_FAILED) { m_hThread = NULL; return false; } return true; } void MemEx::DeleteRemoteThread() { if (!m_hThread) return; #ifdef _WIN64 m_thisMappedView[31] = static_cast<uint8_t>(0xC3); //ret #else m_thisMappedView[19] = static_cast<uint8_t>(0xC3); //ret #endif SetEvent(m_hEvent1); Sleep(1); CloseHandle(m_hEvent1); CloseHandle(m_hEvent2); DuplicateHandle(m_hProcess, m_hEventDuplicate1, NULL, NULL, NULL, FALSE, DUPLICATE_CLOSE_SOURCE); DuplicateHandle(m_hProcess, m_hEventDuplicate2, NULL, NULL, NULL, FALSE, DUPLICATE_CLOSE_SOURCE); CloseHandle(m_hThread); m_hThread = NULL; } //Implementation dependencies(MemIn) #include <cstdint> #include <Psapi.h> std::unordered_map<uintptr_t, MemIn::NopStruct> MemIn::m_Nops; std::unordered_map<uintptr_t, MemIn::HookStruct> MemIn::m_Hooks; std::unordered_map<uintptr_t, size_t> MemIn::m_Pages; MemIn::ProtectRegion::ProtectRegion(const uintptr_t address, const SIZE_T size, const bool protect) : m_Address(NULL), m_Size(size), m_Protection(NULL), m_Success(true) { if (protect) { m_Success = VirtualProtect(reinterpret_cast<LPVOID>(address), size, PAGE_EXECUTE_READWRITE, &m_Protection); m_Address = address; } } MemIn::ProtectRegion::~ProtectRegion() { VirtualProtect(reinterpret_cast<LPVOID>(m_Address), m_Size, m_Protection, &m_Protection); } bool MemIn::Read(const uintptr_t address, void* const buffer, const SIZE_T size) { MEMORY_BASIC_INFORMATION mbi; if (!VirtualQuery(reinterpret_cast<LPCVOID>(address), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) || mbi.Protect & (PAGE_GUARD | PAGE_NOACCESS)) return false; memcpy(buffer, reinterpret_cast<const void*>(address), size); return true; } bool MemIn::Write(const uintptr_t address, const void* const buffer, const SIZE_T size) { MEMORY_BASIC_INFORMATION mbi; if (!VirtualQuery(reinterpret_cast<LPCVOID>(address), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) return false; bool protect = (mbi.Protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_READONLY | PAGE_GUARD)); ProtectRegion pr(address, size, protect); if (!pr.Success()) return false; memcpy(reinterpret_cast<void*>(address), buffer, size); return true; } bool MemIn::Patch(const uintptr_t address, const char* bytes, const size_t size) { return Write(address, bytes, size) && static_cast<bool>(FlushInstructionCache(GetCurrentProcess(), reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(size))); } bool MemIn::Nop(const uintptr_t address, const size_t size, const bool saveBytes) { if (saveBytes) { m_Nops[address].buffer = std::make_unique<uint8_t[]>(size); m_Nops[address].size = size; Read(address, m_Nops[address].buffer.get(), size); } return Set(address, 0x90, size) && static_cast<bool>(FlushInstructionCache(GetCurrentProcess(), reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(size))); } bool MemIn::Restore(const uintptr_t address) { bool bRet = Patch(address, reinterpret_cast<const char*>(m_Nops[address].buffer.get()), m_Nops[address].size); m_Nops.erase(address); return bRet && static_cast<bool>(FlushInstructionCache(GetCurrentProcess(), reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(m_Nops[address].size))); } bool MemIn::Copy(const uintptr_t destinationAddress, const uintptr_t sourceAddress, const size_t size) { ProtectRegion prd(destinationAddress, size), prs(sourceAddress, size); if (!prd.Success() || !prs.Success()) return false; return memcpy(reinterpret_cast<void*>(destinationAddress), reinterpret_cast<const void*>(sourceAddress), size); } bool MemIn::Set(const uintptr_t address, const int value, const size_t size) { ProtectRegion pr(address, size); if (!pr.Success()) return false; return memset(reinterpret_cast<void*>(address), value, size); } bool MemIn::Compare(const uintptr_t address1, const uintptr_t address2, const size_t size) { ProtectRegion pr1(address1, size), pr2(address2, size); if (!pr1.Success() || !pr2.Success()) return false; return memcmp(reinterpret_cast<const void*>(address1), reinterpret_cast<const void*>(address2), size) == 0; } //Credits to: https://gist.github.com/creationix/4710780 bool MemIn::HashMD5(const uintptr_t address, const size_t size, uint8_t* const outHash) { size_t N = ((((size + 8) / 64) + 1) * 64) - 8; std::unique_ptr<uint8_t[]> buffer = std::make_unique<uint8_t[]>(N + 64); Read(address, buffer.get(), size); buffer[size] = static_cast<uint8_t>(0x80); // 0b10000000 *reinterpret_cast<uint32_t*>(buffer.get() + N) = static_cast<uint32_t>(size * 8); uint32_t X[4] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }; for (uint32_t i = 0, AA = X[0], BB = X[1], CC = X[2], DD = X[3]; i < N; i += 64) { for (uint32_t j = 0, f, g; j < 64; j++) { if (j < 16) { f = (BB & CC) | ((~BB) & DD); g = j; } else if (j < 32) { f = (DD & BB) | ((~DD) & CC); g = (5 * j + 1) % 16; } else if (j < 48) { f = BB ^ CC ^ DD; g = (3 * j + 5) % 16; } else { f = CC ^ (BB | (~DD)); g = (7 * j) % 16; } uint32_t temp = DD; DD = CC; CC = BB; BB += ROL((AA + f + k[j] + reinterpret_cast<uint32_t*>(buffer.get() + i)[g]), r[j]); AA = temp; } X[0] += AA, X[1] += BB, X[2] += CC, X[3] += DD; } for (int i = 0; i < 4; i++) reinterpret_cast<uint32_t*>(outHash)[i] = X[i]; return true; } uintptr_t MemIn::PatternScan(const char* const pattern, const char* const mask, const ScanBoundaries& scanBoundaries, const DWORD protect, const size_t numThreads, const bool firstMatch) { std::atomic<uintptr_t> address = -1; uintptr_t start = 0, end = 0; switch (scanBoundaries.scanBoundaries) { case SCAN_BOUNDARIES::RANGE: start = scanBoundaries.start, end = scanBoundaries.end; break; case SCAN_BOUNDARIES::MODULE: DWORD moduleSize; if (!(start = GetModuleBase(scanBoundaries.moduleName, &moduleSize))) return 0; end = start + moduleSize; break; case SCAN_BOUNDARIES::ALL_MODULES: { struct PatternInfo { const char* const pattern, * const mask; DWORD protect; size_t numThreads; bool firstMatch; uintptr_t address; }; PatternInfo pi = { pattern, mask, protect, numThreads, firstMatch, 0 }; EnumModules(GetCurrentProcessId(), [](MODULEENTRY32& me, void* param) { PatternInfo* pi = static_cast<PatternInfo*>(param); return !(pi->address = MemIn::PatternScan(pi->pattern, pi->mask, ScanBoundaries(SCAN_BOUNDARIES::RANGE, reinterpret_cast<uintptr_t>(me.modBaseAddr), reinterpret_cast<uintptr_t>(me.modBaseAddr + me.modBaseSize)), pi->protect, pi->numThreads, pi->firstMatch)); }, &pi); return pi.address; } default: return 0; } size_t chunkSize = (end - start) / numThreads; std::vector<std::thread> threads; for (size_t i = 0; i < numThreads; i++) threads.emplace_back(std::thread(&MemIn::PatternScanImpl, std::ref(address), reinterpret_cast<const uint8_t* const>(pattern), mask, start + chunkSize * i, start + chunkSize * (static_cast<size_t>(i) + 1), protect, firstMatch)); for (auto& thread : threads) thread.join(); return (address.load() != -1) ? address.load() : 0; } uintptr_t MemIn::AOBScan(const char* const AOB, const ScanBoundaries& scanBoundaries, const DWORD protect, size_t* const patternSize, const size_t numThreads, const bool firstMatch) { std::string pattern, mask; AOBToPattern(AOB, pattern, mask); if (patternSize) *patternSize = pattern.size(); return PatternScan(pattern.c_str(), mask.c_str(), scanBoundaries, protect, numThreads, firstMatch); } //Based on https://guidedhacking.com/threads/finddmaaddy-c-multilevel-pointer-function.6292/ uintptr_t MemIn::ReadMultiLevelPointer(uintptr_t base, const std::vector<uint32_t>& offsets) { MEMORY_BASIC_INFORMATION mbi; for (auto& offset : offsets) { if (!VirtualQuery(reinterpret_cast<LPCVOID>(base), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) || mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) return 0; base = *reinterpret_cast<uintptr_t*>(base) + offset; } return base; } bool MemIn::Hook(const uintptr_t address, const void* const callback, uintptr_t* const trampoline, const DWORD saveCpuStateMask) { ProtectRegion pr(address, HOOK_MAX_NUM_REPLACED_BYTES); if (!pr.Success()) return false; size_t numReplacedBytes = 0; while (numReplacedBytes < 5) #ifdef _WIN64 numReplacedBytes += ldisasm(reinterpret_cast<const void*>(address + numReplacedBytes), true); #else numReplacedBytes += ldisasm(reinterpret_cast<const void*>(address + numReplacedBytes), false); #endif #ifdef _WIN64 const bool callbackNearHook = (reinterpret_cast<ptrdiff_t>(callback) - static_cast<ptrdiff_t>(address + 5)) < 0x80000000; const size_t saveCpuStateBufferSize = static_cast<size_t>(saveCpuStateMask || (!saveCpuStateMask && !callbackNearHook) ? 14 : 0) + (saveCpuStateMask ? 8 : 0) + (saveCpuStateMask & FLAGS ? 2 : 0) + (saveCpuStateMask & GPR ? 22 : 0) + (saveCpuStateMask & XMMX ? 78 : 0); #else const size_t saveCpuStateBufferSize = (saveCpuStateMask ? 5 : 0) + (saveCpuStateMask & FLAGS ? 2 : 0) + (saveCpuStateMask & GPR ? 2 : 0) + (saveCpuStateMask & XMMX ? 76 : 0); #endif const size_t trampolineSize = numReplacedBytes + 5; const size_t bufferSize = saveCpuStateBufferSize + trampolineSize; HookStruct hook; uintptr_t bufferAddress = NULL; uint8_t codeCaveNullByte = 0; if (!(bufferAddress = FindCodeCaveBatch(bufferSize, { 0x00, 0xCC }, &codeCaveNullByte, ScanBoundaries(SCAN_BOUNDARIES::RANGE, address > 0x7ffff000 ? address - 0x7ffff000 : 0, address + 0x7ffff000)))) { hook.useCodeCaveAsMemory = false; for (auto page : m_Pages) { if (0x1000 - page.second > bufferSize) { bufferAddress = page.second; page.second += bufferSize; break; } } if (!bufferAddress) { MEMORY_BASIC_INFORMATION mbi; uintptr_t newBufferAddress = address > 0x7ffff000 ? address - 0x7ffff000 : 0; if (!VirtualQuery(reinterpret_cast<LPVOID>(newBufferAddress), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) return false; if (reinterpret_cast<uintptr_t>(mbi.BaseAddress) < (address > 0x7ffff000 ? address - 0x7ffff000 : 0)) newBufferAddress = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; do { if (mbi.State == MEM_FREE) { do { if ((bufferAddress = reinterpret_cast<uintptr_t>(VirtualAlloc(reinterpret_cast<LPVOID>(newBufferAddress), 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE)))) break; else newBufferAddress += 0x1000; } while (newBufferAddress < reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize); } else newBufferAddress = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } while (VirtualQuery(reinterpret_cast<LPVOID>(newBufferAddress), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) && newBufferAddress < address + 0x7ffff000 && !bufferAddress); if (bufferAddress) m_Pages[bufferAddress] = bufferSize; } } uint8_t* buffer = reinterpret_cast<uint8_t*>(bufferAddress); ProtectRegion pr2(bufferAddress, bufferSize); if (!pr2.Success() || !buffer) return false; if (saveCpuStateMask) { #ifdef _WIN64 PLACE8(callback); #endif if (saveCpuStateMask & GPR) { #ifdef _WIN64 // push rax, rcx, rdx, r8, r9, r10, r11 PLACE8(0x4151415041525150); PLACE1(0x52); PLACE2(0x5341); #else PLACE1(0x60); // pushad #endif } if (saveCpuStateMask & XMMX) { #ifdef _WIN64 PLACE4(0x60EC8348); // sub rsp, 0x60 #else PLACE1(0x83); PLACE2(0x60EC); // sub esp, 0x60 #endif PLACE1(0xF3); PLACE4(0x246C7F0F); PLACE1(0x50); // movdqu xmmword ptr ss:[r/esp+0x50], xmm5 PLACE1(0xF3); PLACE4(0x24647F0F); PLACE1(0x40); // movdqu xmmword ptr ss:[r/esp+0x40], xmm4 PLACE1(0xF3); PLACE4(0x245C7F0F); PLACE1(0x30); // movdqu xmmword ptr ss:[r/esp+0x30], xmm3 PLACE1(0xF3); PLACE4(0x24547F0F); PLACE1(0x20); // movdqu xmmword ptr ss:[r/esp+0x20], xmm2 PLACE1(0xF3); PLACE4(0x244C7F0F); PLACE1(0x10); // movdqu xmmword ptr ss:[r/esp+0x10], xmm1 PLACE1(0xF3); PLACE4(0x24047F0F); // movdqu xmmword ptr ss:[r/esp], xmm0 } if (saveCpuStateMask & FLAGS) { PLACE1(0x9C); } // pushfd/q #ifdef _WIN64 PLACE4(0x28EC8348); // sub rsp, 0x28 PLACE2(0x15FF); PLACE4((saveCpuStateMask & GPR ? -11 : 0) + (saveCpuStateMask & XMMX ? -39 : 0) + (saveCpuStateMask & FLAGS ? -1 : 0) - 18); PLACE4(0x28C48348); // add rsp, 0x28 #else PLACE1(0xE8); PLACE4(reinterpret_cast<ptrdiff_t>(callback) - reinterpret_cast<ptrdiff_t>(buffer + 4)); #endif if (saveCpuStateMask & FLAGS) { PLACE1(0x9D); } // popfd/q if (saveCpuStateMask & XMMX) { PLACE1(0xF3); PLACE4(0x24046F0F); // movdqu xmm0, xmmword ptr ss:[r/esp] PLACE1(0xF3); PLACE4(0x244C6F0F); PLACE1(0x10); // movdqu xmm1, xmmword ptr ss:[r/esp+0x10] PLACE1(0xF3); PLACE4(0x24546F0F); PLACE1(0x20); // movdqu xmm2, xmmword ptr ss:[r/esp+0x20] PLACE1(0xF3); PLACE4(0x245C6F0F); PLACE1(0x30); // movdqu xmm3, xmmword ptr ss:[r/esp+0x30] PLACE1(0xF3); PLACE4(0x24646F0F); PLACE1(0x40); // movdqu xmm4, xmmword ptr ss:[r/esp+0x40] PLACE1(0xF3); PLACE4(0x246C6F0F); PLACE1(0x50); // movdqu xmm5, xmmword ptr ss:[r/esp+0x50] #ifdef _WIN64 PLACE4(0x60C48348); // add rsp, 0x60 #else PLACE1(0x83); PLACE2(0x60C4); // add esp, 0x60 #endif } if (saveCpuStateMask & GPR) { #ifdef _WIN64 // pop r11, r10, r9, r8, rdx, rcx, rax PLACE8(0x584159415A415B41); PLACE1(0x5A); PLACE2(0x5859); #else PLACE1(0x61); // popad #endif } } #ifdef _WIN64 else if (!callbackNearHook) { PLACE2(0x25FF); PLACE4(0); PLACE8(callback); } #endif //Copy original instructions memcpy(reinterpret_cast<void*>(buffer), reinterpret_cast<const void*>(address), numReplacedBytes); if (*buffer == 0xE9) *reinterpret_cast<uint32_t*>(buffer + 1) = static_cast<uint32_t>(static_cast<ptrdiff_t>(*reinterpret_cast<uint32_t*>(buffer + 1) + address + 5) - reinterpret_cast<ptrdiff_t>(buffer + 5)); buffer += numReplacedBytes; //Jump back to original function PLACE1(0xE9); PLACE4(static_cast<ptrdiff_t>(address + numReplacedBytes) - reinterpret_cast<ptrdiff_t>(buffer + 4)); //Jump from hooked function to callback(x32 && !saveCpuStateMask) / buffer(x64) buffer = reinterpret_cast<uint8_t*>(address); #ifdef _WIN64 PLACE1(0xE9); PLACE4(((!saveCpuStateMask && callbackNearHook) ? reinterpret_cast<ptrdiff_t>(callback) : static_cast<ptrdiff_t>(bufferAddress)) - reinterpret_cast<ptrdiff_t>(buffer + 4)); #else PLACE1(0xE9); PLACE4((saveCpuStateMask ? static_cast<ptrdiff_t>(bufferAddress) : reinterpret_cast<ptrdiff_t>(callback)) - reinterpret_cast<ptrdiff_t>(buffer + 4)); #endif hook.buffer = bufferAddress; hook.bufferSize = static_cast<uint8_t>(bufferSize); hook.codeCaveNullByte = codeCaveNullByte; hook.numReplacedBytes = static_cast<uint8_t>(numReplacedBytes); m_Hooks[address] = hook; if (trampoline) *trampoline = bufferAddress + saveCpuStateBufferSize; return static_cast<bool>(FlushInstructionCache(GetCurrentProcess(), reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(numReplacedBytes))); } bool MemIn::Unhook(const uintptr_t address) { ProtectRegion pr(address, static_cast<SIZE_T>(m_Hooks[address].numReplacedBytes)), pr2(m_Hooks[address].buffer, m_Hooks[address].bufferSize); if (!pr.Success() || !pr2.Success()) return false; //Restore original instruction(s) memcpy(reinterpret_cast<void*>(address), reinterpret_cast<const void*>(m_Hooks[address].buffer + m_Hooks[address].bufferSize - 5 - m_Hooks[address].numReplacedBytes), m_Hooks[address].numReplacedBytes); if (*reinterpret_cast<uint8_t*>(address) == 0xE9) *reinterpret_cast<uint32_t*>(address + 1) = static_cast<uint32_t>(static_cast<ptrdiff_t>(*reinterpret_cast<uint32_t*>(address + 1) + (m_Hooks[address].buffer + m_Hooks[address].bufferSize)) - static_cast<ptrdiff_t>(address + 5)); //Free memory used to store the buffer if (m_Hooks[address].useCodeCaveAsMemory) memset(reinterpret_cast<void*>(m_Hooks[address].buffer), m_Hooks[address].codeCaveNullByte, static_cast<size_t>(m_Hooks[address].bufferSize)); else { for (auto page : m_Pages) { if (page.first == m_Hooks[address].buffer && !(page.second -= m_Hooks[address].bufferSize)) { VirtualFree(reinterpret_cast<LPVOID>(page.first), 0x1000, MEM_FREE); m_Pages.erase(m_Hooks[address].buffer); } } } m_Hooks.erase(address); return static_cast<bool>(FlushInstructionCache(GetCurrentProcess(), reinterpret_cast<LPCVOID>(address), static_cast<SIZE_T>(m_Hooks[address].numReplacedBytes))); } uintptr_t MemIn::FindCodeCave(const size_t size, const uint32_t nullByte, const ScanBoundaries& scanBoundaries, size_t* const codeCaveSize, const DWORD protection, const size_t numThreads, const bool firstMatch) { uintptr_t address = NULL; if (nullByte != -1) { auto pattern = std::make_unique<char[]>(size), mask = std::make_unique<char[]>(size + 1); memset(pattern.get(), static_cast<int>(nullByte), size); memset(mask.get(), static_cast<int>('x'), size); mask.get()[size] = '\0'; address = PatternScan(pattern.get(), mask.get(), scanBoundaries, protection, numThreads, firstMatch); } else { std::atomic<uintptr_t> atomicAddress = -1; uintptr_t start = 0, end = 0; switch (scanBoundaries.scanBoundaries) { case SCAN_BOUNDARIES::RANGE: start = scanBoundaries.start, end = scanBoundaries.end; break; case SCAN_BOUNDARIES::MODULE: DWORD moduleSize; if (!(start = GetModuleBase(scanBoundaries.moduleName, &moduleSize))) return 0; end = start + moduleSize; break; case SCAN_BOUNDARIES::ALL_MODULES: { struct CodeCaveInfo { size_t size; size_t* const codeCaveSize; DWORD protect; size_t numThreads; bool firstMatch; uintptr_t address; }; CodeCaveInfo cci = { size, codeCaveSize, protection, numThreads, firstMatch, 0 }; EnumModules(GetCurrentProcessId(), [](MODULEENTRY32& me, void* param) { CodeCaveInfo* cci = static_cast<CodeCaveInfo*>(param); return !(cci->address = MemIn::FindCodeCave(cci->size, -1, ScanBoundaries(SCAN_BOUNDARIES::RANGE, reinterpret_cast<uintptr_t>(me.modBaseAddr), reinterpret_cast<uintptr_t>(me.modBaseAddr + me.modBaseSize)), cci->codeCaveSize, cci->protect, cci->numThreads, cci->firstMatch)); }, &cci); return cci.address; } default: return 0; } size_t chunkSize = (end - start) / numThreads; std::vector<std::thread> threads; for (size_t i = 0; i < numThreads; i++) threads.emplace_back(std::thread(&MemIn::FindCodeCaveImpl, std::ref(atomicAddress), size, start + chunkSize * i, start + chunkSize * (static_cast<size_t>(i) + 1), protection, firstMatch)); for (auto& thread : threads) thread.join(); address = (atomicAddress.load() != -1) ? atomicAddress.load() : 0; } if (address && codeCaveSize) { size_t remainingSize = 0; MEMORY_BASIC_INFORMATION mbi; uint8_t realNullByte = nullByte == -1 ? *reinterpret_cast<uint8_t*>(address) : nullByte; while (VirtualQuery(reinterpret_cast<LPCVOID>(address + size + remainingSize), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) && mbi.State == MEM_COMMIT && !(mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD))) { while (address + size + remainingSize < reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize) { if (*reinterpret_cast<uint8_t*>(address + size + remainingSize) == realNullByte) remainingSize++; else { *codeCaveSize = size + remainingSize; return address; } } } *codeCaveSize = size + remainingSize; } return address; } uintptr_t MemIn::FindCodeCaveBatch(const size_t size, const std::vector<uint8_t>& nullBytes, uint8_t* const pNullByte, const ScanBoundaries& scanBoundaries, size_t* const codeCaveSize, const DWORD protection, const size_t numThreads, const bool firstMatch) { for (auto nullByte : nullBytes) { auto address = FindCodeCave(size, nullByte, scanBoundaries, codeCaveSize, protection, numThreads, firstMatch); if (address) { if (pNullByte) *pNullByte = nullByte; return address; } } return 0; } DWORD MemIn::GetProcessIdByName(const TCHAR* processName) { const HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (!hSnapshot) return 0; PROCESSENTRY32 pe32; pe32.dwSize = sizeof(PROCESSENTRY32); if (Process32First(hSnapshot, &pe32)) { do { if (!lstrcmp(processName, pe32.szExeFile)) { CloseHandle(hSnapshot); return pe32.th32ProcessID; } } while (Process32Next(hSnapshot, &pe32)); } CloseHandle(hSnapshot); return 0; } DWORD MemIn::GetProcessIdByWindow(const TCHAR* windowName, const TCHAR* className) { DWORD dwProcessId; GetWindowThreadProcessId(FindWindow(className, windowName), &dwProcessId); return dwProcessId; } uintptr_t MemIn::GetModuleBase(const TCHAR* const moduleName, DWORD* const pModuleSize) { uintptr_t moduleBase = reinterpret_cast<uintptr_t>(GetModuleHandle(moduleName)); if (!moduleBase) return 0; MODULEINFO moduleInfo; K32GetModuleInformation(GetCurrentProcess(), reinterpret_cast<HMODULE>(moduleBase), &moduleInfo, sizeof(MODULEINFO)); if (pModuleSize) *pModuleSize = moduleInfo.SizeOfImage; return moduleBase; } void MemIn::EnumModules(const DWORD processId, bool (*callback)(MODULEENTRY32& me, void* param), void* param) { const HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, processId); if (hSnapshot == INVALID_HANDLE_VALUE) return; MODULEENTRY32 me = { sizeof(MODULEENTRY32) }; if (Module32First(hSnapshot, &me)) { do { if (!callback(me, param)) break; } while (Module32Next(hSnapshot, &me)); } CloseHandle(hSnapshot); } //Credits to: https://guidedhacking.com/threads/universal-pattern-signature-parser.9588/ & https://guidedhacking.com/threads/python-script-to-convert-ces-aob-signature-to-c-s-signature-mask.14095/ void MemIn::AOBToPattern(const char* const AOB, std::string& pattern, std::string& mask) { if (!AOB) return; auto ishex = [](const char c) -> bool { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F'); }; auto hexchartoint = [](const char c) -> uint8_t { return (c >= 'A') ? (c - 'A' + 10) : (c - '0'); }; const char* bytes = static_cast<const char*>(AOB); for (; *bytes != '\0'; bytes++) { if (ishex(*bytes)) pattern += static_cast<char>((ishex(*(bytes + 1))) ? hexchartoint(*bytes) | (hexchartoint(*(bytes++)) << 4) : hexchartoint(*bytes)), mask += 'x'; else if (*bytes == '?') pattern += '\x00', mask += '?', (*(bytes + 1) == '?') ? (bytes++) : (bytes); } } void MemIn::PatternToAOB(const char* const pattern, const char* const mask, std::string& AOB) { for (size_t i = 0; mask[i]; i++) { if (mask[i] == '?') AOB += "??"; else AOB += static_cast<char>((pattern[i] & 0xF0) >> 4) + static_cast<char>(pattern[i] & 0x0F); AOB += ' '; } } //Inspired by https://github.com/cheat-engine/cheat-engine/blob/ac072b6fae1e0541d9e54e2b86452507dde4689a/Cheat%20Engine/ceserver/native-api.c void MemIn::PatternScanImpl(std::atomic<uintptr_t>& address, const uint8_t* const pattern, const char* const mask, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch) { MEMORY_BASIC_INFORMATION mbi; const size_t patternSize = strlen(mask); while ((firstMatch ? true : address.load() == -1) && start < end && VirtualQuery(reinterpret_cast<LPCVOID>(start), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) { if (!(mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) && (mbi.Protect & protect)) { const uint8_t* bytes = reinterpret_cast<const uint8_t*>(start); while (bytes < reinterpret_cast<uint8_t*>(mbi.BaseAddress) + mbi.RegionSize - patternSize) { for (size_t j = 0; j < patternSize; j++) { if (!(mask[j] == '?' || bytes[j] == pattern[j])) goto byte_not_match; } if (bytes != pattern) { //Found match if (reinterpret_cast<uintptr_t>(bytes) < address.load()) address = reinterpret_cast<uintptr_t>(bytes); return; } byte_not_match: bytes++; } } start = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } } void MemIn::FindCodeCaveImpl(std::atomic<uintptr_t>& address, const size_t size, uintptr_t start, const uintptr_t end, const DWORD protect, const bool firstMatch) { MEMORY_BASIC_INFORMATION mbi; size_t count = 0; while ((firstMatch ? true : address.load() == -1) && start < end && VirtualQuery(reinterpret_cast<LPCVOID>(start), &mbi, sizeof(MEMORY_BASIC_INFORMATION))) { if (!(mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) && (mbi.Protect & protect)) { uint8_t lastByte = *reinterpret_cast<uint8_t*>(start); while (start < reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize) { if (*reinterpret_cast<uint8_t*>(start) == lastByte) { if (++count == size) { uintptr_t addressMatch = start - count + 1; //Found match if (addressMatch < address.load()) address = addressMatch; return; } } else count = 0; start++; } } start = reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize; } } #endif // NMD_MEMORY_IMPLEMENTATION #endif // NMD_MEMORY_H
38.447314
1,816
0.69333
[ "object", "vector", "transform" ]
a649b31dc9181b2231047ffdcf72a68348007d09
6,457
cpp
C++
src/index_GIDSNE.cpp
skfzyy/NSG
808ccdf695a94fa16d742ee0723af511125cfe49
[ "MIT" ]
null
null
null
src/index_GIDSNE.cpp
skfzyy/NSG
808ccdf695a94fa16d742ee0723af511125cfe49
[ "MIT" ]
null
null
null
src/index_GIDSNE.cpp
skfzyy/NSG
808ccdf695a94fa16d742ee0723af511125cfe49
[ "MIT" ]
1
2021-12-05T01:58:06.000Z
2021-12-05T01:58:06.000Z
/** * @file index_GIDSNE.cpp * @author shenhangke * @brief * @version 0.1 * @date 2021-11-25 * * @copyright Copyright (c) 2021 * */ #include <efanna2e/index_GIDSNE.h> #include <fstream> #include <queue> void QI::IndexGidsne::loadOriginGraph(std::string filePath, std::string indexFilePath) { std::ifstream file; std::ifstream indexFile; file.open(filePath.c_str(), std::ios::in); indexFile.open(indexFilePath.c_str(), std::ios::in); if (!file.is_open() || !indexFile.is_open()) { return; } std::string strLine; // define a function which split string auto split = [](std::string str) -> std::vector<int> { std::vector<int> result; str = str.substr(0, str.size()); size_t index = str.find('\t'); if (index == str.npos) { return result; } // str=str.substr(0,index); result.push_back(std::stoi(str.substr(0, index))); result.push_back( std::stoi(str.substr(index + 1, str.size()))); if (result.size() == 2) { return result; } else { result.clear(); return result; } }; while (getline(file, strLine)) { // delte comment if (strLine[0] == '#') { continue; } else { std::vector<int> splitResult = split(strLine); if (splitResult.size() != 2) { continue; } else { // save the nn graph in origin graph this->_originGraph[splitResult[0]].push_back( splitResult[1]); } } } while (getline(indexFile, strLine)) { // delte comment if (strLine[0] == '#') { continue; } else { std::vector<int> splitResult = split(strLine); if (splitResult.size() != 2) { continue; } else { this->_originGraphIndex[splitResult[0]] = splitResult[1]; } } } } void QI::IndexGidsne::sync_prune(unsigned q, std::vector<Neighbor>& pool, const Parameters& parameter, boost::dynamic_bitset<>& flags, SimpleNeighbor* cut_graph_) { //遍历过的节点的flags都是true //这个函数应该就是应用MRNG算法来从候选池子中选择m个节点进行处理 unsigned range = parameter.Get<unsigned>("R"); unsigned maxc = parameter.Get<unsigned>("C"); width = range; unsigned start = 0; for (unsigned nn = 0; nn < final_graph_[q].size(); nn++) { //遍历查询节点的邻居节点 unsigned id = final_graph_[q][nn]; //如果是已经在算法1中经历过的节点,就不再进行处理 if (flags[id]) continue; //计算查询节点与他的邻居节点的距离 float dist = distance_->compare( data_ + dimension_ * (size_t)q, data_ + dimension_ * (size_t)id, (unsigned)dimension_); //把查询节点在KNN中的邻居节点加入到pool池子中来 pool.push_back(Neighbor(id, dist, true)); } //按照距离查询节点的大小顺序,把所有的节点进行排序 std::sort(pool.begin(), pool.end()); //这个应该是用来保存邻居节点结果的 std::vector<Neighbor> result; //如果在pool中最近的一个节点就是查询节点的话,start++ if (pool[start].id == q) start++; //首先把pool中距离查询节点最近的一个节点放入结果中 result.push_back(pool[start]); //这里应该是一个迭代的过程,如果按照伪代码来说的话,maxc是选择的节点数m? while (result.size() < range && (++start) < pool.size() && start < maxc) { //每次选择当前距离查询节点最近的节点(排除已经处理过的节点) auto& p = pool[start]; //遮挡? bool occlude = false; //这里应该就是条件 /* 简单来说,这里的条件要满足如下情况: 对于当前在pool中距离查询节点最近的节点来说,要加入到结果集合,需要满足如下条件: 1. 当前节点不能在结果集合中出现过 2. 当前节点到查询节点的距离要小于等于当前节点到结果集合(已经被选中在查询节点最近邻节点集合中)中任意一个顶点的距离 (这一点在论文中有提到,大概就是三角形两边打于第三边之类的) */ for (unsigned t = 0; t < result.size(); t++) { //对当前结果集中的节点进行诶个处理 if (p.id == result[t].id) { //如果在结果集合中找到当前距离查询节点最近的节点,那么就把标志位置true occlude = true; break; } //计算当前节点到结果集合中每个节点的距离 float djk = distance_->compare( data_ + dimension_ * (size_t)result[t].id, data_ + dimension_ * (size_t)p.id, (unsigned)dimension_); if (djk < p.distance) { occlude = true; break; } } bool isExistsPath = false; int realp = this->_originGraphIndex[p.id]; int realq = this->_originGraphIndex[q]; if (this->_pathIndex[realq].count(realp) == 1) { // no path isExistsPath = true; } if (!occlude && isExistsPath) result.push_back(p); } SimpleNeighbor* des_pool = cut_graph_ + (size_t)q * (size_t)range; //这里就是在赋值了 for (size_t t = 0; t < result.size(); t++) { des_pool[t].id = result[t].id; des_pool[t].distance = result[t].distance; } //如果最后选中的节点数小于range,那么就把截止的那个节点的距离设置为-1 if (result.size() < range) { des_pool[result.size()].distance = -1; } } void QI::IndexGidsne::buildOriginPathIndex() { // BFS to search std::queue<int> queueForBFS; auto index = [&](int query) { // clear queueForBFS queueForBFS = std::queue<int>(); this->_pathIndex[query] = std::set<int>(); // init std::vector<int> neighbor = this->_originGraph[query]; for (auto node : neighbor) { queueForBFS.push(node); } while (!queueForBFS.empty()) { int currentNode = queueForBFS.front(); queueForBFS.pop(); if (this->_pathIndex[query].count(currentNode) == 1) { continue; } else { this->_pathIndex[query].insert(currentNode); for (auto nei : this->_originGraph[currentNode]) { queueForBFS.push(nei); } } } }; for (auto const& node : this->_originGraph) { index(node.first); } }
25.027132
70
0.492179
[ "vector" ]
a64e5d882df0c15722faad0a80515de4b697938e
9,893
cc
C++
L1Trigger/VertexFinder/src/InputData.cc
thesps/cmssw
ad5315934948ce96699b29cc1d5b03a59f99634f
[ "Apache-2.0" ]
null
null
null
L1Trigger/VertexFinder/src/InputData.cc
thesps/cmssw
ad5315934948ce96699b29cc1d5b03a59f99634f
[ "Apache-2.0" ]
null
null
null
L1Trigger/VertexFinder/src/InputData.cc
thesps/cmssw
ad5315934948ce96699b29cc1d5b03a59f99634f
[ "Apache-2.0" ]
null
null
null
#include "L1Trigger/VertexFinder/interface/InputData.h" #include <map> #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/InputTag.h" #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h" #include "SimDataFormats/Track/interface/SimTrack.h" // #include "Geometry/Records/interface/StackedTrackerGeometryRecord.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" // TTStubAssociationMap.h forgets to two needed files, so must include them here ... #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" #include "SimTracker/TrackTriggerAssociation/interface/TTClusterAssociationMap.h" #include "SimTracker/TrackTriggerAssociation/interface/TTStubAssociationMap.h" #include "L1Trigger/VertexFinder/interface/AnalysisSettings.h" using namespace std; namespace l1tVertexFinder { InputData::InputData(const edm::Event& iEvent, const edm::EventSetup& iSetup, const AnalysisSettings& settings, const edm::EDGetTokenT<TrackingParticleCollection> tpInputTag, const edm::EDGetTokenT<DetSetVec> stubInputTag, const edm::EDGetTokenT<TTStubAssMap> stubTruthInputTag, const edm::EDGetTokenT<TTClusterAssMap> clusterTruthInputTag) { vTPs_.reserve(2500); // FIXME - filling vStubs_ removed during migration to VertexFinder package; not used in migrated code. // vStubs_.reserve(35000); vAllStubs_.reserve(35000); // Get TrackingParticle info edm::Handle<TrackingParticleCollection> tpHandle; iEvent.getByToken(tpInputTag, tpHandle); unsigned int tpCount = 0; float metY = 0; float metX = 0; float metY_pu = 0; float metX_pu = 0; genPt_ = 0.; genPt_PU_ = 0.; for (unsigned int i = 0; i < tpHandle->size(); i++) { TrackingParticlePtr tpPtr(tpHandle, i); // Store the TrackingParticle info, using class TP to provide easy access to the most useful info. TP tp(tpPtr, tpCount, settings); if (tp.physicsCollision()) { metX += tp.pt() * cos(tp.phi0()); metY += tp.pt() * sin(tp.phi0()); genPt_ += tp.pt(); } else { metX_pu += tp.pt() * cos(tp.phi0()); metY_pu += tp.pt() * sin(tp.phi0()); genPt_PU_ += tp.pt(); } // Only bother storing tp if it could be useful for tracking efficiency or fake rate measurements. if (tp.use()) { vTPs_.push_back(tp); // cout << "tracking particle z0 "<< tp.z0() << " vx "<< tp.vx() << " vy "<< tp.vy() << " vz "<< tp.vz() << " physicsCollision " << tp.physicsCollision() << endl; tpCount++; } } // Total Generated MET in the event genMET_ = sqrt(metX * metX + metY * metY); // Total GenMET in PU events genMET_PU_ = sqrt(metX * metX + metY * metY); cout << "genPt in the event " << genPt_ << endl; cout << "genMET in the event = " << genMET_ << endl; // Also create map relating edm::Ptr<TrackingParticle> to TP. map<edm::Ptr<TrackingParticle>, const TP*> translateTP; for (const TP& tp : vTPs_) { TrackingParticlePtr tpPtr(tp); translateTP[tpPtr] = &tp; } // Get the tracker geometry info needed to unpack the stub info. edm::ESHandle<TrackerGeometry> trackerGeometryHandle; iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometryHandle); const TrackerGeometry* trackerGeometry = trackerGeometryHandle.product(); edm::ESHandle<TrackerTopology> trackerTopologyHandle; iSetup.get<TrackerTopologyRcd>().get(trackerTopologyHandle); const TrackerTopology* trackerTopology = trackerTopologyHandle.product(); // Get stub info, by looping over modules and then stubs inside each module. // Also get the association map from stubs to tracking particles. edm::Handle<DetSetVec> ttStubHandle; edm::Handle<TTStubAssMap> mcTruthTTStubHandle; edm::Handle<TTClusterAssMap> mcTruthTTClusterHandle; // iEvent.getByLabel("TTStubsFromPixelDigis" , "StubAccepted" , ttStubHandle ); // iEvent.getByLabel("TTStubAssociatorFromPixelDigis" , "StubAccepted" , mcTruthTTStubHandle ); // iEvent.getByLabel("TTClusterAssociatorFromPixelDigis", "ClusterAccepted" , mcTruthTTClusterHandle ); iEvent.getByToken(stubInputTag, ttStubHandle); iEvent.getByToken(stubTruthInputTag, mcTruthTTStubHandle); iEvent.getByToken(clusterTruthInputTag, mcTruthTTClusterHandle); std::set<DetId> lStubDetIds; for (DetSetVec::const_iterator p_module = ttStubHandle->begin(); p_module != ttStubHandle->end(); p_module++) { for (DetSet::const_iterator p_ttstub = p_module->begin(); p_ttstub != p_module->end(); p_ttstub++) { lStubDetIds.insert(p_ttstub->getDetId()); } } for (auto gd = trackerGeometry->dets().begin(); gd != trackerGeometry->dets().end(); gd++) { DetId detid = (*gd)->geographicalId(); if (detid.subdetId() != StripSubdetector::TOB && detid.subdetId() != StripSubdetector::TID) continue; // only run on OT if (!trackerTopology->isLower(detid)) continue; // loop on the stacks: choose the lower arbitrarily DetId stackDetid = trackerTopology->stack(detid); // Stub module detid if (lStubDetIds.count(stackDetid) > 0) { assert(stubGeoDetIdMap_.count(stackDetid) == 0); stubGeoDetIdMap_[stackDetid] = detid; } } assert(lStubDetIds.size() == stubGeoDetIdMap_.size()); unsigned int stubCount = 0; for (DetSetVec::const_iterator p_module = ttStubHandle->begin(); p_module != ttStubHandle->end(); p_module++) { for (DetSet::const_iterator p_ttstub = p_module->begin(); p_ttstub != p_module->end(); p_ttstub++) { TTStubRef ttStubRef = edmNew::makeRefTo(ttStubHandle, p_ttstub); // Store the Stub info, using class Stub to provide easy access to the most useful info. Stub stub(ttStubRef, stubCount, settings, trackerGeometry, trackerTopology, stubGeoDetIdMap_); // Also fill truth associating stubs to tracking particles. // stub.fillTruth(vTPs_, mcTruthTTStubHandle, mcTruthTTClusterHandle); stub.fillTruth(translateTP, mcTruthTTStubHandle, mcTruthTTClusterHandle); vAllStubs_.push_back(stub); stubCount++; } } std::map<const TP*, std::vector<const Stub*>> tpStubMap; for (const TP& tp : vTPs_) tpStubMap[&tp] = std::vector<const Stub*>(); for (const Stub& stub : vAllStubs_) { for (const TP* tp : stub.assocTPs()) { tpStubMap[tp].push_back(&stub); } } // std::cout << "Number of stubs read in : " << stubCount << std::endl; // FIXME - filling vStubs_ removed during migration to VertexFinder package; not used in migrated code. // // Produced reduced list containing only the subset of stubs that the user has declared will be // // output by the front-end readout electronics. // for (const Stub& s : vAllStubs_) { // if (s.frontendPass()) vStubs_.push_back( &s ); // } // std::cout << "Number of stubs from FE : " << vStubs_.size() << std::endl; // FIXME - stub ordering removed during migration to VertexFinder package; should not be required. // // Optionally sort stubs according to bend, so highest Pt ones are sent from DTC to GP first. // if (settings->orderStubsByBend()) std::sort(vStubs_.begin(), vStubs_.end(), SortStubsInBend()); // // Note list of stubs produced by each tracking particle. // (By passing vAllStubs_ here instead of vStubs_, it means that any algorithmic efficiencies // measured will be reduced if the tightened frontend electronics cuts, specified in section StubCuts // of Analyze_Defaults_cfi.py, are not 100% efficient). for (unsigned int j = 0; j < vTPs_.size(); j++) { assert(tpStubMap.count(&vTPs_.at(j)) == 1); vTPs_[j].setMatchingStubs(tpStubMap.find(&vTPs_.at(j))->second); if (vTPs_[j].useForAlgEff()) { vertex_.insert(vTPs_[j]); // cout << "here "<< endl; // bool found = false; // unsigned int index = 9999; // for(unsigned int i = 0; i < vVertices_.size(); i++){ // if(vTPs_[j].vz() == vVertices_[i].z()){ // found = true; // index = i; // break; // } // } // if(found){ // vVertices_[index].insert(vTPs_[j]); // } else{ // Vertex vx(vTPs_[j].vz()); // vx.insert(vTPs_[j]); // vVertices_.push_back(vx); // } } else if (vTPs_[j].useForVertexReco()) { bool found = false; for (unsigned int i = 0; i < vertices_.size(); ++i) { if (vTPs_[j].vz() == vertices_[i].vz()) { vertices_[i].insert(vTPs_[j]); found = true; break; } } if (!found) { Vertex vertex(vTPs_[j].vz()); vertex.insert(vTPs_[j]); vertices_.push_back(vertex); } } } for (Vertex vertex : vertices_) { if (vertex.numTracks() >= settings.vx_minTracks()) recoVertices_.push_back(vertex); } cout << vertices_.size() << " pileup vertices in the event, " << recoVertices_.size() << " reconstructable" << endl; vertex_.computeParameters(); if (settings.debug() == 7) { cout << "Vertex " << vertex_.z0() << " containing " << vertex_.numTracks() << " total pT " << vertex_.pT() << endl; } for (unsigned int i = 0; i < vertices_.size(); ++i) { vertices_[i].computeParameters(); } for (unsigned int i = 0; i < recoVertices_.size(); ++i) { recoVertices_[i].computeParameters(); } std::sort(vertices_.begin(), vertices_.end(), SortVertexByZ0()); std::sort(recoVertices_.begin(), recoVertices_.end(), SortVertexByZ0()); } } // end namespace l1tVertexFinder
38.05
168
0.664409
[ "geometry", "vector" ]
a650468c7c7e0515a4f1ca30aaec7453b40e8dc2
41,795
cpp
C++
Voxel/Configuration.cpp
thpe/voxelsdk
f308e4ce5d72e4fca88debc415d894d053193391
[ "BSD-3-Clause" ]
112
2016-01-04T09:25:56.000Z
2022-03-18T17:28:05.000Z
Voxel/Configuration.cpp
thpe/voxelsdk
f308e4ce5d72e4fca88debc415d894d053193391
[ "BSD-3-Clause" ]
149
2015-10-09T08:28:07.000Z
2021-07-09T20:48:09.000Z
Voxel/Configuration.cpp
thpe/voxelsdk
f308e4ce5d72e4fca88debc415d894d053193391
[ "BSD-3-Clause" ]
77
2015-10-21T22:14:59.000Z
2022-03-18T17:26:18.000Z
/* * TI Voxel Lib component. * * Copyright (c) 2014 Texas Instruments Inc. */ #include "Configuration.h" #include "Logger.h" #include "Data2DCodec.h" #include "Timer.h" #include <stdlib.h> #include <fstream> #include <string.h> #include <stdio.h> #ifdef LINUX #define DIR_SEP "/" #define PATH_SEP ':' #elif defined(WINDOWS) #define DIR_SEP "\\" #define PATH_SEP ';' #endif #define BASE_STR "#BASE#" #define VERSION_STR "#VERSION#" #define CONF_FIRMWARE_KEY "fw" #define CONF_LIB_KEY "lib" #define CONF_CONF_KEY "conf" #define CAMERA_PROFILES "camera_profiles" #define CONFIG_VERSION_MAJOR 0 #define CONFIG_VERSION_MINOR 1 namespace Voxel { const Map<String, Configuration::_Path> Configuration::_pathTypes = { { CONF_FIRMWARE_KEY, { BASE_STR DIR_SEP "share" DIR_SEP "voxel-" VERSION_STR DIR_SEP "fw", "VOXEL_FW_PATH" } }, { CONF_LIB_KEY, { BASE_STR DIR_SEP "lib" DIR_SEP "voxel", "VOXEL_LIB_PATH" } }, { CONF_CONF_KEY, { BASE_STR DIR_SEP "share" DIR_SEP "voxel-" VERSION_STR DIR_SEP "conf", "VOXEL_CONF_PATH" } } }; Configuration::Configuration() { if(!Configuration::getSDKPath(_sdkPath)) { #ifdef LINUX _sdkPath = "/usr"; logger(LOG_DEBUG) << "Configuration: Failed to get SDK path from environment, trying standard path of /usr." << std::endl; #else logger(LOG_ERROR) << "Configuration: Failed to get SDK path." << std::endl; #endif } SDKVersion v = Configuration::getSDKVersion(); OutputStringStream ss; ss << (uint)v.major << "." << (uint)v.minor << "." << (uint)v.patch; _sdkVersion = ss.str(); _pathKeys = {BASE_STR, VERSION_STR}; _pathValues = {_sdkPath, _sdkVersion}; } SDKVersion Configuration::getSDKVersion() { SDKVersion v; v.major = VOXEL_MAJOR_VERSION; v.minor = VOXEL_MINOR_VERSION; v.patch = VOXEL_PATCH_VERSION; v.conf = VOXEL_CONF_VERSION; v.abi = VOXEL_ABI_VERSION; return v; } bool Configuration::_addPath(const String &type, const String &path) { auto t = _pathTypes.find(type); if(t == _pathTypes.end()) return false; const _Path &pt = t->second; return Configuration::addPathToEnvironmentVariable(pt.environmentVariable, path); } bool Configuration::addPathToEnvironmentVariable(const String &environmentVariable, const String &path, bool prepend) { char *p = getenv(environmentVariable.c_str()); String result; if(p != 0) { if(prepend) result = path + PATH_SEP + p; else result = p + PATH_SEP + path; } else result = path; #ifdef WINDOWS return _putenv_s(environmentVariable.c_str(), result.c_str()) == 0; #elif defined(LINUX) return setenv(environmentVariable.c_str(), result.c_str(), 1) == 0; #endif } bool Configuration::setEnvironmentVariable(const String &environmentVariable, const String &value) { #ifdef WINDOWS return _putenv_s(environmentVariable.c_str(), value.c_str()) == 0; #elif defined(LINUX) return setenv(environmentVariable.c_str(), value.c_str(), 1) == 0; #endif } bool Configuration::getLocalPath(const String &type, String &path) { // Adding local path ~/.Voxel/<type> // Works typically for Windows char *homeDrive = getenv("HOMEDRIVE"); char *homePath = getenv("HOMEPATH"); if(homeDrive != 0 && homePath != 0) { String s = homeDrive; s += homePath; s += DIR_SEP; s += ".Voxel"; if(!isFilePresent(s) && !makeDirectory(s)) return false; s += DIR_SEP; s += type; if(!isFilePresent(s) && !makeDirectory(s)) return false; path = s; return true; } // Adding local path ~/.Voxel/<type> // Works typically for Linux char *home = getenv("HOME"); if(home != 0) { String s = home; s += DIR_SEP; s += ".Voxel"; if(!isFilePresent(s) && !makeDirectory(s)) return false; s += DIR_SEP; s += type; if(!isFilePresent(s) && !makeDirectory(s)) return false; path = s; return true; } return false; } bool Configuration::getLocalFile(const String &type, String &name) { String path; if(!getLocalPath(type, path)) return false; name = path + DIR_SEP + name; return true; } bool Configuration::_getPaths(const String &type, Vector<String> &paths) { auto t = _pathTypes.find(type); if(t == _pathTypes.end()) return false; const _Path &pt = t->second; paths.clear(); String installPath = substitute(pt.installPath, _pathKeys, _pathValues); logger(LOG_DEBUG) << "Configuration: SDK install path for type '" << type << "' = " << installPath << std::endl; paths.push_back(installPath); char *p = getenv(pt.environmentVariable.c_str()); if(p != 0) { String p1(p); Vector<String> splits; split(p1, PATH_SEP, splits); paths.reserve(paths.size() + splits.size()); paths.insert(paths.begin(), splits.begin(), splits.end()); // Insert at the beginning to prefer over standard path } String localPath; if(getLocalPath(type, localPath)) paths.insert(paths.begin(), localPath); paths.insert(paths.begin(), ""); // Empty path for absolute file paths and also relative file paths if(logger.getCurrentLogLevel() >= LOG_DEBUG) { for(auto i = 0; i < paths.size(); i++) { logger(LOG_DEBUG) << paths[i]; if(i < paths.size() - 1) logger(LOG_DEBUG) << PATH_SEP; } logger(LOG_DEBUG) << std::endl; } return true; } bool Configuration::_get(const String &type, String &name) { Vector<String> paths; if(!_getPaths(type, paths)) return false; for(auto &p: paths) { String n = (p.size() > 0)?(p + DIR_SEP + name):name; std::ifstream f(n, std::ios::binary); if(f.good()) { name = n; return true; } } return false; } bool ConfigSet::isPresent(const String &name) const { if(params.find(name) == params.end()) return false; return true; } bool ConfigurationFile::isPresent(const String &section, const String &name, bool includeParent) const { bool checkParent = false; if(configs.find(section) == configs.end()) checkParent = true; else { const ConfigSet &set = configs.at(section); if(!set.isPresent(name)) checkParent = true; else return true; } if(checkParent && includeParent) { if(section != "global" && _mainConfigurationFile && _parentID >= 0) { ConfigurationFile *parentConfig = _mainConfigurationFile->getCameraProfile(_parentID); // TODO This does not handle circular references between profiles if(parentConfig) { return parentConfig->isPresent(section, name); } } } return false; } bool ConfigurationFile::getConfigSet(const String &section, const ConfigSet *&configSet, bool includeParent) const { if(configs.find(section) != configs.end()) { configSet = &configs.at(section); return true; } else if(includeParent) { if(section != "global" && _mainConfigurationFile && _parentID >= 0) { ConfigurationFile *parentConfig = _mainConfigurationFile->getCameraProfile(_parentID); // TODO This does not handle circular references between profiles if(parentConfig) return parentConfig->getConfigSet(section, configSet); } } return false; } bool ConfigSet::_get(const String &name, String &value) const { if(params.find(name) != params.end()) { value = params.at(name); return true; } return false; } bool ConfigurationFile::_get(const String &section, const String &name, String &value) const { Lock<Mutex> _(_mutex); int parentID; bool checkParent = false; if(configs.find(section) != configs.end()) { const ConfigSet &set = configs.at(section); if(!set._get(name, value)) checkParent = true; else return true; } else checkParent = true; if(checkParent) { if(section != "global" && _mainConfigurationFile && _parentID >= 0) { ConfigurationFile *parentConfig = _mainConfigurationFile->getCameraProfile(_parentID); // TODO This does not handle circular references between profiles if(parentConfig) return parentConfig->_get(section, name, value); } } return false; } String ConfigSet::get(const String &name) const { String value; if(!_get(name, value)) return ""; else return value; } String ConfigurationFile::get(const String &section, const String &name) const { String value; if(!_get(section, name, value)) return ""; else return value; } int ConfigSet::getInteger(const String &name) const { String s = get(name); if(!s.size()) return 0; return atoi(s.c_str()); } int ConfigurationFile::getInteger(const String &section, const String &name) const { String s = get(section, name); if(!s.size()) return 0; return atoi(s.c_str()); } float ConfigSet::getFloat(const String &name) const { String s = get(name); if(!s.size()) return 0.0f; return atof(s.c_str()); } float ConfigurationFile::getFloat(const String &section, const String &name) const { String s = get(section, name); if(!s.size()) return 0.0f; return atof(s.c_str()); } bool ConfigSet::getBoolean(const String &name) const { String s = get(name); if(!s.size()) return false; if(s == "true" || s == "True" || s == "1") return true; else return false; } bool ConfigurationFile::getBoolean(const String &section, const String &name) const { String s = get(section, name); if(!s.size()) return false; if(s == "true" || s == "True" || s == "1") return true; else return false; } bool ConfigurationFile::read(const String &filename) { Configuration c; String f = filename; configs.clear(); if(!c.getConfFile(f)) { logger(LOG_ERROR) << "ConfigurationFile: Failed to get configuration file '" << f << "'" << std::endl; return false; } _fileName = f; InputFileStream fin(f, std::ios::binary | std::ios::in); if (!fin.good()) { logger(LOG_ERROR) << "ConfigurationFile: Could not read file '" << filename << "'" << std::endl; return false; } return read(fin); } bool ConfigurationFile::read(InputStream &in) { { Lock<Mutex> _(_mutex); char buffer[2048]; char name[1000]; char value[1000]; ConfigSet *currentSet = 0; while(in.good()) { in.getline(buffer, 2048); if(strlen(buffer) < 2) { // ignore this line - nothing to do } else if(buffer[0] == '[') // new section { int nret = sscanf(buffer, "[%[^]]]", name); if(nret == 1) currentSet = &configs[name]; else return false; } else if(buffer[0] != '#') // allow comments { int nret = sscanf(buffer, "%[^=] = %[^\t\r\n]", name, value); if(nret >= 1 && currentSet != 0) { String n = name; trim(n); String v; if(nret == 2) { v = value; trim(v); } (*currentSet).paramNames.push_back(n); (*currentSet).params[n] = v; } else return false; } } } if(isPresent("global", "id")) _id = getInteger("global", "id"); if(isPresent("global", "parent")) _parentID = getInteger("global", "parent"); if(isPresent("global", "name")) _profileName = get("global", "name"); return true; } bool ConfigurationFile::_serializeAllDataFiles(OutputStream &out) { for(auto c = configs.begin(); c != configs.end(); c++) { for(auto i = c->second.params.begin(); i != c->second.params.end(); i++) { if(i->second.compare(0, sizeof(FILE_PREFIX) - 1, FILE_PREFIX) == 0) { String f; Vector<uint8_t> d; if(!getFile<uint8_t>(c->first, i->first, f, d)) return false; ConfigDataPacket cp; cp.type = ConfigDataPacket::PACKET_2D_DATA_FILE; Data2DCodec codec(_mainConfigurationFile->_quantizationFactor); Data2DCodec::Array2D in; Data2DCodec::ArrayBool2D invalidPixels; // Just empty array Data2DCodec::ByteArray dout; in.resize(d.size()/sizeof(Data2DCodec::Array2DElementType)); memcpy(in.data(), d.data(), d.size()); if(!codec.compress(in, invalidPixels, dout)) { logger(LOG_ERROR) << "ConfigurationFile: Failed to compress data file '" << f << "'" << std::endl; return false; } uint8_t id = _id; SerializableString section = c->first; SerializableString field = i->first; cp.object.resize(1 + section.serializedSize() + field.serializedSize() + dout.size()); cp.object.put((const char *)&id, sizeof(id)); section.write(cp.object); field.write(cp.object); cp.object.put((const char *)dout.data(), dout.size()); cp.size = cp.object.size(); cp.write(out); } } } return true; } bool ConfigurationFile::_saveAllDataFiles(const String &prefix) { for(auto c = configs.begin(); c != configs.end(); c++) { for(auto i = c->second.params.begin(); i != c->second.params.end(); i++) { if(i->second.compare(0, sizeof(FILE_PREFIX) - 1, FILE_PREFIX) == 0) { String f; Vector<uint8_t> d; if(!getFile<uint8_t>(c->first, i->first, f, d)) return false; if(!setFile<uint8_t>(c->first, i->first, prefix + f, d)) // save the file locally return false; } } } return true; } bool ConfigurationFile::write(OutputStream &out) { Lock<Mutex> _(_mutex); for(auto c = configs.begin(); c != configs.end(); c++) { out << "[" << c->first << "]\n"; for(auto i = 0; i < c->second.paramNames.size(); i++) { out << c->second.paramNames[i] << " = " << c->second.params[c->second.paramNames[i]] << std::endl; } out << std::endl; } return true; } bool ConfigurationFile::write(const String &configFile) { Configuration c; if(configFile != "") // Use new file name or old one itself? { String f = basename(configFile); if(!c.getLocalConfFile(f)) { logger(LOG_ERROR) << "ConfigurationFile: Failed to get configuration local path." << std::endl; return false; } _fileName = f; } else { String f = basename(_fileName); if(!c.getLocalConfFile(f)) { logger(LOG_ERROR) << "ConfigurationFile: Failed to get configuration local path." << std::endl; return false; } _fileName = f; } OutputFileStream fout(_fileName, std::ios::binary | std::ios::out); if (!fout.good()) { logger(LOG_ERROR) << "ConfigurationFile: Could not write file '" << configFile << "'" << std::endl; return false; } logger(LOG_INFO) << "ConfigurationFile: Saving to '" << _fileName << "'..." << std::endl; if(getLocation() == ConfigurationFile::IN_CAMERA && !_saveAllDataFiles(_mainConfigurationFile->_hardwareID + "-")) return false; return write(fout); } bool ConfigSet::_set(const String &name, const String &value) { String n = name, v = value; trim(n); trim(v); params[n] = v; bool present = false; for(auto i = 0; i < paramNames.size(); i++) if(paramNames[i] == n) { present = true; break; } if(!present) paramNames.push_back(name); return true; } bool ConfigSet::set(const String &name, const String &value) { return _set(name, value); } bool ConfigSet::setBoolean(const String &name, bool value) { if(value) return _set(name, "true"); else return _set(name, "false"); } bool ConfigSet::setFloat(const String &name, float value) { OutputStringStream o; o << value; return _set(name, o.str()); } bool ConfigSet::setInteger(const String &name, int value) { OutputStringStream o; o << value; return _set(name, o.str()); } bool ConfigurationFile::_set(const String &section, const String &name, const String &value) { Lock<Mutex> _(_mutex); if(configs.find(section) == configs.end()) configs[section]; // Create section ConfigSet &set = configs.at(section); return set._set(name, value); } bool ConfigurationFile::set(const String &section, const String &name, const String &value) { if(section == "global" && name == "name") _profileName = value; return _set(section, name, value); } bool ConfigurationFile::setBoolean(const String &section, const String &name, bool value) { if(value) return _set(section, name, "true"); else return _set(section, name, "false"); } bool ConfigurationFile::setFloat(const String &section, const String &name, float value) { OutputStringStream s; s << value; return _set(section, name, s.str()); } bool ConfigurationFile::setInteger(const String &section, const String &name, int value) { OutputStringStream s; s << value; if(section == "global") { if(name == "id") _id = value; else if(name == "parent") _parentID = value; } return _set(section, name, s.str()); } bool ConfigSet::remove(const String &name) { if(params.find(name) != params.end()) { params.erase(params.find(name)); for(auto i = paramNames.begin(); i != paramNames.end(); i++) if(name == *i) { paramNames.erase(i); break; } return true; } return false; } bool ConfigurationFile::remove(const String &section, const String &name) { if(configs.find(section) != configs.end()) { ConfigSet &set = configs.at(section); if(set.remove(name)) { if(set.isEmpty()) { configs.erase(configs.find(section)); // Remove section } return true; } } return false; } bool ConfigurationFile::removeSection(const String &section) { auto cf = configs.find(section); if(cf != configs.end()) { configs.erase(cf); return true; } return false; } bool ConfigurationFile::removeFile() { if(_fileName.size() == 0) { logger(LOG_ERROR) << "ConfigurationFile: No file present for current configuration" << std::endl; return false; } InputFileStream f(_fileName); if(!f.good()) { logger(LOG_ERROR) << "ConfigurationFile: Could not find file '" << _fileName << "'" << std::endl; return false; } f.close(); if(::remove(_fileName.c_str()) != 0) { logger(LOG_ERROR) << "ConfigurationFile: Failed to remove file '" << _fileName << "'" << std::endl; return false; } return true; } bool ConfigurationFile::isValidCameraProfile() { if(!isPresent("global", "id")) { logger(LOG_ERROR) << "MainConfigurationFile: Could not get ID of profile " << _fileName << std::endl; return false; } int id = getInteger("global", "id"); if(_mainConfigurationFile->getCameraProfile(id) != 0) { logger(LOG_ERROR) << "MainConfigurationFile: A profile with ID = " << id << " already exists." << std::endl; return false; } if(!isPresent("global", "name")) { logger(LOG_ERROR) << "MainConfigurationFile: Could not get name of profile in " << _fileName << std::endl; return false; } return true; } bool ConfigurationFile::_copyFromParentIfNotPresent(ConfigurationFile *to, bool recurse) { if(!_mainConfigurationFile) return true; ConfigurationFile *parent = _mainConfigurationFile->getCameraProfile(_parentID); if(!parent) return true; for(auto c = parent->configs.begin(); c != parent->configs.end(); c++) { for(auto i = c->second.params.begin(); i != c->second.params.end(); i++) { if(to->isPresent(c->first, i->first, false)) continue; to->set(c->first, i->first, i->second); } } if(recurse) return parent->_copyFromParentIfNotPresent(to, recurse); else return true; } bool MainConfigurationFile::read(const String &configFile) { if(!ConfigurationFile::read(configFile)) return false; _cameraProfiles.clear(); _cameraProfileNames.clear(); _currentCameraProfile = 0; _currentCameraProfileID = -1; String cameraProfiles; if(!isPresent("core", CAMERA_PROFILES)) { logger(LOG_ERROR) << "Could not find 'camera_profiles' in " << configFile << std::endl; return false; } cameraProfiles = get("core", CAMERA_PROFILES); Vector<String> cp; split(cameraProfiles, ',', cp); for(auto i = 0; i < cp.size(); i++) { const String &profileConfigFile = trim(cp[i]); ConfigurationFile cf(this); int id; if(!cf.read(profileConfigFile)) { logger(LOG_ERROR) << "MainConfigurationFile: Could not read " << profileConfigFile << std::endl; return false; } if(!cf.isValidCameraProfile()) { logger(LOG_ERROR) << "MainConfigurationFile: '" << profileConfigFile << "' is not a valid camera profile." << std::endl; return false; } id = cf.getInteger("global", "id"); String cameraProfileName = cf.get("global", "name"); _cameraProfiles[id] = cf; _cameraProfileNames[id] = cameraProfileName; } if(!isPresent("core", "default_profile")) { logger(LOG_ERROR) << "MainConfigurationFile: Default profile not defined in " << configFile << std::endl; return false; } _defaultCameraProfileID = getInteger("core", "default_profile"); if(_cameraProfiles.find(_defaultCameraProfileID) == _cameraProfiles.end()) { logger(LOG_ERROR) << "MainConfigurationFile: Default profile not valid in " << configFile << std::endl; return false; } if(!setCurrentCameraProfile(_defaultCameraProfileID)) { logger(LOG_ERROR) << "MainConfigurationFile: Default profile is defined but not found in " << configFile << std::endl; return false; } return true; } ConfigurationFile *MainConfigurationFile::getCameraProfile(const int id) { if(_cameraProfiles.find(id) != _cameraProfiles.end()) { return &_cameraProfiles.at(id); } return 0; } ConfigurationFile *MainConfigurationFile::getDefaultCameraProfile() { return getCameraProfile(_defaultCameraProfileID); } bool MainConfigurationFile::setCurrentCameraProfile(const int id) { if(_cameraProfiles.find(id) != _cameraProfiles.end()) { _currentCameraProfileID = id; _currentCameraProfile = &_cameraProfiles.at(id); return true; } return false; } int MainConfigurationFile::_getNewCameraProfileID(bool inHost) { int maxID = 0; for(auto c = _cameraProfiles.begin(); c != _cameraProfiles.end(); c++) { if((inHost && c->second.getLocation() == ConfigurationFile::IN_CAMERA) || (!inHost && c->second.getLocation() == ConfigurationFile::IN_HOST)) continue; maxID = std::max(maxID, c->first); } if(inHost && maxID == 0) maxID = 128; return maxID + 1; } int MainConfigurationFile::addCameraProfile(const String &profileName, const int parentID) { if(parentID >= 0 && _cameraProfiles.find(parentID) == _cameraProfiles.end()) return -1; int id = _getNewCameraProfileID(); _cameraProfiles[id] = ConfigurationFile(this); _cameraProfiles[id].setInteger("global", "id", id); _cameraProfiles[id].set("global", "name", profileName); if(parentID >= 0) _cameraProfiles[id].setInteger("global", "parent", parentID); _cameraProfileNames[id] = profileName; String fileName = profileName; fileName.erase(std::remove(fileName.begin(), fileName.end(), ' '), fileName.end()); fileName = _mainConfigName + fileName + ".conf"; if(!_cameraProfiles[id].write(fileName)) { logger(LOG_WARNING) << "MainConfigurationFile: Could not write configuration file for '" << profileName << "' to '" << fileName << "'." << std::endl; } if(!_updateCameraProfileList()) { logger(LOG_WARNING) << "MainConfigurationFile: Could not update profile list in main configuration file '" << _fileName << "'." << std::endl; } return id; } bool MainConfigurationFile::_updateCameraProfileList() { String n; bool first = true; for(auto c = _cameraProfiles.begin(); c != _cameraProfiles.end(); c++) { if(c->second.getLocation() == ConfigurationFile::IN_CAMERA) continue; if(!first) n += ", "; first = false; n += basename(c->second.getConfigFileName()); } if(!set("core", "camera_profiles", n)) return false; if(!write()) return false; return true; } bool MainConfigurationFile::removeAllHardwareCameraProfiles() { bool tryAgain = true; while(tryAgain) { tryAgain = false; for(auto c = _cameraProfiles.begin(); c != _cameraProfiles.end(); c++) { if(c->second.getLocation() == IN_HOST) continue; if(!_removeCameraProfile(c->first, false)) return false; else { tryAgain = true; break; } } } if(!writeToHardware()) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to remove all hardware profiles." << std::endl; return false; } return true; } bool MainConfigurationFile::removeCameraProfile(const int id) { return _removeCameraProfile(id); } bool MainConfigurationFile::_removeCameraProfile(const int id, bool updateHardware) { if(_cameraProfiles.find(id) == _cameraProfiles.end()) return false; ConfigurationFile *c = &_cameraProfiles.at(id); ConfigurationFile *parent = 0; if(_cameraProfiles.find(c->_parentID) != _cameraProfiles.end()) parent = &_cameraProfiles.at(c->_parentID); bool refreshHardware = false; if(c->getLocation() == IN_HOST) { if(!c->removeFile()) return false; } else refreshHardware = true; // Update all those profiles which have this profile as its parent. for(auto config = _cameraProfiles.begin(); config != _cameraProfiles.end(); config++) { if(config->second._parentID == id) { if(!config->second._copyFromParentIfNotPresent(&config->second, false)) { return false; } if(parent) { config->second.setInteger("global", "parent", c->_parentID); config->second._parentID = c->_parentID; } if(config->second.getLocation() == IN_HOST) { if(!config->second.write()) { return false; } } else { refreshHardware = true; } } } _cameraProfiles.erase(_cameraProfiles.find(id)); if(_cameraProfileNames.find(id) != _cameraProfileNames.end()) _cameraProfileNames.erase(_cameraProfileNames.find(id)); if(id == _defaultCameraProfileIDInHardware) { bool changed = false; for(auto config = _cameraProfiles.begin(); config != _cameraProfiles.end(); config++) if(config->second.getLocation() == IN_CAMERA) { changed = true; _defaultCameraProfileIDInHardware = config->first; break; } if(!changed) // Are there H/W profiles remaining? _defaultCameraProfileIDInHardware = -1; } if(updateHardware && refreshHardware && !writeToHardware()) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to update hardware data after removing profile with id = " << id << std::endl; return false; } if(!_updateCameraProfileList()) { logger(LOG_WARNING) << "MainConfigurationFile: Could not update profile list in main configuration file '" << _fileName << "'." << std::endl; } if(id == _defaultCameraProfileID) { bool changed = false; for(auto config = _cameraProfiles.begin(); config != _cameraProfiles.end(); config++) if(config->second.getLocation() == IN_HOST) { if(!setDefaultCameraProfile(config->first)) logger(LOG_ERROR) << "MainConfigurationFile: Failed to update the default profile ID to '" << config->first << "'" << std::endl; break; } } if(id == _currentCameraProfileID) { if(id != _defaultCameraProfileID) return setCurrentCameraProfile(_defaultCameraProfileID); else if(_cameraProfiles.size() > 0) return setCurrentCameraProfile(_cameraProfiles.begin()->first); } return true; } String MainConfigurationFile::get(const String &section, const String &name) const { String value; if(_currentCameraProfile && _currentCameraProfile->_get(section, name, value)) { return value; } if(ConfigurationFile::_get(section, name, value)) return value; return ""; } bool MainConfigurationFile::isPresent(const Voxel::String &section, const Voxel::String &name, bool includeParent) const { if(_currentCameraProfile && _currentCameraProfile->isPresent(section, name, includeParent)) return true; if(ConfigurationFile::isPresent(section, name, includeParent)) return true; return false; } bool MainConfigurationFile::getCameraProfileName(const int id, String &cameraProfileName) { if(_cameraProfileNames.find(id) != _cameraProfileNames.end()) { cameraProfileName = _cameraProfileNames.at(id); return true; } return false; } bool MainConfigurationFile::readFromHardware() { SerializedObject so; Version version; version.major = version.minor = 0; TimeStampType timestamp = 0; Configuration c; String f = _hardwareID + ".bin"; InputFileStream fs; if(c.getConfFile(f)) { fs.open(f, std::ios::in | std::ios::binary); if(fs.good()) { fs.read((char *)&version, sizeof(version)); fs.read((char *)&timestamp, sizeof(timestamp)); } } bool ret = false; if(!hasHardwareConfigurationSupport() || !(ret = _hardwareSerializer->read(version, timestamp, so)) || so.size() == 0) // Last condition is when the data in hardware and backup file in host are the same... { if(hasHardwareConfigurationSupport()) { if(!ret) logger(LOG_WARNING) << "MainConfigurationFile: Failed to read configuration from hardware." << std::endl; else if(so.size() == 0) logger(LOG_INFO) << "MainConfigurationFile: Reading from local copy of hardware configuration data" << std::endl; } if(!fs.is_open() || !fs.good()) { if(hasHardwareConfigurationSupport()) logger(LOG_WARNING) << "MainConfigurationFile: Could not open file '" << f << "'" << std::endl; return false; } fs.seekg(0, std::ios::end); int size = (int)fs.tellg() - sizeof(timestamp) - sizeof(version); if(size == 0) { logger(LOG_ERROR) << "MainConfigurationFile: Null config data '" << f << "'" << std::endl; return false; } so.resize(size); fs.seekg(sizeof(timestamp) + sizeof(version), std::ios::beg); fs.clear(); fs.read((char *)so.getBytes().data(), size); } else { if(!_saveHardwareImage(version, timestamp, so)) { logger(LOG_WARNING) << "MainConfigurationFile: Failed to save locally the configuration image from hardware." << std::endl; } } uint8_t defaultProfileID; if(so.get((char *)&defaultProfileID, sizeof(defaultProfileID)) != sizeof(defaultProfileID)) return false; while(so.size() > so.currentGetOffset()) { ConfigDataPacket p; if(!p.read(so)) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to read configuration packet." << std::endl; return false; } if(p.type == ConfigDataPacket::PACKET_CONFIG) { ConfigurationFile cf(this); int id; InputStringStream ss(String(p.object.getBytes().data(), p.object.size())); if(!cf.read(ss)) { logger(LOG_ERROR) << "MainConfigurationFile: Could not read profile from hardware" << std::endl; return false; } cf._fileName = _hardwareID + "-" + cf._profileName + ".conf"; if(!cf.isValidCameraProfile()) { logger(LOG_ERROR) << "MainConfigurationFile: Profile read from hardware, is not a valid camera profile." << std::endl; return false; } cf._location = ConfigurationFile::IN_CAMERA; id = cf.getInteger("global", "id"); String cameraProfileName = cf.get("global", "name"); _cameraProfiles[id] = cf; _cameraProfileNames[id] = cameraProfileName; } else if(p.type == ConfigDataPacket::PACKET_2D_DATA_FILE) { uint8_t id; if(p.object.get((char *)&id, sizeof(id)) != sizeof(id)) { logger(LOG_ERROR) << "MainConfigurationFile: Could not read 2D data file from hardware" << std::endl; return false; } ConfigurationFile *config = getCameraProfile(id); if(!config) { logger(LOG_ERROR) << "MainConfigurationFile: Invalid camera profile with id = '" << (uint)id << "' found for 2D data file from hardware" << std::endl; return false; } SerializableString s; if(!s.read(p.object)) { logger(LOG_ERROR) << "MainConfigurationFile: Could not read section name for 2D data file from hardware" << std::endl; return false; } String section = s; if(!s.read(p.object)) { logger(LOG_ERROR) << "MainConfigurationFile: Could not read field name for 2D data file from hardware" << std::endl; return false; } String field = s; if(!config->isPresent(section, field)) { logger(LOG_ERROR) << "MainConfigurationFile: Configuration with id = " << id << ", does not contain section = " << section << ", field = " << field << std::endl; return false; } String name = config->get(section, field); if(name.compare(0, sizeof(FILE_PREFIX) - 1, FILE_PREFIX) != 0) { logger(LOG_ERROR) << "MainConfigurationFile: Value at section = " << section << ", field = " << field << ", in configuration with id = " << id << ", is invalid. Value = " << name << std::endl; return false; } name = name.substr(sizeof(FILE_PREFIX) - 1); Data2DCodec codec(_quantizationFactor); Data2DCodec::ByteArray in; Data2DCodec::Array2D out; in.resize(p.object.size() - p.object.currentGetOffset()); p.object.get((char *)in.data(), in.size()); if(!codec.decompress(in, out)) { logger(LOG_ERROR) << "MainConfigurationFile: Could not decompress data at section = " << section << ", field = " << field << ", in configuration with id = " << id << std::endl; return false; } config->_dataFiles[name].resize(out.size()*sizeof(out[0])); memcpy(config->_dataFiles[name].data(), out.data(), out.size()*sizeof(out[0])); } } if(getCameraProfile(defaultProfileID) != 0) _defaultCameraProfileIDInHardware = defaultProfileID; return true; } bool MainConfigurationFile::_saveHardwareImage(Version &version, TimeStampType &timestamp, SerializedObject &so) { Configuration c; String f = _hardwareID + ".bin", path; if(!_hardwareSerializer) { logger(LOG_ERROR) << "MainConfigurationFile: No hardware serializer present." << std::endl; return false; } if(!c.getLocalConfFile(f)) return false; if(!_hardwareSerializer->writeToFile(f, version, timestamp, so)) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to write to hardware." << std::endl; return false; } return true; } bool MainConfigurationFile::writeToHardware() { OutputStringStream ss; uint8_t defaultProfileID = _defaultCameraProfileIDInHardware; ss.write((char *)&defaultProfileID, sizeof(defaultProfileID)); for(auto c = _cameraProfiles.begin(); c != _cameraProfiles.end(); c++) { if(c->second.getLocation() == ConfigurationFile::IN_HOST) continue; ConfigDataPacket cp; cp.type = ConfigDataPacket::PACKET_CONFIG; OutputStringStream oss; if(!c->second.write(oss)) return false; String s = oss.str(); cp.size = s.size(); cp.object.resize(s.size()); cp.object.put((const char *)&s[0], s.size()); if(!cp.write(ss)) return false; if(!c->second._serializeAllDataFiles(ss)) return false; } SerializedObject so; String out = ss.str(); so.resize(out.size()); memcpy(so.getBytes().data(), &out[0], so.size()); Version version; version.major = CONFIG_VERSION_MAJOR; version.minor = CONFIG_VERSION_MINOR; Timer t; TimeStampType timestamp = t.getCurrentRealTime(); if(hasHardwareConfigurationSupport() && !_hardwareSerializer->write(version, timestamp, so)) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to write configuration to hardware." << std::endl; return false; } if(!_saveHardwareImage(version, timestamp, so)) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to save configuration image locally." << std::endl; return false; } return true; } bool MainConfigurationFile::saveCameraProfileToHardware(int &id, bool saveParents, bool setAsDefault, const String &namePrefix) { Vector<int> newIDsAdded; Vector<ConfigurationFile> oldIDsModified; if(!_saveCameraProfileToHardware(id, newIDsAdded, oldIDsModified, saveParents, true, setAsDefault, namePrefix)) { _rollbackCameraProfiles(newIDsAdded, oldIDsModified); return false; } else return true; } bool MainConfigurationFile::_saveCameraProfileToHardware(int &id, Vector<int> &newIDsAdded, Vector<ConfigurationFile> &oldIDsModified, bool saveParents, bool updateHardware, bool setAsDefault, const String &namePrefix) { ConfigurationFile *config = getCameraProfile(id); if(!config) return false; ConfigurationFile oldconfig(*config); ConfigurationFile newconfig(*config); int newid = id; newconfig.setProfileName(namePrefix + newconfig.getProfileName()); if(config->getLocation() == ConfigurationFile::IN_HOST) // Is it in host and not camera? { newid = _getNewCameraProfileID(false); // Get new ID for camera newconfig.setID(newid); newconfig._location = ConfigurationFile::IN_CAMERA; newconfig._fileName = _hardwareID + "-" + newconfig.getProfileName() + ".conf"; } _cameraProfiles[newid] = newconfig; // Set once now to aid saving parents _cameraProfileNames[newid] = newconfig._profileName; if(newid != id) newIDsAdded.push_back(newid); else oldIDsModified.push_back(oldconfig); ConfigurationFile *parent = getCameraProfile(newconfig._parentID); if(parent && parent->getLocation() == ConfigurationFile::IN_HOST) { if(!saveParents) { if(!newconfig.mergeParentConfiguration()) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to merge data from parents" << std::endl; return false; } } else { int parentID = newconfig._parentID; if(!_saveCameraProfileToHardware(parentID, newIDsAdded, oldIDsModified, saveParents, false, false, namePrefix)) { logger(LOG_ERROR) << "MainConfigurationFile: Failed to prepare parent to write to hardware." << std::endl; return false; } newconfig.setParentID(parentID); parent = getCameraProfile(parentID); } } std::cout << "Saving ID = " << id << " (" << newid << ") to hardware..." << std::endl; _cameraProfiles[newid] = newconfig; // Set again to reflect changes related to parent. bool defaultSet = false; int _previousDefault = _defaultCameraProfileIDInHardware; if(_defaultCameraProfileIDInHardware == -1 || setAsDefault) { defaultSet = true; _defaultCameraProfileIDInHardware = newid; } id = newid; if(updateHardware) { if(writeToHardware()) { if(_currentCameraProfileID == id) return setCurrentCameraProfile(newid); return true; } else { if(defaultSet) _defaultCameraProfileIDInHardware = _previousDefault; return false; } } return true; } bool MainConfigurationFile::_rollbackCameraProfiles(const Vector< int >& newIDsAdded, const Vector< ConfigurationFile >& oldIDsModified) { // Roll back old IDs for(auto &c: oldIDsModified) { _cameraProfiles[c.getID()] = c; _cameraProfileNames[c.getID()] = c._profileName; } // Roll back and remove all new IDs for(auto i: newIDsAdded) { _cameraProfileNames.erase(i); _cameraProfiles.erase(i); } return true; } bool MainConfigurationFile::removeDefaultCameraProfileIDInCamera() { if(_defaultCameraProfileIDInHardware == -1) { logger(LOG_ERROR) << "Default profile ID is not set in hardware." << std::endl; return false; } int id = _defaultCameraProfileIDInHardware; _defaultCameraProfileIDInHardware = -1; if(!writeToHardware()) { _defaultCameraProfileIDInHardware = id; return false; } return true; } bool MainConfigurationFile::setDefaultCameraProfile(const int id) { ConfigurationFile *config = getCameraProfile(id); if(!config) return false; logger(LOG_INFO) << "MainConfigurationFile: Setting id = " << id << ", as default camera profile." << std::endl; if(config->getLocation() == ConfigurationFile::IN_CAMERA) { _defaultCameraProfileIDInHardware = id; return writeToHardware(); } else { _defaultCameraProfileID = id; if(!setInteger("core", "default_profile", id)) return false; return write(); } } }
23.965023
218
0.628209
[ "object", "vector" ]
a65585cd2bae57faaaceecbab007238745e17429
14,923
cpp
C++
src/schedule/function_schedule_context.cpp
ChanSiYuan/nncase
6f95be62d1686f5ea2a9806ac97e5817bf1eda3c
[ "Apache-2.0" ]
510
2018-12-29T06:49:36.000Z
2022-03-30T08:36:29.000Z
src/schedule/function_schedule_context.cpp
ChanSiYuan/nncase
6f95be62d1686f5ea2a9806ac97e5817bf1eda3c
[ "Apache-2.0" ]
459
2019-02-17T13:31:29.000Z
2022-03-31T05:55:38.000Z
src/schedule/function_schedule_context.cpp
ChanSiYuan/nncase
6f95be62d1686f5ea2a9806ac97e5817bf1eda3c
[ "Apache-2.0" ]
155
2019-04-16T08:43:24.000Z
2022-03-21T07:27:26.000Z
/* Copyright 2019-2021 Canaan Inc. * * 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 <fmt/format.h> #include <fstream> #include <nncase/ir/ops/bitcast.h> #include <nncase/ir/ops/call.h> #include <nncase/ir/ops/concat.h> #include <nncase/ir/ops/constant.h> #include <nncase/ir/ops/slice.h> #include <nncase/ir/visitor.h> #include <nncase/schedule/schedule_context.h> #include <nncase/targets/target.h> #include <nncase/transforms/neutral/optimize_allocation.h> using namespace nncase; using namespace nncase::ir; using namespace nncase::schedule; using namespace nncase::ir::transforms; namespace { memory_location_t decide_memory_location(ir::output_connector &conn, [[maybe_unused]] bool skip_buffer_alias) noexcept { auto &opcode = conn.owner().runtime_opcode(); if (opcode == op_input_node) return mem_input; else if (opcode == op_constant) return conn.memory_location(); auto inputs = conn.connections(); if (std::any_of(inputs.begin(), inputs.end(), [](input_connector *conn) { return conn->owner().runtime_opcode() == op_output_node; })) return mem_output; //if (opcode == op_call && conn.memory_location() == mem_data) // return mem_shared_data; //if (conn.memory_location() == mem_data // && std::any_of(inputs.begin(), inputs.end(), [](input_connector *conn) { return conn->owner().runtime_opcode() == op_call; })) // return mem_shared_data; return conn.memory_location(); } void update_absolute_offset(logical_buffer &buffer) { if (buffer.absolute_offset()) return; if (buffer.parent()) { auto &parent_buffer = *buffer.parent()->parent; update_absolute_offset(parent_buffer); buffer.absolute_offset() = buffer.parent()->offset + *parent_buffer.absolute_offset(); } else { buffer.absolute_offset() = 0; } } } function_schedule_context::function_schedule_context(ir::graph &graph, module_schedule_context &mod_sched) : mod_sched_(mod_sched) { this->graph = &graph; this->outputs_ = graph.outputs(); this->module = &mod_sched.module_result(); create_allocators(); } void function_schedule_context::create_allocators() { mod_sched_.model_sched().target().register_allocators(module_type(), allocators_, allocator_holder_); // Input & output don't actually allocate inside the module, they are passed from the caller // They just need relative offset, so don't inherit previous allocators for (auto allocator : mod_sched_.allocators()) { if (allocator.first != mem_input && allocator.first != mem_output) allocators_[allocator.first] = allocator.second; } } void function_schedule_context::visit_function(caller_context &caller_ctx) { make_logical_buffers(caller_ctx); if (!mod_sched_.model_sched().skip_buffer_alias()) analyze_buffer_alias(); update_offset(); fix_lifetime(); generate_compute_sequence(); make_physical_buffers(); allocate_physical_buffers(); } void function_schedule_context::end_schedule() { for (auto &allocator : allocator_holder_) { allocator->finish(); if (allocator.get() == allocators_.at(mem_input)) input_pool_size = allocator->max_usage(); else if (allocator.get() == allocators_.at(mem_output)) output_pool_size = allocator->max_usage(); } assign_allocations(); auto dump_dir = mod_sched_.model_sched().dump_dir(); if (!dump_dir.empty()) dump(dump_dir); } void function_schedule_context::generate_compute_sequence() { std::unordered_set<node *> used_inputs; auto alloc_visitor = make_relay_ir_visitor([&](node &node) { if (node.runtime_opcode() == op_input_node) used_inputs.emplace(&node); else if (node.attributes() & node_attr_action) compute_sequence.emplace_back(&node); }); alloc_visitor.visit(outputs_); size_t i = 0; for (auto in : graph->inputs()) { if (used_inputs.contains(in)) { compute_sequence.insert(compute_sequence.begin() + i, in); i++; } } } void function_schedule_context::make_logical_buffers(caller_context &caller_ctx) { auto skip_buffer_alias = mod_sched_.model_sched().skip_buffer_alias(); lifetime_recorder lr(logical_buffers_, logical_buffer_map_); // 1. Adjust base age to caller's age lr.current_age(caller_ctx.lifetime.current_age()); // 2. Estimate buffer lifetime auto alloc_visitor = make_relay_ir_visitor([&](node &node) { for (auto out : node.outputs()) lr.allocate(*out, decide_memory_location(*out, skip_buffer_alias)); lr.grow_age(); if (auto c = node_cast<call>(node)) { caller_context new_caller_ctx { lr }; mod_sched_.model_sched().visit_function(c->target(), new_caller_ctx); } for (auto in : node.inputs()) { auto out = in->connection(); assert(out); lr.release(*out); } }); alloc_visitor.visit(outputs_); // 3. Adjust caller's age to now caller_ctx.lifetime.current_age(lr.current_age()); } void function_schedule_context::analyze_buffer_alias() { pass_manager pmgr(*graph, mod_sched_.model_sched().target()); pmgr.schedule_context(this); pmgr.add_pass<alias_slice_buffer_pass>(); pmgr.add_pass<alias_bitcast_buffer_pass>(); pmgr.add_pass<alias_concat_buffer_pass>(); pmgr.run(); } void function_schedule_context::update_offset() { for (auto &bp : logical_buffers_) update_absolute_offset(bp); } void function_schedule_context::fix_lifetime() { // Assign parent for (auto &bp : logical_buffers_) { auto &p = bp.parent(); if (p) { auto parent = p->parent; while (parent->parent()) parent = parent->parent()->parent; p->parent = parent; } } // Extend lifetime for (auto &bp : logical_buffers_) { auto &lifetime = bp.lifetime(); if (bp.parent()) { auto &p_liftime = bp.parent()->parent->lifetime(); auto birth = std::min(lifetime.birth, p_liftime.birth); auto end = std::max(lifetime.end(), p_liftime.end()); p_liftime.birth = birth; p_liftime.age = end - birth; } } } void function_schedule_context::make_physical_buffers() { std::unordered_map<logical_buffer *, size_t> physical_ids; for (auto &bp : logical_buffers_) { if (!bp.parent()) { auto id = physical_ids.size(); physical_ids.emplace(&bp, id); auto &pb = physical_buffers_.emplace_back(id, bp); if (auto c = node_cast<constant>(bp.owner().owner())) pb.alignment(c->alignment()); } } // Assign parents for (auto &bp : logical_buffers_) { auto parent = bp.parent() ? bp.parent()->parent : &bp; bp.physical() = &physical_buffers_.at(physical_ids.at(parent)); } } void function_schedule_context::allocate_physical_buffers() { std::vector<physical_buffer *> orders; orders.reserve(physical_buffers_.size()); for (auto &b : physical_buffers_) orders.emplace_back(&b); std::sort(orders.begin(), orders.end(), [](const physical_buffer *lhs, const physical_buffer *rhs) { return lhs->lifetime().birth < rhs->lifetime().birth; }); for (auto &b : orders) { auto location = b->owner().memory_location(); if (location != mem_shared_data) allocators_.at(location)->mark(*b); else mod_sched_.shared_allocator(b->owner().shared_module()).mark(*b); } } void function_schedule_context::assign_allocations() { for (auto &b : physical_buffers_) b.allocation() = memory_span { allocators_.at(b.owner().memory_location())->allocations().at(&b) }; auto alloc_visitor = make_relay_ir_visitor([&](node &node) { for (auto out : node.outputs()) { auto &lbuf = *logical_buffer_map_.at(out); auto &owner = lbuf.physical()->owner(); auto &memory = lbuf.physical()->allocation(); // TODO: take account of subbuffer buffer_allocation alloc {}; alloc.memory_location = owner.memory_location(); alloc.type = lbuf.type(); alloc.size = allocators_.at(alloc.memory_location)->get_size_in_bytes(lbuf); alloc.shape = lbuf.shape(); assert(lbuf.strides_shape().size()); alloc.strides_shape = lbuf.strides_shape(); alloc.strides = to_strides(alloc.strides_shape); alloc.start = memory.start; alloc.start += *lbuf.absolute_offset(); module->allocations.emplace(out, alloc); } }); alloc_visitor.visit(outputs_); } void function_schedule_context::dump(const std::filesystem::path &dump_dir) { std::ofstream writer(dump_dir / (graph->escaped_name() + ".sched")); auto fmt_shape = [&](const logical_buffer &buf) { auto alloc = module->allocations.at(&buf.owner()); return fmt::format("<{} {} {} bytes of {}>", datatype_names(buf.type()), ir::to_string(buf.shape()), alloc.size, ir::to_string(buf.strides_shape())); }; // 1. allocation writer << ".physical_buffer" << std::endl; for (auto &buf : physical_buffers_) { auto alloc = buf.allocation(); writer << fmt::format("%{} : {} @{}[{}, {}]", buf.id(), fmt_shape(buf.owner()), to_string(buf.owner().memory_location()), alloc.start, alloc.end()) << std::endl; } // 2. compute sequence writer << std::endl << ".compute_sequence" << std::endl; //auto print_inputs = [&]() // 2.1 function name writer << "fn " << graph->escaped_name() << "("; // 2.2 inputs { bool comma = false; for (auto in : graph->inputs()) { if (!comma) comma = true; else writer << ", "; auto &lbuf = *logical_buffer_map_.at(&in->output()); auto &pbuf = *lbuf.physical(); writer << '%' << pbuf.id(); } } writer << ") : ("; // 2.2 input shapes { bool comma = false; for (auto in : graph->inputs()) { if (!comma) comma = true; else writer << ", "; auto &lbuf = *logical_buffer_map_.at(&in->output()); writer << fmt_shape(lbuf); } } writer << ") -> ("; // 2.3 output shapes { bool comma = false; for (auto in : graph->outputs()) { if (!comma) comma = true; else writer << ", "; auto &lbuf = *logical_buffer_map_.at(in->input().connection()); writer << fmt_shape(lbuf); } } writer << ")" << std::endl; #define IDENT " " // 2.4 body writer << '{' << std::endl; for (auto node : compute_sequence) { // 2.4.1 outputs if (node->runtime_opcode() != op_output_node) { bool comma = false; for (auto out : node->outputs()) { if (!comma) comma = true; else writer << ", "; auto &lbuf = *logical_buffer_map_.at(out); auto &pbuf = *lbuf.physical(); auto &alloc = module->allocations.at(out); auto pbuf_alloc = pbuf.allocation(); if (alloc.size == pbuf_alloc.size) writer << IDENT << fmt::format("%{}", pbuf.id()); else writer << IDENT << fmt::format("%{}[{}, {}]", pbuf.id(), alloc.start - pbuf_alloc.start, alloc.linear_end() - pbuf_alloc.start); } // 2.4.2 inst name writer << " = " << node->runtime_opcode().name << "("; } else { writer << IDENT << "return "; } // 2.4.3 inputs { bool comma = false; for (auto in : node->inputs()) { if (!comma) comma = true; else writer << ", "; auto &lbuf = *logical_buffer_map_.at(in->connection()); auto &pbuf = *lbuf.physical(); auto &alloc = module->allocations.at(in->connection()); auto pbuf_alloc = pbuf.allocation(); if (alloc.size == pbuf.allocation().size) writer << fmt::format("%{}", pbuf.id()); else writer << fmt::format("%{}[{}, {}]", pbuf.id(), alloc.start - pbuf_alloc.start, alloc.linear_end() - pbuf_alloc.start); } } if (node->runtime_opcode() == op_output_node) { writer << " : ("; } else { writer << ") : ("; } // 2.4.4 input shapes { bool comma = false; for (auto in : node->inputs()) { if (!comma) comma = true; else writer << ", "; auto &lbuf = *logical_buffer_map_.at(in->connection()); writer << fmt_shape(lbuf); } } if (node->runtime_opcode() == op_output_node) { writer << ")" << std::endl; continue; } else { writer << ") -> ("; } // 2.4.5 output shapes { bool comma = false; for (auto out : node->outputs()) { if (!comma) comma = true; else writer << ", "; auto &lbuf = *logical_buffer_map_.at(out); writer << fmt_shape(lbuf); } } writer << ")" << std::endl; } writer << '}' << std::endl; }
29.550495
162
0.556456
[ "shape", "vector" ]
a6577d9c7a9b37374377935ee8b64a49597f0fab
4,462
hpp
C++
include/iterpp.hpp
green7ea/iterpp
6a37966666fad27051765694f7cf9a1a84f45281
[ "MIT" ]
1
2019-12-16T14:27:45.000Z
2019-12-16T14:27:45.000Z
include/iterpp.hpp
green7ea/iterpp
6a37966666fad27051765694f7cf9a1a84f45281
[ "MIT" ]
null
null
null
include/iterpp.hpp
green7ea/iterpp
6a37966666fad27051765694f7cf9a1a84f45281
[ "MIT" ]
null
null
null
/* * Copyright 2019 Emmanuel Boudreault * * 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. */ #ifndef ITERPP_HPP #define ITERPP_HPP #include <vector> #include <optional> #include <functional> #include <string> template <typename T> struct RangeIter { T start; T end; T inc; __attribute__((always_inline)) std::optional<T> next() { if (start < end) { return start++; } return std::nullopt; } }; template <typename Iterator> struct CppIter { using T = typename Iterator::value_type; Iterator current; Iterator end; __attribute__((always_inline)) std::optional<T> next() { if (current != end) { return *current++; } return std::nullopt; } }; template <typename T, typename Iterator> struct FilterIter { Iterator iter; std::function<bool (T)> func; __attribute__((always_inline)) std::optional<T> next() { for (std::optional<T> item = iter.next(); item; item = iter.next()) { if (func(*item)) { return item; } } return std::nullopt; } }; template <typename In, typename Out, typename Iterator> struct MapIter { Iterator iter; std::function<Out (In)> func; __attribute__((always_inline)) std::optional<Out> next() { const std::optional<In> item = iter.next(); return item ? std::optional<Out>{ func(*item) } : std::nullopt; } }; template <typename T, typename Iterator> struct MetaIter { Iterator iter; __attribute__((always_inline)) std::optional<T> next() { return iter.next(); } __attribute__((always_inline)) MetaIter<T, FilterIter<T, Iterator>> filter(const std::function<bool (T)> &filter_func) { return MetaIter<T, FilterIter<T, Iterator>> { FilterIter<T, Iterator> { iter, filter_func } }; } template <typename Out> __attribute__((always_inline)) MetaIter<Out, MapIter<T, Out, Iterator>> map(const std::function<Out (T)> &map_func) { return MetaIter<Out, MapIter<T, Out, Iterator>> { MapIter<T, Out, Iterator> { iter, map_func } }; } __attribute__((always_inline)) std::optional<T> find_first(const std::function<bool (T)> &func) { for (std::optional<T> item = iter.next(); item; item = iter.next()) { if (func(*item)) { return item; } } return std::nullopt; } __attribute__((always_inline)) T sum(T start = 0) { for (std::optional<T> item = iter.next(); item; item = iter.next()) { start += *item; } return start; } __attribute__((always_inline)) std::string join(const std::string &sep = ", ") { std::string str = ""; const std::optional<T> first = iter.next(); if (first) { str.append(*first); } for (std::optional<T> item = iter.next(); item; item = iter.next()) { str.append(sep); str.append(*item); } return str; } }; template <typename Iterator> __attribute__((always_inline)) static MetaIter<typename Iterator::value_type, CppIter<Iterator>> iter(const Iterator &begin, const Iterator &end) { return MetaIter<typename Iterator::value_type, CppIter<Iterator>> { CppIter<Iterator> { begin, end } }; } __attribute__((always_inline)) static MetaIter<int, RangeIter<int>> range(int start, int stop, int inc = 1) { return MetaIter<int, RangeIter<int>> { RangeIter<int> { start, stop, inc } }; } #endif // ITERPP_HPP
21.349282
71
0.655536
[ "vector" ]
a659415520062e8bbd09d7e042a6491f90cb9baa
37,269
cpp
C++
src/qt/qtwebkit/Source/WebCore/rendering/RenderGrid.cpp
viewdy/phantomjs
eddb0db1d253fd0c546060a4555554c8ee08c13c
[ "BSD-3-Clause" ]
1
2021-02-09T10:24:31.000Z
2021-02-09T10:24:31.000Z
src/qt/qtwebkit/Source/WebCore/rendering/RenderGrid.cpp
mrampersad/phantomjs
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
[ "BSD-3-Clause" ]
null
null
null
src/qt/qtwebkit/Source/WebCore/rendering/RenderGrid.cpp
mrampersad/phantomjs
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
[ "BSD-3-Clause" ]
1
2017-03-19T13:03:23.000Z
2017-03-19T13:03:23.000Z
/* * Copyright (C) 2011 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. ``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 COMPUTER, INC. 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 "config.h" #include "RenderGrid.h" #include "LayoutRepainter.h" #include "NotImplemented.h" #include "RenderLayer.h" #include "RenderView.h" namespace WebCore { static const int infinity = intMaxForLayoutUnit; class GridTrack { public: GridTrack() : m_usedBreadth(0) , m_maxBreadth(0) { } void growUsedBreadth(LayoutUnit growth) { ASSERT(growth >= 0); m_usedBreadth += growth; } LayoutUnit usedBreadth() const { return m_usedBreadth; } void growMaxBreadth(LayoutUnit growth) { if (m_maxBreadth == infinity) m_maxBreadth = m_usedBreadth + growth; else m_maxBreadth += growth; } LayoutUnit maxBreadthIfNotInfinite() const { return (m_maxBreadth == infinity) ? m_usedBreadth : m_maxBreadth; } LayoutUnit m_usedBreadth; LayoutUnit m_maxBreadth; }; class RenderGrid::GridIterator { WTF_MAKE_NONCOPYABLE(GridIterator); public: // |direction| is the direction that is fixed to |fixedTrackIndex| so e.g // GridIterator(m_grid, ForColumns, 1) will walk over the rows of the 2nd column. GridIterator(const Vector<Vector<Vector<RenderBox*, 1> > >& grid, TrackSizingDirection direction, size_t fixedTrackIndex) : m_grid(grid) , m_direction(direction) , m_rowIndex((direction == ForColumns) ? 0 : fixedTrackIndex) , m_columnIndex((direction == ForColumns) ? fixedTrackIndex : 0) , m_childIndex(0) { ASSERT(m_rowIndex < m_grid.size()); ASSERT(m_columnIndex < m_grid[0].size()); } RenderBox* nextGridItem() { if (!m_grid.size()) return 0; size_t& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m_columnIndex; const size_t endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_grid.size() : m_grid[0].size(); for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex) { const Vector<RenderBox*>& children = m_grid[m_rowIndex][m_columnIndex]; if (m_childIndex < children.size()) return children[m_childIndex++]; m_childIndex = 0; } return 0; } PassOwnPtr<GridCoordinate> nextEmptyGridArea() { if (m_grid.isEmpty()) return nullptr; size_t& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m_columnIndex; const size_t endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_grid.size() : m_grid[0].size(); for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex) { const Vector<RenderBox*>& children = m_grid[m_rowIndex][m_columnIndex]; if (children.isEmpty()) { OwnPtr<GridCoordinate> result = adoptPtr(new GridCoordinate(GridSpan(m_rowIndex, m_rowIndex), GridSpan(m_columnIndex, m_columnIndex))); // Advance the iterator to avoid an infinite loop where we would return the same grid area over and over. ++varyingTrackIndex; return result.release(); } } return nullptr; } private: const Vector<Vector<Vector<RenderBox*, 1> > >& m_grid; TrackSizingDirection m_direction; size_t m_rowIndex; size_t m_columnIndex; size_t m_childIndex; }; RenderGrid::RenderGrid(Element* element) : RenderBlock(element) { // All of our children must be block level. setChildrenInline(false); } RenderGrid::~RenderGrid() { } void RenderGrid::layoutBlock(bool relayoutChildren, LayoutUnit) { ASSERT(needsLayout()); if (!relayoutChildren && simplifiedLayout()) return; // FIXME: Much of this method is boiler plate that matches RenderBox::layoutBlock and Render*FlexibleBox::layoutBlock. // It would be nice to refactor some of the duplicate code. LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); // Regions changing widths can force us to relayout our children. RenderFlowThread* flowThread = flowThreadContainingBlock(); if (logicalWidthChangedInRegions(flowThread)) relayoutChildren = true; if (updateRegionsAndShapesBeforeChildLayout(flowThread)) relayoutChildren = true; LayoutSize previousSize = size(); setLogicalHeight(0); updateLogicalWidth(); layoutGridItems(); LayoutUnit oldClientAfterEdge = clientLogicalBottom(); updateLogicalHeight(); if (size() != previousSize) relayoutChildren = true; layoutPositionedObjects(relayoutChildren || isRoot()); updateRegionsAndShapesAfterChildLayout(flowThread); computeOverflow(oldClientAfterEdge); statePusher.pop(); updateLayerTransform(); // Update our scroll information if we're overflow:auto/scroll/hidden now that we know if // we overflow or not. updateScrollInfoAfterLayout(); repainter.repaintAfterLayout(); setNeedsLayout(false); } void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const { const_cast<RenderGrid*>(this)->placeItemsOnGrid(); // FIXME: This is an inefficient way to fill our sizes as it will try every grid areas, when we would // only want to account for fixed grid tracks and grid items. Also this will be incorrect if we have spanning // grid items. for (size_t i = 0; i < gridColumnCount(); ++i) { const GridTrackSize& trackSize = gridTrackSize(ForColumns, i); LayoutUnit minTrackBreadth = computePreferredTrackWidth(trackSize.minTrackBreadth(), i); LayoutUnit maxTrackBreadth = computePreferredTrackWidth(trackSize.maxTrackBreadth(), i); maxTrackBreadth = std::max(maxTrackBreadth, minTrackBreadth); minLogicalWidth += minTrackBreadth; maxLogicalWidth += maxTrackBreadth; // FIXME: This should add in the scrollbarWidth (e.g. see RenderFlexibleBox). } const_cast<RenderGrid*>(this)->clearGrid(); } void RenderGrid::computePreferredLogicalWidths() { ASSERT(preferredLogicalWidthsDirty()); m_minPreferredLogicalWidth = 0; m_maxPreferredLogicalWidth = 0; // FIXME: We don't take our own logical width into account. Once we do, we need to make sure // we apply (and test the interaction with) min-width / max-width. computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth); LayoutUnit borderAndPaddingInInlineDirection = borderAndPaddingLogicalWidth(); m_minPreferredLogicalWidth += borderAndPaddingInInlineDirection; m_maxPreferredLogicalWidth += borderAndPaddingInInlineDirection; setPreferredLogicalWidthsDirty(false); } LayoutUnit RenderGrid::computePreferredTrackWidth(const Length& length, size_t trackIndex) const { if (length.isFixed()) { // Grid areas don't have borders, margins or paddings so we don't need to account for them. return length.intValue(); } if (length.isMinContent()) { LayoutUnit minContentSize = 0; GridIterator iterator(m_grid, ForColumns, trackIndex); while (RenderBox* gridItem = iterator.nextGridItem()) { // FIXME: We should include the child's fixed margins like RenderFlexibleBox. minContentSize = std::max(minContentSize, gridItem->minPreferredLogicalWidth()); } return minContentSize; } if (length.isMaxContent()) { LayoutUnit maxContentSize = 0; GridIterator iterator(m_grid, ForColumns, trackIndex); while (RenderBox* gridItem = iterator.nextGridItem()) { // FIXME: We should include the child's fixed margins like RenderFlexibleBox. maxContentSize = std::max(maxContentSize, gridItem->maxPreferredLogicalWidth()); } return maxContentSize; } // FIXME: css3-sizing mentions that we should resolve "definite sizes" // (including <percentage> and calc()) but we don't do it elsewhere. return 0; } void RenderGrid::computedUsedBreadthOfGridTracks(TrackSizingDirection direction, Vector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks) { LayoutUnit availableLogicalSpace = (direction == ForColumns) ? availableLogicalWidth() : availableLogicalHeight(IncludeMarginBorderPadding); Vector<GridTrack>& tracks = (direction == ForColumns) ? columnTracks : rowTracks; for (size_t i = 0; i < tracks.size(); ++i) { GridTrack& track = tracks[i]; const GridTrackSize& trackSize = gridTrackSize(direction, i); const Length& minTrackBreadth = trackSize.minTrackBreadth(); const Length& maxTrackBreadth = trackSize.maxTrackBreadth(); track.m_usedBreadth = computeUsedBreadthOfMinLength(direction, minTrackBreadth); track.m_maxBreadth = computeUsedBreadthOfMaxLength(direction, maxTrackBreadth); track.m_maxBreadth = std::max(track.m_maxBreadth, track.m_usedBreadth); } // FIXME: We shouldn't call resolveContentBasedTrackSizingFunctions if we have no min-content / max-content tracks. resolveContentBasedTrackSizingFunctions(direction, columnTracks, rowTracks, availableLogicalSpace); if (availableLogicalSpace <= 0) return; const size_t tracksSize = tracks.size(); Vector<GridTrack*> tracksForDistribution(tracksSize); for (size_t i = 0; i < tracksSize; ++i) tracksForDistribution[i] = tracks.data() + i; distributeSpaceToTracks(tracksForDistribution, 0, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth, availableLogicalSpace); } LayoutUnit RenderGrid::computeUsedBreadthOfMinLength(TrackSizingDirection direction, const Length& trackLength) const { if (trackLength.isFixed() || trackLength.isPercent() || trackLength.isViewportPercentage()) return computeUsedBreadthOfSpecifiedLength(direction, trackLength); ASSERT(trackLength.isMinContent() || trackLength.isMaxContent() || trackLength.isAuto()); return 0; } LayoutUnit RenderGrid::computeUsedBreadthOfMaxLength(TrackSizingDirection direction, const Length& trackLength) const { if (trackLength.isFixed() || trackLength.isPercent() || trackLength.isViewportPercentage()) { LayoutUnit computedBreadth = computeUsedBreadthOfSpecifiedLength(direction, trackLength); // FIXME: We should ASSERT that computedBreadth cannot return infinity but it's currently // possible. See https://bugs.webkit.org/show_bug.cgi?id=107053 return computedBreadth; } ASSERT(trackLength.isMinContent() || trackLength.isMaxContent() || trackLength.isAuto()); return infinity; } LayoutUnit RenderGrid::computeUsedBreadthOfSpecifiedLength(TrackSizingDirection direction, const Length& trackLength) const { // FIXME: We still need to support calc() here (https://webkit.org/b/103761). ASSERT(trackLength.isFixed() || trackLength.isPercent() || trackLength.isViewportPercentage()); return valueForLength(trackLength, direction == ForColumns ? logicalWidth() : computeContentLogicalHeight(style()->logicalHeight()), view()); } const GridTrackSize& RenderGrid::gridTrackSize(TrackSizingDirection direction, size_t i) const { const Vector<GridTrackSize>& trackStyles = (direction == ForColumns) ? style()->gridColumns() : style()->gridRows(); if (i >= trackStyles.size()) return (direction == ForColumns) ? style()->gridAutoColumns() : style()->gridAutoRows(); return trackStyles[i]; } static size_t estimatedGridSizeForPosition(const GridPosition& position) { if (position.isAuto()) return 1; return std::max(position.integerPosition(), 1); } size_t RenderGrid::maximumIndexInDirection(TrackSizingDirection direction) const { const Vector<GridTrackSize>& trackStyles = (direction == ForColumns) ? style()->gridColumns() : style()->gridRows(); size_t maximumIndex = std::max<size_t>(1, trackStyles.size()); for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { // This function bypasses the cache (cachedGridCoordinate()) as it is used to build it. // Also we can't call resolveGridPositionsFromStyle here as it assumes that the grid is build and we are in // the middle of building it. However we should be able to share more code with the previous logic (FIXME). const GridPosition& initialPosition = (direction == ForColumns) ? child->style()->gridItemStart() : child->style()->gridItemBefore(); const GridPosition& finalPosition = (direction == ForColumns) ? child->style()->gridItemEnd() : child->style()->gridItemAfter(); size_t estimatedSizeForInitialPosition = estimatedGridSizeForPosition(initialPosition); size_t estimatedSizeForFinalPosition = estimatedGridSizeForPosition(finalPosition); ASSERT(estimatedSizeForInitialPosition); ASSERT(estimatedSizeForFinalPosition); maximumIndex = std::max(maximumIndex, estimatedSizeForInitialPosition); maximumIndex = std::max(maximumIndex, estimatedSizeForFinalPosition); } return maximumIndex; } LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox* child, Vector<GridTrack>& columnTracks) { // FIXME: We shouldn't force a layout every time this function is called but // 1) Return computeLogicalHeight's value if it's available. Unfortunately computeLogicalHeight // doesn't return if the logical height is available so would need to be changed. // 2) Relayout if the column track's used breadth changed OR the logical height is unavailable. if (!child->needsLayout()) child->setNeedsLayout(true, MarkOnlyThis); child->setOverrideContainingBlockContentLogicalWidth(gridAreaBreadthForChild(child, ForColumns, columnTracks)); // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). child->setOverrideContainingBlockContentLogicalHeight(-1); child->layout(); return child->logicalHeight(); } LayoutUnit RenderGrid::minContentForChild(RenderBox* child, TrackSizingDirection direction, Vector<GridTrack>& columnTracks) { bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizontalWritingMode(); // FIXME: Properly support orthogonal writing mode. if (hasOrthogonalWritingMode) return 0; if (direction == ForColumns) { // FIXME: It's unclear if we should return the intrinsic width or the preferred width. // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html return child->minPreferredLogicalWidth(); } return logicalContentHeightForChild(child, columnTracks); } LayoutUnit RenderGrid::maxContentForChild(RenderBox* child, TrackSizingDirection direction, Vector<GridTrack>& columnTracks) { bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizontalWritingMode(); // FIXME: Properly support orthogonal writing mode. if (hasOrthogonalWritingMode) return LayoutUnit(); if (direction == ForColumns) { // FIXME: It's unclear if we should return the intrinsic width or the preferred width. // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html return child->maxPreferredLogicalWidth(); } return logicalContentHeightForChild(child, columnTracks); } void RenderGrid::resolveContentBasedTrackSizingFunctions(TrackSizingDirection direction, Vector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks, LayoutUnit& availableLogicalSpace) { // FIXME: Split the grid tracks once we support fractions (step 1 of the algorithm). Vector<GridTrack>& tracks = (direction == ForColumns) ? columnTracks : rowTracks; // FIXME: Per step 2 of the specification, we should order the grid items by increasing span. for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { resolveContentBasedTrackSizingFunctionsForItems(direction, columnTracks, rowTracks, child, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::minContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); resolveContentBasedTrackSizingFunctionsForItems(direction, columnTracks, rowTracks, child, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); resolveContentBasedTrackSizingFunctionsForItems(direction, columnTracks, rowTracks, child, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::minContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); resolveContentBasedTrackSizingFunctionsForItems(direction, columnTracks, rowTracks, child, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); } for (size_t i = 0; i < tracks.size(); ++i) { GridTrack& track = tracks[i]; if (track.m_maxBreadth == infinity) track.m_maxBreadth = track.m_usedBreadth; availableLogicalSpace -= track.m_usedBreadth; } } void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(TrackSizingDirection direction, Vector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks, RenderBox* gridItem, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGetter, AccumulatorGrowFunction trackGrowthFunction) { const GridCoordinate coordinate = cachedGridCoordinate(gridItem); const size_t initialTrackIndex = (direction == ForColumns) ? coordinate.columns.initialPositionIndex : coordinate.rows.initialPositionIndex; const size_t finalTrackIndex = (direction == ForColumns) ? coordinate.columns.finalPositionIndex : coordinate.rows.finalPositionIndex; Vector<GridTrack*> tracks; for (size_t trackIndex = initialTrackIndex; trackIndex <= finalTrackIndex; ++trackIndex) { const GridTrackSize& trackSize = gridTrackSize(direction, trackIndex); if (!(trackSize.*filterFunction)()) continue; GridTrack& track = (direction == ForColumns) ? columnTracks[trackIndex] : rowTracks[trackIndex]; tracks.append(&track); } LayoutUnit additionalBreadthSpace = (this->*sizingFunction)(gridItem, direction, columnTracks); for (size_t trackIndexForSpace = initialTrackIndex; trackIndexForSpace <= finalTrackIndex; ++trackIndexForSpace) { GridTrack& track = (direction == ForColumns) ? columnTracks[trackIndexForSpace] : rowTracks[trackIndexForSpace]; additionalBreadthSpace -= (track.*trackGetter)(); } // FIXME: We should pass different values for |tracksForGrowthAboveMaxBreadth|. distributeSpaceToTracks(tracks, &tracks, trackGetter, trackGrowthFunction, additionalBreadthSpace); } static bool sortByGridTrackGrowthPotential(const GridTrack* track1, const GridTrack* track2) { return (track1->m_maxBreadth - track1->m_usedBreadth) < (track2->m_maxBreadth - track2->m_usedBreadth); } void RenderGrid::distributeSpaceToTracks(Vector<GridTrack*>& tracks, Vector<GridTrack*>* tracksForGrowthAboveMaxBreadth, AccumulatorGetter trackGetter, AccumulatorGrowFunction trackGrowthFunction, LayoutUnit& availableLogicalSpace) { std::sort(tracks.begin(), tracks.end(), sortByGridTrackGrowthPotential); size_t tracksSize = tracks.size(); Vector<LayoutUnit> updatedTrackBreadths(tracksSize); for (size_t i = 0; i < tracksSize; ++i) { GridTrack& track = *tracks[i]; LayoutUnit availableLogicalSpaceShare = availableLogicalSpace / (tracksSize - i); LayoutUnit trackBreadth = (tracks[i]->*trackGetter)(); LayoutUnit growthShare = std::min(availableLogicalSpaceShare, track.m_maxBreadth - trackBreadth); updatedTrackBreadths[i] = trackBreadth + growthShare; availableLogicalSpace -= growthShare; } if (availableLogicalSpace > 0 && tracksForGrowthAboveMaxBreadth) { tracksSize = tracksForGrowthAboveMaxBreadth->size(); for (size_t i = 0; i < tracksSize; ++i) { LayoutUnit growthShare = availableLogicalSpace / (tracksSize - i); updatedTrackBreadths[i] += growthShare; availableLogicalSpace -= growthShare; } } for (size_t i = 0; i < tracksSize; ++i) { LayoutUnit growth = updatedTrackBreadths[i] - (tracks[i]->*trackGetter)(); if (growth >= 0) (tracks[i]->*trackGrowthFunction)(growth); } } #ifndef NDEBUG bool RenderGrid::tracksAreWiderThanMinTrackBreadth(TrackSizingDirection direction, const Vector<GridTrack>& tracks) { for (size_t i = 0; i < tracks.size(); ++i) { const GridTrackSize& trackSize = gridTrackSize(direction, i); const Length& minTrackBreadth = trackSize.minTrackBreadth(); if (computeUsedBreadthOfMinLength(direction, minTrackBreadth) > tracks[i].m_usedBreadth) return false; } return true; } #endif void RenderGrid::growGrid(TrackSizingDirection direction) { if (direction == ForColumns) { const size_t oldColumnSize = m_grid[0].size(); for (size_t row = 0; row < m_grid.size(); ++row) m_grid[row].grow(oldColumnSize + 1); } else { const size_t oldRowSize = m_grid.size(); m_grid.grow(oldRowSize + 1); m_grid[oldRowSize].grow(m_grid[0].size()); } } void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coordinate) { m_grid[coordinate.rows.initialPositionIndex][coordinate.columns.initialPositionIndex].append(child); m_gridItemCoordinate.set(child, coordinate); } void RenderGrid::insertItemIntoGrid(RenderBox* child, size_t rowTrack, size_t columnTrack) { const GridSpan& rowSpan = resolveGridPositionsFromAutoPlacementPosition(child, ForRows, rowTrack); const GridSpan& columnSpan = resolveGridPositionsFromAutoPlacementPosition(child, ForColumns, columnTrack); insertItemIntoGrid(child, GridCoordinate(rowSpan, columnSpan)); } void RenderGrid::placeItemsOnGrid() { ASSERT(!gridWasPopulated()); ASSERT(m_gridItemCoordinate.isEmpty()); m_grid.grow(maximumIndexInDirection(ForRows)); size_t maximumColumnIndex = maximumIndexInDirection(ForColumns); for (size_t i = 0; i < m_grid.size(); ++i) m_grid[i].grow(maximumColumnIndex); Vector<RenderBox*> autoMajorAxisAutoGridItems; Vector<RenderBox*> specifiedMajorAxisAutoGridItems; GridAutoFlow autoFlow = style()->gridAutoFlow(); for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { // FIXME: We never re-resolve positions if the grid is grown during auto-placement which may lead auto / <integer> // positions to not match the author's intent. The specification is unclear on what should be done in this case. OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(child, ForRows); OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(child, ForColumns); if (!rowPositions || !columnPositions) { GridSpan* majorAxisPositions = (autoPlacementMajorAxisDirection() == ForColumns) ? columnPositions.get() : rowPositions.get(); if (!majorAxisPositions) autoMajorAxisAutoGridItems.append(child); else specifiedMajorAxisAutoGridItems.append(child); continue; } insertItemIntoGrid(child, GridCoordinate(*rowPositions, *columnPositions)); } ASSERT(gridRowCount() >= style()->gridRows().size()); ASSERT(gridColumnCount() >= style()->gridColumns().size()); if (autoFlow == AutoFlowNone) { // If we did collect some grid items, they won't be placed thus never laid out. ASSERT(!autoMajorAxisAutoGridItems.size()); ASSERT(!specifiedMajorAxisAutoGridItems.size()); return; } placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems); } void RenderGrid::placeSpecifiedMajorAxisItemsOnGrid(Vector<RenderBox*> autoGridItems) { for (size_t i = 0; i < autoGridItems.size(); ++i) { OwnPtr<GridSpan> majorAxisPositions = resolveGridPositionsFromStyle(autoGridItems[i], autoPlacementMajorAxisDirection()); GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), majorAxisPositions->initialPositionIndex); if (OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea()) { insertItemIntoGrid(autoGridItems[i], emptyGridArea->rows.initialPositionIndex, emptyGridArea->columns.initialPositionIndex); continue; } growGrid(autoPlacementMinorAxisDirection()); OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea(); ASSERT(emptyGridArea); insertItemIntoGrid(autoGridItems[i], emptyGridArea->rows.initialPositionIndex, emptyGridArea->columns.initialPositionIndex); } } void RenderGrid::placeAutoMajorAxisItemsOnGrid(Vector<RenderBox*> autoGridItems) { for (size_t i = 0; i < autoGridItems.size(); ++i) placeAutoMajorAxisItemOnGrid(autoGridItems[i]); } void RenderGrid::placeAutoMajorAxisItemOnGrid(RenderBox* gridItem) { OwnPtr<GridSpan> minorAxisPositions = resolveGridPositionsFromStyle(gridItem, autoPlacementMinorAxisDirection()); ASSERT(!resolveGridPositionsFromStyle(gridItem, autoPlacementMajorAxisDirection())); size_t minorAxisIndex = 0; if (minorAxisPositions) { minorAxisIndex = minorAxisPositions->initialPositionIndex; GridIterator iterator(m_grid, autoPlacementMinorAxisDirection(), minorAxisIndex); if (OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea()) { insertItemIntoGrid(gridItem, emptyGridArea->rows.initialPositionIndex, emptyGridArea->columns.initialPositionIndex); return; } } else { const size_t endOfMajorAxis = (autoPlacementMajorAxisDirection() == ForColumns) ? gridColumnCount() : gridRowCount(); for (size_t majorAxisIndex = 0; majorAxisIndex < endOfMajorAxis; ++majorAxisIndex) { GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), majorAxisIndex); if (OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea()) { insertItemIntoGrid(gridItem, emptyGridArea->rows.initialPositionIndex, emptyGridArea->columns.initialPositionIndex); return; } } } // We didn't find an empty grid area so we need to create an extra major axis line and insert our gridItem in it. const size_t columnIndex = (autoPlacementMajorAxisDirection() == ForColumns) ? m_grid[0].size() : minorAxisIndex; const size_t rowIndex = (autoPlacementMajorAxisDirection() == ForColumns) ? minorAxisIndex : m_grid.size(); growGrid(autoPlacementMajorAxisDirection()); insertItemIntoGrid(gridItem, rowIndex, columnIndex); } RenderGrid::TrackSizingDirection RenderGrid::autoPlacementMajorAxisDirection() const { GridAutoFlow flow = style()->gridAutoFlow(); ASSERT(flow != AutoFlowNone); return (flow == AutoFlowColumn) ? ForColumns : ForRows; } RenderGrid::TrackSizingDirection RenderGrid::autoPlacementMinorAxisDirection() const { GridAutoFlow flow = style()->gridAutoFlow(); ASSERT(flow != AutoFlowNone); return (flow == AutoFlowColumn) ? ForRows : ForColumns; } void RenderGrid::clearGrid() { m_grid.clear(); m_gridItemCoordinate.clear(); } void RenderGrid::layoutGridItems() { placeItemsOnGrid(); Vector<GridTrack> columnTracks(gridColumnCount()); Vector<GridTrack> rowTracks(gridRowCount()); computedUsedBreadthOfGridTracks(ForColumns, columnTracks, rowTracks); ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, columnTracks)); computedUsedBreadthOfGridTracks(ForRows, columnTracks, rowTracks); ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, rowTracks)); for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { LayoutPoint childPosition = findChildLogicalPosition(child, columnTracks, rowTracks); // Because the grid area cannot be styled, we don't need to adjust // the grid breadth to account for 'box-sizing'. LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOverrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogicalWidth() : LayoutUnit(); LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOverrideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogicalHeight() : LayoutUnit(); // FIXME: For children in a content sized track, we clear the overrideContainingBlockContentLogicalHeight // in minContentForChild / maxContentForChild which means that we will always relayout the child. LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, columnTracks); LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadthForChild(child, ForRows, rowTracks); if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingBlockContentLogicalWidth || oldOverrideContainingBlockContentLogicalHeight != overrideContainingBlockContentLogicalHeight) child->setNeedsLayout(true, MarkOnlyThis); child->setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth); child->setOverrideContainingBlockContentLogicalHeight(overrideContainingBlockContentLogicalHeight); LayoutRect oldChildRect = child->frameRect(); // FIXME: Grid items should stretch to fill their cells. Once we // implement grid-{column,row}-align, we can also shrink to fit. For // now, just size as if we were a regular child. child->layoutIfNeeded(); // FIXME: Handle border & padding on the grid element. child->setLogicalLocation(childPosition); // If the child moved, we have to repaint it as well as any floating/positioned // descendants. An exception is if we need a layout. In this case, we know we're going to // repaint ourselves (and the child) anyway. if (!selfNeedsLayout() && child->checkForRepaintDuringLayout()) child->repaintDuringLayoutIfMoved(oldChildRect); } for (size_t i = 0; i < rowTracks.size(); ++i) setLogicalHeight(logicalHeight() + rowTracks[i].m_usedBreadth); // FIXME: We should handle min / max logical height. setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); clearGrid(); } RenderGrid::GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox* gridItem) const { ASSERT(m_gridItemCoordinate.contains(gridItem)); return m_gridItemCoordinate.get(gridItem); } RenderGrid::GridSpan RenderGrid::resolveGridPositionsFromAutoPlacementPosition(const RenderBox*, TrackSizingDirection, size_t initialPosition) const { // FIXME: We don't support spanning with auto positions yet. Once we do, this is wrong. Also we should make // sure the grid can accomodate the new item as we only grow 1 position in a given direction. return GridSpan(initialPosition, initialPosition); } PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveGridPositionsFromStyle(const RenderBox* gridItem, TrackSizingDirection direction) const { ASSERT(gridWasPopulated()); const GridPosition& initialPosition = (direction == ForColumns) ? gridItem->style()->gridItemStart() : gridItem->style()->gridItemBefore(); const GridPositionSide initialPositionSide = (direction == ForColumns) ? StartSide : BeforeSide; const GridPosition& finalPosition = (direction == ForColumns) ? gridItem->style()->gridItemEnd() : gridItem->style()->gridItemAfter(); const GridPositionSide finalPositionSide = (direction == ForColumns) ? EndSide : AfterSide; if (initialPosition.isAuto() && finalPosition.isAuto()) { if (style()->gridAutoFlow() == AutoFlowNone) return adoptPtr(new GridSpan(0, 0)); // We can't get our grid positions without running the auto placement algorithm. return nullptr; } if (initialPosition.isAuto()) { // Infer the position from the final position ('auto / 1' case). const size_t finalResolvedPosition = resolveGridPositionFromStyle(finalPosition, finalPositionSide); return adoptPtr(new GridSpan(finalResolvedPosition, finalResolvedPosition)); } if (finalPosition.isAuto()) { // Infer our position from the initial position ('1 / auto' case). const size_t initialResolvedPosition = resolveGridPositionFromStyle(initialPosition, initialPositionSide); return adoptPtr(new GridSpan(initialResolvedPosition, initialResolvedPosition)); } return adoptPtr(new GridSpan(resolveGridPositionFromStyle(initialPosition, initialPositionSide), resolveGridPositionFromStyle(finalPosition, finalPositionSide))); } size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, GridPositionSide side) const { ASSERT(gridWasPopulated()); // FIXME: Handle other values for grid-{row,column} like ranges or line names. switch (position.type()) { case IntegerPosition: { // FIXME: What does a non-positive integer mean for a column/row? size_t resolvedPosition = position.isPositive() ? position.integerPosition() - 1 : 0; if (side == StartSide || side == BeforeSide) return resolvedPosition; const size_t endOfTrack = (side == EndSide) ? gridColumnCount() - 1 : gridRowCount() - 1; ASSERT(endOfTrack >= resolvedPosition); return endOfTrack - resolvedPosition; } case AutoPosition: // 'auto' depends on the opposite position for resolution (e.g. grid-row: auto / 1). ASSERT_NOT_REACHED(); return 0; } ASSERT_NOT_REACHED(); return 0; } LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirection direction, const Vector<GridTrack>& tracks) const { const GridCoordinate& coordinate = cachedGridCoordinate(child); const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coordinate.rows; LayoutUnit gridAreaBreadth = 0; for (size_t trackIndex = span.initialPositionIndex; trackIndex <= span.finalPositionIndex; ++trackIndex) gridAreaBreadth += tracks[trackIndex].m_usedBreadth; return gridAreaBreadth; } LayoutPoint RenderGrid::findChildLogicalPosition(RenderBox* child, const Vector<GridTrack>& columnTracks, const Vector<GridTrack>& rowTracks) { const GridCoordinate& coordinate = cachedGridCoordinate(child); // The grid items should be inside the grid container's border box, that's why they need to be shifted. LayoutPoint offset(borderAndPaddingStart(), borderAndPaddingBefore()); // FIXME: |columnTrack| and |rowTrack| should be smaller than our column / row count. for (size_t i = 0; i < coordinate.columns.initialPositionIndex && i < columnTracks.size(); ++i) offset.setX(offset.x() + columnTracks[i].m_usedBreadth); for (size_t i = 0; i < coordinate.rows.initialPositionIndex && i < rowTracks.size(); ++i) offset.setY(offset.y() + rowTracks[i].m_usedBreadth); // FIXME: Handle margins on the grid item. return offset; } const char* RenderGrid::renderName() const { if (isFloating()) return "RenderGrid (floating)"; if (isOutOfFlowPositioned()) return "RenderGrid (positioned)"; if (isAnonymous()) return "RenderGrid (generated)"; if (isRelPositioned()) return "RenderGrid (relative positioned)"; return "RenderGrid"; } } // namespace WebCore
45.45
318
0.725643
[ "render", "vector" ]
a65b2ab53a7306245185fa2ff89372b4306019c9
31,339
hpp
C++
src/gpu/nvidia/cudnn_conv_inner_product_impl.hpp
Gxllii/oneDNN
419c2c39da0ea83ec56318c0c24bf07b7e69281c
[ "Apache-2.0" ]
1
2020-12-24T02:32:43.000Z
2020-12-24T02:32:43.000Z
src/gpu/nvidia/cudnn_conv_inner_product_impl.hpp
Gxllii/oneDNN
419c2c39da0ea83ec56318c0c24bf07b7e69281c
[ "Apache-2.0" ]
null
null
null
src/gpu/nvidia/cudnn_conv_inner_product_impl.hpp
Gxllii/oneDNN
419c2c39da0ea83ec56318c0c24bf07b7e69281c
[ "Apache-2.0" ]
1
2020-08-19T06:15:19.000Z
2020-08-19T06:15:19.000Z
/******************************************************************************* * Copyright 2020 Intel Corporation * Copyright 2020 Codeplay Software Limited * * 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 GPU_NVIDIA_CUDNN_CONV_INNER_PRODUCT_IMPL_HPP #define GPU_NVIDIA_CUDNN_CONV_INNER_PRODUCT_IMPL_HPP #include "cublas_v2.h" #include "cudnn.h" #include "common/type_helpers.hpp" #include "gpu/nvidia/cudnn_conv_filter_adjustment_base.hpp" #include "gpu/nvidia/cudnn_inner_product_impl.hpp" #include "gpu/nvidia/sycl_cuda_engine.hpp" #include "gpu/nvidia/sycl_cuda_stream.hpp" #include "gpu/nvidia/sycl_cuda_utils.hpp" namespace dnnl { namespace impl { namespace gpu { namespace nvidia { struct cudnn_conv_inner_product_impl_base_t : public cudnn_inner_product_fwd_base_t, public cudnn_conv_filter_adjustment_base_t { bool unfold_dimensions_ = false; cudnnConvolutionDescriptor_t conv_desc_ = nullptr; cudnnFilterDescriptor_t filter_desc_; status_t filter_tag( const memory_desc_t &md, format_tag_t &weight_tag) const { using namespace format_tag; weight_tag = memory_desc_matches_one_of_tag(md, oidhw, odhwi, dhwio, oihw, ohwi, hwio, oiw, owi, wio, aBcd4b, any); // blocked layouts if (weight_tag == undef) return status::unimplemented; return status::success; } status_t source_tag(const memory_desc_t &md, format_tag_t &src_tag) const { using namespace format_tag; src_tag = memory_desc_matches_one_of_tag( md, ncdhw, ndhwc, nchw, nhwc, ncw, nwc, aBcd4b, any); if (src_tag == undef) return status::unimplemented; return status::success; } virtual ~cudnn_conv_inner_product_impl_base_t() { if (conv_desc_) { CUDNN_EXECUTE_FUNC_V(cudnnDestroyConvolutionDescriptor, conv_desc_); } if (filter_desc_) { CUDNN_EXECUTE_FUNC_V(cudnnDestroyFilterDescriptor, filter_desc_); } for (size_t i = 0; i < NUM_IO - 1; i++) { if (tensor_descs_[i]) { CUDNN_EXECUTE_FUNC_V( cudnnDestroyTensorDescriptor, tensor_descs_[i]); } } } void unfold_dims(io memory_index, int *folded_dims, int *folded_strides, cudnnTensorFormat_t format, int ndims) { folded_dims[0] = dims_[memory_index][0]; folded_dims[1] = dims_[memory_index][1]; for (int i = 2; i < ndims; i++) { folded_dims[1] *= dims_[memory_index][i]; folded_dims[i] = 1; } for (int i = 2; i < ndims; i++) { folded_strides[i] = (format == CUDNN_TENSOR_NHWC ? folded_dims[1] : 1); } folded_strides[1] = 1; folded_strides[0] = folded_dims[1]; } virtual void execute(cudnnHandle_t handle, cublasHandle_t, const std::vector<void *> &args) const = 0; }; struct cudnn_conv_inner_product_fwd_impl_t : public cudnn_conv_inner_product_impl_base_t { bool use_fused_path_for_blocking_ = false; bool input_is_blocked_ = false; bool filter_is_blocked_ = false; cudnnConvolutionFwdAlgo_t algo_; cudnnActivationDescriptor_t act_desc_fuse_relu; cudnnActivationDescriptor_t act_desc_no_relu_; cudnnTensorFormat_t source_format_; ~cudnn_conv_inner_product_fwd_impl_t() { if (with_bias_) { CUDNN_EXECUTE_FUNC_V( cudnnDestroyActivationDescriptor, act_desc_fuse_relu); } if ((with_eltwise_ && !with_relu_) || (!with_bias_ && with_relu_)) { CUDNN_EXECUTE_FUNC_V( cudnnDestroyActivationDescriptor, act_desc_no_relu_); } } virtual status_t init(engine_t *engine, inner_product_pd_t *pd, bool with_relu, bool with_eltwise, bool with_sum, bool use_fuse_path_for_blocking) override { with_bias_ = pd->with_bias(); with_relu_ = with_relu; with_eltwise_ = with_eltwise; use_fused_path_for_blocking_ = use_fuse_path_for_blocking; output_scales_ = pd->attr()->output_scales_.scales_[0]; with_sum_ = with_sum; scale_bias_ = (output_scales_ != 1) && with_bias_; // scaling factor to add the previous destination value to the current // computation sum_scale_ = sum_scale(pd); input_is_blocked_ = pd->src_md()->format_desc.blocking.inner_blks[0] == 4; filter_is_blocked_ = pd->weights_md(0)->format_desc.blocking.inner_blks[0] == 4; // Pad out the dimensions to at least 4. if (pd->ndims() > CUDNN_DIM_MAX || pd->ndims() < 2) { return status::invalid_arguments; } ndims_ = pd->ndims() < 4 ? 4 : pd->ndims(); // Initialise meta-data from the descriptors. // Convert the padded dimensions to the dimensions expected by cuDNN. get_4d_tensor_descriptor( pd->src_md(), dims_[io::src], strides_[io::src]); get_4d_tensor_descriptor( pd->weights_md(), dims_[io::wei], strides_[io::wei]); get_4d_tensor_descriptor( pd->dst_md(), dims_[io::dst], strides_[io::dst]); // Convert oneDNN data types to their cuDNN counterparts. CHECK(convert_data_type(pd->src_md(), &data_types_[io::src])); CHECK(convert_data_type(pd->weights_md(0), &data_types_[io::wei])); if (input_is_blocked_) { data_types_[io::dst] = CUDNN_DATA_INT8x4; } else { CHECK(convert_data_type(pd->dst_md(), &data_types_[io::dst])); } // Ensure INT8 types are accumulated with INT32. if (data_types_[io::src] != CUDNN_DATA_HALF && data_types_[io::src] != CUDNN_DATA_FLOAT) { data_types_[NUM_IO] = CUDNN_DATA_INT32; } cudnnTensorFormat_t weights_format; format_tag_t w_tag, s_tag; CHECK(filter_tag(*pd->weights_md(0), w_tag)); CHECK(source_tag(*pd->src_md(0), s_tag)); CHECK(get_format( pd->src_md(), source_format_, pd->src_md()->ndims == 2)); // Currently cuDNN does not support // cudnnConvolutionBiasActivationForward // for 5D convolution. Therefore we have to unfold the dims for 5d when // it is 5d. Also cuDNN does not support s8 type and nhwc format for // 5d convolution. unfold_dimensions_ = ndims_ > 4 && ((pd->weights_md(0)->data_type == data_type::s8) || (source_format_ == CUDNN_TENSOR_NHWC) || with_bias_); if (!supported_filter_format(pd->weights_md(0)) || (unfold_dimensions_ && (w_tag != s_tag)) || ((source_format_ == CUDNN_TENSOR_NCHW) && (w_tag != s_tag))) { set_filter_format( ndims_, dims_[io::wei], strides_[NUM_IO], source_format_); CHECK(init_filter_transformation(data_types_[io::wei], ndims_, dims_[io::wei], strides_[io::wei], strides_[NUM_IO])); filter_using_spatial_format_ = true; // we transform the filter based on src format weights_format = source_format_; pd->scratchpad_registry().registrar().book( memory_tracking::names::key_none, memory_desc_wrapper(pd->weights_md(0)).size(), size_t(1)); } else { CHECK(get_format(pd->weights_md(0), weights_format, pd->weights_md(0)->ndims == 2)); } if (scale_bias_) { pd->scratchpad_registry().registrar().book( memory_tracking::names::key_conv_adjusted_scales, memory_desc_wrapper(pd->weights_md(1)).size(), size_t(1)); } // Copy over the strides. if (with_bias_) { CHECK(convert_data_type(pd->weights_md(1), &data_types_[io::bia])); set_bias_dims(weights_format, ndims_, pd->OC()); } // cuDNN requires Input and output feature maps to be a multiple of 4 // for int8. only nhwc is supported for int8// cudnn doesnot support // 5d convolution format for int8 if ((pd->weights_md(0)->data_type == data_type::s8) && ((pd->IC() % 4 != 0) || (pd->OC() % 4 != 0))) { return status::unimplemented; } // source format and weight format are the same at this stage if (unfold_dimensions_) { unfold_dims(io::wei, dims_[io::wei], strides_[io::wei], source_format_, ndims_); unfold_dims(io::src, dims_[io::src], strides_[io::src], source_format_, ndims_); ndims_ = 4; } if (input_is_blocked_) { CHECK(create_and_set_tensor_descriptor_ex(&tensor_descs_[io::src], CUDNN_TENSOR_NCHW_VECT_C, data_types_[io::src], ndims_, dims_[io::src])); } else { CHECK(create_and_set_tensor_descriptor(&tensor_descs_[io::src], data_types_[io::src], ndims_, dims_[io::src], strides_[io::src])); } if (with_bias_) { CHECK(create_and_set_tensor_descriptor(&tensor_descs_[io::bia], data_types_[io::bia], ndims_, dims_[io::bia], strides_[io::bia])); } // If input is blocked, the output needs to be as well. if (input_is_blocked_) { CHECK(create_and_set_tensor_descriptor_ex(&tensor_descs_[io::dst], CUDNN_TENSOR_NCHW_VECT_C, data_types_[io::dst], ndims_, dims_[io::dst])); } else { cudnnTensorFormat_t out_format = filter_is_blocked_ ? CUDNN_TENSOR_NCHW : weights_format; CHECK(create_and_set_tensor_descriptor_ex(&tensor_descs_[io::dst], out_format, data_types_[io::dst], ndims_, dims_[io::dst])); } CHECK(create_and_set_filter_descriptor(&filter_desc_, weights_format, data_types_[io::wei], ndims_, dims_[io::wei], strides_[io::wei])); // Set the convolution. For inner product, this means unit strides and // dilation, no padding, and with cross-correlation as the mode. int conv_dims = ndims_ - 2; std::vector<int> unit_strides(conv_dims, 1); std::vector<int> unit_dilation(conv_dims, 1); std::vector<int> zero_padding(conv_dims, 0); CHECK(create_and_set_conv_descriptor(&conv_desc_, conv_dims, zero_padding.data(), unit_strides.data(), unit_dilation.data(), CUDNN_CROSS_CORRELATION, data_types_[NUM_IO])); auto &sycl_engine = *utils::downcast<sycl_cuda_engine_t *>(engine); stream_t *service_stream; CHECK(sycl_engine.get_service_stream(service_stream)); auto cuda_stream = utils::downcast<sycl_cuda_stream_t *>(service_stream); auto handle = cuda_stream->get_cudnn_handle(); // Inner product can choose whatever algorithm it prefers, although // for the identity post-op the IMPLICIT_PRECOMP_GEMM must be used. // there is a bug in nvidia that cannot support // cudnnGetConvolutionForwardAlgorithm for int8 type if (pd->src_md()->data_type != data_type::s8 && pd->weights_md(0)->data_type != data_type::s8) { cudnnConvolutionFwdPreference_t algo_pref = CUDNN_CONVOLUTION_FWD_PREFER_FASTEST; CHECK(CUDNN_EXECUTE_FUNC_S(cudnnGetConvolutionForwardAlgorithm, handle, tensor_descs_[io::src], filter_desc_, conv_desc_, tensor_descs_[io::dst], algo_pref, 0, &algo_)); } else { algo_ = CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM; } if (!with_relu_) { algo_ = CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM; } // Allocate the workspace from the algorithm selection, if applicable. CHECK(CUDNN_EXECUTE_FUNC_S(cudnnGetConvolutionForwardWorkspaceSize, handle, tensor_descs_[io::src], filter_desc_, conv_desc_, tensor_descs_[io::dst], algo_, &workspace_size_)); if (workspace_size_ > 0) { pd->scratchpad_registry().registrar().book( memory_tracking::names::key_iprod_int_dat_in_acc_dt, workspace_size_, size_t(1)); } // Add the eltwise op. Note that this only applies to the forward pass. CHECK(create_and_set_op_descriptor(pd)); return status::success; } void execute(cudnnHandle_t handle, cublasHandle_t, const std::vector<void *> &args) const override { auto x = args[0], w = args[1], b = args[2], y = args[3], workspace = args[4]; assert(args.size() == 7); auto w_arg = w; if (filter_using_spatial_format_) { void *transformed_w = args[5]; transform_filter(handle, w, transformed_w); w_arg = transformed_w; } if (with_bias_) { auto scaled_bias = b; if (scale_bias_) { void *output_scale_workspace = args[6]; CUDNN_EXECUTE_FUNC(cudnnAddTensor, handle, &output_scales_, tensor_descs_[io::bia], b, &beta_, tensor_descs_[io::bia], output_scale_workspace); scaled_bias = output_scale_workspace; } CUDNN_EXECUTE_FUNC(cudnnConvolutionBiasActivationForward, handle, &output_scales_, tensor_descs_[io::src], x, filter_desc_, w_arg, conv_desc_, algo_, workspace, workspace_size_, &sum_scale_, tensor_descs_[io::dst], y, tensor_descs_[io::bia], scaled_bias, act_desc_fuse_relu, tensor_descs_[io::dst], y); } else { CUDNN_EXECUTE_FUNC(cudnnConvolutionForward, handle, &output_scales_, tensor_descs_[io::src], x, filter_desc_, w_arg, conv_desc_, algo_, workspace, workspace_size_, &sum_scale_, tensor_descs_[io::dst], y); } if ((with_eltwise_ && !with_relu_) || (!with_bias_ && with_relu_)) { CUDNN_EXECUTE_FUNC(cudnnActivationForward, handle, act_desc_no_relu_, &alpha_, tensor_descs_[io::dst], y, &beta_, tensor_descs_[io::dst], y); } } private: status_t create_and_set_op_descriptor(inner_product_pd_t *pd) { if (with_bias_) { auto mode_fuse = with_relu_ ? CUDNN_ACTIVATION_RELU : CUDNN_ACTIVATION_IDENTITY; CHECK(CUDNN_EXECUTE_FUNC_S( cudnnCreateActivationDescriptor, &act_desc_fuse_relu)); // For ReLU, a ceiling of 0 means no limit. CHECK(CUDNN_EXECUTE_FUNC_S(cudnnSetActivationDescriptor, act_desc_fuse_relu, mode_fuse, cudnnNanPropagation_t::CUDNN_NOT_PROPAGATE_NAN, eltwise_alpha(pd))); } if ((with_eltwise_ && !with_relu_) || (!with_bias_ && with_relu_)) { CHECK(CUDNN_EXECUTE_FUNC_S( cudnnCreateActivationDescriptor, &act_desc_no_relu_)); cudnnActivationMode_t no_relu_mode; switch (eltwise_algorithm_kind(pd)) { case alg_kind::eltwise_tanh: no_relu_mode = CUDNN_ACTIVATION_TANH; break; case alg_kind::eltwise_elu: no_relu_mode = CUDNN_ACTIVATION_ELU; break; case alg_kind::eltwise_relu: no_relu_mode = CUDNN_ACTIVATION_RELU; break; case alg_kind::eltwise_logistic: no_relu_mode = CUDNN_ACTIVATION_SIGMOID; break; case alg_kind::eltwise_bounded_relu: no_relu_mode = CUDNN_ACTIVATION_CLIPPED_RELU; break; default: return status::unimplemented; } CHECK(CUDNN_EXECUTE_FUNC_S(cudnnSetActivationDescriptor, act_desc_no_relu_, no_relu_mode, cudnnNanPropagation_t::CUDNN_NOT_PROPAGATE_NAN, eltwise_alpha(pd))); } return status::success; } }; struct cudnn_conv_inner_product_bwd_data_impl_t : public cudnn_conv_inner_product_impl_base_t { cudnnConvolutionBwdDataAlgo_t algo_; // the type of filter depends on dy, however since dy is nc // for nhwc filter the source must be nhwc as well. // So we use the src type for transforming the filter. cudnnTensorFormat_t diff_source_format_; virtual status_t init(engine_t *engine, inner_product_pd_t *pd, bool /*with_relu*/, bool /*with_eltwise*/, bool /*with_sum */, bool /*using_fused_path_for_blocking*/) override { // Pad out the dimensions to 4 if (pd->ndims() > CUDNN_DIM_MAX || pd->ndims() < 2) { return status::invalid_arguments; } ndims_ = pd->ndims() < 4 ? 4 : pd->ndims(); // Initialise meta-data from the descriptors. // Convert the padded dimensions to the dimensions expected by cuDNN. get_4d_tensor_descriptor( pd->diff_src_md(), dims_[io::src], strides_[io::src]); get_4d_tensor_descriptor( pd->weights_md(), dims_[io::wei], strides_[io::wei]); get_4d_tensor_descriptor( pd->diff_dst_md(), dims_[io::dst], strides_[io::dst]); // Convert oneDNN data types to their cuDNN counterparts. CHECK(convert_data_type(pd->diff_src_md(), &data_types_[io::src])); CHECK(convert_data_type(pd->weights_md(0), &data_types_[io::wei])); CHECK(convert_data_type(pd->diff_dst_md(), &data_types_[io::dst])); format_tag_t w_tag, s_tag; CHECK(filter_tag(*pd->weights_md(0), w_tag)); CHECK(source_tag(*pd->diff_src_md(0), s_tag)); cudnnTensorFormat_t weights_format; CHECK(get_format(pd->diff_src_md(), diff_source_format_)); // Currently nvidia does not support cudnnConvolution // for 5D convolution when the filter format is nhwc. // Therefore we have to unfold the dims for 5d when it is 5d. unfold_dimensions_ = ndims_ > 4 && ((diff_source_format_ == CUDNN_TENSOR_NHWC)); // Copy over the strides. // weight format and dy format must be the same, since dx is the result // here, we check with diff_src, to make sure we get the correct result. if (!supported_filter_format(pd->weights_md(0)) || (w_tag != s_tag)) { set_filter_format(ndims_, dims_[io::wei], strides_[NUM_IO], diff_source_format_); CHECK(init_filter_transformation(data_types_[io::wei], ndims_, dims_[io::wei], strides_[io::wei], strides_[NUM_IO])); filter_using_spatial_format_ = true; // the type of weight format must match weights_format = diff_source_format_; pd->scratchpad_registry().registrar().book( memory_tracking::names::key_none, memory_desc_wrapper(pd->weights_md(0)).size(), size_t(1)); } else { CHECK(get_format(pd->weights_md(0), weights_format)); } // source format and weight format are the same at this stage if (unfold_dimensions_) { unfold_dims(io::wei, dims_[io::wei], strides_[io::wei], diff_source_format_, ndims_); unfold_dims(io::src, dims_[io::src], strides_[io::src], diff_source_format_, ndims_); ndims_ = 4; } // Set the tensor descriptors from the dimensions and strides. CHECK(create_and_set_tensor_descriptor(&tensor_descs_[io::src], data_types_[io::src], ndims_, dims_[io::src], strides_[io::src])); CHECK(create_and_set_tensor_descriptor(&tensor_descs_[io::dst], data_types_[io::dst], ndims_, dims_[io::dst], strides_[io::dst])); CHECK(create_and_set_filter_descriptor(&filter_desc_, weights_format, data_types_[io::wei], ndims_, dims_[io::wei], strides_[io::wei])); // Set the convolution. For inner product, this means unit strides and // dilation, no padding, and with cross-correlation as the mode. int conv_dims = ndims_ - 2; std::vector<int> unit_strides(conv_dims, 1); std::vector<int> unit_dilation(conv_dims, 1); std::vector<int> zero_padding(conv_dims, 0); CHECK(create_and_set_conv_descriptor(&conv_desc_, conv_dims, zero_padding.data(), unit_strides.data(), unit_dilation.data(), CUDNN_CROSS_CORRELATION, data_types_[NUM_IO])); auto &sycl_engine = *utils::downcast<sycl_cuda_engine_t *>(engine); stream_t *service_stream; CHECK(sycl_engine.get_service_stream(service_stream)); auto cuda_stream = utils::downcast<sycl_cuda_stream_t *>(service_stream); auto handle = cuda_stream->get_cudnn_handle(); // Inner product can choose whatever algorithm it prefers. cudnnConvolutionBwdDataPreference_t algo_pref = CUDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST; CUDNN_EXECUTE_FUNC(cudnnGetConvolutionBackwardDataAlgorithm, handle, filter_desc_, tensor_descs_[io::dst], conv_desc_, tensor_descs_[io::src], algo_pref, 0, &algo_); // Allocate the workspace from the algorithm selection, if applicable. CUDNN_EXECUTE_FUNC(cudnnGetConvolutionBackwardDataWorkspaceSize, handle, filter_desc_, tensor_descs_[io::dst], conv_desc_, tensor_descs_[io::src], algo_, &workspace_size_); if (workspace_size_ > 0) { pd->scratchpad_registry().registrar().book( memory_tracking::names::key_iprod_int_dat_in_acc_dt, workspace_size_, size_t(1)); } return status::success; } void execute(cudnnHandle_t handle, cublasHandle_t, const std::vector<void *> &args) const override { assert(args.size() == 5); auto dx = args[0], w = args[1], dy = args[2], workspace = args[3]; auto w_arg = w; if (filter_using_spatial_format_) { auto transformed_w = args[4]; transform_filter(handle, w, transformed_w); w_arg = transformed_w; } CUDNN_EXECUTE_FUNC(cudnnConvolutionBackwardData, handle, &alpha_, filter_desc_, w_arg, tensor_descs_[io::dst], dy, conv_desc_, algo_, workspace, workspace_size_, &beta_, tensor_descs_[io::src], dx); } }; struct cudnn_conv_inner_product_bwd_weights_impl_t : public cudnn_conv_inner_product_impl_base_t { cudnnConvolutionBwdFilterAlgo_t algo_; cudnnTensorFormat_t source_format_; virtual status_t init(engine_t *engine, inner_product_pd_t *pd, bool /*with_relu*/, bool /*with_eltwise*/, bool /*with_sum */, bool /*using_fused_path_for_blocking*/) override { // If any of the dimensions are 0 we should not continue with creating // cudnn descriptors with_bias_ = pd->with_bias(); // Pad out the dimensions to 4 if (pd->ndims() > CUDNN_DIM_MAX || pd->ndims() < 2) { return status::invalid_arguments; } ndims_ = pd->ndims() < 4 ? 4 : pd->ndims(); // Initialise meta-data from the descriptors. // Convert the padded dimensions to the dimensions expected by cuDNN. get_4d_tensor_descriptor( pd->src_md(), dims_[io::src], strides_[io::src]); get_4d_tensor_descriptor( pd->diff_weights_md(), dims_[io::wei], strides_[io::wei]); get_4d_tensor_descriptor( pd->diff_dst_md(), dims_[io::dst], strides_[io::dst]); format_tag_t w_tag, s_tag; CHECK(filter_tag(*pd->diff_weights_md(0), w_tag)); CHECK(source_tag(*pd->src_md(0), s_tag)); cudnnTensorFormat_t diff_weights_format; CHECK(get_format(pd->src_md(0), source_format_)); // Currently nvidia does not support cudnnConvolution // for 5D convolution when the filter format is nhwc. // Therefore we have to unfold the dims for 5d when it is 5d. unfold_dimensions_ = ndims_ > 4 && ((source_format_ == CUDNN_TENSOR_NHWC)); // weight format and src format must be the same. // we check with src, to make sure we get the correct result. if (!supported_filter_format(pd->diff_weights_md(0)) || (w_tag != s_tag)) { set_filter_format( ndims_, dims_[io::wei], strides_[NUM_IO], source_format_); CHECK(init_filter_transformation(data_types_[io::wei], ndims_, dims_[io::wei], strides_[NUM_IO], strides_[io::wei])); filter_using_spatial_format_ = true; // the type of weight format must match diff_weights_format = source_format_; pd->scratchpad_registry().registrar().book( memory_tracking::names::key_none, memory_desc_wrapper(pd->diff_weights_md(0)).size(), size_t(1)); } else { CHECK(get_format(pd->diff_weights_md(0), diff_weights_format)); } // Copy over the strides. // Convert oneDNN data types to their cuDNN counterparts. CHECK(convert_data_type(pd->src_md(), &data_types_[io::src])); CHECK(convert_data_type(pd->diff_weights_md(0), &data_types_[io::wei])); CHECK(convert_data_type(pd->diff_dst_md(), &data_types_[io::dst])); // source format and weight format are the same at this stage if (unfold_dimensions_) { unfold_dims(io::wei, dims_[io::wei], strides_[io::wei], source_format_, ndims_); unfold_dims(io::src, dims_[io::src], strides_[io::src], source_format_, ndims_); ndims_ = 4; } if (with_bias_) { set_bias_dims(diff_weights_format, ndims_, pd->OC()); CHECK(convert_data_type( pd->diff_weights_md(1), &data_types_[io::bia])); } // Set the tensor descriptors from the dimensions and strides. CHECK(create_and_set_tensor_descriptor(&tensor_descs_[io::src], data_types_[io::src], ndims_, dims_[io::src], strides_[io::src])); CHECK(create_and_set_filter_descriptor(&filter_desc_, diff_weights_format, data_types_[io::wei], ndims_, dims_[io::wei], strides_[io::wei])); // oneDNN does not set unused dimensions and strides in the output, so // we do that here. If nhwc filter, then repeat the N stride for the // spatial dimensions. CHECK(create_and_set_tensor_descriptor(&tensor_descs_[io::dst], data_types_[io::dst], ndims_, dims_[io::dst], strides_[io::dst])); if (with_bias_) { CHECK(create_and_set_tensor_descriptor(&tensor_descs_[io::bia], data_types_[io::bia], ndims_, dims_[io::bia], strides_[io::bia])); } // Set the convolution. For inner product, this means unit strides and // dilation, no padding, and with cross-correlation as the mode. int conv_dims = ndims_ - 2; std::vector<int> unit_strides(conv_dims, 1); std::vector<int> unit_dilation(conv_dims, 1); std::vector<int> zero_padding(conv_dims, 0); CHECK(create_and_set_conv_descriptor(&conv_desc_, conv_dims, zero_padding.data(), unit_strides.data(), unit_dilation.data(), CUDNN_CROSS_CORRELATION, data_types_[NUM_IO])); auto &sycl_engine = *utils::downcast<sycl_cuda_engine_t *>(engine); stream_t *service_stream; CHECK(sycl_engine.get_service_stream(service_stream)); auto cuda_stream = utils::downcast<sycl_cuda_stream_t *>(service_stream); auto handle = cuda_stream->get_cudnn_handle(); // Inner product can choose whatever algorithm it prefers. cudnnConvolutionBwdFilterPreference_t algo_pref = CUDNN_CONVOLUTION_BWD_FILTER_PREFER_FASTEST; CUDNN_EXECUTE_FUNC(cudnnGetConvolutionBackwardFilterAlgorithm, handle, tensor_descs_[io::src], tensor_descs_[io::dst], conv_desc_, filter_desc_, algo_pref, 0, &algo_); // Allocate the workspace from the algorithm selection, if applicable. CUDNN_EXECUTE_FUNC_S(cudnnGetConvolutionBackwardFilterWorkspaceSize, handle, tensor_descs_[io::src], tensor_descs_[io::dst], conv_desc_, filter_desc_, algo_, &workspace_size_); if (workspace_size_ > 0) { pd->scratchpad_registry().registrar().book( memory_tracking::names::key_iprod_int_dat_in_acc_dt, workspace_size_, size_t(1)); } return status::success; } void execute(cudnnHandle_t handle, cublasHandle_t, const std::vector<void *> &args) const override { assert(args.size() == 6); auto x = args[0], dy = args[1], dw = args[2], db = args[3], workspace = args[4]; auto dw_arg = filter_using_spatial_format_ ? args[5] : dw; CUDNN_EXECUTE_FUNC(cudnnConvolutionBackwardFilter, handle, &alpha_, tensor_descs_[io::src], x, tensor_descs_[io::dst], dy, conv_desc_, algo_, workspace, workspace_size_, &beta_, filter_desc_, dw_arg); if (filter_using_spatial_format_) { // The output of weight is in nvida specific format, // however a user requires the oneDNN format as an output transform_filter(handle, dw_arg, dw); } if (with_bias_) { CUDNN_EXECUTE_FUNC(cudnnConvolutionBackwardBias, handle, &alpha_, tensor_descs_[io::dst], dy, &beta_, tensor_descs_[io::bia], db); } } }; } // namespace nvidia } // namespace gpu } // namespace impl } // namespace dnnl #endif
44.64245
80
0.608316
[ "vector", "transform" ]
a65bac3a2f626bacb23c33c40a0470ca085f39c9
1,704
cpp
C++
Two-Pointers/Array3Pointers.cpp
ssokjin/Interview-Bit
8714d3d627eb5875f49d205af779b59ca33ab4a3
[ "MIT" ]
513
2016-08-16T12:52:14.000Z
2022-03-30T19:32:10.000Z
Two-Pointers/Array3Pointers.cpp
CodeOctal/Interview-Bit
88c021685d6cdef17906d077411ce34723363a08
[ "MIT" ]
25
2018-02-14T15:25:48.000Z
2022-03-23T11:52:08.000Z
Two-Pointers/Array3Pointers.cpp
CodeOctal/Interview-Bit
88c021685d6cdef17906d077411ce34723363a08
[ "MIT" ]
505
2016-09-02T15:04:20.000Z
2022-03-25T06:36:31.000Z
// https://www.interviewbit.com/problems/array-3-pointers/ int checkMax(int a, int b, int c){ int max = a; if(max < b){ max = b; } if(max < c){ max = c; } return max; } int Solution::minimize(const vector<int> &A, const vector<int> &B, const vector<int> &C) { // Do not write main() function. // Do not read input, instead use the arguments to the function. // Do not print the output, instead return values as specified // Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details int i = 0, j = 0, k = 0; int sol = INT_MAX; int temp, temp1, temp2, temp3; while(i < A.size() || j < B.size() || k < C.size()){ sol = min(sol, checkMax(abs(A[i] - B[j]), abs(B[j] - C[k]), abs(C[k] - A[i]))); if(i+1 < A.size()){ temp1 = checkMax(abs(A[i+1] - B[j]), abs(B[j] - C[k]), abs(C[k] - A[i+1])); } else{ temp1 = INT_MAX; } if(j+1 < B.size()){ temp2 = checkMax(abs(A[i] - B[j+1]), abs(B[j+1] - C[k]), abs(C[k] - A[i])); } else{ temp2 = INT_MAX; } if(k+1 < C.size()){ temp3 = checkMax(abs(A[i] - B[j]), abs(B[j] - C[k+1]), abs(C[k+1] - A[i])); } else{ temp3 = INT_MAX; } temp = min(temp1, temp2); temp = min(temp, temp3); if(temp == INT_MAX){ return sol; } else if(temp == temp1){ i++; } else if(temp == temp2){ j++; } else{ k++; } } return sol; }
25.058824
93
0.439554
[ "vector" ]
a660b3cae66b1c63347c1854f1dbc15351e17d22
1,375
cpp
C++
SPOJ/SPOJ/magic.cpp
aqfaridi/Competitve-Programming-Codes
d055de2f42d3d6bc36e03e67804a1dd6b212241f
[ "MIT" ]
null
null
null
SPOJ/SPOJ/magic.cpp
aqfaridi/Competitve-Programming-Codes
d055de2f42d3d6bc36e03e67804a1dd6b212241f
[ "MIT" ]
null
null
null
SPOJ/SPOJ/magic.cpp
aqfaridi/Competitve-Programming-Codes
d055de2f42d3d6bc36e03e67804a1dd6b212241f
[ "MIT" ]
null
null
null
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <climits> #include <cassert> #include <iomanip> #include <vector> #include <utility> #include <map> #include <set> #include <list> #include <stack> #include <queue> #include <deque> #include <bitset> #include <complex> #include <numeric> #include <functional> #include <sstream> #include <algorithm> #define MAX 1000010 #define MOD 1000000007 using namespace std; typedef long long LL; typedef unsigned long long uLL; int main() { string str; bool flag = false; bool sett = false; cin>>str; if(str[0]=='4') cout<<"NO"<<endl; else { int l = str.length(); int i; for(i=0;i<l-2;i++) { if(str[i]=='4' && str[i+1]=='4' && str[i+2]=='4') { sett = true; break; } } if(sett) { cout<<"NO"<<endl; flag = true; } for(i=0;i<l;i++) { if(str[i]=='3' || str[i]=='2' || str[i]=='5' || str[i]=='6' ||str[i]=='7' || str[i]=='0' || str[i]=='8' || str[i]=='9') break; } if(!flag) if(i!=(l)) cout<<"NO"<<endl; else cout<<"YES"<<endl; } return 0; }
19.642857
131
0.461818
[ "vector" ]
a66a11bb4356f9c28456d7df25d3c65a1a424cfe
3,287
cc
C++
onnxruntime/core/providers/cuda/tensor/tile.cc
qizhen816/onnxruntime
ec4f6c099b3d3e2ea91106809b8979753af3a3e9
[ "MIT" ]
1
2020-07-12T14:56:55.000Z
2020-07-12T14:56:55.000Z
onnxruntime/core/providers/cuda/tensor/tile.cc
Mookel/onnxruntime
a61400de01130123c1acef4bd4d646cf723cc80f
[ "MIT" ]
null
null
null
onnxruntime/core/providers/cuda/tensor/tile.cc
Mookel/onnxruntime
a61400de01130123c1acef4bd4d646cf723cc80f
[ "MIT" ]
null
null
null
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "core/providers/cuda/tensor/tile.h" #include "core/providers/cpu/tensor/utils.h" #include "tile_impl.h" using namespace onnxruntime::common; namespace onnxruntime { namespace cuda { #define REGISTER_KERNEL_TYPED(T) \ ONNX_OPERATOR_TYPED_KERNEL_EX( \ Tile, \ kOnnxDomain, \ 6, \ T, \ kCudaExecutionProvider, \ KernelDefBuilder() \ .InputMemoryType<OrtMemTypeCPUInput>(1) \ .TypeConstraint("T", DataTypeImpl::GetTensorType<T>()) \ .TypeConstraint("T1", DataTypeImpl::GetTensorType<int64_t>()), \ Tile<T>); template <typename T> Status Tile<T>::ComputeInternal(OpKernelContext* ctx) const { auto& input_tensor = *ctx->Input<Tensor>(0); auto& repeats_tensor = *ctx->Input<Tensor>(1); int32_t rank = static_cast<int32_t>(input_tensor.Shape().NumDimensions()); if (repeats_tensor.Shape().NumDimensions() != 1) return Status(ONNXRUNTIME, INVALID_ARGUMENT, "'repeat' input tensor must be 1 dimensional"); if (size_t(repeats_tensor.Shape().Size()) != rank) return Status(ONNXRUNTIME, INVALID_ARGUMENT, "'repeat' input tensor must have the same length as the 'input' tensor"); // Calculate the shape of the output tensor auto* repeats = repeats_tensor.template Data<int64_t>(); const auto& input_shape = input_tensor.Shape().GetDims(); std::vector<int64_t> output_dims(input_shape); for (auto axis = 0; axis < rank; axis++) output_dims[axis] *= repeats[axis]; TensorShape outputShape(output_dims); auto& output_tensor = *ctx->Output(0, outputShape); T* output_data = output_tensor.template MutableData<T>(); const T* input_data = input_tensor.template Data<T>(); TensorPitches input_pitches(input_shape); TArray<int64_t> input_strides(input_pitches); TArray<fast_divmod> fdm_input_shape(rank); for (int32_t i = 0; i < input_shape.size(); ++i) { fdm_input_shape[i] = fast_divmod(gsl::narrow_cast<int>(input_shape[i])); } TArray<fast_divmod> fdm_output_strides(rank); TensorPitches output_pitches(output_dims); for (auto i = 0; i < rank; i++) { fdm_output_strides[i] = fast_divmod(static_cast<int>(output_pitches[i])); } if (output_tensor.Shape().Size() > 0) { TileImpl( rank, fdm_input_shape, input_strides, reinterpret_cast<const typename ToCudaType<T>::MappedType*>(input_data), fdm_output_strides, reinterpret_cast<typename ToCudaType<T>::MappedType*>(output_data), output_tensor.Shape().Size()); } return Status::OK(); } #define SPECIALIZED_COMPUTE(T) \ REGISTER_KERNEL_TYPED(T) \ template Status Tile<T>::ComputeInternal(OpKernelContext* ctx) const; SPECIALIZED_COMPUTE(float) SPECIALIZED_COMPUTE(double) SPECIALIZED_COMPUTE(MLFloat16) } // namespace cuda } // namespace onnxruntime
38.670588
122
0.62519
[ "shape", "vector" ]
a66c43f77575e608fc78e628981419e4e7946e98
17,105
hpp
C++
include/depthai-shared/datatype/RawStereoDepthConfig.hpp
kamleshbhalui/depthai-shared
28da84fc8a81b8d692d801924598ce9cb34ac761
[ "MIT" ]
null
null
null
include/depthai-shared/datatype/RawStereoDepthConfig.hpp
kamleshbhalui/depthai-shared
28da84fc8a81b8d692d801924598ce9cb34ac761
[ "MIT" ]
null
null
null
include/depthai-shared/datatype/RawStereoDepthConfig.hpp
kamleshbhalui/depthai-shared
28da84fc8a81b8d692d801924598ce9cb34ac761
[ "MIT" ]
null
null
null
#pragma once #include <cstdint> #include <depthai-shared/common/optional.hpp> #include <vector> #include "DatatypeEnum.hpp" #include "RawBuffer.hpp" #include "depthai-shared/utility/Serialization.hpp" namespace dai { /** * Median filter config for disparity post-processing */ enum class MedianFilter : int32_t { MEDIAN_OFF = 0, KERNEL_3x3 = 3, KERNEL_5x5 = 5, KERNEL_7x7 = 7 }; /// RawStereoDepthConfig configuration structure struct RawStereoDepthConfig : public RawBuffer { using MedianFilter = dai::MedianFilter; struct AlgorithmControl { /** * Align the disparity/depth to the perspective of a rectified output, or center it */ enum class DepthAlign : int32_t { RECTIFIED_RIGHT, RECTIFIED_LEFT, CENTER }; /** * Set the disparity/depth alignment to the perspective of a rectified output, or center it */ DepthAlign depthAlign = DepthAlign::RECTIFIED_RIGHT; /** * Computes and combines disparities in both L-R and R-L directions, and combine them. * For better occlusion handling */ bool enableLeftRightCheck = true; /** * Disparity range increased from 95 to 190, combined from full resolution and downscaled images. * Suitable for short range objects */ bool enableExtended = false; /** * Computes disparity with sub-pixel interpolation (5 fractional bits), suitable for long range */ bool enableSubpixel = false; /** * Left-right check threshold for left-right, right-left disparity map combine, 0..128 * Used only when left-right check mode is enabled. * Defines the maximum difference between the confidence of pixels from left-right and right-left confidence maps */ std::int32_t leftRightCheckThreshold = 10; /** * Number of fractional bits for subpixel mode * * Valid values: 3,4,5 * * Defines the number of fractional disparities: 2^x * * Median filter postprocessing is supported only for 3 fractional bits */ std::int32_t subpixelFractionalBits = 3; DEPTHAI_SERIALIZE(AlgorithmControl, depthAlign, enableLeftRightCheck, enableExtended, enableSubpixel, leftRightCheckThreshold, subpixelFractionalBits); }; /** * Controls the flow of stereo algorithm - left-right check, subpixel etc. */ AlgorithmControl algorithmControl; /** * Post-processing filters, all the filters are applied in disparity domain. */ struct PostProcessing { /** * Set kernel size for disparity/depth median filtering, or disable */ MedianFilter median = MedianFilter::KERNEL_5x5; /** * Sigma value for bilateral filter. 0 means disabled. * A larger value of the parameter means that farther colors within the pixel neighborhood will be mixed together. */ std::int16_t bilateralSigmaValue = 0; /** * 1D edge-preserving spatial filter using high-order domain transform. */ struct SpatialFilter { static constexpr const std::int32_t DEFAULT_DELTA_VALUE = 3; /** * Whether to enable or disable the filter. */ bool enable = false; /** * An in-place heuristic symmetric hole-filling mode applied horizontally during the filter passes. * Intended to rectify minor artefacts with minimal performance impact. * Search radius for hole filling. */ std::uint8_t holeFillingRadius = 2; /** * The Alpha factor in an exponential moving average with Alpha=1 - no filter. Alpha = 0 - infinite filter. * Determines the amount of smoothing. */ float alpha = 0.5f; /** * Step-size boundary. Establishes the threshold used to preserve "edges". * If the disparity value between neighboring pixels exceed the disparity threshold set by this delta parameter, * then filtering will be temporarily disabled. * Default value 0 means auto: 3 disparity integer levels. * In case of subpixel mode it's 3*number of subpixel levels. */ std::int32_t delta = 0; /** * Nubmer of iterations over the image in both horizontal and vertical direction. */ std::int32_t numIterations = 1; DEPTHAI_SERIALIZE(SpatialFilter, enable, holeFillingRadius, alpha, delta, numIterations); }; /** * Edge-preserving filtering: This type of filter will smooth the depth noise while attempting to preserve edges. */ SpatialFilter spatialFilter; /** * Temporal filtering with optional persistence. * More details about the filter can be found here: */ struct TemporalFilter { static constexpr const std::int32_t DEFAULT_DELTA_VALUE = 3; /** * Whether to enable or disable the filter. */ bool enable = false; /** * Persistency algorithm type. */ enum class PersistencyMode : int32_t { PERSISTENCY_OFF = 0, VALID_8_OUT_OF_8 = 1, VALID_2_IN_LAST_3 = 2, VALID_2_IN_LAST_4 = 3, VALID_2_OUT_OF_8 = 4, VALID_1_IN_LAST_2 = 5, VALID_1_IN_LAST_5 = 6, VALID_1_IN_LAST_8 = 7, PERSISTENCY_INDEFINITELY = 8, }; /** * Persistency mode. * If the current disparity/depth value is invalid, it will be replaced by an older value, based on persistency mode. */ PersistencyMode persistencyMode = PersistencyMode::VALID_2_IN_LAST_4; /** * The Alpha factor in an exponential moving average with Alpha=1 - no filter. Alpha = 0 - infinite filter. * Determines the extent of the temporal history that should be averaged. */ float alpha = 0.4f; /** * Step-size boundary. Establishes the threshold used to preserve surfaces (edges). * If the disparity value between neighboring pixels exceed the disparity threshold set by this delta parameter, * then filtering will be temporarily disabled. * Default value 0 means auto: 3 disparity integer levels. * In case of subpixel mode it's 3*number of subpixel levels. */ std::int32_t delta = 0; DEPTHAI_SERIALIZE(TemporalFilter, enable, persistencyMode, alpha, delta); }; /** * Temporal filtering with optional persistence. * More details about the filter can be found here: */ TemporalFilter temporalFilter; /** * Threshold filtering. * Filters out distances outside of a given interval. */ struct ThresholdFilter { /** * Minimum range in millimeters. * Depth values under this value are invalidated. */ std::int32_t minRange = 0; /** * Minimum range in millimeters. * Depth values over this value are invalidated. */ std::int32_t maxRange = 65535; DEPTHAI_SERIALIZE(ThresholdFilter, minRange, maxRange); }; /** * Threshold filtering. * Filters out distances outside of a given interval. */ ThresholdFilter thresholdFilter; /** * Speckle filtering. * Removes speckle noise. */ struct SpeckleFilter { /** * Whether to enable or disable the filter. */ bool enable = false; /** * Speckle search range. */ std::uint32_t speckleRange = 50; DEPTHAI_SERIALIZE(SpeckleFilter, enable, speckleRange); }; /** * Speckle filtering. * Removes speckle noise. */ SpeckleFilter speckleFilter; /** * Decimation filter. * Reduces the depth scene complexity. The filter runs on kernel sizes [2x2] to [8x8] pixels. */ struct DecimationFilter { /** * Decimation factor. * Valid values are 1,2,3,4. * Disparity/depth map x/y resolution will be decimated with this value. */ std::uint32_t decimationFactor = 1; /** * Decimation algorithm type. */ enum class DecimationMode : int32_t { PIXEL_SKIPPING = 0, NON_ZERO_MEDIAN = 1, NON_ZERO_MEAN = 2, }; /** * Decimation algorithm type. */ DecimationMode decimationMode = DecimationMode::PIXEL_SKIPPING; DEPTHAI_SERIALIZE(DecimationFilter, decimationFactor, decimationMode); }; /** * Decimation filter. * Reduces disparity/depth map x/y complexity, reducing runtime complexity for other filters. */ DecimationFilter decimationFilter; DEPTHAI_SERIALIZE(PostProcessing, median, bilateralSigmaValue, spatialFilter, temporalFilter, thresholdFilter, speckleFilter, decimationFilter); }; /** * Controls the postprocessing of disparity and/or depth map. */ PostProcessing postProcessing; /** * The basic cost function used by the Stereo Accelerator for matching the left and right images is the Census * Transform. It works on a block of pixels and computes a bit vector which represents the structure of the * image in that block. * There are two types of Census Transform based on how the middle pixel is used: * Classic Approach and Modified Census. The comparisons that are made between pixels can be or not thresholded. * In some cases a mask can be applied to filter out only specific bits from the entire bit stream. * All these approaches are: * Classic Approach: Uses middle pixel to compare against all its neighbors over a defined window. Each * comparison results in a new bit, that is 0 if central pixel is smaller, or 1 if is it bigger than its neighbor. * Modified Census Transform: same as classic Census Transform, but instead of comparing central pixel * with its neighbors, the window mean will be compared with each pixel over the window. * Thresholding Census Transform: same as classic Census Transform, but it is not enough that a * neighbor pixel to be bigger than the central pixel, it must be significant bigger (based on a threshold). * Census Transform with Mask: same as classic Census Transform, but in this case not all of the pixel from * the support window are part of the binary descriptor. We use a ma sk “M” to define which pixels are part * of the binary descriptor (1), and which pixels should be skipped (0). */ struct CensusTransform { /** * Census transform kernel size possible values. */ enum class KernelSize : std::int32_t { AUTO = -1, KERNEL_5x5 = 0, KERNEL_7x7, KERNEL_7x9 }; /** * Census transform kernel size. */ KernelSize kernelSize = KernelSize::AUTO; /** * Census transform mask, default - auto, mask is set based on resolution and kernel size. * Disabled for 400p input resolution. * Enabled for 720p. * 0XA82415 for 5x5 census transform kernel. * 0XAA02A8154055 for 7x7 census transform kernel. * 0X2AA00AA805540155 for 7x9 census transform kernel. * Empirical values. */ uint64_t kernelMask = 0; /** * If enabled, each pixel in the window is compared with the mean window value instead of the central pixel. */ bool enableMeanMode = true; /** * Census transform comparison threshold value. */ uint32_t threshold = 0; DEPTHAI_SERIALIZE(CensusTransform, kernelSize, kernelMask, enableMeanMode, threshold); }; /** * Census transform settings. */ CensusTransform censusTransform; /** * The matching cost is way of measuring the similarity of image locations in stereo correspondence * algorithm. Based on the configuration parameters and based on the descriptor type, a linear equation * is applied to computing the cost for each candidate disparity at each pixel. */ struct CostMatching { /** * Disparity search range: 64 or 96 pixels are supported by the HW. */ enum class DisparityWidth : std::uint32_t { DISPARITY_64, DISPARITY_96 }; /** * Disparity search range, default 96 pixels. */ DisparityWidth disparityWidth = DisparityWidth::DISPARITY_96; /** * Disparity companding using sparse matching. * Matching pixel by pixel for N disparities. * Matching every 2nd pixel for M disparitites. * Matching every 4th pixel for T disparities. * In case of 96 disparities: N=48, M=32, T=16. * This way the search range is extended to 176 disparities, by sparse matching. * Note: when enabling this flag only depth map will be affected, disparity map is not. */ bool enableCompanding = false; /** * Used only for debug purposes, SW postprocessing handled only invalid value of 0 properly. */ uint8_t invalidDisparityValue = 0; /** * Disparities with confidence value under this threshold are accepted. * Higher confidence threshold means disparities with less confidence are accepted too. */ uint8_t confidenceThreshold = 245; /** * The linear equation applied for computing the cost is: * COMB_COST = α*AD + β*(CTC<<3). * CLAMP(COMB_COST >> 5, threshold). * Where AD is the Absolute Difference between 2 pixels values. * CTC is the Census Transform Cost between 2 pixels, based on Hamming distance (xor). * The α and β parameters are subject to fine tuning by the user. */ struct LinearEquationParameters { uint8_t alpha = 0; uint8_t beta = 2; uint8_t threshold = 127; DEPTHAI_SERIALIZE(LinearEquationParameters, alpha, beta, threshold); }; /** * Cost calculation linear equation parameters. */ LinearEquationParameters linearEquationParameters; DEPTHAI_SERIALIZE(CostMatching, disparityWidth, enableCompanding, invalidDisparityValue, confidenceThreshold, linearEquationParameters); }; /** * Cost matching settings. */ CostMatching costMatching; /** * Cost Aggregation is based on Semi Global Block Matching (SGBM). This algorithm uses a semi global * technique to aggregate the cost map. Ultimately the idea is to build inertia into the stereo algorithm. If * a pixel has very little texture information, then odds are the correct disparity for this pixel is close to * that of the previous pixel considered. This means that we get improved results in areas with low * texture. */ struct CostAggregation { static constexpr const int defaultPenaltyP1 = 250; static constexpr const int defaultPenaltyP2 = 500; /** * Cost calculation linear equation parameters. */ uint8_t divisionFactor = 1; /** * Horizontal P1 penalty cost parameter. */ uint16_t horizontalPenaltyCostP1 = defaultPenaltyP1; /** * Horizontal P2 penalty cost parameter. */ uint16_t horizontalPenaltyCostP2 = defaultPenaltyP2; /** * Vertical P1 penalty cost parameter. */ uint16_t verticalPenaltyCostP1 = defaultPenaltyP1; /** * Vertical P2 penalty cost parameter. */ uint16_t verticalPenaltyCostP2 = defaultPenaltyP2; DEPTHAI_SERIALIZE(CostAggregation, divisionFactor, horizontalPenaltyCostP1, horizontalPenaltyCostP2, verticalPenaltyCostP1, verticalPenaltyCostP2); }; /** * Cost aggregation settings. */ CostAggregation costAggregation; void serialize(std::vector<std::uint8_t>& metadata, DatatypeEnum& datatype) const override { metadata = utility::serialize(*this); datatype = DatatypeEnum::StereoDepthConfig; }; DEPTHAI_SERIALIZE(RawStereoDepthConfig, algorithmControl, postProcessing, censusTransform, costMatching, costAggregation); }; } // namespace dai
37.347162
159
0.616603
[ "vector", "transform" ]
a66e449437dc9f1e670f37a2b29b5f7bba55ddfa
285,015
cpp
C++
AR Sound Postcard Player/Library/Il2cppBuildCache/iOS/il2cppOutput/Assembly-CSharp.cpp
laurencecliffe/AAR-Postcard-Player
7b28bc7e8c4b8f57252e4ea4094d3e425196c657
[ "MIT" ]
null
null
null
AR Sound Postcard Player/Library/Il2cppBuildCache/iOS/il2cppOutput/Assembly-CSharp.cpp
laurencecliffe/AAR-Postcard-Player
7b28bc7e8c4b8f57252e4ea4094d3e425196c657
[ "MIT" ]
null
null
null
AR Sound Postcard Player/Library/Il2cppBuildCache/iOS/il2cppOutput/Assembly-CSharp.cpp
laurencecliffe/AAR-Postcard-Player
7b28bc7e8c4b8f57252e4ea4094d3e425196c657
[ "MIT" ]
null
null
null
#include "pch-cpp.hpp" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <limits> #include <stdint.h> template <typename T1> struct VirtActionInvoker1 { typedef void (*Action)(void*, T1, const RuntimeMethod*); static inline void Invoke (Il2CppMethodSlot slot, RuntimeObject* obj, T1 p1) { const VirtualInvokeData& invokeData = il2cpp_codegen_get_virtual_invoke_data(slot, obj); ((Action)invokeData.methodPtr)(obj, p1, invokeData.method); } }; // System.Action`1<UnityEngine.XR.ARFoundation.ARSessionStateChangedEventArgs> struct Action_1_t5DF84322FFE12A24465E48164961CD724D109521; // System.Action`1<UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs> struct Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032; // System.Collections.Generic.Dictionary`2<System.Guid,UnityEngine.XR.ARSubsystems.XRReferenceImage> struct Dictionary_2_t1D971BA151CCF2A891990C13C7561FEC253BC7CF; // System.Collections.Generic.Dictionary`2<System.Object,System.Object> struct Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D; // System.Collections.Generic.Dictionary`2<System.String,UnityEngine.GameObject> struct Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C; // System.Collections.Generic.Dictionary`2<UnityEngine.XR.ARSubsystems.TrackableId,UnityEngine.XR.ARFoundation.ARTrackedImage> struct Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E; // System.Collections.Generic.IEqualityComparer`1<System.String> struct IEqualityComparer_1_tE6A65C5E45E33FD7D9849FD0914DE3AD32B68050; // System.Collections.Generic.Dictionary`2/KeyCollection<System.String,UnityEngine.GameObject> struct KeyCollection_t8B43E8504381EBAE726A65E47CF5C58389CCDCD3; // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> struct List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F; // System.Collections.Generic.List`1<System.Object> struct List_1_t3F94120C77410A62EAE48421CF166B83AB95A2F5; // System.Collections.Generic.List`1<UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem> struct List_1_t19D4B5E8CD4DAF90FBAC8A83E6F7E9C0939C7BE0; // System.Collections.Generic.List`1<UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystemDescriptor> struct List_1_t179969632C4CD7B25BEBAA7DA12BA4C8F82F69F2; // System.Collections.Generic.List`1<UnityEngine.XR.ARSubsystems.XRSessionSubsystem> struct List_1_tC3943A359D121C56123E4142DF967EF5FCCAF2C3; // System.Collections.Generic.List`1<UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor> struct List_1_tDA25459A722F5B00FFE84463D9952660BC3F6673; // UnityEngine.UI.CoroutineTween.TweenRunner`1<UnityEngine.UI.CoroutineTween.ColorTween> struct TweenRunner_1_tD84B9953874682FCC36990AF2C54D748293908F3; // System.Collections.Generic.Dictionary`2/ValueCollection<System.Object,System.Object> struct ValueCollection_t0ACCC25930444F15B1857D00E9FB6021E5842852; // System.Collections.Generic.Dictionary`2/ValueCollection<System.String,UnityEngine.GameObject> struct ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59; // System.Collections.Generic.Dictionary`2/Entry<System.String,UnityEngine.GameObject>[] struct EntryU5BU5D_t954984A7FAD7638C56E3980445C36F374F9CC3ED; // UnityEngine.XR.ARFoundation.ARTrackedImage[] struct ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142; // System.Char[] struct CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34; // System.Delegate[] struct DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8; // Enemy[] struct EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0; // UnityEngine.GameObject[] struct GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642; // System.Int32[] struct Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32; // System.IntPtr[] struct IntPtrU5BU5D_t27FC72B0409D75AAF33EC42498E8094E95FEE9A6; // System.Object[] struct ObjectU5BU5D_tC1F4EE0DB0B7300255F5FD4AF64FE4C585CF5ADE; // System.Diagnostics.StackTrace[] struct StackTraceU5BU5D_t4AD999C288CB6D1F38A299D12B1598D606588971; // UnityEngine.UIVertex[] struct UIVertexU5BU5D_tE3D523C48DFEBC775876720DE2539A79FB7E5E5A; // UnityEngine.Vector2[] struct Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA; // UnityEngine.Vector3[] struct Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4; // UnityEngine.XR.ARFoundation.ARSession struct ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B; // UnityEngine.XR.ARFoundation.ARSessionOrigin struct ARSessionOrigin_tA15648434106370D592D12C00B93054EC6CE6AE1; // UnityEngine.XR.ARFoundation.ARTrackedImage struct ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7; // UnityEngine.XR.ARFoundation.ARTrackedImageManager struct ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2; // System.AsyncCallback struct AsyncCallback_tA7921BEF974919C46FF8F9D9867C567B200BB0EA; // UnityEngine.Behaviour struct Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9; // UnityEngine.Canvas struct Canvas_t2B7E56B7BDC287962E092755372E214ACB6393EA; // UnityEngine.CanvasRenderer struct CanvasRenderer_tCF8ABE659F7C3A6ED0D99A988D0BDFB651310F0E; // UnityEngine.Component struct Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684; // System.DelegateData struct DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288; // DisableScreenSleeping struct DisableScreenSleeping_t721C4DDFE6A41229AABD432937B146D77CED2420; // Enemy struct Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627; // FindClosest struct FindClosest_t502181BF1D570545238207A41095AF8DCF41E819; // UnityEngine.UI.FontData struct FontData_t0F1E9B3ED8136CD40782AC9A6AFB69CAD127C738; // UnityEngine.GameObject struct GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319; // System.IAsyncResult struct IAsyncResult_tC9F97BF36FCF122D29D3101D80642278297BF370; // System.Collections.IDictionary struct IDictionary_t99871C56B8EC2452AC5C4CF3831695E617B89D3A; // System.Collections.IEnumerator struct IEnumerator_t5956F3AFB7ECF1117E3BC5890E7FC7B7F7A04105; // ImageTracking struct ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80; // MakePostcard struct MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF; // UnityEngine.Material struct Material_t8927C00353A72755313F046D0CE85178AE8218EE; // MenuControl struct MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778; // UnityEngine.Mesh struct Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6; // System.Reflection.MethodInfo struct MethodInfo_t; // UnityEngine.MonoBehaviour struct MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A; // System.NotSupportedException struct NotSupportedException_tB9D89F0E9470A2C423D239D7C68EE0CFD77F9339; // UnityEngine.Object struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A; // System.Security.Cryptography.RandomNumberGenerator struct RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50; // UnityEngine.UI.RectMask2D struct RectMask2D_tD909811991B341D752E4C978C89EFB80FA7A2B15; // UnityEngine.RectTransform struct RectTransform_t8A6A306FB29A6C8C22010CF9040E319753571072; // System.Text.RegularExpressions.Regex struct Regex_t90F443D398F44965EA241A652ED75DF5BA072A1F; // System.Runtime.Serialization.SafeSerializationManager struct SafeSerializationManager_tDE44F029589A028F8A3053C5C06153FAB4AAE29F; // System.String struct String_t; // UnityEngine.UI.Text struct Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1; // UnityEngine.TextGenerator struct TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70; // UnityEngine.Texture2D struct Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF; // TrackingState struct TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD; // UnityEngine.Transform struct Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1; // UnityEngine.Events.UnityAction struct UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099; // UnityEngine.UI.VertexHelper struct VertexHelper_tDE8B67D3B076061C4F8DF325B0D63ED2E5367E55; // System.Void struct Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5; // UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem struct XRImageTrackingSubsystem_tBC68AD21C11D8D67F3343844E129DF505FF705CE; // UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary struct XRReferenceImageLibrary_tC415743C1DDCE2331D5B0F159B2A1D72A70C44B2; // UnityEngine.XR.ARSubsystems.XRSessionSubsystem struct XRSessionSubsystem_t8AD3C01568AA19BF038D23A6031FF9814CAF93CD; // UnityEngine.UI.MaskableGraphic/CullStateChangedEvent struct CullStateChangedEvent_t9B69755DEBEF041C3CC15C3604610BDD72856BD4; // TrackingState/<Start>d__3 struct U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2; IL2CPP_EXTERN_C RuntimeClass* ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* Debug_tEB68BCBEB8EFD60F8043C67146DC05E7F50F374B_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* NotSupportedException_tB9D89F0E9470A2C423D239D7C68EE0CFD77F9339_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* RuntimeManager_t87723E19BD688665EF5E4375DDA0AC4C1762F48A_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* SceneManager_tEC9D10ECC0377F8AE5AEEB5A789FFD24364440FA_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C RuntimeClass* U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2_il2cpp_TypeInfo_var; IL2CPP_EXTERN_C String_t* _stringLiteral05F29CE2C3E06492FAFE36672D97EF781FABE332; IL2CPP_EXTERN_C String_t* _stringLiteral116273CD5D8FA85B2B09F79802D1EDD0C11FFC66; IL2CPP_EXTERN_C String_t* _stringLiteral23AF701FF440280F9BDD61B514BB41F48690A8DA; IL2CPP_EXTERN_C String_t* _stringLiteral27FD14CFE32223C443750A097C6E310D28F90764; IL2CPP_EXTERN_C String_t* _stringLiteral4772D75F86FF8033EF18BEB5A2555DE7B32A6367; IL2CPP_EXTERN_C String_t* _stringLiteral509C084586320A910444D73ACF5386F77869E8FB; IL2CPP_EXTERN_C String_t* _stringLiteral5A350421A6B211C96799ECB935A49263F4151989; IL2CPP_EXTERN_C String_t* _stringLiteral75DC5674555374787C274EE541661679A3633A2A; IL2CPP_EXTERN_C String_t* _stringLiteral76EEBE76F86A4AA251CB82FFE984B55CE979F8B0; IL2CPP_EXTERN_C String_t* _stringLiteral97F6A0D5A49A9E5B5967996FDDA9C89F1DB3C249; IL2CPP_EXTERN_C String_t* _stringLiteralAFD6B8CE125A895141C64EC9E3F8A30B4AC588B4; IL2CPP_EXTERN_C String_t* _stringLiteralB15C3B1E5301A454B1F6EF3D4C8C3CA94F73285F; IL2CPP_EXTERN_C String_t* _stringLiteralBE26ADEBA1E2A48086FCB0B8D271B53D826E6CD1; IL2CPP_EXTERN_C String_t* _stringLiteralC3B453E9F0C07BDDAE29F036F419A22466145753; IL2CPP_EXTERN_C String_t* _stringLiteralD0B41CA0013533DCFC7C034949701DA4C558A039; IL2CPP_EXTERN_C String_t* _stringLiteralD7A59EABF0C51AF863757F81CFC978C0C90E24B3; IL2CPP_EXTERN_C String_t* _stringLiteralDA39A3EE5E6B4B0D3255BFEF95601890AFD80709; IL2CPP_EXTERN_C String_t* _stringLiteralE3DB1B6CF792E1BF1AED62392910B83816D9FC52; IL2CPP_EXTERN_C const RuntimeMethod* Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Dictionary_2_Add_m6D23729A58240291FAD0B2A484D107C5D06B8A78_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Dictionary_2__ctor_m627A706D7F24292D51368C749EB140EFE869376A_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Dictionary_2_get_Item_mC4E467FB6129C74774CC33C4A8E3B1F00A73E15A_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Dictionary_2_get_Values_mCE27229BD2853EB5DD18823A44CB838915891AF5_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Enumerator_Dispose_mA7C5E1105681D1F3AEFE0B3D8F403231775794CC_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Enumerator_MoveNext_mCB1E114B7C949E2BE0521FAB1DCD32D836AA838E_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Enumerator_get_Current_mD4B9742F53CF6579D470CB4824D954C4590A53B0_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* GameObject_GetComponent_TisMakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF_m0CB94270367E249EACBB0933F846EFF09FFEF5F6_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* GameObject_GetComponent_TisText_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1_mD98876EFC776CB8D02A1394AE6A72DC47F271C65_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* ImageTracking_ImageChanged_mF71CEAFEC17C56EA45ED003E88C0A51609B8105A_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Object_FindObjectOfType_TisARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2_m660417E625FD0A66345200E2670A25DD17AA6A22_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Object_FindObjectsOfType_TisEnemy_tF0E5C8811BC93A523814C562C545DB3C1A755627_mAAE5765443D834ABFAA93E538F961D94D5E8340B_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Object_FindObjectsOfType_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_mA1495EFEECA7BF44DA43D9813F575C92968F0B4F_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* Object_Instantiate_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_m81B599A0051F8F4543E5C73A11585E96E940943B_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* U3CStartU3Ed__3_System_Collections_IEnumerator_Reset_m8E7D19A65210DCE4B77F291C0736EF58E854BC4D_RuntimeMethod_var; IL2CPP_EXTERN_C const RuntimeMethod* ValueCollection_GetEnumerator_m4F21A422DA7CBC55B4596D04154835F270B15957_RuntimeMethod_var; struct Delegate_t_marshaled_com; struct Delegate_t_marshaled_pinvoke; struct Exception_t_marshaled_com; struct Exception_t_marshaled_pinvoke; struct EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0; struct GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642; IL2CPP_EXTERN_C_BEGIN IL2CPP_EXTERN_C_END #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // <Module> struct U3CModuleU3E_tFDCAFCBB4B3431CFF2DC4D3E03FBFDF54EFF7E9A { public: public: }; // System.Object // System.Collections.Generic.Dictionary`2<System.String,UnityEngine.GameObject> struct Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C : public RuntimeObject { public: // System.Int32[] System.Collections.Generic.Dictionary`2::buckets Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32* ___buckets_0; // System.Collections.Generic.Dictionary`2/Entry<TKey,TValue>[] System.Collections.Generic.Dictionary`2::entries EntryU5BU5D_t954984A7FAD7638C56E3980445C36F374F9CC3ED* ___entries_1; // System.Int32 System.Collections.Generic.Dictionary`2::count int32_t ___count_2; // System.Int32 System.Collections.Generic.Dictionary`2::version int32_t ___version_3; // System.Int32 System.Collections.Generic.Dictionary`2::freeList int32_t ___freeList_4; // System.Int32 System.Collections.Generic.Dictionary`2::freeCount int32_t ___freeCount_5; // System.Collections.Generic.IEqualityComparer`1<TKey> System.Collections.Generic.Dictionary`2::comparer RuntimeObject* ___comparer_6; // System.Collections.Generic.Dictionary`2/KeyCollection<TKey,TValue> System.Collections.Generic.Dictionary`2::keys KeyCollection_t8B43E8504381EBAE726A65E47CF5C58389CCDCD3 * ___keys_7; // System.Collections.Generic.Dictionary`2/ValueCollection<TKey,TValue> System.Collections.Generic.Dictionary`2::values ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 * ___values_8; // System.Object System.Collections.Generic.Dictionary`2::_syncRoot RuntimeObject * ____syncRoot_9; public: inline static int32_t get_offset_of_buckets_0() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___buckets_0)); } inline Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32* get_buckets_0() const { return ___buckets_0; } inline Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32** get_address_of_buckets_0() { return &___buckets_0; } inline void set_buckets_0(Int32U5BU5D_t70F1BDC14B1786481B176D6139A5E3B87DC54C32* value) { ___buckets_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___buckets_0), (void*)value); } inline static int32_t get_offset_of_entries_1() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___entries_1)); } inline EntryU5BU5D_t954984A7FAD7638C56E3980445C36F374F9CC3ED* get_entries_1() const { return ___entries_1; } inline EntryU5BU5D_t954984A7FAD7638C56E3980445C36F374F9CC3ED** get_address_of_entries_1() { return &___entries_1; } inline void set_entries_1(EntryU5BU5D_t954984A7FAD7638C56E3980445C36F374F9CC3ED* value) { ___entries_1 = value; Il2CppCodeGenWriteBarrier((void**)(&___entries_1), (void*)value); } inline static int32_t get_offset_of_count_2() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___count_2)); } inline int32_t get_count_2() const { return ___count_2; } inline int32_t* get_address_of_count_2() { return &___count_2; } inline void set_count_2(int32_t value) { ___count_2 = value; } inline static int32_t get_offset_of_version_3() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___version_3)); } inline int32_t get_version_3() const { return ___version_3; } inline int32_t* get_address_of_version_3() { return &___version_3; } inline void set_version_3(int32_t value) { ___version_3 = value; } inline static int32_t get_offset_of_freeList_4() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___freeList_4)); } inline int32_t get_freeList_4() const { return ___freeList_4; } inline int32_t* get_address_of_freeList_4() { return &___freeList_4; } inline void set_freeList_4(int32_t value) { ___freeList_4 = value; } inline static int32_t get_offset_of_freeCount_5() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___freeCount_5)); } inline int32_t get_freeCount_5() const { return ___freeCount_5; } inline int32_t* get_address_of_freeCount_5() { return &___freeCount_5; } inline void set_freeCount_5(int32_t value) { ___freeCount_5 = value; } inline static int32_t get_offset_of_comparer_6() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___comparer_6)); } inline RuntimeObject* get_comparer_6() const { return ___comparer_6; } inline RuntimeObject** get_address_of_comparer_6() { return &___comparer_6; } inline void set_comparer_6(RuntimeObject* value) { ___comparer_6 = value; Il2CppCodeGenWriteBarrier((void**)(&___comparer_6), (void*)value); } inline static int32_t get_offset_of_keys_7() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___keys_7)); } inline KeyCollection_t8B43E8504381EBAE726A65E47CF5C58389CCDCD3 * get_keys_7() const { return ___keys_7; } inline KeyCollection_t8B43E8504381EBAE726A65E47CF5C58389CCDCD3 ** get_address_of_keys_7() { return &___keys_7; } inline void set_keys_7(KeyCollection_t8B43E8504381EBAE726A65E47CF5C58389CCDCD3 * value) { ___keys_7 = value; Il2CppCodeGenWriteBarrier((void**)(&___keys_7), (void*)value); } inline static int32_t get_offset_of_values_8() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ___values_8)); } inline ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 * get_values_8() const { return ___values_8; } inline ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 ** get_address_of_values_8() { return &___values_8; } inline void set_values_8(ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 * value) { ___values_8 = value; Il2CppCodeGenWriteBarrier((void**)(&___values_8), (void*)value); } inline static int32_t get_offset_of__syncRoot_9() { return static_cast<int32_t>(offsetof(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C, ____syncRoot_9)); } inline RuntimeObject * get__syncRoot_9() const { return ____syncRoot_9; } inline RuntimeObject ** get_address_of__syncRoot_9() { return &____syncRoot_9; } inline void set__syncRoot_9(RuntimeObject * value) { ____syncRoot_9 = value; Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_9), (void*)value); } }; // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> struct List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F : public RuntimeObject { public: // T[] System.Collections.Generic.List`1::_items ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142* ____items_1; // System.Int32 System.Collections.Generic.List`1::_size int32_t ____size_2; // System.Int32 System.Collections.Generic.List`1::_version int32_t ____version_3; // System.Object System.Collections.Generic.List`1::_syncRoot RuntimeObject * ____syncRoot_4; public: inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F, ____items_1)); } inline ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142* get__items_1() const { return ____items_1; } inline ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142** get_address_of__items_1() { return &____items_1; } inline void set__items_1(ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142* value) { ____items_1 = value; Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value); } inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F, ____size_2)); } inline int32_t get__size_2() const { return ____size_2; } inline int32_t* get_address_of__size_2() { return &____size_2; } inline void set__size_2(int32_t value) { ____size_2 = value; } inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F, ____version_3)); } inline int32_t get__version_3() const { return ____version_3; } inline int32_t* get_address_of__version_3() { return &____version_3; } inline void set__version_3(int32_t value) { ____version_3 = value; } inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F, ____syncRoot_4)); } inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; } inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; } inline void set__syncRoot_4(RuntimeObject * value) { ____syncRoot_4 = value; Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value); } }; struct List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F_StaticFields { public: // T[] System.Collections.Generic.List`1::_emptyArray ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142* ____emptyArray_5; public: inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F_StaticFields, ____emptyArray_5)); } inline ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142* get__emptyArray_5() const { return ____emptyArray_5; } inline ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142** get_address_of__emptyArray_5() { return &____emptyArray_5; } inline void set__emptyArray_5(ARTrackedImageU5BU5D_t63FA636B7BA07C17EE59D7707CEED317A3B23142* value) { ____emptyArray_5 = value; Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value); } }; // System.Collections.Generic.Dictionary`2/ValueCollection<System.String,UnityEngine.GameObject> struct ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 : public RuntimeObject { public: // System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/ValueCollection::dictionary Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * ___dictionary_0; public: inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59, ___dictionary_0)); } inline Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * get_dictionary_0() const { return ___dictionary_0; } inline Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C ** get_address_of_dictionary_0() { return &___dictionary_0; } inline void set_dictionary_0(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * value) { ___dictionary_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value); } }; struct Il2CppArrayBounds; // System.Array // System.String struct String_t : public RuntimeObject { public: // System.Int32 System.String::m_stringLength int32_t ___m_stringLength_0; // System.Char System.String::m_firstChar Il2CppChar ___m_firstChar_1; public: inline static int32_t get_offset_of_m_stringLength_0() { return static_cast<int32_t>(offsetof(String_t, ___m_stringLength_0)); } inline int32_t get_m_stringLength_0() const { return ___m_stringLength_0; } inline int32_t* get_address_of_m_stringLength_0() { return &___m_stringLength_0; } inline void set_m_stringLength_0(int32_t value) { ___m_stringLength_0 = value; } inline static int32_t get_offset_of_m_firstChar_1() { return static_cast<int32_t>(offsetof(String_t, ___m_firstChar_1)); } inline Il2CppChar get_m_firstChar_1() const { return ___m_firstChar_1; } inline Il2CppChar* get_address_of_m_firstChar_1() { return &___m_firstChar_1; } inline void set_m_firstChar_1(Il2CppChar value) { ___m_firstChar_1 = value; } }; struct String_t_StaticFields { public: // System.String System.String::Empty String_t* ___Empty_5; public: inline static int32_t get_offset_of_Empty_5() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___Empty_5)); } inline String_t* get_Empty_5() const { return ___Empty_5; } inline String_t** get_address_of_Empty_5() { return &___Empty_5; } inline void set_Empty_5(String_t* value) { ___Empty_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___Empty_5), (void*)value); } }; // System.ValueType struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52 : public RuntimeObject { public: public: }; // Native definition for P/Invoke marshalling of System.ValueType struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_pinvoke { }; // Native definition for COM marshalling of System.ValueType struct ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52_marshaled_com { }; // TrackingState/<Start>d__3 struct U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 : public RuntimeObject { public: // System.Int32 TrackingState/<Start>d__3::<>1__state int32_t ___U3CU3E1__state_0; // System.Object TrackingState/<Start>d__3::<>2__current RuntimeObject * ___U3CU3E2__current_1; // TrackingState TrackingState/<Start>d__3::<>4__this TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * ___U3CU3E4__this_2; public: inline static int32_t get_offset_of_U3CU3E1__state_0() { return static_cast<int32_t>(offsetof(U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2, ___U3CU3E1__state_0)); } inline int32_t get_U3CU3E1__state_0() const { return ___U3CU3E1__state_0; } inline int32_t* get_address_of_U3CU3E1__state_0() { return &___U3CU3E1__state_0; } inline void set_U3CU3E1__state_0(int32_t value) { ___U3CU3E1__state_0 = value; } inline static int32_t get_offset_of_U3CU3E2__current_1() { return static_cast<int32_t>(offsetof(U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2, ___U3CU3E2__current_1)); } inline RuntimeObject * get_U3CU3E2__current_1() const { return ___U3CU3E2__current_1; } inline RuntimeObject ** get_address_of_U3CU3E2__current_1() { return &___U3CU3E2__current_1; } inline void set_U3CU3E2__current_1(RuntimeObject * value) { ___U3CU3E2__current_1 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CU3E2__current_1), (void*)value); } inline static int32_t get_offset_of_U3CU3E4__this_2() { return static_cast<int32_t>(offsetof(U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2, ___U3CU3E4__this_2)); } inline TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * get_U3CU3E4__this_2() const { return ___U3CU3E4__this_2; } inline TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD ** get_address_of_U3CU3E4__this_2() { return &___U3CU3E4__this_2; } inline void set_U3CU3E4__this_2(TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * value) { ___U3CU3E4__this_2 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CU3E4__this_2), (void*)value); } }; // System.Collections.Generic.List`1/Enumerator<UnityEngine.XR.ARFoundation.ARTrackedImage> struct Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 { public: // System.Collections.Generic.List`1<T> System.Collections.Generic.List`1/Enumerator::list List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___list_0; // System.Int32 System.Collections.Generic.List`1/Enumerator::index int32_t ___index_1; // System.Int32 System.Collections.Generic.List`1/Enumerator::version int32_t ___version_2; // T System.Collections.Generic.List`1/Enumerator::current ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * ___current_3; public: inline static int32_t get_offset_of_list_0() { return static_cast<int32_t>(offsetof(Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4, ___list_0)); } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * get_list_0() const { return ___list_0; } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F ** get_address_of_list_0() { return &___list_0; } inline void set_list_0(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * value) { ___list_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___list_0), (void*)value); } inline static int32_t get_offset_of_index_1() { return static_cast<int32_t>(offsetof(Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4, ___index_1)); } inline int32_t get_index_1() const { return ___index_1; } inline int32_t* get_address_of_index_1() { return &___index_1; } inline void set_index_1(int32_t value) { ___index_1 = value; } inline static int32_t get_offset_of_version_2() { return static_cast<int32_t>(offsetof(Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4, ___version_2)); } inline int32_t get_version_2() const { return ___version_2; } inline int32_t* get_address_of_version_2() { return &___version_2; } inline void set_version_2(int32_t value) { ___version_2 = value; } inline static int32_t get_offset_of_current_3() { return static_cast<int32_t>(offsetof(Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4, ___current_3)); } inline ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * get_current_3() const { return ___current_3; } inline ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 ** get_address_of_current_3() { return &___current_3; } inline void set_current_3(ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * value) { ___current_3 = value; Il2CppCodeGenWriteBarrier((void**)(&___current_3), (void*)value); } }; // System.Collections.Generic.List`1/Enumerator<System.Object> struct Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6 { public: // System.Collections.Generic.List`1<T> System.Collections.Generic.List`1/Enumerator::list List_1_t3F94120C77410A62EAE48421CF166B83AB95A2F5 * ___list_0; // System.Int32 System.Collections.Generic.List`1/Enumerator::index int32_t ___index_1; // System.Int32 System.Collections.Generic.List`1/Enumerator::version int32_t ___version_2; // T System.Collections.Generic.List`1/Enumerator::current RuntimeObject * ___current_3; public: inline static int32_t get_offset_of_list_0() { return static_cast<int32_t>(offsetof(Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6, ___list_0)); } inline List_1_t3F94120C77410A62EAE48421CF166B83AB95A2F5 * get_list_0() const { return ___list_0; } inline List_1_t3F94120C77410A62EAE48421CF166B83AB95A2F5 ** get_address_of_list_0() { return &___list_0; } inline void set_list_0(List_1_t3F94120C77410A62EAE48421CF166B83AB95A2F5 * value) { ___list_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___list_0), (void*)value); } inline static int32_t get_offset_of_index_1() { return static_cast<int32_t>(offsetof(Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6, ___index_1)); } inline int32_t get_index_1() const { return ___index_1; } inline int32_t* get_address_of_index_1() { return &___index_1; } inline void set_index_1(int32_t value) { ___index_1 = value; } inline static int32_t get_offset_of_version_2() { return static_cast<int32_t>(offsetof(Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6, ___version_2)); } inline int32_t get_version_2() const { return ___version_2; } inline int32_t* get_address_of_version_2() { return &___version_2; } inline void set_version_2(int32_t value) { ___version_2 = value; } inline static int32_t get_offset_of_current_3() { return static_cast<int32_t>(offsetof(Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6, ___current_3)); } inline RuntimeObject * get_current_3() const { return ___current_3; } inline RuntimeObject ** get_address_of_current_3() { return &___current_3; } inline void set_current_3(RuntimeObject * value) { ___current_3 = value; Il2CppCodeGenWriteBarrier((void**)(&___current_3), (void*)value); } }; // System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.Object,System.Object> struct Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2 { public: // System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::dictionary Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D * ___dictionary_0; // System.Int32 System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::index int32_t ___index_1; // System.Int32 System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::version int32_t ___version_2; // TValue System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::currentValue RuntimeObject * ___currentValue_3; public: inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2, ___dictionary_0)); } inline Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D * get_dictionary_0() const { return ___dictionary_0; } inline Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D ** get_address_of_dictionary_0() { return &___dictionary_0; } inline void set_dictionary_0(Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D * value) { ___dictionary_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value); } inline static int32_t get_offset_of_index_1() { return static_cast<int32_t>(offsetof(Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2, ___index_1)); } inline int32_t get_index_1() const { return ___index_1; } inline int32_t* get_address_of_index_1() { return &___index_1; } inline void set_index_1(int32_t value) { ___index_1 = value; } inline static int32_t get_offset_of_version_2() { return static_cast<int32_t>(offsetof(Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2, ___version_2)); } inline int32_t get_version_2() const { return ___version_2; } inline int32_t* get_address_of_version_2() { return &___version_2; } inline void set_version_2(int32_t value) { ___version_2 = value; } inline static int32_t get_offset_of_currentValue_3() { return static_cast<int32_t>(offsetof(Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2, ___currentValue_3)); } inline RuntimeObject * get_currentValue_3() const { return ___currentValue_3; } inline RuntimeObject ** get_address_of_currentValue_3() { return &___currentValue_3; } inline void set_currentValue_3(RuntimeObject * value) { ___currentValue_3 = value; Il2CppCodeGenWriteBarrier((void**)(&___currentValue_3), (void*)value); } }; // System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.String,UnityEngine.GameObject> struct Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 { public: // System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::dictionary Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * ___dictionary_0; // System.Int32 System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::index int32_t ___index_1; // System.Int32 System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::version int32_t ___version_2; // TValue System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator::currentValue GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___currentValue_3; public: inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56, ___dictionary_0)); } inline Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * get_dictionary_0() const { return ___dictionary_0; } inline Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C ** get_address_of_dictionary_0() { return &___dictionary_0; } inline void set_dictionary_0(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * value) { ___dictionary_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value); } inline static int32_t get_offset_of_index_1() { return static_cast<int32_t>(offsetof(Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56, ___index_1)); } inline int32_t get_index_1() const { return ___index_1; } inline int32_t* get_address_of_index_1() { return &___index_1; } inline void set_index_1(int32_t value) { ___index_1 = value; } inline static int32_t get_offset_of_version_2() { return static_cast<int32_t>(offsetof(Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56, ___version_2)); } inline int32_t get_version_2() const { return ___version_2; } inline int32_t* get_address_of_version_2() { return &___version_2; } inline void set_version_2(int32_t value) { ___version_2 = value; } inline static int32_t get_offset_of_currentValue_3() { return static_cast<int32_t>(offsetof(Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56, ___currentValue_3)); } inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_currentValue_3() const { return ___currentValue_3; } inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_currentValue_3() { return &___currentValue_3; } inline void set_currentValue_3(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value) { ___currentValue_3 = value; Il2CppCodeGenWriteBarrier((void**)(&___currentValue_3), (void*)value); } }; // UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs struct ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C { public: // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs::<added>k__BackingField List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CaddedU3Ek__BackingField_0; // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs::<updated>k__BackingField List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CupdatedU3Ek__BackingField_1; // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs::<removed>k__BackingField List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CremovedU3Ek__BackingField_2; public: inline static int32_t get_offset_of_U3CaddedU3Ek__BackingField_0() { return static_cast<int32_t>(offsetof(ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C, ___U3CaddedU3Ek__BackingField_0)); } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * get_U3CaddedU3Ek__BackingField_0() const { return ___U3CaddedU3Ek__BackingField_0; } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F ** get_address_of_U3CaddedU3Ek__BackingField_0() { return &___U3CaddedU3Ek__BackingField_0; } inline void set_U3CaddedU3Ek__BackingField_0(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * value) { ___U3CaddedU3Ek__BackingField_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CaddedU3Ek__BackingField_0), (void*)value); } inline static int32_t get_offset_of_U3CupdatedU3Ek__BackingField_1() { return static_cast<int32_t>(offsetof(ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C, ___U3CupdatedU3Ek__BackingField_1)); } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * get_U3CupdatedU3Ek__BackingField_1() const { return ___U3CupdatedU3Ek__BackingField_1; } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F ** get_address_of_U3CupdatedU3Ek__BackingField_1() { return &___U3CupdatedU3Ek__BackingField_1; } inline void set_U3CupdatedU3Ek__BackingField_1(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * value) { ___U3CupdatedU3Ek__BackingField_1 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CupdatedU3Ek__BackingField_1), (void*)value); } inline static int32_t get_offset_of_U3CremovedU3Ek__BackingField_2() { return static_cast<int32_t>(offsetof(ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C, ___U3CremovedU3Ek__BackingField_2)); } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * get_U3CremovedU3Ek__BackingField_2() const { return ___U3CremovedU3Ek__BackingField_2; } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F ** get_address_of_U3CremovedU3Ek__BackingField_2() { return &___U3CremovedU3Ek__BackingField_2; } inline void set_U3CremovedU3Ek__BackingField_2(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * value) { ___U3CremovedU3Ek__BackingField_2 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CremovedU3Ek__BackingField_2), (void*)value); } }; // Native definition for P/Invoke marshalling of UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs struct ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C_marshaled_pinvoke { List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CaddedU3Ek__BackingField_0; List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CupdatedU3Ek__BackingField_1; List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CremovedU3Ek__BackingField_2; }; // Native definition for COM marshalling of UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs struct ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C_marshaled_com { List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CaddedU3Ek__BackingField_0; List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CupdatedU3Ek__BackingField_1; List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___U3CremovedU3Ek__BackingField_2; }; // System.Boolean struct Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37 { public: // System.Boolean System.Boolean::m_value bool ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37, ___m_value_0)); } inline bool get_m_value_0() const { return ___m_value_0; } inline bool* get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(bool value) { ___m_value_0 = value; } }; struct Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields { public: // System.String System.Boolean::TrueString String_t* ___TrueString_5; // System.String System.Boolean::FalseString String_t* ___FalseString_6; public: inline static int32_t get_offset_of_TrueString_5() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields, ___TrueString_5)); } inline String_t* get_TrueString_5() const { return ___TrueString_5; } inline String_t** get_address_of_TrueString_5() { return &___TrueString_5; } inline void set_TrueString_5(String_t* value) { ___TrueString_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___TrueString_5), (void*)value); } inline static int32_t get_offset_of_FalseString_6() { return static_cast<int32_t>(offsetof(Boolean_t07D1E3F34E4813023D64F584DFF7B34C9D922F37_StaticFields, ___FalseString_6)); } inline String_t* get_FalseString_6() const { return ___FalseString_6; } inline String_t** get_address_of_FalseString_6() { return &___FalseString_6; } inline void set_FalseString_6(String_t* value) { ___FalseString_6 = value; Il2CppCodeGenWriteBarrier((void**)(&___FalseString_6), (void*)value); } }; // UnityEngine.Color struct Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659 { public: // System.Single UnityEngine.Color::r float ___r_0; // System.Single UnityEngine.Color::g float ___g_1; // System.Single UnityEngine.Color::b float ___b_2; // System.Single UnityEngine.Color::a float ___a_3; public: inline static int32_t get_offset_of_r_0() { return static_cast<int32_t>(offsetof(Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659, ___r_0)); } inline float get_r_0() const { return ___r_0; } inline float* get_address_of_r_0() { return &___r_0; } inline void set_r_0(float value) { ___r_0 = value; } inline static int32_t get_offset_of_g_1() { return static_cast<int32_t>(offsetof(Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659, ___g_1)); } inline float get_g_1() const { return ___g_1; } inline float* get_address_of_g_1() { return &___g_1; } inline void set_g_1(float value) { ___g_1 = value; } inline static int32_t get_offset_of_b_2() { return static_cast<int32_t>(offsetof(Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659, ___b_2)); } inline float get_b_2() const { return ___b_2; } inline float* get_address_of_b_2() { return &___b_2; } inline void set_b_2(float value) { ___b_2 = value; } inline static int32_t get_offset_of_a_3() { return static_cast<int32_t>(offsetof(Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659, ___a_3)); } inline float get_a_3() const { return ___a_3; } inline float* get_address_of_a_3() { return &___a_3; } inline void set_a_3(float value) { ___a_3 = value; } }; // System.Enum struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA : public ValueType_tDBF999C1B75C48C68621878250DBF6CDBCF51E52 { public: public: }; struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA_StaticFields { public: // System.Char[] System.Enum::enumSeperatorCharArray CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34* ___enumSeperatorCharArray_0; public: inline static int32_t get_offset_of_enumSeperatorCharArray_0() { return static_cast<int32_t>(offsetof(Enum_t23B90B40F60E677A8025267341651C94AE079CDA_StaticFields, ___enumSeperatorCharArray_0)); } inline CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34* get_enumSeperatorCharArray_0() const { return ___enumSeperatorCharArray_0; } inline CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34** get_address_of_enumSeperatorCharArray_0() { return &___enumSeperatorCharArray_0; } inline void set_enumSeperatorCharArray_0(CharU5BU5D_t7B7FC5BC8091AA3B9CB0B29CDD80B5EE9254AA34* value) { ___enumSeperatorCharArray_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___enumSeperatorCharArray_0), (void*)value); } }; // Native definition for P/Invoke marshalling of System.Enum struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA_marshaled_pinvoke { }; // Native definition for COM marshalling of System.Enum struct Enum_t23B90B40F60E677A8025267341651C94AE079CDA_marshaled_com { }; // System.Guid struct Guid_t { public: // System.Int32 System.Guid::_a int32_t ____a_1; // System.Int16 System.Guid::_b int16_t ____b_2; // System.Int16 System.Guid::_c int16_t ____c_3; // System.Byte System.Guid::_d uint8_t ____d_4; // System.Byte System.Guid::_e uint8_t ____e_5; // System.Byte System.Guid::_f uint8_t ____f_6; // System.Byte System.Guid::_g uint8_t ____g_7; // System.Byte System.Guid::_h uint8_t ____h_8; // System.Byte System.Guid::_i uint8_t ____i_9; // System.Byte System.Guid::_j uint8_t ____j_10; // System.Byte System.Guid::_k uint8_t ____k_11; public: inline static int32_t get_offset_of__a_1() { return static_cast<int32_t>(offsetof(Guid_t, ____a_1)); } inline int32_t get__a_1() const { return ____a_1; } inline int32_t* get_address_of__a_1() { return &____a_1; } inline void set__a_1(int32_t value) { ____a_1 = value; } inline static int32_t get_offset_of__b_2() { return static_cast<int32_t>(offsetof(Guid_t, ____b_2)); } inline int16_t get__b_2() const { return ____b_2; } inline int16_t* get_address_of__b_2() { return &____b_2; } inline void set__b_2(int16_t value) { ____b_2 = value; } inline static int32_t get_offset_of__c_3() { return static_cast<int32_t>(offsetof(Guid_t, ____c_3)); } inline int16_t get__c_3() const { return ____c_3; } inline int16_t* get_address_of__c_3() { return &____c_3; } inline void set__c_3(int16_t value) { ____c_3 = value; } inline static int32_t get_offset_of__d_4() { return static_cast<int32_t>(offsetof(Guid_t, ____d_4)); } inline uint8_t get__d_4() const { return ____d_4; } inline uint8_t* get_address_of__d_4() { return &____d_4; } inline void set__d_4(uint8_t value) { ____d_4 = value; } inline static int32_t get_offset_of__e_5() { return static_cast<int32_t>(offsetof(Guid_t, ____e_5)); } inline uint8_t get__e_5() const { return ____e_5; } inline uint8_t* get_address_of__e_5() { return &____e_5; } inline void set__e_5(uint8_t value) { ____e_5 = value; } inline static int32_t get_offset_of__f_6() { return static_cast<int32_t>(offsetof(Guid_t, ____f_6)); } inline uint8_t get__f_6() const { return ____f_6; } inline uint8_t* get_address_of__f_6() { return &____f_6; } inline void set__f_6(uint8_t value) { ____f_6 = value; } inline static int32_t get_offset_of__g_7() { return static_cast<int32_t>(offsetof(Guid_t, ____g_7)); } inline uint8_t get__g_7() const { return ____g_7; } inline uint8_t* get_address_of__g_7() { return &____g_7; } inline void set__g_7(uint8_t value) { ____g_7 = value; } inline static int32_t get_offset_of__h_8() { return static_cast<int32_t>(offsetof(Guid_t, ____h_8)); } inline uint8_t get__h_8() const { return ____h_8; } inline uint8_t* get_address_of__h_8() { return &____h_8; } inline void set__h_8(uint8_t value) { ____h_8 = value; } inline static int32_t get_offset_of__i_9() { return static_cast<int32_t>(offsetof(Guid_t, ____i_9)); } inline uint8_t get__i_9() const { return ____i_9; } inline uint8_t* get_address_of__i_9() { return &____i_9; } inline void set__i_9(uint8_t value) { ____i_9 = value; } inline static int32_t get_offset_of__j_10() { return static_cast<int32_t>(offsetof(Guid_t, ____j_10)); } inline uint8_t get__j_10() const { return ____j_10; } inline uint8_t* get_address_of__j_10() { return &____j_10; } inline void set__j_10(uint8_t value) { ____j_10 = value; } inline static int32_t get_offset_of__k_11() { return static_cast<int32_t>(offsetof(Guid_t, ____k_11)); } inline uint8_t get__k_11() const { return ____k_11; } inline uint8_t* get_address_of__k_11() { return &____k_11; } inline void set__k_11(uint8_t value) { ____k_11 = value; } }; struct Guid_t_StaticFields { public: // System.Guid System.Guid::Empty Guid_t ___Empty_0; // System.Object System.Guid::_rngAccess RuntimeObject * ____rngAccess_12; // System.Security.Cryptography.RandomNumberGenerator System.Guid::_rng RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 * ____rng_13; // System.Security.Cryptography.RandomNumberGenerator System.Guid::_fastRng RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 * ____fastRng_14; public: inline static int32_t get_offset_of_Empty_0() { return static_cast<int32_t>(offsetof(Guid_t_StaticFields, ___Empty_0)); } inline Guid_t get_Empty_0() const { return ___Empty_0; } inline Guid_t * get_address_of_Empty_0() { return &___Empty_0; } inline void set_Empty_0(Guid_t value) { ___Empty_0 = value; } inline static int32_t get_offset_of__rngAccess_12() { return static_cast<int32_t>(offsetof(Guid_t_StaticFields, ____rngAccess_12)); } inline RuntimeObject * get__rngAccess_12() const { return ____rngAccess_12; } inline RuntimeObject ** get_address_of__rngAccess_12() { return &____rngAccess_12; } inline void set__rngAccess_12(RuntimeObject * value) { ____rngAccess_12 = value; Il2CppCodeGenWriteBarrier((void**)(&____rngAccess_12), (void*)value); } inline static int32_t get_offset_of__rng_13() { return static_cast<int32_t>(offsetof(Guid_t_StaticFields, ____rng_13)); } inline RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 * get__rng_13() const { return ____rng_13; } inline RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 ** get_address_of__rng_13() { return &____rng_13; } inline void set__rng_13(RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 * value) { ____rng_13 = value; Il2CppCodeGenWriteBarrier((void**)(&____rng_13), (void*)value); } inline static int32_t get_offset_of__fastRng_14() { return static_cast<int32_t>(offsetof(Guid_t_StaticFields, ____fastRng_14)); } inline RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 * get__fastRng_14() const { return ____fastRng_14; } inline RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 ** get_address_of__fastRng_14() { return &____fastRng_14; } inline void set__fastRng_14(RandomNumberGenerator_t2CB5440F189986116A2FA9F907AE52644047AC50 * value) { ____fastRng_14 = value; Il2CppCodeGenWriteBarrier((void**)(&____fastRng_14), (void*)value); } }; // System.Int32 struct Int32_tFDE5F8CD43D10453F6A2E0C77FE48C6CC7009046 { public: // System.Int32 System.Int32::m_value int32_t ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Int32_tFDE5F8CD43D10453F6A2E0C77FE48C6CC7009046, ___m_value_0)); } inline int32_t get_m_value_0() const { return ___m_value_0; } inline int32_t* get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(int32_t value) { ___m_value_0 = value; } }; // System.IntPtr struct IntPtr_t { public: // System.Void* System.IntPtr::m_value void* ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); } inline void* get_m_value_0() const { return ___m_value_0; } inline void** get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(void* value) { ___m_value_0 = value; } }; struct IntPtr_t_StaticFields { public: // System.IntPtr System.IntPtr::Zero intptr_t ___Zero_1; public: inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); } inline intptr_t get_Zero_1() const { return ___Zero_1; } inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; } inline void set_Zero_1(intptr_t value) { ___Zero_1 = value; } }; // UnityEngine.Quaternion struct Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 { public: // System.Single UnityEngine.Quaternion::x float ___x_0; // System.Single UnityEngine.Quaternion::y float ___y_1; // System.Single UnityEngine.Quaternion::z float ___z_2; // System.Single UnityEngine.Quaternion::w float ___w_3; public: inline static int32_t get_offset_of_x_0() { return static_cast<int32_t>(offsetof(Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4, ___x_0)); } inline float get_x_0() const { return ___x_0; } inline float* get_address_of_x_0() { return &___x_0; } inline void set_x_0(float value) { ___x_0 = value; } inline static int32_t get_offset_of_y_1() { return static_cast<int32_t>(offsetof(Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4, ___y_1)); } inline float get_y_1() const { return ___y_1; } inline float* get_address_of_y_1() { return &___y_1; } inline void set_y_1(float value) { ___y_1 = value; } inline static int32_t get_offset_of_z_2() { return static_cast<int32_t>(offsetof(Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4, ___z_2)); } inline float get_z_2() const { return ___z_2; } inline float* get_address_of_z_2() { return &___z_2; } inline void set_z_2(float value) { ___z_2 = value; } inline static int32_t get_offset_of_w_3() { return static_cast<int32_t>(offsetof(Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4, ___w_3)); } inline float get_w_3() const { return ___w_3; } inline float* get_address_of_w_3() { return &___w_3; } inline void set_w_3(float value) { ___w_3 = value; } }; struct Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4_StaticFields { public: // UnityEngine.Quaternion UnityEngine.Quaternion::identityQuaternion Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 ___identityQuaternion_4; public: inline static int32_t get_offset_of_identityQuaternion_4() { return static_cast<int32_t>(offsetof(Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4_StaticFields, ___identityQuaternion_4)); } inline Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 get_identityQuaternion_4() const { return ___identityQuaternion_4; } inline Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 * get_address_of_identityQuaternion_4() { return &___identityQuaternion_4; } inline void set_identityQuaternion_4(Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 value) { ___identityQuaternion_4 = value; } }; // UnityEngine.SceneManagement.Scene struct Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE { public: // System.Int32 UnityEngine.SceneManagement.Scene::m_Handle int32_t ___m_Handle_0; public: inline static int32_t get_offset_of_m_Handle_0() { return static_cast<int32_t>(offsetof(Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE, ___m_Handle_0)); } inline int32_t get_m_Handle_0() const { return ___m_Handle_0; } inline int32_t* get_address_of_m_Handle_0() { return &___m_Handle_0; } inline void set_m_Handle_0(int32_t value) { ___m_Handle_0 = value; } }; // UnityEngine.XR.ARSubsystems.SerializableGuid struct SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC { public: // System.UInt64 UnityEngine.XR.ARSubsystems.SerializableGuid::m_GuidLow uint64_t ___m_GuidLow_1; // System.UInt64 UnityEngine.XR.ARSubsystems.SerializableGuid::m_GuidHigh uint64_t ___m_GuidHigh_2; public: inline static int32_t get_offset_of_m_GuidLow_1() { return static_cast<int32_t>(offsetof(SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC, ___m_GuidLow_1)); } inline uint64_t get_m_GuidLow_1() const { return ___m_GuidLow_1; } inline uint64_t* get_address_of_m_GuidLow_1() { return &___m_GuidLow_1; } inline void set_m_GuidLow_1(uint64_t value) { ___m_GuidLow_1 = value; } inline static int32_t get_offset_of_m_GuidHigh_2() { return static_cast<int32_t>(offsetof(SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC, ___m_GuidHigh_2)); } inline uint64_t get_m_GuidHigh_2() const { return ___m_GuidHigh_2; } inline uint64_t* get_address_of_m_GuidHigh_2() { return &___m_GuidHigh_2; } inline void set_m_GuidHigh_2(uint64_t value) { ___m_GuidHigh_2 = value; } }; struct SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC_StaticFields { public: // UnityEngine.XR.ARSubsystems.SerializableGuid UnityEngine.XR.ARSubsystems.SerializableGuid::k_Empty SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC ___k_Empty_0; public: inline static int32_t get_offset_of_k_Empty_0() { return static_cast<int32_t>(offsetof(SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC_StaticFields, ___k_Empty_0)); } inline SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC get_k_Empty_0() const { return ___k_Empty_0; } inline SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC * get_address_of_k_Empty_0() { return &___k_Empty_0; } inline void set_k_Empty_0(SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC value) { ___k_Empty_0 = value; } }; // System.Single struct Single_tE07797BA3C98D4CA9B5A19413C19A76688AB899E { public: // System.Single System.Single::m_value float ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Single_tE07797BA3C98D4CA9B5A19413C19A76688AB899E, ___m_value_0)); } inline float get_m_value_0() const { return ___m_value_0; } inline float* get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(float value) { ___m_value_0 = value; } }; // UnityEngine.XR.ARSubsystems.TrackableId struct TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B { public: // System.UInt64 UnityEngine.XR.ARSubsystems.TrackableId::m_SubId1 uint64_t ___m_SubId1_2; // System.UInt64 UnityEngine.XR.ARSubsystems.TrackableId::m_SubId2 uint64_t ___m_SubId2_3; public: inline static int32_t get_offset_of_m_SubId1_2() { return static_cast<int32_t>(offsetof(TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B, ___m_SubId1_2)); } inline uint64_t get_m_SubId1_2() const { return ___m_SubId1_2; } inline uint64_t* get_address_of_m_SubId1_2() { return &___m_SubId1_2; } inline void set_m_SubId1_2(uint64_t value) { ___m_SubId1_2 = value; } inline static int32_t get_offset_of_m_SubId2_3() { return static_cast<int32_t>(offsetof(TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B, ___m_SubId2_3)); } inline uint64_t get_m_SubId2_3() const { return ___m_SubId2_3; } inline uint64_t* get_address_of_m_SubId2_3() { return &___m_SubId2_3; } inline void set_m_SubId2_3(uint64_t value) { ___m_SubId2_3 = value; } }; struct TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B_StaticFields { public: // System.Text.RegularExpressions.Regex UnityEngine.XR.ARSubsystems.TrackableId::s_TrackableIdRegex Regex_t90F443D398F44965EA241A652ED75DF5BA072A1F * ___s_TrackableIdRegex_0; // UnityEngine.XR.ARSubsystems.TrackableId UnityEngine.XR.ARSubsystems.TrackableId::s_InvalidId TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B ___s_InvalidId_1; public: inline static int32_t get_offset_of_s_TrackableIdRegex_0() { return static_cast<int32_t>(offsetof(TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B_StaticFields, ___s_TrackableIdRegex_0)); } inline Regex_t90F443D398F44965EA241A652ED75DF5BA072A1F * get_s_TrackableIdRegex_0() const { return ___s_TrackableIdRegex_0; } inline Regex_t90F443D398F44965EA241A652ED75DF5BA072A1F ** get_address_of_s_TrackableIdRegex_0() { return &___s_TrackableIdRegex_0; } inline void set_s_TrackableIdRegex_0(Regex_t90F443D398F44965EA241A652ED75DF5BA072A1F * value) { ___s_TrackableIdRegex_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_TrackableIdRegex_0), (void*)value); } inline static int32_t get_offset_of_s_InvalidId_1() { return static_cast<int32_t>(offsetof(TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B_StaticFields, ___s_InvalidId_1)); } inline TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B get_s_InvalidId_1() const { return ___s_InvalidId_1; } inline TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B * get_address_of_s_InvalidId_1() { return &___s_InvalidId_1; } inline void set_s_InvalidId_1(TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B value) { ___s_InvalidId_1 = value; } }; // UnityEngine.Vector2 struct Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 { public: // System.Single UnityEngine.Vector2::x float ___x_0; // System.Single UnityEngine.Vector2::y float ___y_1; public: inline static int32_t get_offset_of_x_0() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9, ___x_0)); } inline float get_x_0() const { return ___x_0; } inline float* get_address_of_x_0() { return &___x_0; } inline void set_x_0(float value) { ___x_0 = value; } inline static int32_t get_offset_of_y_1() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9, ___y_1)); } inline float get_y_1() const { return ___y_1; } inline float* get_address_of_y_1() { return &___y_1; } inline void set_y_1(float value) { ___y_1 = value; } }; struct Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields { public: // UnityEngine.Vector2 UnityEngine.Vector2::zeroVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___zeroVector_2; // UnityEngine.Vector2 UnityEngine.Vector2::oneVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___oneVector_3; // UnityEngine.Vector2 UnityEngine.Vector2::upVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___upVector_4; // UnityEngine.Vector2 UnityEngine.Vector2::downVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___downVector_5; // UnityEngine.Vector2 UnityEngine.Vector2::leftVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___leftVector_6; // UnityEngine.Vector2 UnityEngine.Vector2::rightVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___rightVector_7; // UnityEngine.Vector2 UnityEngine.Vector2::positiveInfinityVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___positiveInfinityVector_8; // UnityEngine.Vector2 UnityEngine.Vector2::negativeInfinityVector Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___negativeInfinityVector_9; public: inline static int32_t get_offset_of_zeroVector_2() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___zeroVector_2)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_zeroVector_2() const { return ___zeroVector_2; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_zeroVector_2() { return &___zeroVector_2; } inline void set_zeroVector_2(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___zeroVector_2 = value; } inline static int32_t get_offset_of_oneVector_3() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___oneVector_3)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_oneVector_3() const { return ___oneVector_3; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_oneVector_3() { return &___oneVector_3; } inline void set_oneVector_3(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___oneVector_3 = value; } inline static int32_t get_offset_of_upVector_4() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___upVector_4)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_upVector_4() const { return ___upVector_4; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_upVector_4() { return &___upVector_4; } inline void set_upVector_4(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___upVector_4 = value; } inline static int32_t get_offset_of_downVector_5() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___downVector_5)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_downVector_5() const { return ___downVector_5; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_downVector_5() { return &___downVector_5; } inline void set_downVector_5(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___downVector_5 = value; } inline static int32_t get_offset_of_leftVector_6() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___leftVector_6)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_leftVector_6() const { return ___leftVector_6; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_leftVector_6() { return &___leftVector_6; } inline void set_leftVector_6(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___leftVector_6 = value; } inline static int32_t get_offset_of_rightVector_7() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___rightVector_7)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_rightVector_7() const { return ___rightVector_7; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_rightVector_7() { return &___rightVector_7; } inline void set_rightVector_7(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___rightVector_7 = value; } inline static int32_t get_offset_of_positiveInfinityVector_8() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___positiveInfinityVector_8)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_positiveInfinityVector_8() const { return ___positiveInfinityVector_8; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_positiveInfinityVector_8() { return &___positiveInfinityVector_8; } inline void set_positiveInfinityVector_8(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___positiveInfinityVector_8 = value; } inline static int32_t get_offset_of_negativeInfinityVector_9() { return static_cast<int32_t>(offsetof(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9_StaticFields, ___negativeInfinityVector_9)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_negativeInfinityVector_9() const { return ___negativeInfinityVector_9; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_negativeInfinityVector_9() { return &___negativeInfinityVector_9; } inline void set_negativeInfinityVector_9(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___negativeInfinityVector_9 = value; } }; // UnityEngine.Vector3 struct Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E { public: // System.Single UnityEngine.Vector3::x float ___x_2; // System.Single UnityEngine.Vector3::y float ___y_3; // System.Single UnityEngine.Vector3::z float ___z_4; public: inline static int32_t get_offset_of_x_2() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___x_2)); } inline float get_x_2() const { return ___x_2; } inline float* get_address_of_x_2() { return &___x_2; } inline void set_x_2(float value) { ___x_2 = value; } inline static int32_t get_offset_of_y_3() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___y_3)); } inline float get_y_3() const { return ___y_3; } inline float* get_address_of_y_3() { return &___y_3; } inline void set_y_3(float value) { ___y_3 = value; } inline static int32_t get_offset_of_z_4() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E, ___z_4)); } inline float get_z_4() const { return ___z_4; } inline float* get_address_of_z_4() { return &___z_4; } inline void set_z_4(float value) { ___z_4 = value; } }; struct Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields { public: // UnityEngine.Vector3 UnityEngine.Vector3::zeroVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___zeroVector_5; // UnityEngine.Vector3 UnityEngine.Vector3::oneVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___oneVector_6; // UnityEngine.Vector3 UnityEngine.Vector3::upVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___upVector_7; // UnityEngine.Vector3 UnityEngine.Vector3::downVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___downVector_8; // UnityEngine.Vector3 UnityEngine.Vector3::leftVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___leftVector_9; // UnityEngine.Vector3 UnityEngine.Vector3::rightVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___rightVector_10; // UnityEngine.Vector3 UnityEngine.Vector3::forwardVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___forwardVector_11; // UnityEngine.Vector3 UnityEngine.Vector3::backVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___backVector_12; // UnityEngine.Vector3 UnityEngine.Vector3::positiveInfinityVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___positiveInfinityVector_13; // UnityEngine.Vector3 UnityEngine.Vector3::negativeInfinityVector Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___negativeInfinityVector_14; public: inline static int32_t get_offset_of_zeroVector_5() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___zeroVector_5)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_zeroVector_5() const { return ___zeroVector_5; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_zeroVector_5() { return &___zeroVector_5; } inline void set_zeroVector_5(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___zeroVector_5 = value; } inline static int32_t get_offset_of_oneVector_6() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___oneVector_6)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_oneVector_6() const { return ___oneVector_6; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_oneVector_6() { return &___oneVector_6; } inline void set_oneVector_6(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___oneVector_6 = value; } inline static int32_t get_offset_of_upVector_7() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___upVector_7)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_upVector_7() const { return ___upVector_7; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_upVector_7() { return &___upVector_7; } inline void set_upVector_7(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___upVector_7 = value; } inline static int32_t get_offset_of_downVector_8() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___downVector_8)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_downVector_8() const { return ___downVector_8; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_downVector_8() { return &___downVector_8; } inline void set_downVector_8(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___downVector_8 = value; } inline static int32_t get_offset_of_leftVector_9() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___leftVector_9)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_leftVector_9() const { return ___leftVector_9; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_leftVector_9() { return &___leftVector_9; } inline void set_leftVector_9(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___leftVector_9 = value; } inline static int32_t get_offset_of_rightVector_10() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___rightVector_10)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_rightVector_10() const { return ___rightVector_10; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_rightVector_10() { return &___rightVector_10; } inline void set_rightVector_10(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___rightVector_10 = value; } inline static int32_t get_offset_of_forwardVector_11() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___forwardVector_11)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_forwardVector_11() const { return ___forwardVector_11; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_forwardVector_11() { return &___forwardVector_11; } inline void set_forwardVector_11(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___forwardVector_11 = value; } inline static int32_t get_offset_of_backVector_12() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___backVector_12)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_backVector_12() const { return ___backVector_12; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_backVector_12() { return &___backVector_12; } inline void set_backVector_12(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___backVector_12 = value; } inline static int32_t get_offset_of_positiveInfinityVector_13() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___positiveInfinityVector_13)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_positiveInfinityVector_13() const { return ___positiveInfinityVector_13; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_positiveInfinityVector_13() { return &___positiveInfinityVector_13; } inline void set_positiveInfinityVector_13(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___positiveInfinityVector_13 = value; } inline static int32_t get_offset_of_negativeInfinityVector_14() { return static_cast<int32_t>(offsetof(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E_StaticFields, ___negativeInfinityVector_14)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_negativeInfinityVector_14() const { return ___negativeInfinityVector_14; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_negativeInfinityVector_14() { return &___negativeInfinityVector_14; } inline void set_negativeInfinityVector_14(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___negativeInfinityVector_14 = value; } }; // UnityEngine.Vector4 struct Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 { public: // System.Single UnityEngine.Vector4::x float ___x_1; // System.Single UnityEngine.Vector4::y float ___y_2; // System.Single UnityEngine.Vector4::z float ___z_3; // System.Single UnityEngine.Vector4::w float ___w_4; public: inline static int32_t get_offset_of_x_1() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7, ___x_1)); } inline float get_x_1() const { return ___x_1; } inline float* get_address_of_x_1() { return &___x_1; } inline void set_x_1(float value) { ___x_1 = value; } inline static int32_t get_offset_of_y_2() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7, ___y_2)); } inline float get_y_2() const { return ___y_2; } inline float* get_address_of_y_2() { return &___y_2; } inline void set_y_2(float value) { ___y_2 = value; } inline static int32_t get_offset_of_z_3() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7, ___z_3)); } inline float get_z_3() const { return ___z_3; } inline float* get_address_of_z_3() { return &___z_3; } inline void set_z_3(float value) { ___z_3 = value; } inline static int32_t get_offset_of_w_4() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7, ___w_4)); } inline float get_w_4() const { return ___w_4; } inline float* get_address_of_w_4() { return &___w_4; } inline void set_w_4(float value) { ___w_4 = value; } }; struct Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7_StaticFields { public: // UnityEngine.Vector4 UnityEngine.Vector4::zeroVector Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 ___zeroVector_5; // UnityEngine.Vector4 UnityEngine.Vector4::oneVector Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 ___oneVector_6; // UnityEngine.Vector4 UnityEngine.Vector4::positiveInfinityVector Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 ___positiveInfinityVector_7; // UnityEngine.Vector4 UnityEngine.Vector4::negativeInfinityVector Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 ___negativeInfinityVector_8; public: inline static int32_t get_offset_of_zeroVector_5() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7_StaticFields, ___zeroVector_5)); } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 get_zeroVector_5() const { return ___zeroVector_5; } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 * get_address_of_zeroVector_5() { return &___zeroVector_5; } inline void set_zeroVector_5(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 value) { ___zeroVector_5 = value; } inline static int32_t get_offset_of_oneVector_6() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7_StaticFields, ___oneVector_6)); } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 get_oneVector_6() const { return ___oneVector_6; } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 * get_address_of_oneVector_6() { return &___oneVector_6; } inline void set_oneVector_6(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 value) { ___oneVector_6 = value; } inline static int32_t get_offset_of_positiveInfinityVector_7() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7_StaticFields, ___positiveInfinityVector_7)); } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 get_positiveInfinityVector_7() const { return ___positiveInfinityVector_7; } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 * get_address_of_positiveInfinityVector_7() { return &___positiveInfinityVector_7; } inline void set_positiveInfinityVector_7(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 value) { ___positiveInfinityVector_7 = value; } inline static int32_t get_offset_of_negativeInfinityVector_8() { return static_cast<int32_t>(offsetof(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7_StaticFields, ___negativeInfinityVector_8)); } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 get_negativeInfinityVector_8() const { return ___negativeInfinityVector_8; } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 * get_address_of_negativeInfinityVector_8() { return &___negativeInfinityVector_8; } inline void set_negativeInfinityVector_8(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 value) { ___negativeInfinityVector_8 = value; } }; // System.Void struct Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5 { public: union { struct { }; uint8_t Void_t700C6383A2A510C2CF4DD86DABD5CA9FF70ADAC5__padding[1]; }; public: }; // UnityEngine.XR.ARFoundation.ARSessionState struct ARSessionState_tC5054273C7CB11C5C40D36745DDD2AF056ED1F25 { public: // System.Int32 UnityEngine.XR.ARFoundation.ARSessionState::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(ARSessionState_tC5054273C7CB11C5C40D36745DDD2AF056ED1F25, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; // FMOD.Studio.Bus struct Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F { public: // System.IntPtr FMOD.Studio.Bus::handle intptr_t ___handle_0; public: inline static int32_t get_offset_of_handle_0() { return static_cast<int32_t>(offsetof(Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F, ___handle_0)); } inline intptr_t get_handle_0() const { return ___handle_0; } inline intptr_t* get_address_of_handle_0() { return &___handle_0; } inline void set_handle_0(intptr_t value) { ___handle_0 = value; } }; // System.Delegate struct Delegate_t : public RuntimeObject { public: // System.IntPtr System.Delegate::method_ptr Il2CppMethodPointer ___method_ptr_0; // System.IntPtr System.Delegate::invoke_impl intptr_t ___invoke_impl_1; // System.Object System.Delegate::m_target RuntimeObject * ___m_target_2; // System.IntPtr System.Delegate::method intptr_t ___method_3; // System.IntPtr System.Delegate::delegate_trampoline intptr_t ___delegate_trampoline_4; // System.IntPtr System.Delegate::extra_arg intptr_t ___extra_arg_5; // System.IntPtr System.Delegate::method_code intptr_t ___method_code_6; // System.Reflection.MethodInfo System.Delegate::method_info MethodInfo_t * ___method_info_7; // System.Reflection.MethodInfo System.Delegate::original_method_info MethodInfo_t * ___original_method_info_8; // System.DelegateData System.Delegate::data DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * ___data_9; // System.Boolean System.Delegate::method_is_virtual bool ___method_is_virtual_10; public: inline static int32_t get_offset_of_method_ptr_0() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_ptr_0)); } inline Il2CppMethodPointer get_method_ptr_0() const { return ___method_ptr_0; } inline Il2CppMethodPointer* get_address_of_method_ptr_0() { return &___method_ptr_0; } inline void set_method_ptr_0(Il2CppMethodPointer value) { ___method_ptr_0 = value; } inline static int32_t get_offset_of_invoke_impl_1() { return static_cast<int32_t>(offsetof(Delegate_t, ___invoke_impl_1)); } inline intptr_t get_invoke_impl_1() const { return ___invoke_impl_1; } inline intptr_t* get_address_of_invoke_impl_1() { return &___invoke_impl_1; } inline void set_invoke_impl_1(intptr_t value) { ___invoke_impl_1 = value; } inline static int32_t get_offset_of_m_target_2() { return static_cast<int32_t>(offsetof(Delegate_t, ___m_target_2)); } inline RuntimeObject * get_m_target_2() const { return ___m_target_2; } inline RuntimeObject ** get_address_of_m_target_2() { return &___m_target_2; } inline void set_m_target_2(RuntimeObject * value) { ___m_target_2 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_target_2), (void*)value); } inline static int32_t get_offset_of_method_3() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_3)); } inline intptr_t get_method_3() const { return ___method_3; } inline intptr_t* get_address_of_method_3() { return &___method_3; } inline void set_method_3(intptr_t value) { ___method_3 = value; } inline static int32_t get_offset_of_delegate_trampoline_4() { return static_cast<int32_t>(offsetof(Delegate_t, ___delegate_trampoline_4)); } inline intptr_t get_delegate_trampoline_4() const { return ___delegate_trampoline_4; } inline intptr_t* get_address_of_delegate_trampoline_4() { return &___delegate_trampoline_4; } inline void set_delegate_trampoline_4(intptr_t value) { ___delegate_trampoline_4 = value; } inline static int32_t get_offset_of_extra_arg_5() { return static_cast<int32_t>(offsetof(Delegate_t, ___extra_arg_5)); } inline intptr_t get_extra_arg_5() const { return ___extra_arg_5; } inline intptr_t* get_address_of_extra_arg_5() { return &___extra_arg_5; } inline void set_extra_arg_5(intptr_t value) { ___extra_arg_5 = value; } inline static int32_t get_offset_of_method_code_6() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_code_6)); } inline intptr_t get_method_code_6() const { return ___method_code_6; } inline intptr_t* get_address_of_method_code_6() { return &___method_code_6; } inline void set_method_code_6(intptr_t value) { ___method_code_6 = value; } inline static int32_t get_offset_of_method_info_7() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_info_7)); } inline MethodInfo_t * get_method_info_7() const { return ___method_info_7; } inline MethodInfo_t ** get_address_of_method_info_7() { return &___method_info_7; } inline void set_method_info_7(MethodInfo_t * value) { ___method_info_7 = value; Il2CppCodeGenWriteBarrier((void**)(&___method_info_7), (void*)value); } inline static int32_t get_offset_of_original_method_info_8() { return static_cast<int32_t>(offsetof(Delegate_t, ___original_method_info_8)); } inline MethodInfo_t * get_original_method_info_8() const { return ___original_method_info_8; } inline MethodInfo_t ** get_address_of_original_method_info_8() { return &___original_method_info_8; } inline void set_original_method_info_8(MethodInfo_t * value) { ___original_method_info_8 = value; Il2CppCodeGenWriteBarrier((void**)(&___original_method_info_8), (void*)value); } inline static int32_t get_offset_of_data_9() { return static_cast<int32_t>(offsetof(Delegate_t, ___data_9)); } inline DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * get_data_9() const { return ___data_9; } inline DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 ** get_address_of_data_9() { return &___data_9; } inline void set_data_9(DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * value) { ___data_9 = value; Il2CppCodeGenWriteBarrier((void**)(&___data_9), (void*)value); } inline static int32_t get_offset_of_method_is_virtual_10() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_is_virtual_10)); } inline bool get_method_is_virtual_10() const { return ___method_is_virtual_10; } inline bool* get_address_of_method_is_virtual_10() { return &___method_is_virtual_10; } inline void set_method_is_virtual_10(bool value) { ___method_is_virtual_10 = value; } }; // Native definition for P/Invoke marshalling of System.Delegate struct Delegate_t_marshaled_pinvoke { intptr_t ___method_ptr_0; intptr_t ___invoke_impl_1; Il2CppIUnknown* ___m_target_2; intptr_t ___method_3; intptr_t ___delegate_trampoline_4; intptr_t ___extra_arg_5; intptr_t ___method_code_6; MethodInfo_t * ___method_info_7; MethodInfo_t * ___original_method_info_8; DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * ___data_9; int32_t ___method_is_virtual_10; }; // Native definition for COM marshalling of System.Delegate struct Delegate_t_marshaled_com { intptr_t ___method_ptr_0; intptr_t ___invoke_impl_1; Il2CppIUnknown* ___m_target_2; intptr_t ___method_3; intptr_t ___delegate_trampoline_4; intptr_t ___extra_arg_5; intptr_t ___method_code_6; MethodInfo_t * ___method_info_7; MethodInfo_t * ___original_method_info_8; DelegateData_t17DD30660E330C49381DAA99F934BE75CB11F288 * ___data_9; int32_t ___method_is_virtual_10; }; // System.Exception struct Exception_t : public RuntimeObject { public: // System.String System.Exception::_className String_t* ____className_1; // System.String System.Exception::_message String_t* ____message_2; // System.Collections.IDictionary System.Exception::_data RuntimeObject* ____data_3; // System.Exception System.Exception::_innerException Exception_t * ____innerException_4; // System.String System.Exception::_helpURL String_t* ____helpURL_5; // System.Object System.Exception::_stackTrace RuntimeObject * ____stackTrace_6; // System.String System.Exception::_stackTraceString String_t* ____stackTraceString_7; // System.String System.Exception::_remoteStackTraceString String_t* ____remoteStackTraceString_8; // System.Int32 System.Exception::_remoteStackIndex int32_t ____remoteStackIndex_9; // System.Object System.Exception::_dynamicMethods RuntimeObject * ____dynamicMethods_10; // System.Int32 System.Exception::_HResult int32_t ____HResult_11; // System.String System.Exception::_source String_t* ____source_12; // System.Runtime.Serialization.SafeSerializationManager System.Exception::_safeSerializationManager SafeSerializationManager_tDE44F029589A028F8A3053C5C06153FAB4AAE29F * ____safeSerializationManager_13; // System.Diagnostics.StackTrace[] System.Exception::captured_traces StackTraceU5BU5D_t4AD999C288CB6D1F38A299D12B1598D606588971* ___captured_traces_14; // System.IntPtr[] System.Exception::native_trace_ips IntPtrU5BU5D_t27FC72B0409D75AAF33EC42498E8094E95FEE9A6* ___native_trace_ips_15; public: inline static int32_t get_offset_of__className_1() { return static_cast<int32_t>(offsetof(Exception_t, ____className_1)); } inline String_t* get__className_1() const { return ____className_1; } inline String_t** get_address_of__className_1() { return &____className_1; } inline void set__className_1(String_t* value) { ____className_1 = value; Il2CppCodeGenWriteBarrier((void**)(&____className_1), (void*)value); } inline static int32_t get_offset_of__message_2() { return static_cast<int32_t>(offsetof(Exception_t, ____message_2)); } inline String_t* get__message_2() const { return ____message_2; } inline String_t** get_address_of__message_2() { return &____message_2; } inline void set__message_2(String_t* value) { ____message_2 = value; Il2CppCodeGenWriteBarrier((void**)(&____message_2), (void*)value); } inline static int32_t get_offset_of__data_3() { return static_cast<int32_t>(offsetof(Exception_t, ____data_3)); } inline RuntimeObject* get__data_3() const { return ____data_3; } inline RuntimeObject** get_address_of__data_3() { return &____data_3; } inline void set__data_3(RuntimeObject* value) { ____data_3 = value; Il2CppCodeGenWriteBarrier((void**)(&____data_3), (void*)value); } inline static int32_t get_offset_of__innerException_4() { return static_cast<int32_t>(offsetof(Exception_t, ____innerException_4)); } inline Exception_t * get__innerException_4() const { return ____innerException_4; } inline Exception_t ** get_address_of__innerException_4() { return &____innerException_4; } inline void set__innerException_4(Exception_t * value) { ____innerException_4 = value; Il2CppCodeGenWriteBarrier((void**)(&____innerException_4), (void*)value); } inline static int32_t get_offset_of__helpURL_5() { return static_cast<int32_t>(offsetof(Exception_t, ____helpURL_5)); } inline String_t* get__helpURL_5() const { return ____helpURL_5; } inline String_t** get_address_of__helpURL_5() { return &____helpURL_5; } inline void set__helpURL_5(String_t* value) { ____helpURL_5 = value; Il2CppCodeGenWriteBarrier((void**)(&____helpURL_5), (void*)value); } inline static int32_t get_offset_of__stackTrace_6() { return static_cast<int32_t>(offsetof(Exception_t, ____stackTrace_6)); } inline RuntimeObject * get__stackTrace_6() const { return ____stackTrace_6; } inline RuntimeObject ** get_address_of__stackTrace_6() { return &____stackTrace_6; } inline void set__stackTrace_6(RuntimeObject * value) { ____stackTrace_6 = value; Il2CppCodeGenWriteBarrier((void**)(&____stackTrace_6), (void*)value); } inline static int32_t get_offset_of__stackTraceString_7() { return static_cast<int32_t>(offsetof(Exception_t, ____stackTraceString_7)); } inline String_t* get__stackTraceString_7() const { return ____stackTraceString_7; } inline String_t** get_address_of__stackTraceString_7() { return &____stackTraceString_7; } inline void set__stackTraceString_7(String_t* value) { ____stackTraceString_7 = value; Il2CppCodeGenWriteBarrier((void**)(&____stackTraceString_7), (void*)value); } inline static int32_t get_offset_of__remoteStackTraceString_8() { return static_cast<int32_t>(offsetof(Exception_t, ____remoteStackTraceString_8)); } inline String_t* get__remoteStackTraceString_8() const { return ____remoteStackTraceString_8; } inline String_t** get_address_of__remoteStackTraceString_8() { return &____remoteStackTraceString_8; } inline void set__remoteStackTraceString_8(String_t* value) { ____remoteStackTraceString_8 = value; Il2CppCodeGenWriteBarrier((void**)(&____remoteStackTraceString_8), (void*)value); } inline static int32_t get_offset_of__remoteStackIndex_9() { return static_cast<int32_t>(offsetof(Exception_t, ____remoteStackIndex_9)); } inline int32_t get__remoteStackIndex_9() const { return ____remoteStackIndex_9; } inline int32_t* get_address_of__remoteStackIndex_9() { return &____remoteStackIndex_9; } inline void set__remoteStackIndex_9(int32_t value) { ____remoteStackIndex_9 = value; } inline static int32_t get_offset_of__dynamicMethods_10() { return static_cast<int32_t>(offsetof(Exception_t, ____dynamicMethods_10)); } inline RuntimeObject * get__dynamicMethods_10() const { return ____dynamicMethods_10; } inline RuntimeObject ** get_address_of__dynamicMethods_10() { return &____dynamicMethods_10; } inline void set__dynamicMethods_10(RuntimeObject * value) { ____dynamicMethods_10 = value; Il2CppCodeGenWriteBarrier((void**)(&____dynamicMethods_10), (void*)value); } inline static int32_t get_offset_of__HResult_11() { return static_cast<int32_t>(offsetof(Exception_t, ____HResult_11)); } inline int32_t get__HResult_11() const { return ____HResult_11; } inline int32_t* get_address_of__HResult_11() { return &____HResult_11; } inline void set__HResult_11(int32_t value) { ____HResult_11 = value; } inline static int32_t get_offset_of__source_12() { return static_cast<int32_t>(offsetof(Exception_t, ____source_12)); } inline String_t* get__source_12() const { return ____source_12; } inline String_t** get_address_of__source_12() { return &____source_12; } inline void set__source_12(String_t* value) { ____source_12 = value; Il2CppCodeGenWriteBarrier((void**)(&____source_12), (void*)value); } inline static int32_t get_offset_of__safeSerializationManager_13() { return static_cast<int32_t>(offsetof(Exception_t, ____safeSerializationManager_13)); } inline SafeSerializationManager_tDE44F029589A028F8A3053C5C06153FAB4AAE29F * get__safeSerializationManager_13() const { return ____safeSerializationManager_13; } inline SafeSerializationManager_tDE44F029589A028F8A3053C5C06153FAB4AAE29F ** get_address_of__safeSerializationManager_13() { return &____safeSerializationManager_13; } inline void set__safeSerializationManager_13(SafeSerializationManager_tDE44F029589A028F8A3053C5C06153FAB4AAE29F * value) { ____safeSerializationManager_13 = value; Il2CppCodeGenWriteBarrier((void**)(&____safeSerializationManager_13), (void*)value); } inline static int32_t get_offset_of_captured_traces_14() { return static_cast<int32_t>(offsetof(Exception_t, ___captured_traces_14)); } inline StackTraceU5BU5D_t4AD999C288CB6D1F38A299D12B1598D606588971* get_captured_traces_14() const { return ___captured_traces_14; } inline StackTraceU5BU5D_t4AD999C288CB6D1F38A299D12B1598D606588971** get_address_of_captured_traces_14() { return &___captured_traces_14; } inline void set_captured_traces_14(StackTraceU5BU5D_t4AD999C288CB6D1F38A299D12B1598D606588971* value) { ___captured_traces_14 = value; Il2CppCodeGenWriteBarrier((void**)(&___captured_traces_14), (void*)value); } inline static int32_t get_offset_of_native_trace_ips_15() { return static_cast<int32_t>(offsetof(Exception_t, ___native_trace_ips_15)); } inline IntPtrU5BU5D_t27FC72B0409D75AAF33EC42498E8094E95FEE9A6* get_native_trace_ips_15() const { return ___native_trace_ips_15; } inline IntPtrU5BU5D_t27FC72B0409D75AAF33EC42498E8094E95FEE9A6** get_address_of_native_trace_ips_15() { return &___native_trace_ips_15; } inline void set_native_trace_ips_15(IntPtrU5BU5D_t27FC72B0409D75AAF33EC42498E8094E95FEE9A6* value) { ___native_trace_ips_15 = value; Il2CppCodeGenWriteBarrier((void**)(&___native_trace_ips_15), (void*)value); } }; struct Exception_t_StaticFields { public: // System.Object System.Exception::s_EDILock RuntimeObject * ___s_EDILock_0; public: inline static int32_t get_offset_of_s_EDILock_0() { return static_cast<int32_t>(offsetof(Exception_t_StaticFields, ___s_EDILock_0)); } inline RuntimeObject * get_s_EDILock_0() const { return ___s_EDILock_0; } inline RuntimeObject ** get_address_of_s_EDILock_0() { return &___s_EDILock_0; } inline void set_s_EDILock_0(RuntimeObject * value) { ___s_EDILock_0 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_EDILock_0), (void*)value); } }; // Native definition for P/Invoke marshalling of System.Exception struct Exception_t_marshaled_pinvoke { char* ____className_1; char* ____message_2; RuntimeObject* ____data_3; Exception_t_marshaled_pinvoke* ____innerException_4; char* ____helpURL_5; Il2CppIUnknown* ____stackTrace_6; char* ____stackTraceString_7; char* ____remoteStackTraceString_8; int32_t ____remoteStackIndex_9; Il2CppIUnknown* ____dynamicMethods_10; int32_t ____HResult_11; char* ____source_12; SafeSerializationManager_tDE44F029589A028F8A3053C5C06153FAB4AAE29F * ____safeSerializationManager_13; StackTraceU5BU5D_t4AD999C288CB6D1F38A299D12B1598D606588971* ___captured_traces_14; Il2CppSafeArray/*NONE*/* ___native_trace_ips_15; }; // Native definition for COM marshalling of System.Exception struct Exception_t_marshaled_com { Il2CppChar* ____className_1; Il2CppChar* ____message_2; RuntimeObject* ____data_3; Exception_t_marshaled_com* ____innerException_4; Il2CppChar* ____helpURL_5; Il2CppIUnknown* ____stackTrace_6; Il2CppChar* ____stackTraceString_7; Il2CppChar* ____remoteStackTraceString_8; int32_t ____remoteStackIndex_9; Il2CppIUnknown* ____dynamicMethods_10; int32_t ____HResult_11; Il2CppChar* ____source_12; SafeSerializationManager_tDE44F029589A028F8A3053C5C06153FAB4AAE29F * ____safeSerializationManager_13; StackTraceU5BU5D_t4AD999C288CB6D1F38A299D12B1598D606588971* ___captured_traces_14; Il2CppSafeArray/*NONE*/* ___native_trace_ips_15; }; // UnityEngine.XR.ARSubsystems.NotTrackingReason struct NotTrackingReason_t853CA5527FA4E156B45DD1BD3E3E978C78BC49A9 { public: // System.Int32 UnityEngine.XR.ARSubsystems.NotTrackingReason::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(NotTrackingReason_t853CA5527FA4E156B45DD1BD3E3E978C78BC49A9, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; // UnityEngine.Object struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A : public RuntimeObject { public: // System.IntPtr UnityEngine.Object::m_CachedPtr intptr_t ___m_CachedPtr_0; public: inline static int32_t get_offset_of_m_CachedPtr_0() { return static_cast<int32_t>(offsetof(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A, ___m_CachedPtr_0)); } inline intptr_t get_m_CachedPtr_0() const { return ___m_CachedPtr_0; } inline intptr_t* get_address_of_m_CachedPtr_0() { return &___m_CachedPtr_0; } inline void set_m_CachedPtr_0(intptr_t value) { ___m_CachedPtr_0 = value; } }; struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_StaticFields { public: // System.Int32 UnityEngine.Object::OffsetOfInstanceIDInCPlusPlusObject int32_t ___OffsetOfInstanceIDInCPlusPlusObject_1; public: inline static int32_t get_offset_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return static_cast<int32_t>(offsetof(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_StaticFields, ___OffsetOfInstanceIDInCPlusPlusObject_1)); } inline int32_t get_OffsetOfInstanceIDInCPlusPlusObject_1() const { return ___OffsetOfInstanceIDInCPlusPlusObject_1; } inline int32_t* get_address_of_OffsetOfInstanceIDInCPlusPlusObject_1() { return &___OffsetOfInstanceIDInCPlusPlusObject_1; } inline void set_OffsetOfInstanceIDInCPlusPlusObject_1(int32_t value) { ___OffsetOfInstanceIDInCPlusPlusObject_1 = value; } }; // Native definition for P/Invoke marshalling of UnityEngine.Object struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_marshaled_pinvoke { intptr_t ___m_CachedPtr_0; }; // Native definition for COM marshalling of UnityEngine.Object struct Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_marshaled_com { intptr_t ___m_CachedPtr_0; }; // UnityEngine.Pose struct Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A { public: // UnityEngine.Vector3 UnityEngine.Pose::position Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___position_0; // UnityEngine.Quaternion UnityEngine.Pose::rotation Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 ___rotation_1; public: inline static int32_t get_offset_of_position_0() { return static_cast<int32_t>(offsetof(Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A, ___position_0)); } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E get_position_0() const { return ___position_0; } inline Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * get_address_of_position_0() { return &___position_0; } inline void set_position_0(Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E value) { ___position_0 = value; } inline static int32_t get_offset_of_rotation_1() { return static_cast<int32_t>(offsetof(Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A, ___rotation_1)); } inline Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 get_rotation_1() const { return ___rotation_1; } inline Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 * get_address_of_rotation_1() { return &___rotation_1; } inline void set_rotation_1(Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 value) { ___rotation_1 = value; } }; struct Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A_StaticFields { public: // UnityEngine.Pose UnityEngine.Pose::k_Identity Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A ___k_Identity_2; public: inline static int32_t get_offset_of_k_Identity_2() { return static_cast<int32_t>(offsetof(Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A_StaticFields, ___k_Identity_2)); } inline Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A get_k_Identity_2() const { return ___k_Identity_2; } inline Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A * get_address_of_k_Identity_2() { return &___k_Identity_2; } inline void set_k_Identity_2(Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A value) { ___k_Identity_2 = value; } }; // FMOD.RESULT struct RESULT_tA266F07EE553FBA39F31FBC2F1F424CD44ED3D21 { public: // System.Int32 FMOD.RESULT::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(RESULT_tA266F07EE553FBA39F31FBC2F1F424CD44ED3D21, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; // FMOD.Studio.STOP_MODE struct STOP_MODE_t0D345A0029CF35F2BB418BB366FBE26A3ED965D5 { public: // System.Int32 FMOD.Studio.STOP_MODE::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(STOP_MODE_t0D345A0029CF35F2BB418BB366FBE26A3ED965D5, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; // UnityEngine.XR.ARSubsystems.SessionAvailability struct SessionAvailability_tF5E98733E00C91772417EDEF3B3A6FA1DF653FCD { public: // System.Int32 UnityEngine.XR.ARSubsystems.SessionAvailability::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(SessionAvailability_tF5E98733E00C91772417EDEF3B3A6FA1DF653FCD, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; // UnityEngine.XR.ARFoundation.TrackingMode struct TrackingMode_t494215013DD008CD55735FEBB426C0F188B72646 { public: // System.Int32 UnityEngine.XR.ARFoundation.TrackingMode::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(TrackingMode_t494215013DD008CD55735FEBB426C0F188B72646, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; // UnityEngine.XR.ARSubsystems.TrackingState struct TrackingState_tB6996ED0D52D2A17DFACC90800705B81D370FC38 { public: // System.Int32 UnityEngine.XR.ARSubsystems.TrackingState::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(TrackingState_tB6996ED0D52D2A17DFACC90800705B81D370FC38, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; // UnityEngine.XR.ARSubsystems.XRReferenceImage struct XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 { public: // UnityEngine.XR.ARSubsystems.SerializableGuid UnityEngine.XR.ARSubsystems.XRReferenceImage::m_SerializedGuid SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC ___m_SerializedGuid_0; // UnityEngine.XR.ARSubsystems.SerializableGuid UnityEngine.XR.ARSubsystems.XRReferenceImage::m_SerializedTextureGuid SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC ___m_SerializedTextureGuid_1; // UnityEngine.Vector2 UnityEngine.XR.ARSubsystems.XRReferenceImage::m_Size Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___m_Size_2; // System.Boolean UnityEngine.XR.ARSubsystems.XRReferenceImage::m_SpecifySize bool ___m_SpecifySize_3; // System.String UnityEngine.XR.ARSubsystems.XRReferenceImage::m_Name String_t* ___m_Name_4; // UnityEngine.Texture2D UnityEngine.XR.ARSubsystems.XRReferenceImage::m_Texture Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * ___m_Texture_5; public: inline static int32_t get_offset_of_m_SerializedGuid_0() { return static_cast<int32_t>(offsetof(XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467, ___m_SerializedGuid_0)); } inline SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC get_m_SerializedGuid_0() const { return ___m_SerializedGuid_0; } inline SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC * get_address_of_m_SerializedGuid_0() { return &___m_SerializedGuid_0; } inline void set_m_SerializedGuid_0(SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC value) { ___m_SerializedGuid_0 = value; } inline static int32_t get_offset_of_m_SerializedTextureGuid_1() { return static_cast<int32_t>(offsetof(XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467, ___m_SerializedTextureGuid_1)); } inline SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC get_m_SerializedTextureGuid_1() const { return ___m_SerializedTextureGuid_1; } inline SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC * get_address_of_m_SerializedTextureGuid_1() { return &___m_SerializedTextureGuid_1; } inline void set_m_SerializedTextureGuid_1(SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC value) { ___m_SerializedTextureGuid_1 = value; } inline static int32_t get_offset_of_m_Size_2() { return static_cast<int32_t>(offsetof(XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467, ___m_Size_2)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_m_Size_2() const { return ___m_Size_2; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_m_Size_2() { return &___m_Size_2; } inline void set_m_Size_2(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___m_Size_2 = value; } inline static int32_t get_offset_of_m_SpecifySize_3() { return static_cast<int32_t>(offsetof(XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467, ___m_SpecifySize_3)); } inline bool get_m_SpecifySize_3() const { return ___m_SpecifySize_3; } inline bool* get_address_of_m_SpecifySize_3() { return &___m_SpecifySize_3; } inline void set_m_SpecifySize_3(bool value) { ___m_SpecifySize_3 = value; } inline static int32_t get_offset_of_m_Name_4() { return static_cast<int32_t>(offsetof(XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467, ___m_Name_4)); } inline String_t* get_m_Name_4() const { return ___m_Name_4; } inline String_t** get_address_of_m_Name_4() { return &___m_Name_4; } inline void set_m_Name_4(String_t* value) { ___m_Name_4 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Name_4), (void*)value); } inline static int32_t get_offset_of_m_Texture_5() { return static_cast<int32_t>(offsetof(XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467, ___m_Texture_5)); } inline Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * get_m_Texture_5() const { return ___m_Texture_5; } inline Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF ** get_address_of_m_Texture_5() { return &___m_Texture_5; } inline void set_m_Texture_5(Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * value) { ___m_Texture_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Texture_5), (void*)value); } }; // Native definition for P/Invoke marshalling of UnityEngine.XR.ARSubsystems.XRReferenceImage struct XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467_marshaled_pinvoke { SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC ___m_SerializedGuid_0; SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC ___m_SerializedTextureGuid_1; Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___m_Size_2; int32_t ___m_SpecifySize_3; char* ___m_Name_4; Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * ___m_Texture_5; }; // Native definition for COM marshalling of UnityEngine.XR.ARSubsystems.XRReferenceImage struct XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467_marshaled_com { SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC ___m_SerializedGuid_0; SerializableGuid_t5F8E8B4FF33F91AF9B16C6CC3F75AE00014505CC ___m_SerializedTextureGuid_1; Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___m_Size_2; int32_t ___m_SpecifySize_3; Il2CppChar* ___m_Name_4; Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * ___m_Texture_5; }; // UnityEngine.Component struct Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684 : public Object_tF2F3778131EFF286AF62B7B013A170F95A91571A { public: public: }; // UnityEngine.GameObject struct GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 : public Object_tF2F3778131EFF286AF62B7B013A170F95A91571A { public: public: }; // System.MulticastDelegate struct MulticastDelegate_t : public Delegate_t { public: // System.Delegate[] System.MulticastDelegate::delegates DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8* ___delegates_11; public: inline static int32_t get_offset_of_delegates_11() { return static_cast<int32_t>(offsetof(MulticastDelegate_t, ___delegates_11)); } inline DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8* get_delegates_11() const { return ___delegates_11; } inline DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8** get_address_of_delegates_11() { return &___delegates_11; } inline void set_delegates_11(DelegateU5BU5D_t677D8FE08A5F99E8EE49150B73966CD6E9BF7DB8* value) { ___delegates_11 = value; Il2CppCodeGenWriteBarrier((void**)(&___delegates_11), (void*)value); } }; // Native definition for P/Invoke marshalling of System.MulticastDelegate struct MulticastDelegate_t_marshaled_pinvoke : public Delegate_t_marshaled_pinvoke { Delegate_t_marshaled_pinvoke** ___delegates_11; }; // Native definition for COM marshalling of System.MulticastDelegate struct MulticastDelegate_t_marshaled_com : public Delegate_t_marshaled_com { Delegate_t_marshaled_com** ___delegates_11; }; // System.SystemException struct SystemException_tC551B4D6EE3772B5F32C71EE8C719F4B43ECCC62 : public Exception_t { public: public: }; // UnityEngine.XR.ARSubsystems.XRTrackedImage struct XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F { public: // UnityEngine.XR.ARSubsystems.TrackableId UnityEngine.XR.ARSubsystems.XRTrackedImage::m_Id TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B ___m_Id_1; // System.Guid UnityEngine.XR.ARSubsystems.XRTrackedImage::m_SourceImageId Guid_t ___m_SourceImageId_2; // UnityEngine.Pose UnityEngine.XR.ARSubsystems.XRTrackedImage::m_Pose Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A ___m_Pose_3; // UnityEngine.Vector2 UnityEngine.XR.ARSubsystems.XRTrackedImage::m_Size Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 ___m_Size_4; // UnityEngine.XR.ARSubsystems.TrackingState UnityEngine.XR.ARSubsystems.XRTrackedImage::m_TrackingState int32_t ___m_TrackingState_5; // System.IntPtr UnityEngine.XR.ARSubsystems.XRTrackedImage::m_NativePtr intptr_t ___m_NativePtr_6; public: inline static int32_t get_offset_of_m_Id_1() { return static_cast<int32_t>(offsetof(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F, ___m_Id_1)); } inline TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B get_m_Id_1() const { return ___m_Id_1; } inline TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B * get_address_of_m_Id_1() { return &___m_Id_1; } inline void set_m_Id_1(TrackableId_t17A59B04292038BB1B77BEACD41221D2700BE90B value) { ___m_Id_1 = value; } inline static int32_t get_offset_of_m_SourceImageId_2() { return static_cast<int32_t>(offsetof(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F, ___m_SourceImageId_2)); } inline Guid_t get_m_SourceImageId_2() const { return ___m_SourceImageId_2; } inline Guid_t * get_address_of_m_SourceImageId_2() { return &___m_SourceImageId_2; } inline void set_m_SourceImageId_2(Guid_t value) { ___m_SourceImageId_2 = value; } inline static int32_t get_offset_of_m_Pose_3() { return static_cast<int32_t>(offsetof(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F, ___m_Pose_3)); } inline Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A get_m_Pose_3() const { return ___m_Pose_3; } inline Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A * get_address_of_m_Pose_3() { return &___m_Pose_3; } inline void set_m_Pose_3(Pose_t9F30358E65733E60A1DC8682FDB7104F40C9434A value) { ___m_Pose_3 = value; } inline static int32_t get_offset_of_m_Size_4() { return static_cast<int32_t>(offsetof(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F, ___m_Size_4)); } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 get_m_Size_4() const { return ___m_Size_4; } inline Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 * get_address_of_m_Size_4() { return &___m_Size_4; } inline void set_m_Size_4(Vector2_tBB32F2736AEC229A7BFBCE18197EC0F6AC7EC2D9 value) { ___m_Size_4 = value; } inline static int32_t get_offset_of_m_TrackingState_5() { return static_cast<int32_t>(offsetof(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F, ___m_TrackingState_5)); } inline int32_t get_m_TrackingState_5() const { return ___m_TrackingState_5; } inline int32_t* get_address_of_m_TrackingState_5() { return &___m_TrackingState_5; } inline void set_m_TrackingState_5(int32_t value) { ___m_TrackingState_5 = value; } inline static int32_t get_offset_of_m_NativePtr_6() { return static_cast<int32_t>(offsetof(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F, ___m_NativePtr_6)); } inline intptr_t get_m_NativePtr_6() const { return ___m_NativePtr_6; } inline intptr_t* get_address_of_m_NativePtr_6() { return &___m_NativePtr_6; } inline void set_m_NativePtr_6(intptr_t value) { ___m_NativePtr_6 = value; } }; struct XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F_StaticFields { public: // UnityEngine.XR.ARSubsystems.XRTrackedImage UnityEngine.XR.ARSubsystems.XRTrackedImage::s_Default XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F ___s_Default_0; public: inline static int32_t get_offset_of_s_Default_0() { return static_cast<int32_t>(offsetof(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F_StaticFields, ___s_Default_0)); } inline XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F get_s_Default_0() const { return ___s_Default_0; } inline XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F * get_address_of_s_Default_0() { return &___s_Default_0; } inline void set_s_Default_0(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F value) { ___s_Default_0 = value; } }; // System.Action`1<UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs> struct Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 : public MulticastDelegate_t { public: public: }; // UnityEngine.Behaviour struct Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9 : public Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684 { public: public: }; // System.NotSupportedException struct NotSupportedException_tB9D89F0E9470A2C423D239D7C68EE0CFD77F9339 : public SystemException_tC551B4D6EE3772B5F32C71EE8C719F4B43ECCC62 { public: public: }; // UnityEngine.Transform struct Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 : public Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684 { public: public: }; // UnityEngine.MonoBehaviour struct MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A : public Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9 { public: public: }; // UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3<UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem,UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystemDescriptor,UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem/Provider> struct SubsystemLifecycleManager_3_t7C1FB63AA7729DFE7395F05FEA49B5C2A2F8D750 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: // TSubsystem UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3::<subsystem>k__BackingField XRImageTrackingSubsystem_tBC68AD21C11D8D67F3343844E129DF505FF705CE * ___U3CsubsystemU3Ek__BackingField_4; public: inline static int32_t get_offset_of_U3CsubsystemU3Ek__BackingField_4() { return static_cast<int32_t>(offsetof(SubsystemLifecycleManager_3_t7C1FB63AA7729DFE7395F05FEA49B5C2A2F8D750, ___U3CsubsystemU3Ek__BackingField_4)); } inline XRImageTrackingSubsystem_tBC68AD21C11D8D67F3343844E129DF505FF705CE * get_U3CsubsystemU3Ek__BackingField_4() const { return ___U3CsubsystemU3Ek__BackingField_4; } inline XRImageTrackingSubsystem_tBC68AD21C11D8D67F3343844E129DF505FF705CE ** get_address_of_U3CsubsystemU3Ek__BackingField_4() { return &___U3CsubsystemU3Ek__BackingField_4; } inline void set_U3CsubsystemU3Ek__BackingField_4(XRImageTrackingSubsystem_tBC68AD21C11D8D67F3343844E129DF505FF705CE * value) { ___U3CsubsystemU3Ek__BackingField_4 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CsubsystemU3Ek__BackingField_4), (void*)value); } }; struct SubsystemLifecycleManager_3_t7C1FB63AA7729DFE7395F05FEA49B5C2A2F8D750_StaticFields { public: // System.Collections.Generic.List`1<TSubsystemDescriptor> UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3::s_SubsystemDescriptors List_1_t179969632C4CD7B25BEBAA7DA12BA4C8F82F69F2 * ___s_SubsystemDescriptors_5; // System.Collections.Generic.List`1<TSubsystem> UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3::s_SubsystemInstances List_1_t19D4B5E8CD4DAF90FBAC8A83E6F7E9C0939C7BE0 * ___s_SubsystemInstances_6; public: inline static int32_t get_offset_of_s_SubsystemDescriptors_5() { return static_cast<int32_t>(offsetof(SubsystemLifecycleManager_3_t7C1FB63AA7729DFE7395F05FEA49B5C2A2F8D750_StaticFields, ___s_SubsystemDescriptors_5)); } inline List_1_t179969632C4CD7B25BEBAA7DA12BA4C8F82F69F2 * get_s_SubsystemDescriptors_5() const { return ___s_SubsystemDescriptors_5; } inline List_1_t179969632C4CD7B25BEBAA7DA12BA4C8F82F69F2 ** get_address_of_s_SubsystemDescriptors_5() { return &___s_SubsystemDescriptors_5; } inline void set_s_SubsystemDescriptors_5(List_1_t179969632C4CD7B25BEBAA7DA12BA4C8F82F69F2 * value) { ___s_SubsystemDescriptors_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_SubsystemDescriptors_5), (void*)value); } inline static int32_t get_offset_of_s_SubsystemInstances_6() { return static_cast<int32_t>(offsetof(SubsystemLifecycleManager_3_t7C1FB63AA7729DFE7395F05FEA49B5C2A2F8D750_StaticFields, ___s_SubsystemInstances_6)); } inline List_1_t19D4B5E8CD4DAF90FBAC8A83E6F7E9C0939C7BE0 * get_s_SubsystemInstances_6() const { return ___s_SubsystemInstances_6; } inline List_1_t19D4B5E8CD4DAF90FBAC8A83E6F7E9C0939C7BE0 ** get_address_of_s_SubsystemInstances_6() { return &___s_SubsystemInstances_6; } inline void set_s_SubsystemInstances_6(List_1_t19D4B5E8CD4DAF90FBAC8A83E6F7E9C0939C7BE0 * value) { ___s_SubsystemInstances_6 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_SubsystemInstances_6), (void*)value); } }; // UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3<UnityEngine.XR.ARSubsystems.XRSessionSubsystem,UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor,UnityEngine.XR.ARSubsystems.XRSessionSubsystem/Provider> struct SubsystemLifecycleManager_3_tE412F7818499B8C9886AA713B6FD9F15DC2BBAFD : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: // TSubsystem UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3::<subsystem>k__BackingField XRSessionSubsystem_t8AD3C01568AA19BF038D23A6031FF9814CAF93CD * ___U3CsubsystemU3Ek__BackingField_4; public: inline static int32_t get_offset_of_U3CsubsystemU3Ek__BackingField_4() { return static_cast<int32_t>(offsetof(SubsystemLifecycleManager_3_tE412F7818499B8C9886AA713B6FD9F15DC2BBAFD, ___U3CsubsystemU3Ek__BackingField_4)); } inline XRSessionSubsystem_t8AD3C01568AA19BF038D23A6031FF9814CAF93CD * get_U3CsubsystemU3Ek__BackingField_4() const { return ___U3CsubsystemU3Ek__BackingField_4; } inline XRSessionSubsystem_t8AD3C01568AA19BF038D23A6031FF9814CAF93CD ** get_address_of_U3CsubsystemU3Ek__BackingField_4() { return &___U3CsubsystemU3Ek__BackingField_4; } inline void set_U3CsubsystemU3Ek__BackingField_4(XRSessionSubsystem_t8AD3C01568AA19BF038D23A6031FF9814CAF93CD * value) { ___U3CsubsystemU3Ek__BackingField_4 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CsubsystemU3Ek__BackingField_4), (void*)value); } }; struct SubsystemLifecycleManager_3_tE412F7818499B8C9886AA713B6FD9F15DC2BBAFD_StaticFields { public: // System.Collections.Generic.List`1<TSubsystemDescriptor> UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3::s_SubsystemDescriptors List_1_tDA25459A722F5B00FFE84463D9952660BC3F6673 * ___s_SubsystemDescriptors_5; // System.Collections.Generic.List`1<TSubsystem> UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`3::s_SubsystemInstances List_1_tC3943A359D121C56123E4142DF967EF5FCCAF2C3 * ___s_SubsystemInstances_6; public: inline static int32_t get_offset_of_s_SubsystemDescriptors_5() { return static_cast<int32_t>(offsetof(SubsystemLifecycleManager_3_tE412F7818499B8C9886AA713B6FD9F15DC2BBAFD_StaticFields, ___s_SubsystemDescriptors_5)); } inline List_1_tDA25459A722F5B00FFE84463D9952660BC3F6673 * get_s_SubsystemDescriptors_5() const { return ___s_SubsystemDescriptors_5; } inline List_1_tDA25459A722F5B00FFE84463D9952660BC3F6673 ** get_address_of_s_SubsystemDescriptors_5() { return &___s_SubsystemDescriptors_5; } inline void set_s_SubsystemDescriptors_5(List_1_tDA25459A722F5B00FFE84463D9952660BC3F6673 * value) { ___s_SubsystemDescriptors_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_SubsystemDescriptors_5), (void*)value); } inline static int32_t get_offset_of_s_SubsystemInstances_6() { return static_cast<int32_t>(offsetof(SubsystemLifecycleManager_3_tE412F7818499B8C9886AA713B6FD9F15DC2BBAFD_StaticFields, ___s_SubsystemInstances_6)); } inline List_1_tC3943A359D121C56123E4142DF967EF5FCCAF2C3 * get_s_SubsystemInstances_6() const { return ___s_SubsystemInstances_6; } inline List_1_tC3943A359D121C56123E4142DF967EF5FCCAF2C3 ** get_address_of_s_SubsystemInstances_6() { return &___s_SubsystemInstances_6; } inline void set_s_SubsystemInstances_6(List_1_tC3943A359D121C56123E4142DF967EF5FCCAF2C3 * value) { ___s_SubsystemInstances_6 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_SubsystemInstances_6), (void*)value); } }; // UnityEngine.XR.ARFoundation.ARTrackable struct ARTrackable_tE630E6237048700E730F3E3C2799F6CA07029DB3 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: public: }; // DisableScreenSleeping struct DisableScreenSleeping_t721C4DDFE6A41229AABD432937B146D77CED2420 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: public: }; // Enemy struct Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: public: }; // FindClosest struct FindClosest_t502181BF1D570545238207A41095AF8DCF41E819 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: public: }; // ImageTracking struct ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: // UnityEngine.GameObject[] ImageTracking::placeablePrefabs GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* ___placeablePrefabs_4; // System.Collections.Generic.Dictionary`2<System.String,UnityEngine.GameObject> ImageTracking::spawnedPrefabs Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * ___spawnedPrefabs_5; // UnityEngine.XR.ARFoundation.ARTrackedImageManager ImageTracking::trackedImageManager ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * ___trackedImageManager_6; public: inline static int32_t get_offset_of_placeablePrefabs_4() { return static_cast<int32_t>(offsetof(ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80, ___placeablePrefabs_4)); } inline GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* get_placeablePrefabs_4() const { return ___placeablePrefabs_4; } inline GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642** get_address_of_placeablePrefabs_4() { return &___placeablePrefabs_4; } inline void set_placeablePrefabs_4(GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* value) { ___placeablePrefabs_4 = value; Il2CppCodeGenWriteBarrier((void**)(&___placeablePrefabs_4), (void*)value); } inline static int32_t get_offset_of_spawnedPrefabs_5() { return static_cast<int32_t>(offsetof(ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80, ___spawnedPrefabs_5)); } inline Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * get_spawnedPrefabs_5() const { return ___spawnedPrefabs_5; } inline Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C ** get_address_of_spawnedPrefabs_5() { return &___spawnedPrefabs_5; } inline void set_spawnedPrefabs_5(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * value) { ___spawnedPrefabs_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___spawnedPrefabs_5), (void*)value); } inline static int32_t get_offset_of_trackedImageManager_6() { return static_cast<int32_t>(offsetof(ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80, ___trackedImageManager_6)); } inline ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * get_trackedImageManager_6() const { return ___trackedImageManager_6; } inline ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 ** get_address_of_trackedImageManager_6() { return &___trackedImageManager_6; } inline void set_trackedImageManager_6(ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * value) { ___trackedImageManager_6 = value; Il2CppCodeGenWriteBarrier((void**)(&___trackedImageManager_6), (void*)value); } }; // MakePostcard struct MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: // System.String MakePostcard::PostcardName String_t* ___PostcardName_4; // System.String MakePostcard::PostcardDescription String_t* ___PostcardDescription_5; // System.String MakePostcard::PostcardLink String_t* ___PostcardLink_6; public: inline static int32_t get_offset_of_PostcardName_4() { return static_cast<int32_t>(offsetof(MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF, ___PostcardName_4)); } inline String_t* get_PostcardName_4() const { return ___PostcardName_4; } inline String_t** get_address_of_PostcardName_4() { return &___PostcardName_4; } inline void set_PostcardName_4(String_t* value) { ___PostcardName_4 = value; Il2CppCodeGenWriteBarrier((void**)(&___PostcardName_4), (void*)value); } inline static int32_t get_offset_of_PostcardDescription_5() { return static_cast<int32_t>(offsetof(MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF, ___PostcardDescription_5)); } inline String_t* get_PostcardDescription_5() const { return ___PostcardDescription_5; } inline String_t** get_address_of_PostcardDescription_5() { return &___PostcardDescription_5; } inline void set_PostcardDescription_5(String_t* value) { ___PostcardDescription_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___PostcardDescription_5), (void*)value); } inline static int32_t get_offset_of_PostcardLink_6() { return static_cast<int32_t>(offsetof(MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF, ___PostcardLink_6)); } inline String_t* get_PostcardLink_6() const { return ___PostcardLink_6; } inline String_t** get_address_of_PostcardLink_6() { return &___PostcardLink_6; } inline void set_PostcardLink_6(String_t* value) { ___PostcardLink_6 = value; Il2CppCodeGenWriteBarrier((void**)(&___PostcardLink_6), (void*)value); } }; // MenuControl struct MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778 : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: // UnityEngine.SceneManagement.Scene MenuControl::activeScene Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE ___activeScene_4; // System.String MenuControl::sceneName String_t* ___sceneName_5; // FMOD.Studio.Bus MenuControl::masterBus Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F ___masterBus_6; // UnityEngine.GameObject[] MenuControl::objects GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* ___objects_7; // UnityEngine.GameObject[] MenuControl::audioInstances GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* ___audioInstances_8; public: inline static int32_t get_offset_of_activeScene_4() { return static_cast<int32_t>(offsetof(MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778, ___activeScene_4)); } inline Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE get_activeScene_4() const { return ___activeScene_4; } inline Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE * get_address_of_activeScene_4() { return &___activeScene_4; } inline void set_activeScene_4(Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE value) { ___activeScene_4 = value; } inline static int32_t get_offset_of_sceneName_5() { return static_cast<int32_t>(offsetof(MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778, ___sceneName_5)); } inline String_t* get_sceneName_5() const { return ___sceneName_5; } inline String_t** get_address_of_sceneName_5() { return &___sceneName_5; } inline void set_sceneName_5(String_t* value) { ___sceneName_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___sceneName_5), (void*)value); } inline static int32_t get_offset_of_masterBus_6() { return static_cast<int32_t>(offsetof(MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778, ___masterBus_6)); } inline Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F get_masterBus_6() const { return ___masterBus_6; } inline Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F * get_address_of_masterBus_6() { return &___masterBus_6; } inline void set_masterBus_6(Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F value) { ___masterBus_6 = value; } inline static int32_t get_offset_of_objects_7() { return static_cast<int32_t>(offsetof(MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778, ___objects_7)); } inline GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* get_objects_7() const { return ___objects_7; } inline GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642** get_address_of_objects_7() { return &___objects_7; } inline void set_objects_7(GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* value) { ___objects_7 = value; Il2CppCodeGenWriteBarrier((void**)(&___objects_7), (void*)value); } inline static int32_t get_offset_of_audioInstances_8() { return static_cast<int32_t>(offsetof(MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778, ___audioInstances_8)); } inline GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* get_audioInstances_8() const { return ___audioInstances_8; } inline GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642** get_address_of_audioInstances_8() { return &___audioInstances_8; } inline void set_audioInstances_8(GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* value) { ___audioInstances_8 = value; Il2CppCodeGenWriteBarrier((void**)(&___audioInstances_8), (void*)value); } }; // TrackingState struct TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: // UnityEngine.XR.ARFoundation.ARSession TrackingState::m_Session ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B * ___m_Session_4; // UnityEngine.UI.Text TrackingState::m_Text Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * ___m_Text_5; public: inline static int32_t get_offset_of_m_Session_4() { return static_cast<int32_t>(offsetof(TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD, ___m_Session_4)); } inline ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B * get_m_Session_4() const { return ___m_Session_4; } inline ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B ** get_address_of_m_Session_4() { return &___m_Session_4; } inline void set_m_Session_4(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B * value) { ___m_Session_4 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Session_4), (void*)value); } inline static int32_t get_offset_of_m_Text_5() { return static_cast<int32_t>(offsetof(TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD, ___m_Text_5)); } inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * get_m_Text_5() const { return ___m_Text_5; } inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 ** get_address_of_m_Text_5() { return &___m_Text_5; } inline void set_m_Text_5(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * value) { ___m_Text_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Text_5), (void*)value); } }; // UnityEngine.EventSystems.UIBehaviour struct UIBehaviour_tD1C6E2D542222546D68510ECE74036EFBC3C3B0E : public MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A { public: public: }; // UnityEngine.XR.ARFoundation.ARTrackableManager`5<UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem,UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystemDescriptor,UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem/Provider,UnityEngine.XR.ARSubsystems.XRTrackedImage,UnityEngine.XR.ARFoundation.ARTrackedImage> struct ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A : public SubsystemLifecycleManager_3_t7C1FB63AA7729DFE7395F05FEA49B5C2A2F8D750 { public: // UnityEngine.XR.ARFoundation.ARSessionOrigin UnityEngine.XR.ARFoundation.ARTrackableManager`5::<sessionOrigin>k__BackingField ARSessionOrigin_tA15648434106370D592D12C00B93054EC6CE6AE1 * ___U3CsessionOriginU3Ek__BackingField_8; // System.Collections.Generic.Dictionary`2<UnityEngine.XR.ARSubsystems.TrackableId,TTrackable> UnityEngine.XR.ARFoundation.ARTrackableManager`5::m_Trackables Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E * ___m_Trackables_9; // System.Collections.Generic.Dictionary`2<UnityEngine.XR.ARSubsystems.TrackableId,TTrackable> UnityEngine.XR.ARFoundation.ARTrackableManager`5::m_PendingAdds Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E * ___m_PendingAdds_10; public: inline static int32_t get_offset_of_U3CsessionOriginU3Ek__BackingField_8() { return static_cast<int32_t>(offsetof(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A, ___U3CsessionOriginU3Ek__BackingField_8)); } inline ARSessionOrigin_tA15648434106370D592D12C00B93054EC6CE6AE1 * get_U3CsessionOriginU3Ek__BackingField_8() const { return ___U3CsessionOriginU3Ek__BackingField_8; } inline ARSessionOrigin_tA15648434106370D592D12C00B93054EC6CE6AE1 ** get_address_of_U3CsessionOriginU3Ek__BackingField_8() { return &___U3CsessionOriginU3Ek__BackingField_8; } inline void set_U3CsessionOriginU3Ek__BackingField_8(ARSessionOrigin_tA15648434106370D592D12C00B93054EC6CE6AE1 * value) { ___U3CsessionOriginU3Ek__BackingField_8 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CsessionOriginU3Ek__BackingField_8), (void*)value); } inline static int32_t get_offset_of_m_Trackables_9() { return static_cast<int32_t>(offsetof(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A, ___m_Trackables_9)); } inline Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E * get_m_Trackables_9() const { return ___m_Trackables_9; } inline Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E ** get_address_of_m_Trackables_9() { return &___m_Trackables_9; } inline void set_m_Trackables_9(Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E * value) { ___m_Trackables_9 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Trackables_9), (void*)value); } inline static int32_t get_offset_of_m_PendingAdds_10() { return static_cast<int32_t>(offsetof(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A, ___m_PendingAdds_10)); } inline Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E * get_m_PendingAdds_10() const { return ___m_PendingAdds_10; } inline Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E ** get_address_of_m_PendingAdds_10() { return &___m_PendingAdds_10; } inline void set_m_PendingAdds_10(Dictionary_2_tD95D4B180F0B4EEF3668344392936E58ECF7069E * value) { ___m_PendingAdds_10 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_PendingAdds_10), (void*)value); } }; struct ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A_StaticFields { public: // UnityEngine.XR.ARFoundation.ARTrackableManager`5<TSubsystem,TSubsystemDescriptor,TProvider,TSessionRelativeData,TTrackable> UnityEngine.XR.ARFoundation.ARTrackableManager`5::<instance>k__BackingField ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A * ___U3CinstanceU3Ek__BackingField_7; // System.Collections.Generic.List`1<TTrackable> UnityEngine.XR.ARFoundation.ARTrackableManager`5::s_Added List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___s_Added_11; // System.Collections.Generic.List`1<TTrackable> UnityEngine.XR.ARFoundation.ARTrackableManager`5::s_Updated List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___s_Updated_12; // System.Collections.Generic.List`1<TTrackable> UnityEngine.XR.ARFoundation.ARTrackableManager`5::s_Removed List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ___s_Removed_13; public: inline static int32_t get_offset_of_U3CinstanceU3Ek__BackingField_7() { return static_cast<int32_t>(offsetof(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A_StaticFields, ___U3CinstanceU3Ek__BackingField_7)); } inline ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A * get_U3CinstanceU3Ek__BackingField_7() const { return ___U3CinstanceU3Ek__BackingField_7; } inline ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A ** get_address_of_U3CinstanceU3Ek__BackingField_7() { return &___U3CinstanceU3Ek__BackingField_7; } inline void set_U3CinstanceU3Ek__BackingField_7(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A * value) { ___U3CinstanceU3Ek__BackingField_7 = value; Il2CppCodeGenWriteBarrier((void**)(&___U3CinstanceU3Ek__BackingField_7), (void*)value); } inline static int32_t get_offset_of_s_Added_11() { return static_cast<int32_t>(offsetof(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A_StaticFields, ___s_Added_11)); } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * get_s_Added_11() const { return ___s_Added_11; } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F ** get_address_of_s_Added_11() { return &___s_Added_11; } inline void set_s_Added_11(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * value) { ___s_Added_11 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_Added_11), (void*)value); } inline static int32_t get_offset_of_s_Updated_12() { return static_cast<int32_t>(offsetof(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A_StaticFields, ___s_Updated_12)); } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * get_s_Updated_12() const { return ___s_Updated_12; } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F ** get_address_of_s_Updated_12() { return &___s_Updated_12; } inline void set_s_Updated_12(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * value) { ___s_Updated_12 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_Updated_12), (void*)value); } inline static int32_t get_offset_of_s_Removed_13() { return static_cast<int32_t>(offsetof(ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A_StaticFields, ___s_Removed_13)); } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * get_s_Removed_13() const { return ___s_Removed_13; } inline List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F ** get_address_of_s_Removed_13() { return &___s_Removed_13; } inline void set_s_Removed_13(List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * value) { ___s_Removed_13 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_Removed_13), (void*)value); } }; // UnityEngine.XR.ARFoundation.ARTrackable`2<UnityEngine.XR.ARSubsystems.XRTrackedImage,UnityEngine.XR.ARFoundation.ARTrackedImage> struct ARTrackable_2_tBE8960CB1D0030EBBEED67D06F8B1ADB69EB3CB1 : public ARTrackable_tE630E6237048700E730F3E3C2799F6CA07029DB3 { public: // System.Boolean UnityEngine.XR.ARFoundation.ARTrackable`2::m_DestroyOnRemoval bool ___m_DestroyOnRemoval_4; // System.Boolean UnityEngine.XR.ARFoundation.ARTrackable`2::<pending>k__BackingField bool ___U3CpendingU3Ek__BackingField_5; // TSessionRelativeData UnityEngine.XR.ARFoundation.ARTrackable`2::<sessionRelativeData>k__BackingField XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F ___U3CsessionRelativeDataU3Ek__BackingField_6; public: inline static int32_t get_offset_of_m_DestroyOnRemoval_4() { return static_cast<int32_t>(offsetof(ARTrackable_2_tBE8960CB1D0030EBBEED67D06F8B1ADB69EB3CB1, ___m_DestroyOnRemoval_4)); } inline bool get_m_DestroyOnRemoval_4() const { return ___m_DestroyOnRemoval_4; } inline bool* get_address_of_m_DestroyOnRemoval_4() { return &___m_DestroyOnRemoval_4; } inline void set_m_DestroyOnRemoval_4(bool value) { ___m_DestroyOnRemoval_4 = value; } inline static int32_t get_offset_of_U3CpendingU3Ek__BackingField_5() { return static_cast<int32_t>(offsetof(ARTrackable_2_tBE8960CB1D0030EBBEED67D06F8B1ADB69EB3CB1, ___U3CpendingU3Ek__BackingField_5)); } inline bool get_U3CpendingU3Ek__BackingField_5() const { return ___U3CpendingU3Ek__BackingField_5; } inline bool* get_address_of_U3CpendingU3Ek__BackingField_5() { return &___U3CpendingU3Ek__BackingField_5; } inline void set_U3CpendingU3Ek__BackingField_5(bool value) { ___U3CpendingU3Ek__BackingField_5 = value; } inline static int32_t get_offset_of_U3CsessionRelativeDataU3Ek__BackingField_6() { return static_cast<int32_t>(offsetof(ARTrackable_2_tBE8960CB1D0030EBBEED67D06F8B1ADB69EB3CB1, ___U3CsessionRelativeDataU3Ek__BackingField_6)); } inline XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F get_U3CsessionRelativeDataU3Ek__BackingField_6() const { return ___U3CsessionRelativeDataU3Ek__BackingField_6; } inline XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F * get_address_of_U3CsessionRelativeDataU3Ek__BackingField_6() { return &___U3CsessionRelativeDataU3Ek__BackingField_6; } inline void set_U3CsessionRelativeDataU3Ek__BackingField_6(XRTrackedImage_t92B53E0621C6D2E930761110E719F0E9580A722F value) { ___U3CsessionRelativeDataU3Ek__BackingField_6 = value; } }; // UnityEngine.XR.ARFoundation.ARSession struct ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B : public SubsystemLifecycleManager_3_tE412F7818499B8C9886AA713B6FD9F15DC2BBAFD { public: // System.Boolean UnityEngine.XR.ARFoundation.ARSession::m_AttemptUpdate bool ___m_AttemptUpdate_7; // System.Boolean UnityEngine.XR.ARFoundation.ARSession::m_MatchFrameRate bool ___m_MatchFrameRate_8; // UnityEngine.XR.ARFoundation.TrackingMode UnityEngine.XR.ARFoundation.ARSession::m_TrackingMode int32_t ___m_TrackingMode_9; public: inline static int32_t get_offset_of_m_AttemptUpdate_7() { return static_cast<int32_t>(offsetof(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B, ___m_AttemptUpdate_7)); } inline bool get_m_AttemptUpdate_7() const { return ___m_AttemptUpdate_7; } inline bool* get_address_of_m_AttemptUpdate_7() { return &___m_AttemptUpdate_7; } inline void set_m_AttemptUpdate_7(bool value) { ___m_AttemptUpdate_7 = value; } inline static int32_t get_offset_of_m_MatchFrameRate_8() { return static_cast<int32_t>(offsetof(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B, ___m_MatchFrameRate_8)); } inline bool get_m_MatchFrameRate_8() const { return ___m_MatchFrameRate_8; } inline bool* get_address_of_m_MatchFrameRate_8() { return &___m_MatchFrameRate_8; } inline void set_m_MatchFrameRate_8(bool value) { ___m_MatchFrameRate_8 = value; } inline static int32_t get_offset_of_m_TrackingMode_9() { return static_cast<int32_t>(offsetof(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B, ___m_TrackingMode_9)); } inline int32_t get_m_TrackingMode_9() const { return ___m_TrackingMode_9; } inline int32_t* get_address_of_m_TrackingMode_9() { return &___m_TrackingMode_9; } inline void set_m_TrackingMode_9(int32_t value) { ___m_TrackingMode_9 = value; } }; struct ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_StaticFields { public: // System.Action`1<UnityEngine.XR.ARFoundation.ARSessionStateChangedEventArgs> UnityEngine.XR.ARFoundation.ARSession::stateChanged Action_1_t5DF84322FFE12A24465E48164961CD724D109521 * ___stateChanged_10; // UnityEngine.XR.ARFoundation.ARSessionState UnityEngine.XR.ARFoundation.ARSession::s_State int32_t ___s_State_11; // UnityEngine.XR.ARSubsystems.NotTrackingReason UnityEngine.XR.ARFoundation.ARSession::s_NotTrackingReason int32_t ___s_NotTrackingReason_12; // UnityEngine.XR.ARSubsystems.SessionAvailability UnityEngine.XR.ARFoundation.ARSession::s_Availability int32_t ___s_Availability_13; public: inline static int32_t get_offset_of_stateChanged_10() { return static_cast<int32_t>(offsetof(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_StaticFields, ___stateChanged_10)); } inline Action_1_t5DF84322FFE12A24465E48164961CD724D109521 * get_stateChanged_10() const { return ___stateChanged_10; } inline Action_1_t5DF84322FFE12A24465E48164961CD724D109521 ** get_address_of_stateChanged_10() { return &___stateChanged_10; } inline void set_stateChanged_10(Action_1_t5DF84322FFE12A24465E48164961CD724D109521 * value) { ___stateChanged_10 = value; Il2CppCodeGenWriteBarrier((void**)(&___stateChanged_10), (void*)value); } inline static int32_t get_offset_of_s_State_11() { return static_cast<int32_t>(offsetof(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_StaticFields, ___s_State_11)); } inline int32_t get_s_State_11() const { return ___s_State_11; } inline int32_t* get_address_of_s_State_11() { return &___s_State_11; } inline void set_s_State_11(int32_t value) { ___s_State_11 = value; } inline static int32_t get_offset_of_s_NotTrackingReason_12() { return static_cast<int32_t>(offsetof(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_StaticFields, ___s_NotTrackingReason_12)); } inline int32_t get_s_NotTrackingReason_12() const { return ___s_NotTrackingReason_12; } inline int32_t* get_address_of_s_NotTrackingReason_12() { return &___s_NotTrackingReason_12; } inline void set_s_NotTrackingReason_12(int32_t value) { ___s_NotTrackingReason_12 = value; } inline static int32_t get_offset_of_s_Availability_13() { return static_cast<int32_t>(offsetof(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_StaticFields, ___s_Availability_13)); } inline int32_t get_s_Availability_13() const { return ___s_Availability_13; } inline int32_t* get_address_of_s_Availability_13() { return &___s_Availability_13; } inline void set_s_Availability_13(int32_t value) { ___s_Availability_13 = value; } }; // UnityEngine.UI.Graphic struct Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24 : public UIBehaviour_tD1C6E2D542222546D68510ECE74036EFBC3C3B0E { public: // UnityEngine.Material UnityEngine.UI.Graphic::m_Material Material_t8927C00353A72755313F046D0CE85178AE8218EE * ___m_Material_6; // UnityEngine.Color UnityEngine.UI.Graphic::m_Color Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659 ___m_Color_7; // System.Boolean UnityEngine.UI.Graphic::m_SkipLayoutUpdate bool ___m_SkipLayoutUpdate_8; // System.Boolean UnityEngine.UI.Graphic::m_SkipMaterialUpdate bool ___m_SkipMaterialUpdate_9; // System.Boolean UnityEngine.UI.Graphic::m_RaycastTarget bool ___m_RaycastTarget_10; // UnityEngine.Vector4 UnityEngine.UI.Graphic::m_RaycastPadding Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 ___m_RaycastPadding_11; // UnityEngine.RectTransform UnityEngine.UI.Graphic::m_RectTransform RectTransform_t8A6A306FB29A6C8C22010CF9040E319753571072 * ___m_RectTransform_12; // UnityEngine.CanvasRenderer UnityEngine.UI.Graphic::m_CanvasRenderer CanvasRenderer_tCF8ABE659F7C3A6ED0D99A988D0BDFB651310F0E * ___m_CanvasRenderer_13; // UnityEngine.Canvas UnityEngine.UI.Graphic::m_Canvas Canvas_t2B7E56B7BDC287962E092755372E214ACB6393EA * ___m_Canvas_14; // System.Boolean UnityEngine.UI.Graphic::m_VertsDirty bool ___m_VertsDirty_15; // System.Boolean UnityEngine.UI.Graphic::m_MaterialDirty bool ___m_MaterialDirty_16; // UnityEngine.Events.UnityAction UnityEngine.UI.Graphic::m_OnDirtyLayoutCallback UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * ___m_OnDirtyLayoutCallback_17; // UnityEngine.Events.UnityAction UnityEngine.UI.Graphic::m_OnDirtyVertsCallback UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * ___m_OnDirtyVertsCallback_18; // UnityEngine.Events.UnityAction UnityEngine.UI.Graphic::m_OnDirtyMaterialCallback UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * ___m_OnDirtyMaterialCallback_19; // UnityEngine.Mesh UnityEngine.UI.Graphic::m_CachedMesh Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 * ___m_CachedMesh_22; // UnityEngine.Vector2[] UnityEngine.UI.Graphic::m_CachedUvs Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* ___m_CachedUvs_23; // UnityEngine.UI.CoroutineTween.TweenRunner`1<UnityEngine.UI.CoroutineTween.ColorTween> UnityEngine.UI.Graphic::m_ColorTweenRunner TweenRunner_1_tD84B9953874682FCC36990AF2C54D748293908F3 * ___m_ColorTweenRunner_24; // System.Boolean UnityEngine.UI.Graphic::<useLegacyMeshGeneration>k__BackingField bool ___U3CuseLegacyMeshGenerationU3Ek__BackingField_25; public: inline static int32_t get_offset_of_m_Material_6() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_Material_6)); } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE * get_m_Material_6() const { return ___m_Material_6; } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE ** get_address_of_m_Material_6() { return &___m_Material_6; } inline void set_m_Material_6(Material_t8927C00353A72755313F046D0CE85178AE8218EE * value) { ___m_Material_6 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Material_6), (void*)value); } inline static int32_t get_offset_of_m_Color_7() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_Color_7)); } inline Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659 get_m_Color_7() const { return ___m_Color_7; } inline Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659 * get_address_of_m_Color_7() { return &___m_Color_7; } inline void set_m_Color_7(Color_tF40DAF76C04FFECF3FE6024F85A294741C9CC659 value) { ___m_Color_7 = value; } inline static int32_t get_offset_of_m_SkipLayoutUpdate_8() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_SkipLayoutUpdate_8)); } inline bool get_m_SkipLayoutUpdate_8() const { return ___m_SkipLayoutUpdate_8; } inline bool* get_address_of_m_SkipLayoutUpdate_8() { return &___m_SkipLayoutUpdate_8; } inline void set_m_SkipLayoutUpdate_8(bool value) { ___m_SkipLayoutUpdate_8 = value; } inline static int32_t get_offset_of_m_SkipMaterialUpdate_9() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_SkipMaterialUpdate_9)); } inline bool get_m_SkipMaterialUpdate_9() const { return ___m_SkipMaterialUpdate_9; } inline bool* get_address_of_m_SkipMaterialUpdate_9() { return &___m_SkipMaterialUpdate_9; } inline void set_m_SkipMaterialUpdate_9(bool value) { ___m_SkipMaterialUpdate_9 = value; } inline static int32_t get_offset_of_m_RaycastTarget_10() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_RaycastTarget_10)); } inline bool get_m_RaycastTarget_10() const { return ___m_RaycastTarget_10; } inline bool* get_address_of_m_RaycastTarget_10() { return &___m_RaycastTarget_10; } inline void set_m_RaycastTarget_10(bool value) { ___m_RaycastTarget_10 = value; } inline static int32_t get_offset_of_m_RaycastPadding_11() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_RaycastPadding_11)); } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 get_m_RaycastPadding_11() const { return ___m_RaycastPadding_11; } inline Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 * get_address_of_m_RaycastPadding_11() { return &___m_RaycastPadding_11; } inline void set_m_RaycastPadding_11(Vector4_tA56A37FC5661BCC89C3DDC24BE12BA5BCB6A02C7 value) { ___m_RaycastPadding_11 = value; } inline static int32_t get_offset_of_m_RectTransform_12() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_RectTransform_12)); } inline RectTransform_t8A6A306FB29A6C8C22010CF9040E319753571072 * get_m_RectTransform_12() const { return ___m_RectTransform_12; } inline RectTransform_t8A6A306FB29A6C8C22010CF9040E319753571072 ** get_address_of_m_RectTransform_12() { return &___m_RectTransform_12; } inline void set_m_RectTransform_12(RectTransform_t8A6A306FB29A6C8C22010CF9040E319753571072 * value) { ___m_RectTransform_12 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_RectTransform_12), (void*)value); } inline static int32_t get_offset_of_m_CanvasRenderer_13() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_CanvasRenderer_13)); } inline CanvasRenderer_tCF8ABE659F7C3A6ED0D99A988D0BDFB651310F0E * get_m_CanvasRenderer_13() const { return ___m_CanvasRenderer_13; } inline CanvasRenderer_tCF8ABE659F7C3A6ED0D99A988D0BDFB651310F0E ** get_address_of_m_CanvasRenderer_13() { return &___m_CanvasRenderer_13; } inline void set_m_CanvasRenderer_13(CanvasRenderer_tCF8ABE659F7C3A6ED0D99A988D0BDFB651310F0E * value) { ___m_CanvasRenderer_13 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_CanvasRenderer_13), (void*)value); } inline static int32_t get_offset_of_m_Canvas_14() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_Canvas_14)); } inline Canvas_t2B7E56B7BDC287962E092755372E214ACB6393EA * get_m_Canvas_14() const { return ___m_Canvas_14; } inline Canvas_t2B7E56B7BDC287962E092755372E214ACB6393EA ** get_address_of_m_Canvas_14() { return &___m_Canvas_14; } inline void set_m_Canvas_14(Canvas_t2B7E56B7BDC287962E092755372E214ACB6393EA * value) { ___m_Canvas_14 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Canvas_14), (void*)value); } inline static int32_t get_offset_of_m_VertsDirty_15() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_VertsDirty_15)); } inline bool get_m_VertsDirty_15() const { return ___m_VertsDirty_15; } inline bool* get_address_of_m_VertsDirty_15() { return &___m_VertsDirty_15; } inline void set_m_VertsDirty_15(bool value) { ___m_VertsDirty_15 = value; } inline static int32_t get_offset_of_m_MaterialDirty_16() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_MaterialDirty_16)); } inline bool get_m_MaterialDirty_16() const { return ___m_MaterialDirty_16; } inline bool* get_address_of_m_MaterialDirty_16() { return &___m_MaterialDirty_16; } inline void set_m_MaterialDirty_16(bool value) { ___m_MaterialDirty_16 = value; } inline static int32_t get_offset_of_m_OnDirtyLayoutCallback_17() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_OnDirtyLayoutCallback_17)); } inline UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * get_m_OnDirtyLayoutCallback_17() const { return ___m_OnDirtyLayoutCallback_17; } inline UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 ** get_address_of_m_OnDirtyLayoutCallback_17() { return &___m_OnDirtyLayoutCallback_17; } inline void set_m_OnDirtyLayoutCallback_17(UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * value) { ___m_OnDirtyLayoutCallback_17 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_OnDirtyLayoutCallback_17), (void*)value); } inline static int32_t get_offset_of_m_OnDirtyVertsCallback_18() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_OnDirtyVertsCallback_18)); } inline UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * get_m_OnDirtyVertsCallback_18() const { return ___m_OnDirtyVertsCallback_18; } inline UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 ** get_address_of_m_OnDirtyVertsCallback_18() { return &___m_OnDirtyVertsCallback_18; } inline void set_m_OnDirtyVertsCallback_18(UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * value) { ___m_OnDirtyVertsCallback_18 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_OnDirtyVertsCallback_18), (void*)value); } inline static int32_t get_offset_of_m_OnDirtyMaterialCallback_19() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_OnDirtyMaterialCallback_19)); } inline UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * get_m_OnDirtyMaterialCallback_19() const { return ___m_OnDirtyMaterialCallback_19; } inline UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 ** get_address_of_m_OnDirtyMaterialCallback_19() { return &___m_OnDirtyMaterialCallback_19; } inline void set_m_OnDirtyMaterialCallback_19(UnityAction_t22E545F8BE0A62EE051C6A83E209587A0DB1C099 * value) { ___m_OnDirtyMaterialCallback_19 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_OnDirtyMaterialCallback_19), (void*)value); } inline static int32_t get_offset_of_m_CachedMesh_22() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_CachedMesh_22)); } inline Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 * get_m_CachedMesh_22() const { return ___m_CachedMesh_22; } inline Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 ** get_address_of_m_CachedMesh_22() { return &___m_CachedMesh_22; } inline void set_m_CachedMesh_22(Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 * value) { ___m_CachedMesh_22 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_CachedMesh_22), (void*)value); } inline static int32_t get_offset_of_m_CachedUvs_23() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_CachedUvs_23)); } inline Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* get_m_CachedUvs_23() const { return ___m_CachedUvs_23; } inline Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA** get_address_of_m_CachedUvs_23() { return &___m_CachedUvs_23; } inline void set_m_CachedUvs_23(Vector2U5BU5D_tE0F58A2D6D8592B5EC37D9CDEF09103A02E5D7FA* value) { ___m_CachedUvs_23 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_CachedUvs_23), (void*)value); } inline static int32_t get_offset_of_m_ColorTweenRunner_24() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___m_ColorTweenRunner_24)); } inline TweenRunner_1_tD84B9953874682FCC36990AF2C54D748293908F3 * get_m_ColorTweenRunner_24() const { return ___m_ColorTweenRunner_24; } inline TweenRunner_1_tD84B9953874682FCC36990AF2C54D748293908F3 ** get_address_of_m_ColorTweenRunner_24() { return &___m_ColorTweenRunner_24; } inline void set_m_ColorTweenRunner_24(TweenRunner_1_tD84B9953874682FCC36990AF2C54D748293908F3 * value) { ___m_ColorTweenRunner_24 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_ColorTweenRunner_24), (void*)value); } inline static int32_t get_offset_of_U3CuseLegacyMeshGenerationU3Ek__BackingField_25() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24, ___U3CuseLegacyMeshGenerationU3Ek__BackingField_25)); } inline bool get_U3CuseLegacyMeshGenerationU3Ek__BackingField_25() const { return ___U3CuseLegacyMeshGenerationU3Ek__BackingField_25; } inline bool* get_address_of_U3CuseLegacyMeshGenerationU3Ek__BackingField_25() { return &___U3CuseLegacyMeshGenerationU3Ek__BackingField_25; } inline void set_U3CuseLegacyMeshGenerationU3Ek__BackingField_25(bool value) { ___U3CuseLegacyMeshGenerationU3Ek__BackingField_25 = value; } }; struct Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24_StaticFields { public: // UnityEngine.Material UnityEngine.UI.Graphic::s_DefaultUI Material_t8927C00353A72755313F046D0CE85178AE8218EE * ___s_DefaultUI_4; // UnityEngine.Texture2D UnityEngine.UI.Graphic::s_WhiteTexture Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * ___s_WhiteTexture_5; // UnityEngine.Mesh UnityEngine.UI.Graphic::s_Mesh Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 * ___s_Mesh_20; // UnityEngine.UI.VertexHelper UnityEngine.UI.Graphic::s_VertexHelper VertexHelper_tDE8B67D3B076061C4F8DF325B0D63ED2E5367E55 * ___s_VertexHelper_21; public: inline static int32_t get_offset_of_s_DefaultUI_4() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24_StaticFields, ___s_DefaultUI_4)); } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE * get_s_DefaultUI_4() const { return ___s_DefaultUI_4; } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE ** get_address_of_s_DefaultUI_4() { return &___s_DefaultUI_4; } inline void set_s_DefaultUI_4(Material_t8927C00353A72755313F046D0CE85178AE8218EE * value) { ___s_DefaultUI_4 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_DefaultUI_4), (void*)value); } inline static int32_t get_offset_of_s_WhiteTexture_5() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24_StaticFields, ___s_WhiteTexture_5)); } inline Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * get_s_WhiteTexture_5() const { return ___s_WhiteTexture_5; } inline Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF ** get_address_of_s_WhiteTexture_5() { return &___s_WhiteTexture_5; } inline void set_s_WhiteTexture_5(Texture2D_t9B604D0D8E28032123641A7E7338FA872E2698BF * value) { ___s_WhiteTexture_5 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_WhiteTexture_5), (void*)value); } inline static int32_t get_offset_of_s_Mesh_20() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24_StaticFields, ___s_Mesh_20)); } inline Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 * get_s_Mesh_20() const { return ___s_Mesh_20; } inline Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 ** get_address_of_s_Mesh_20() { return &___s_Mesh_20; } inline void set_s_Mesh_20(Mesh_t2F5992DBA650D5862B43D3823ACD997132A57DA6 * value) { ___s_Mesh_20 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_Mesh_20), (void*)value); } inline static int32_t get_offset_of_s_VertexHelper_21() { return static_cast<int32_t>(offsetof(Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24_StaticFields, ___s_VertexHelper_21)); } inline VertexHelper_tDE8B67D3B076061C4F8DF325B0D63ED2E5367E55 * get_s_VertexHelper_21() const { return ___s_VertexHelper_21; } inline VertexHelper_tDE8B67D3B076061C4F8DF325B0D63ED2E5367E55 ** get_address_of_s_VertexHelper_21() { return &___s_VertexHelper_21; } inline void set_s_VertexHelper_21(VertexHelper_tDE8B67D3B076061C4F8DF325B0D63ED2E5367E55 * value) { ___s_VertexHelper_21 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_VertexHelper_21), (void*)value); } }; // UnityEngine.XR.ARFoundation.ARTrackedImage struct ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 : public ARTrackable_2_tBE8960CB1D0030EBBEED67D06F8B1ADB69EB3CB1 { public: // UnityEngine.XR.ARSubsystems.XRReferenceImage UnityEngine.XR.ARFoundation.ARTrackedImage::<referenceImage>k__BackingField XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 ___U3CreferenceImageU3Ek__BackingField_7; public: inline static int32_t get_offset_of_U3CreferenceImageU3Ek__BackingField_7() { return static_cast<int32_t>(offsetof(ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7, ___U3CreferenceImageU3Ek__BackingField_7)); } inline XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 get_U3CreferenceImageU3Ek__BackingField_7() const { return ___U3CreferenceImageU3Ek__BackingField_7; } inline XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 * get_address_of_U3CreferenceImageU3Ek__BackingField_7() { return &___U3CreferenceImageU3Ek__BackingField_7; } inline void set_U3CreferenceImageU3Ek__BackingField_7(XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 value) { ___U3CreferenceImageU3Ek__BackingField_7 = value; Il2CppCodeGenWriteBarrier((void**)&(((&___U3CreferenceImageU3Ek__BackingField_7))->___m_Name_4), (void*)NULL); #if IL2CPP_ENABLE_STRICT_WRITE_BARRIERS Il2CppCodeGenWriteBarrier((void**)&(((&___U3CreferenceImageU3Ek__BackingField_7))->___m_Texture_5), (void*)NULL); #endif } }; // UnityEngine.XR.ARFoundation.ARTrackedImageManager struct ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 : public ARTrackableManager_5_t80C2ED1443D89CD862DA603E7D68435F74C0103A { public: // UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary UnityEngine.XR.ARFoundation.ARTrackedImageManager::m_SerializedLibrary XRReferenceImageLibrary_tC415743C1DDCE2331D5B0F159B2A1D72A70C44B2 * ___m_SerializedLibrary_14; // System.Int32 UnityEngine.XR.ARFoundation.ARTrackedImageManager::m_MaxNumberOfMovingImages int32_t ___m_MaxNumberOfMovingImages_15; // UnityEngine.GameObject UnityEngine.XR.ARFoundation.ARTrackedImageManager::m_TrackedImagePrefab GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___m_TrackedImagePrefab_16; // System.Action`1<UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs> UnityEngine.XR.ARFoundation.ARTrackedImageManager::trackedImagesChanged Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * ___trackedImagesChanged_17; // System.Collections.Generic.Dictionary`2<System.Guid,UnityEngine.XR.ARSubsystems.XRReferenceImage> UnityEngine.XR.ARFoundation.ARTrackedImageManager::m_ReferenceImages Dictionary_2_t1D971BA151CCF2A891990C13C7561FEC253BC7CF * ___m_ReferenceImages_18; public: inline static int32_t get_offset_of_m_SerializedLibrary_14() { return static_cast<int32_t>(offsetof(ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2, ___m_SerializedLibrary_14)); } inline XRReferenceImageLibrary_tC415743C1DDCE2331D5B0F159B2A1D72A70C44B2 * get_m_SerializedLibrary_14() const { return ___m_SerializedLibrary_14; } inline XRReferenceImageLibrary_tC415743C1DDCE2331D5B0F159B2A1D72A70C44B2 ** get_address_of_m_SerializedLibrary_14() { return &___m_SerializedLibrary_14; } inline void set_m_SerializedLibrary_14(XRReferenceImageLibrary_tC415743C1DDCE2331D5B0F159B2A1D72A70C44B2 * value) { ___m_SerializedLibrary_14 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_SerializedLibrary_14), (void*)value); } inline static int32_t get_offset_of_m_MaxNumberOfMovingImages_15() { return static_cast<int32_t>(offsetof(ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2, ___m_MaxNumberOfMovingImages_15)); } inline int32_t get_m_MaxNumberOfMovingImages_15() const { return ___m_MaxNumberOfMovingImages_15; } inline int32_t* get_address_of_m_MaxNumberOfMovingImages_15() { return &___m_MaxNumberOfMovingImages_15; } inline void set_m_MaxNumberOfMovingImages_15(int32_t value) { ___m_MaxNumberOfMovingImages_15 = value; } inline static int32_t get_offset_of_m_TrackedImagePrefab_16() { return static_cast<int32_t>(offsetof(ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2, ___m_TrackedImagePrefab_16)); } inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * get_m_TrackedImagePrefab_16() const { return ___m_TrackedImagePrefab_16; } inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** get_address_of_m_TrackedImagePrefab_16() { return &___m_TrackedImagePrefab_16; } inline void set_m_TrackedImagePrefab_16(GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value) { ___m_TrackedImagePrefab_16 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_TrackedImagePrefab_16), (void*)value); } inline static int32_t get_offset_of_trackedImagesChanged_17() { return static_cast<int32_t>(offsetof(ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2, ___trackedImagesChanged_17)); } inline Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * get_trackedImagesChanged_17() const { return ___trackedImagesChanged_17; } inline Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 ** get_address_of_trackedImagesChanged_17() { return &___trackedImagesChanged_17; } inline void set_trackedImagesChanged_17(Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * value) { ___trackedImagesChanged_17 = value; Il2CppCodeGenWriteBarrier((void**)(&___trackedImagesChanged_17), (void*)value); } inline static int32_t get_offset_of_m_ReferenceImages_18() { return static_cast<int32_t>(offsetof(ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2, ___m_ReferenceImages_18)); } inline Dictionary_2_t1D971BA151CCF2A891990C13C7561FEC253BC7CF * get_m_ReferenceImages_18() const { return ___m_ReferenceImages_18; } inline Dictionary_2_t1D971BA151CCF2A891990C13C7561FEC253BC7CF ** get_address_of_m_ReferenceImages_18() { return &___m_ReferenceImages_18; } inline void set_m_ReferenceImages_18(Dictionary_2_t1D971BA151CCF2A891990C13C7561FEC253BC7CF * value) { ___m_ReferenceImages_18 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_ReferenceImages_18), (void*)value); } }; // UnityEngine.UI.MaskableGraphic struct MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE : public Graphic_tF07D777035055CF93BA5F46F77ED5EDFEFF9AE24 { public: // System.Boolean UnityEngine.UI.MaskableGraphic::m_ShouldRecalculateStencil bool ___m_ShouldRecalculateStencil_26; // UnityEngine.Material UnityEngine.UI.MaskableGraphic::m_MaskMaterial Material_t8927C00353A72755313F046D0CE85178AE8218EE * ___m_MaskMaterial_27; // UnityEngine.UI.RectMask2D UnityEngine.UI.MaskableGraphic::m_ParentMask RectMask2D_tD909811991B341D752E4C978C89EFB80FA7A2B15 * ___m_ParentMask_28; // System.Boolean UnityEngine.UI.MaskableGraphic::m_Maskable bool ___m_Maskable_29; // System.Boolean UnityEngine.UI.MaskableGraphic::m_IsMaskingGraphic bool ___m_IsMaskingGraphic_30; // System.Boolean UnityEngine.UI.MaskableGraphic::m_IncludeForMasking bool ___m_IncludeForMasking_31; // UnityEngine.UI.MaskableGraphic/CullStateChangedEvent UnityEngine.UI.MaskableGraphic::m_OnCullStateChanged CullStateChangedEvent_t9B69755DEBEF041C3CC15C3604610BDD72856BD4 * ___m_OnCullStateChanged_32; // System.Boolean UnityEngine.UI.MaskableGraphic::m_ShouldRecalculate bool ___m_ShouldRecalculate_33; // System.Int32 UnityEngine.UI.MaskableGraphic::m_StencilValue int32_t ___m_StencilValue_34; // UnityEngine.Vector3[] UnityEngine.UI.MaskableGraphic::m_Corners Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* ___m_Corners_35; public: inline static int32_t get_offset_of_m_ShouldRecalculateStencil_26() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_ShouldRecalculateStencil_26)); } inline bool get_m_ShouldRecalculateStencil_26() const { return ___m_ShouldRecalculateStencil_26; } inline bool* get_address_of_m_ShouldRecalculateStencil_26() { return &___m_ShouldRecalculateStencil_26; } inline void set_m_ShouldRecalculateStencil_26(bool value) { ___m_ShouldRecalculateStencil_26 = value; } inline static int32_t get_offset_of_m_MaskMaterial_27() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_MaskMaterial_27)); } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE * get_m_MaskMaterial_27() const { return ___m_MaskMaterial_27; } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE ** get_address_of_m_MaskMaterial_27() { return &___m_MaskMaterial_27; } inline void set_m_MaskMaterial_27(Material_t8927C00353A72755313F046D0CE85178AE8218EE * value) { ___m_MaskMaterial_27 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_MaskMaterial_27), (void*)value); } inline static int32_t get_offset_of_m_ParentMask_28() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_ParentMask_28)); } inline RectMask2D_tD909811991B341D752E4C978C89EFB80FA7A2B15 * get_m_ParentMask_28() const { return ___m_ParentMask_28; } inline RectMask2D_tD909811991B341D752E4C978C89EFB80FA7A2B15 ** get_address_of_m_ParentMask_28() { return &___m_ParentMask_28; } inline void set_m_ParentMask_28(RectMask2D_tD909811991B341D752E4C978C89EFB80FA7A2B15 * value) { ___m_ParentMask_28 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_ParentMask_28), (void*)value); } inline static int32_t get_offset_of_m_Maskable_29() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_Maskable_29)); } inline bool get_m_Maskable_29() const { return ___m_Maskable_29; } inline bool* get_address_of_m_Maskable_29() { return &___m_Maskable_29; } inline void set_m_Maskable_29(bool value) { ___m_Maskable_29 = value; } inline static int32_t get_offset_of_m_IsMaskingGraphic_30() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_IsMaskingGraphic_30)); } inline bool get_m_IsMaskingGraphic_30() const { return ___m_IsMaskingGraphic_30; } inline bool* get_address_of_m_IsMaskingGraphic_30() { return &___m_IsMaskingGraphic_30; } inline void set_m_IsMaskingGraphic_30(bool value) { ___m_IsMaskingGraphic_30 = value; } inline static int32_t get_offset_of_m_IncludeForMasking_31() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_IncludeForMasking_31)); } inline bool get_m_IncludeForMasking_31() const { return ___m_IncludeForMasking_31; } inline bool* get_address_of_m_IncludeForMasking_31() { return &___m_IncludeForMasking_31; } inline void set_m_IncludeForMasking_31(bool value) { ___m_IncludeForMasking_31 = value; } inline static int32_t get_offset_of_m_OnCullStateChanged_32() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_OnCullStateChanged_32)); } inline CullStateChangedEvent_t9B69755DEBEF041C3CC15C3604610BDD72856BD4 * get_m_OnCullStateChanged_32() const { return ___m_OnCullStateChanged_32; } inline CullStateChangedEvent_t9B69755DEBEF041C3CC15C3604610BDD72856BD4 ** get_address_of_m_OnCullStateChanged_32() { return &___m_OnCullStateChanged_32; } inline void set_m_OnCullStateChanged_32(CullStateChangedEvent_t9B69755DEBEF041C3CC15C3604610BDD72856BD4 * value) { ___m_OnCullStateChanged_32 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_OnCullStateChanged_32), (void*)value); } inline static int32_t get_offset_of_m_ShouldRecalculate_33() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_ShouldRecalculate_33)); } inline bool get_m_ShouldRecalculate_33() const { return ___m_ShouldRecalculate_33; } inline bool* get_address_of_m_ShouldRecalculate_33() { return &___m_ShouldRecalculate_33; } inline void set_m_ShouldRecalculate_33(bool value) { ___m_ShouldRecalculate_33 = value; } inline static int32_t get_offset_of_m_StencilValue_34() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_StencilValue_34)); } inline int32_t get_m_StencilValue_34() const { return ___m_StencilValue_34; } inline int32_t* get_address_of_m_StencilValue_34() { return &___m_StencilValue_34; } inline void set_m_StencilValue_34(int32_t value) { ___m_StencilValue_34 = value; } inline static int32_t get_offset_of_m_Corners_35() { return static_cast<int32_t>(offsetof(MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE, ___m_Corners_35)); } inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* get_m_Corners_35() const { return ___m_Corners_35; } inline Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4** get_address_of_m_Corners_35() { return &___m_Corners_35; } inline void set_m_Corners_35(Vector3U5BU5D_t5FB88EAA33E46838BDC2ABDAEA3E8727491CB9E4* value) { ___m_Corners_35 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Corners_35), (void*)value); } }; // UnityEngine.UI.Text struct Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 : public MaskableGraphic_t0DB59E37E3C8AD2F5A4FB7FB091630CB21370CCE { public: // UnityEngine.UI.FontData UnityEngine.UI.Text::m_FontData FontData_t0F1E9B3ED8136CD40782AC9A6AFB69CAD127C738 * ___m_FontData_36; // System.String UnityEngine.UI.Text::m_Text String_t* ___m_Text_37; // UnityEngine.TextGenerator UnityEngine.UI.Text::m_TextCache TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 * ___m_TextCache_38; // UnityEngine.TextGenerator UnityEngine.UI.Text::m_TextCacheForLayout TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 * ___m_TextCacheForLayout_39; // System.Boolean UnityEngine.UI.Text::m_DisableFontTextureRebuiltCallback bool ___m_DisableFontTextureRebuiltCallback_41; // UnityEngine.UIVertex[] UnityEngine.UI.Text::m_TempVerts UIVertexU5BU5D_tE3D523C48DFEBC775876720DE2539A79FB7E5E5A* ___m_TempVerts_42; public: inline static int32_t get_offset_of_m_FontData_36() { return static_cast<int32_t>(offsetof(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1, ___m_FontData_36)); } inline FontData_t0F1E9B3ED8136CD40782AC9A6AFB69CAD127C738 * get_m_FontData_36() const { return ___m_FontData_36; } inline FontData_t0F1E9B3ED8136CD40782AC9A6AFB69CAD127C738 ** get_address_of_m_FontData_36() { return &___m_FontData_36; } inline void set_m_FontData_36(FontData_t0F1E9B3ED8136CD40782AC9A6AFB69CAD127C738 * value) { ___m_FontData_36 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_FontData_36), (void*)value); } inline static int32_t get_offset_of_m_Text_37() { return static_cast<int32_t>(offsetof(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1, ___m_Text_37)); } inline String_t* get_m_Text_37() const { return ___m_Text_37; } inline String_t** get_address_of_m_Text_37() { return &___m_Text_37; } inline void set_m_Text_37(String_t* value) { ___m_Text_37 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_Text_37), (void*)value); } inline static int32_t get_offset_of_m_TextCache_38() { return static_cast<int32_t>(offsetof(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1, ___m_TextCache_38)); } inline TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 * get_m_TextCache_38() const { return ___m_TextCache_38; } inline TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 ** get_address_of_m_TextCache_38() { return &___m_TextCache_38; } inline void set_m_TextCache_38(TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 * value) { ___m_TextCache_38 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_TextCache_38), (void*)value); } inline static int32_t get_offset_of_m_TextCacheForLayout_39() { return static_cast<int32_t>(offsetof(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1, ___m_TextCacheForLayout_39)); } inline TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 * get_m_TextCacheForLayout_39() const { return ___m_TextCacheForLayout_39; } inline TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 ** get_address_of_m_TextCacheForLayout_39() { return &___m_TextCacheForLayout_39; } inline void set_m_TextCacheForLayout_39(TextGenerator_t893F256D3587633108E00E5731CDC5A77AFF1B70 * value) { ___m_TextCacheForLayout_39 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_TextCacheForLayout_39), (void*)value); } inline static int32_t get_offset_of_m_DisableFontTextureRebuiltCallback_41() { return static_cast<int32_t>(offsetof(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1, ___m_DisableFontTextureRebuiltCallback_41)); } inline bool get_m_DisableFontTextureRebuiltCallback_41() const { return ___m_DisableFontTextureRebuiltCallback_41; } inline bool* get_address_of_m_DisableFontTextureRebuiltCallback_41() { return &___m_DisableFontTextureRebuiltCallback_41; } inline void set_m_DisableFontTextureRebuiltCallback_41(bool value) { ___m_DisableFontTextureRebuiltCallback_41 = value; } inline static int32_t get_offset_of_m_TempVerts_42() { return static_cast<int32_t>(offsetof(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1, ___m_TempVerts_42)); } inline UIVertexU5BU5D_tE3D523C48DFEBC775876720DE2539A79FB7E5E5A* get_m_TempVerts_42() const { return ___m_TempVerts_42; } inline UIVertexU5BU5D_tE3D523C48DFEBC775876720DE2539A79FB7E5E5A** get_address_of_m_TempVerts_42() { return &___m_TempVerts_42; } inline void set_m_TempVerts_42(UIVertexU5BU5D_tE3D523C48DFEBC775876720DE2539A79FB7E5E5A* value) { ___m_TempVerts_42 = value; Il2CppCodeGenWriteBarrier((void**)(&___m_TempVerts_42), (void*)value); } }; struct Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1_StaticFields { public: // UnityEngine.Material UnityEngine.UI.Text::s_DefaultText Material_t8927C00353A72755313F046D0CE85178AE8218EE * ___s_DefaultText_40; public: inline static int32_t get_offset_of_s_DefaultText_40() { return static_cast<int32_t>(offsetof(Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1_StaticFields, ___s_DefaultText_40)); } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE * get_s_DefaultText_40() const { return ___s_DefaultText_40; } inline Material_t8927C00353A72755313F046D0CE85178AE8218EE ** get_address_of_s_DefaultText_40() { return &___s_DefaultText_40; } inline void set_s_DefaultText_40(Material_t8927C00353A72755313F046D0CE85178AE8218EE * value) { ___s_DefaultText_40 = value; Il2CppCodeGenWriteBarrier((void**)(&___s_DefaultText_40), (void*)value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif // Enemy[] struct EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0 : public RuntimeArray { public: ALIGN_FIELD (8) Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * m_Items[1]; public: inline Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * GetAt(il2cpp_array_size_t index) const { IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length); return m_Items[index]; } inline Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 ** GetAddressAt(il2cpp_array_size_t index) { IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length); return m_Items + index; } inline void SetAt(il2cpp_array_size_t index, Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * value) { IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length); m_Items[index] = value; Il2CppCodeGenWriteBarrier((void**)m_Items + index, (void*)value); } inline Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * GetAtUnchecked(il2cpp_array_size_t index) const { return m_Items[index]; } inline Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 ** GetAddressAtUnchecked(il2cpp_array_size_t index) { return m_Items + index; } inline void SetAtUnchecked(il2cpp_array_size_t index, Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * value) { m_Items[index] = value; Il2CppCodeGenWriteBarrier((void**)m_Items + index, (void*)value); } }; // UnityEngine.GameObject[] struct GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642 : public RuntimeArray { public: ALIGN_FIELD (8) GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * m_Items[1]; public: inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * GetAt(il2cpp_array_size_t index) const { IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length); return m_Items[index]; } inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** GetAddressAt(il2cpp_array_size_t index) { IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length); return m_Items + index; } inline void SetAt(il2cpp_array_size_t index, GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value) { IL2CPP_ARRAY_BOUNDS_CHECK(index, (uint32_t)(this)->max_length); m_Items[index] = value; Il2CppCodeGenWriteBarrier((void**)m_Items + index, (void*)value); } inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * GetAtUnchecked(il2cpp_array_size_t index) const { return m_Items[index]; } inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 ** GetAddressAtUnchecked(il2cpp_array_size_t index) { return m_Items + index; } inline void SetAtUnchecked(il2cpp_array_size_t index, GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * value) { m_Items[index] = value; Il2CppCodeGenWriteBarrier((void**)m_Items + index, (void*)value); } }; // !!0[] UnityEngine.Object::FindObjectsOfType<System.Object>() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR ObjectU5BU5D_tC1F4EE0DB0B7300255F5FD4AF64FE4C585CF5ADE* Object_FindObjectsOfType_TisRuntimeObject_m0015B67D48097755F4D6B1D2614DA7ED5C899F18_gshared (const RuntimeMethod* method); // !!0 UnityEngine.GameObject::GetComponent<System.Object>() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject * GameObject_GetComponent_TisRuntimeObject_mCE43118393A796C759AC5D43257AB2330881767D_gshared (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * __this, const RuntimeMethod* method); // !!0 UnityEngine.Object::FindObjectOfType<System.Object>() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject * Object_FindObjectOfType_TisRuntimeObject_m25AA6DB6AABFD5D66AFA1A8C0E91A7AF61429C37_gshared (const RuntimeMethod* method); // !!0 UnityEngine.Object::Instantiate<System.Object>(!!0,UnityEngine.Vector3,UnityEngine.Quaternion) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject * Object_Instantiate_TisRuntimeObject_mB05DEC51C29EF5BB8BD17D055E80217F11E571AA_gshared (RuntimeObject * ___original0, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___position1, Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 ___rotation2, const RuntimeMethod* method); // System.Void System.Collections.Generic.Dictionary`2<System.Object,System.Object>::Add(!0,!1) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Dictionary_2_Add_m830DC29CD6F7128D4990D460CCCDE032E3B693D9_gshared (Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D * __this, RuntimeObject * ___key0, RuntimeObject * ___value1, const RuntimeMethod* method); // System.Void System.Action`1<UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs>::.ctor(System.Object,System.IntPtr) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3_gshared (Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * __this, RuntimeObject * ___object0, intptr_t ___method1, const RuntimeMethod* method); // System.Collections.Generic.List`1/Enumerator<!0> System.Collections.Generic.List`1<System.Object>::GetEnumerator() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6 List_1_GetEnumerator_m1739A5E25DF502A6984F9B98CFCAC2D3FABCF233_gshared (List_1_t3F94120C77410A62EAE48421CF166B83AB95A2F5 * __this, const RuntimeMethod* method); // !0 System.Collections.Generic.List`1/Enumerator<System.Object>::get_Current() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR RuntimeObject * Enumerator_get_Current_m9C4EBBD2108B51885E750F927D7936290C8E20EE_gshared_inline (Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6 * __this, const RuntimeMethod* method); // System.Boolean System.Collections.Generic.List`1/Enumerator<System.Object>::MoveNext() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool Enumerator_MoveNext_m2E56233762839CE55C67E00AC8DD3D4D3F6C0DF0_gshared (Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6 * __this, const RuntimeMethod* method); // System.Void System.Collections.Generic.List`1/Enumerator<System.Object>::Dispose() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Enumerator_Dispose_mCFB225D9E5E597A1CC8F958E53BEA1367D8AC7B8_gshared (Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6 * __this, const RuntimeMethod* method); // !1 System.Collections.Generic.Dictionary`2<System.Object,System.Object>::get_Item(!0) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject * Dictionary_2_get_Item_mB1398A10D048A0246178C59F95003BD338CE7394_gshared (Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D * __this, RuntimeObject * ___key0, const RuntimeMethod* method); // System.Collections.Generic.Dictionary`2/ValueCollection<!0,!1> System.Collections.Generic.Dictionary`2<System.Object,System.Object>::get_Values() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR ValueCollection_t0ACCC25930444F15B1857D00E9FB6021E5842852 * Dictionary_2_get_Values_mC8EC343FADAE6B9CB93639D7FBCDB19ACD807DB5_gshared (Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D * __this, const RuntimeMethod* method); // System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<!0,!1> System.Collections.Generic.Dictionary`2/ValueCollection<System.Object,System.Object>::GetEnumerator() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2 ValueCollection_GetEnumerator_m401C0FF4E5F0194244B19D7B9EF4B173FB7E88C3_gshared (ValueCollection_t0ACCC25930444F15B1857D00E9FB6021E5842852 * __this, const RuntimeMethod* method); // !1 System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.Object,System.Object>::get_Current() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR RuntimeObject * Enumerator_get_Current_m5EAB60888D4E661A01C7F32AD890D785F8B6225B_gshared_inline (Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2 * __this, const RuntimeMethod* method); // System.Boolean System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.Object,System.Object>::MoveNext() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool Enumerator_MoveNext_mAEC22D730EB290F4405C47EE9F330B3CD4E2DC68_gshared (Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2 * __this, const RuntimeMethod* method); // System.Void System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.Object,System.Object>::Dispose() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Enumerator_Dispose_m20B0D06631B9715D2C26F9F0D0665BF0092FF7A6_gshared (Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2 * __this, const RuntimeMethod* method); // System.Void System.Collections.Generic.Dictionary`2<System.Object,System.Object>::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Dictionary_2__ctor_m2C8EE5C13636D67F6C451C4935049F534AEC658F_gshared (Dictionary_2_tBD1E3221EBD04CEBDA49B84779912E91F56B958D * __this, const RuntimeMethod* method); // System.Void UnityEngine.Screen::set_sleepTimeout(System.Int32) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Screen_set_sleepTimeout_mE9A766E696E76AC77EAADB4CA6412454577FCBB3 (int32_t ___value0, const RuntimeMethod* method); // System.Void UnityEngine.MonoBehaviour::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED (MonoBehaviour_t37A501200D970A8257124B0EAE00A0FF3DDC354A * __this, const RuntimeMethod* method); // System.Void FindClosest::FindClosestEnemy() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void FindClosest_FindClosestEnemy_m961EDEED3E1B3BE41F50E3151EED68F5087332C3 (FindClosest_t502181BF1D570545238207A41095AF8DCF41E819 * __this, const RuntimeMethod* method); // !!0[] UnityEngine.Object::FindObjectsOfType<Enemy>() inline EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0* Object_FindObjectsOfType_TisEnemy_tF0E5C8811BC93A523814C562C545DB3C1A755627_mAAE5765443D834ABFAA93E538F961D94D5E8340B (const RuntimeMethod* method) { return (( EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0* (*) (const RuntimeMethod*))Object_FindObjectsOfType_TisRuntimeObject_m0015B67D48097755F4D6B1D2614DA7ED5C899F18_gshared)(method); } // UnityEngine.GameObject UnityEngine.GameObject::Find(System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * GameObject_Find_m20157C941F1A9DA0E33E0ACA1324FAA41C2B199B (String_t* ___name0, const RuntimeMethod* method); // !!0 UnityEngine.GameObject::GetComponent<UnityEngine.UI.Text>() inline Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * GameObject_GetComponent_TisText_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1_mD98876EFC776CB8D02A1394AE6A72DC47F271C65 (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * __this, const RuntimeMethod* method) { return (( Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * (*) (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 *, const RuntimeMethod*))GameObject_GetComponent_TisRuntimeObject_mCE43118393A796C759AC5D43257AB2330881767D_gshared)(__this, method); } // UnityEngine.Transform UnityEngine.Component::get_transform() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * Component_get_transform_mE8496EBC45BEB1BADB5F314960F1DF1C952FA11F (Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684 * __this, const RuntimeMethod* method); // UnityEngine.Vector3 UnityEngine.Transform::get_position() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E Transform_get_position_m40A8A9895568D56FFC687B57F30E8D53CB5EA341 (Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * __this, const RuntimeMethod* method); // UnityEngine.Transform UnityEngine.GameObject::get_transform() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * GameObject_get_transform_m16A80BB92B6C8C5AB696E447014D45EDF1E4DE34 (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * __this, const RuntimeMethod* method); // UnityEngine.Vector3 UnityEngine.Vector3::op_Subtraction(UnityEngine.Vector3,UnityEngine.Vector3) IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E Vector3_op_Subtraction_m2725C96965D5C0B1F9715797E51762B13A5FED58_inline (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___a0, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___b1, const RuntimeMethod* method); // System.Single UnityEngine.Vector3::get_sqrMagnitude() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR float Vector3_get_sqrMagnitude_mC567EE6DF411501A8FE1F23A0038862630B88249 (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * __this, const RuntimeMethod* method); // System.Boolean UnityEngine.Object::op_Inequality(UnityEngine.Object,UnityEngine.Object) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool Object_op_Inequality_mE1F187520BD83FB7D86A6D850710C4D42B864E90 (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A * ___x0, Object_tF2F3778131EFF286AF62B7B013A170F95A91571A * ___y1, const RuntimeMethod* method); // System.String UnityEngine.Object::get_name() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR String_t* Object_get_name_m0C7BC870ED2F0DC5A2FB09628136CD7D1CB82CFB (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A * __this, const RuntimeMethod* method); // System.Void UnityEngine.Debug::Log(System.Object) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Debug_Log_mC26E5AD0D8D156C7FFD173AA15827F69225E9DB8 (RuntimeObject * ___message0, const RuntimeMethod* method); // !!0 UnityEngine.GameObject::GetComponent<MakePostcard>() inline MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * GameObject_GetComponent_TisMakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF_m0CB94270367E249EACBB0933F846EFF09FFEF5F6 (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * __this, const RuntimeMethod* method) { return (( MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * (*) (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 *, const RuntimeMethod*))GameObject_GetComponent_TisRuntimeObject_mCE43118393A796C759AC5D43257AB2330881767D_gshared)(__this, method); } // System.String System.String::Concat(System.String,System.String,System.String,System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR String_t* String_Concat_m37A5BF26F8F8F1892D60D727303B23FB604FEE78 (String_t* ___str00, String_t* ___str11, String_t* ___str22, String_t* ___str33, const RuntimeMethod* method); // !!0 UnityEngine.Object::FindObjectOfType<UnityEngine.XR.ARFoundation.ARTrackedImageManager>() inline ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * Object_FindObjectOfType_TisARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2_m660417E625FD0A66345200E2670A25DD17AA6A22 (const RuntimeMethod* method) { return (( ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * (*) (const RuntimeMethod*))Object_FindObjectOfType_TisRuntimeObject_m25AA6DB6AABFD5D66AFA1A8C0E91A7AF61429C37_gshared)(method); } // UnityEngine.Vector3 UnityEngine.Vector3::get_zero() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E Vector3_get_zero_m1A8F7993167785F750B6B01762D22C2597C84EF6 (const RuntimeMethod* method); // UnityEngine.Quaternion UnityEngine.Quaternion::get_identity() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 Quaternion_get_identity_mF2E565DBCE793A1AE6208056D42CA7C59D83A702 (const RuntimeMethod* method); // !!0 UnityEngine.Object::Instantiate<UnityEngine.GameObject>(!!0,UnityEngine.Vector3,UnityEngine.Quaternion) inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * Object_Instantiate_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_m81B599A0051F8F4543E5C73A11585E96E940943B (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___original0, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___position1, Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 ___rotation2, const RuntimeMethod* method) { return (( GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * (*) (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 *, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E , Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 , const RuntimeMethod*))Object_Instantiate_TisRuntimeObject_mB05DEC51C29EF5BB8BD17D055E80217F11E571AA_gshared)(___original0, ___position1, ___rotation2, method); } // System.Void UnityEngine.Object::set_name(System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Object_set_name_m87C4006618ADB325ABE5439DF159E10DD8DD0781 (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A * __this, String_t* ___value0, const RuntimeMethod* method); // System.Void UnityEngine.GameObject::SetActive(System.Boolean) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void GameObject_SetActive_mCF1EEF2A314F3AE85DA581FF52EB06ACEF2FFF86 (GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * __this, bool ___value0, const RuntimeMethod* method); // System.Void System.Collections.Generic.Dictionary`2<System.String,UnityEngine.GameObject>::Add(!0,!1) inline void Dictionary_2_Add_m6D23729A58240291FAD0B2A484D107C5D06B8A78 (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * __this, String_t* ___key0, GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * ___value1, const RuntimeMethod* method) { (( void (*) (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C *, String_t*, GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 *, const RuntimeMethod*))Dictionary_2_Add_m830DC29CD6F7128D4990D460CCCDE032E3B693D9_gshared)(__this, ___key0, ___value1, method); } // System.Void System.Action`1<UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs>::.ctor(System.Object,System.IntPtr) inline void Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3 (Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * __this, RuntimeObject * ___object0, intptr_t ___method1, const RuntimeMethod* method) { (( void (*) (Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 *, RuntimeObject *, intptr_t, const RuntimeMethod*))Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3_gshared)(__this, ___object0, ___method1, method); } // System.Void UnityEngine.XR.ARFoundation.ARTrackedImageManager::add_trackedImagesChanged(System.Action`1<UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs>) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ARTrackedImageManager_add_trackedImagesChanged_m72C17C9ECEEFADD229EA80CD20ED1254336F3D76 (ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * __this, Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * ___value0, const RuntimeMethod* method); // System.Void UnityEngine.XR.ARFoundation.ARTrackedImageManager::remove_trackedImagesChanged(System.Action`1<UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs>) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ARTrackedImageManager_remove_trackedImagesChanged_mE28AE7C3CD3F208C9891976125E8A0ED3641EDAF (ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * __this, Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * ___value0, const RuntimeMethod* method); // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs::get_added() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ARTrackedImagesChangedEventArgs_get_added_m0E81E3C161242C2508B90BCC73605F551AD53B4E_inline (ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C * __this, const RuntimeMethod* method); // System.Collections.Generic.List`1/Enumerator<!0> System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage>::GetEnumerator() inline Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86 (List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * __this, const RuntimeMethod* method) { return (( Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 (*) (List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F *, const RuntimeMethod*))List_1_GetEnumerator_m1739A5E25DF502A6984F9B98CFCAC2D3FABCF233_gshared)(__this, method); } // !0 System.Collections.Generic.List`1/Enumerator<UnityEngine.XR.ARFoundation.ARTrackedImage>::get_Current() inline ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_inline (Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 * __this, const RuntimeMethod* method) { return (( ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * (*) (Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *, const RuntimeMethod*))Enumerator_get_Current_m9C4EBBD2108B51885E750F927D7936290C8E20EE_gshared_inline)(__this, method); } // System.Void ImageTracking::UpdateImage(UnityEngine.XR.ARFoundation.ARTrackedImage) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ImageTracking_UpdateImage_m6EA667E6284B239584418E7AA908EE43D6403BE2 (ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 * __this, ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * ___trackedImage0, const RuntimeMethod* method); // System.Boolean System.Collections.Generic.List`1/Enumerator<UnityEngine.XR.ARFoundation.ARTrackedImage>::MoveNext() inline bool Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7 (Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 * __this, const RuntimeMethod* method) { return (( bool (*) (Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *, const RuntimeMethod*))Enumerator_MoveNext_m2E56233762839CE55C67E00AC8DD3D4D3F6C0DF0_gshared)(__this, method); } // System.Void System.Collections.Generic.List`1/Enumerator<UnityEngine.XR.ARFoundation.ARTrackedImage>::Dispose() inline void Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C (Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 * __this, const RuntimeMethod* method) { (( void (*) (Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *, const RuntimeMethod*))Enumerator_Dispose_mCFB225D9E5E597A1CC8F958E53BEA1367D8AC7B8_gshared)(__this, method); } // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs::get_updated() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ARTrackedImagesChangedEventArgs_get_updated_mBEB295B97B6C25E4DC4447383F529C9E475E4041_inline (ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C * __this, const RuntimeMethod* method); // System.Collections.Generic.List`1<UnityEngine.XR.ARFoundation.ARTrackedImage> UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs::get_removed() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ARTrackedImagesChangedEventArgs_get_removed_mF4C9906743C7270B1AAD4B43E74CDB9CB5208E57_inline (ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C * __this, const RuntimeMethod* method); // UnityEngine.XR.ARSubsystems.XRReferenceImage UnityEngine.XR.ARFoundation.ARTrackedImage::get_referenceImage() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 ARTrackedImage_get_referenceImage_m6061DE2D46F8060065B64EF3860A0B0085B569E4_inline (ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * __this, const RuntimeMethod* method); // System.String UnityEngine.XR.ARSubsystems.XRReferenceImage::get_name() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR String_t* XRReferenceImage_get_name_mE8F3368C2587552333AB78EA72A02E5B73E355C7_inline (XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 * __this, const RuntimeMethod* method); // !1 System.Collections.Generic.Dictionary`2<System.String,UnityEngine.GameObject>::get_Item(!0) inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * Dictionary_2_get_Item_mC4E467FB6129C74774CC33C4A8E3B1F00A73E15A (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * __this, String_t* ___key0, const RuntimeMethod* method) { return (( GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * (*) (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C *, String_t*, const RuntimeMethod*))Dictionary_2_get_Item_mB1398A10D048A0246178C59F95003BD338CE7394_gshared)(__this, ___key0, method); } // System.Void UnityEngine.Transform::set_position(UnityEngine.Vector3) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Transform_set_position_mB169E52D57EEAC1E3F22C5395968714E4F00AC91 (Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * __this, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___value0, const RuntimeMethod* method); // System.Collections.Generic.Dictionary`2/ValueCollection<!0,!1> System.Collections.Generic.Dictionary`2<System.String,UnityEngine.GameObject>::get_Values() inline ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 * Dictionary_2_get_Values_mCE27229BD2853EB5DD18823A44CB838915891AF5 (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * __this, const RuntimeMethod* method) { return (( ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 * (*) (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C *, const RuntimeMethod*))Dictionary_2_get_Values_mC8EC343FADAE6B9CB93639D7FBCDB19ACD807DB5_gshared)(__this, method); } // System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<!0,!1> System.Collections.Generic.Dictionary`2/ValueCollection<System.String,UnityEngine.GameObject>::GetEnumerator() inline Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 ValueCollection_GetEnumerator_m4F21A422DA7CBC55B4596D04154835F270B15957 (ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 * __this, const RuntimeMethod* method) { return (( Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 (*) (ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 *, const RuntimeMethod*))ValueCollection_GetEnumerator_m401C0FF4E5F0194244B19D7B9EF4B173FB7E88C3_gshared)(__this, method); } // !1 System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.String,UnityEngine.GameObject>::get_Current() inline GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * Enumerator_get_Current_mD4B9742F53CF6579D470CB4824D954C4590A53B0_inline (Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 * __this, const RuntimeMethod* method) { return (( GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * (*) (Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 *, const RuntimeMethod*))Enumerator_get_Current_m5EAB60888D4E661A01C7F32AD890D785F8B6225B_gshared_inline)(__this, method); } // System.Boolean System.String::op_Inequality(System.String,System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool String_op_Inequality_mDDA2DDED3E7EF042987EB7180EE3E88105F0AAE2 (String_t* ___a0, String_t* ___b1, const RuntimeMethod* method); // System.Boolean System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.String,UnityEngine.GameObject>::MoveNext() inline bool Enumerator_MoveNext_mCB1E114B7C949E2BE0521FAB1DCD32D836AA838E (Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 * __this, const RuntimeMethod* method) { return (( bool (*) (Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 *, const RuntimeMethod*))Enumerator_MoveNext_mAEC22D730EB290F4405C47EE9F330B3CD4E2DC68_gshared)(__this, method); } // System.Void System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator<System.String,UnityEngine.GameObject>::Dispose() inline void Enumerator_Dispose_mA7C5E1105681D1F3AEFE0B3D8F403231775794CC (Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 * __this, const RuntimeMethod* method) { (( void (*) (Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 *, const RuntimeMethod*))Enumerator_Dispose_m20B0D06631B9715D2C26F9F0D0665BF0092FF7A6_gshared)(__this, method); } // System.Void System.Collections.Generic.Dictionary`2<System.String,UnityEngine.GameObject>::.ctor() inline void Dictionary_2__ctor_m627A706D7F24292D51368C749EB140EFE869376A (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * __this, const RuntimeMethod* method) { (( void (*) (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C *, const RuntimeMethod*))Dictionary_2__ctor_m2C8EE5C13636D67F6C451C4935049F534AEC658F_gshared)(__this, method); } // UnityEngine.SceneManagement.Scene UnityEngine.SceneManagement.SceneManager::GetActiveScene() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE SceneManager_GetActiveScene_mB9A5037FFB576B2432D0BFEF6A161B7C4C1921A4 (const RuntimeMethod* method); // System.String UnityEngine.SceneManagement.Scene::get_name() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR String_t* Scene_get_name_m38F195D7CA6417FED310C23E4D8E86150C7835B8 (Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE * __this, const RuntimeMethod* method); // FMOD.Studio.Bus FMODUnity.RuntimeManager::GetBus(System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F RuntimeManager_GetBus_mB8F90AC016A626B013743C59CCCAC9918ED79A2C (String_t* ___path0, const RuntimeMethod* method); // !!0[] UnityEngine.Object::FindObjectsOfType<UnityEngine.GameObject>() inline GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* Object_FindObjectsOfType_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_mA1495EFEECA7BF44DA43D9813F575C92968F0B4F (const RuntimeMethod* method) { return (( GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* (*) (const RuntimeMethod*))Object_FindObjectsOfType_TisRuntimeObject_m0015B67D48097755F4D6B1D2614DA7ED5C899F18_gshared)(method); } // UnityEngine.GameObject[] UnityEngine.GameObject::FindGameObjectsWithTag(System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* GameObject_FindGameObjectsWithTag_m0948320611DC82590D59A36D1C57155B1B6CE186 (String_t* ___tag0, const RuntimeMethod* method); // System.Boolean System.String::op_Equality(System.String,System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool String_op_Equality_m2B91EE68355F142F67095973D32EB5828B7B73CB (String_t* ___a0, String_t* ___b1, const RuntimeMethod* method); // System.Void UnityEngine.SceneManagement.SceneManager::LoadScene(System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void SceneManager_LoadScene_m7DAF30213E99396ECBDB1BD40CC34CCF36902092 (String_t* ___sceneName0, const RuntimeMethod* method); // System.Void UnityEngine.Object::Destroy(UnityEngine.Object) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Object_Destroy_m3EEDB6ECD49A541EC826EA8E1C8B599F7AF67D30 (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A * ___obj0, const RuntimeMethod* method); // FMOD.RESULT FMOD.Studio.Bus::stopAllEvents(FMOD.Studio.STOP_MODE) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR int32_t Bus_stopAllEvents_mCCFEB7E04F9EC684896881E001E6B457FD5AE4BB (Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F * __this, int32_t ___mode0, const RuntimeMethod* method); // System.Void UnityEngine.Behaviour::set_enabled(System.Boolean) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Behaviour_set_enabled_mDE415591B28853D1CD764C53CB499A2142247F32 (Behaviour_t1A3DDDCF73B4627928FBFE02ED52B7251777DBD9 * __this, bool ___value0, const RuntimeMethod* method); // System.Void TrackingState/<Start>d__3::.ctor(System.Int32) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void U3CStartU3Ed__3__ctor_m57C016DC249E940ECD9801A22FD4DE9E94442806 (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * __this, int32_t ___U3CU3E1__state0, const RuntimeMethod* method); // System.Boolean UnityEngine.Object::op_Equality(UnityEngine.Object,UnityEngine.Object) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool Object_op_Equality_mEE9EC7EB5C7DC3E95B94AB904E1986FC4D566D54 (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A * ___x0, Object_tF2F3778131EFF286AF62B7B013A170F95A91571A * ___y1, const RuntimeMethod* method); // UnityEngine.GameObject UnityEngine.Component::get_gameObject() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * Component_get_gameObject_m55DC35B149AFB9157582755383BA954655FE0C5B (Component_t62FBC8D2420DA4BE9037AFE430740F6B3EECA684 * __this, const RuntimeMethod* method); // System.String System.String::Concat(System.String,System.String) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR String_t* String_Concat_m4B4AB72618348C5DFBFBA8DED84B9E2EBDB55E1B (String_t* ___str00, String_t* ___str11, const RuntimeMethod* method); // UnityEngine.XR.ARFoundation.ARSessionState UnityEngine.XR.ARFoundation.ARSession::get_state() IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR int32_t ARSession_get_state_m623161F1E2E5BA2752C821DD409880E6647CA130_inline (const RuntimeMethod* method); // System.Void System.Object::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Object__ctor_m88880E0413421D13FD95325EDCE231707CE1F405 (RuntimeObject * __this, const RuntimeMethod* method); // System.Collections.IEnumerator UnityEngine.XR.ARFoundation.ARSession::CheckAvailability() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject* ARSession_CheckAvailability_mCC906561CCCE269C11B69D2216C39120563F00FD (const RuntimeMethod* method); // System.Void System.NotSupportedException::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void NotSupportedException__ctor_m3EA81A5B209A87C3ADA47443F2AFFF735E5256EE (NotSupportedException_tB9D89F0E9470A2C423D239D7C68EE0CFD77F9339 * __this, const RuntimeMethod* method); // System.Void UnityEngine.Vector3::.ctor(System.Single,System.Single,System.Single) IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void Vector3__ctor_m57495F692C6CE1CEF278CAD9A98221165D37E636_inline (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * __this, float ___x0, float ___y1, float ___z2, const RuntimeMethod* method); #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void DisableScreenSleeping::Start() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void DisableScreenSleeping_Start_mDA67E1D86AA25699A62152A1DDF9589BC7F5078A (DisableScreenSleeping_t721C4DDFE6A41229AABD432937B146D77CED2420 * __this, const RuntimeMethod* method) { { // Screen.sleepTimeout = SleepTimeout.NeverSleep; Screen_set_sleepTimeout_mE9A766E696E76AC77EAADB4CA6412454577FCBB3((-1), /*hidden argument*/NULL); // } return; } } // System.Void DisableScreenSleeping::Update() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void DisableScreenSleeping_Update_m1F263B654B5CDA87F0A97AA9E4D85C007F646CEF (DisableScreenSleeping_t721C4DDFE6A41229AABD432937B146D77CED2420 * __this, const RuntimeMethod* method) { { // } return; } } // System.Void DisableScreenSleeping::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void DisableScreenSleeping__ctor_mF26D6447AB8BBBCEDE194DC7FA532C358FA38736 (DisableScreenSleeping_t721C4DDFE6A41229AABD432937B146D77CED2420 * __this, const RuntimeMethod* method) { { MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED(__this, /*hidden argument*/NULL); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void Enemy::Start() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Enemy_Start_m9FA35B427F2B9FDFD390E9812C2556775C62CB02 (Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * __this, const RuntimeMethod* method) { { // } return; } } // System.Void Enemy::Update() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Enemy_Update_mA01EE7AF5D3B97687752E9D22BECB4A3E13F8FD2 (Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * __this, const RuntimeMethod* method) { { // } return; } } // System.Void Enemy::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void Enemy__ctor_m3C82F8269DE4132408E15B523907244771640734 (Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * __this, const RuntimeMethod* method) { { MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED(__this, /*hidden argument*/NULL); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void FindClosest::Start() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void FindClosest_Start_mF954EF122834C0482B99F76BB64B0CBBF3BC9E3F (FindClosest_t502181BF1D570545238207A41095AF8DCF41E819 * __this, const RuntimeMethod* method) { { // } return; } } // System.Void FindClosest::Update() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void FindClosest_Update_m04188BD3F62F95FF16814C7856DE8D9EDA763173 (FindClosest_t502181BF1D570545238207A41095AF8DCF41E819 * __this, const RuntimeMethod* method) { { // FindClosestEnemy (); FindClosest_FindClosestEnemy_m961EDEED3E1B3BE41F50E3151EED68F5087332C3(__this, /*hidden argument*/NULL); // } return; } } // System.Void FindClosest::FindClosestEnemy() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void FindClosest_FindClosestEnemy_m961EDEED3E1B3BE41F50E3151EED68F5087332C3 (FindClosest_t502181BF1D570545238207A41095AF8DCF41E819 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Debug_tEB68BCBEB8EFD60F8043C67146DC05E7F50F374B_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&GameObject_GetComponent_TisMakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF_m0CB94270367E249EACBB0933F846EFF09FFEF5F6_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&GameObject_GetComponent_TisText_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1_mD98876EFC776CB8D02A1394AE6A72DC47F271C65_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_FindObjectsOfType_TisEnemy_tF0E5C8811BC93A523814C562C545DB3C1A755627_mAAE5765443D834ABFAA93E538F961D94D5E8340B_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral116273CD5D8FA85B2B09F79802D1EDD0C11FFC66); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral27FD14CFE32223C443750A097C6E310D28F90764); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralB15C3B1E5301A454B1F6EF3D4C8C3CA94F73285F); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralE3DB1B6CF792E1BF1AED62392910B83816D9FC52); s_Il2CppMethodInitialized = true; } float V_0 = 0.0f; Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * V_1 = NULL; String_t* V_2 = NULL; String_t* V_3 = NULL; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * V_4 = NULL; Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * V_5 = NULL; EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0* V_6 = NULL; int32_t V_7 = 0; Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * V_8 = NULL; float V_9 = 0.0f; Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E V_10; memset((&V_10), 0, sizeof(V_10)); { // float distanceToClosestEnemy = Mathf.Infinity; V_0 = (std::numeric_limits<float>::infinity()); // Enemy closestEnemy = null; V_1 = (Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 *)NULL; // Enemy[] allEnemies = GameObject.FindObjectsOfType<Enemy>(); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0* L_0; L_0 = Object_FindObjectsOfType_TisEnemy_tF0E5C8811BC93A523814C562C545DB3C1A755627_mAAE5765443D834ABFAA93E538F961D94D5E8340B(/*hidden argument*/Object_FindObjectsOfType_TisEnemy_tF0E5C8811BC93A523814C562C545DB3C1A755627_mAAE5765443D834ABFAA93E538F961D94D5E8340B_RuntimeMethod_var); // GameObject arCamera = GameObject.Find("AR Camera"); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_1; L_1 = GameObject_Find_m20157C941F1A9DA0E33E0ACA1324FAA41C2B199B(_stringLiteralE3DB1B6CF792E1BF1AED62392910B83816D9FC52, /*hidden argument*/NULL); V_4 = L_1; // Text infoPanel = GameObject.Find("InfoText").GetComponent<Text>(); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_2; L_2 = GameObject_Find_m20157C941F1A9DA0E33E0ACA1324FAA41C2B199B(_stringLiteral27FD14CFE32223C443750A097C6E310D28F90764, /*hidden argument*/NULL); NullCheck(L_2); Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * L_3; L_3 = GameObject_GetComponent_TisText_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1_mD98876EFC776CB8D02A1394AE6A72DC47F271C65(L_2, /*hidden argument*/GameObject_GetComponent_TisText_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1_mD98876EFC776CB8D02A1394AE6A72DC47F271C65_RuntimeMethod_var); V_5 = L_3; // foreach (Enemy currentEnemy in allEnemies) { V_6 = L_0; V_7 = 0; goto IL_0071; } IL_0031: { // foreach (Enemy currentEnemy in allEnemies) { EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0* L_4 = V_6; int32_t L_5 = V_7; NullCheck(L_4); int32_t L_6 = L_5; Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * L_7 = (L_4)->GetAt(static_cast<il2cpp_array_size_t>(L_6)); V_8 = L_7; // float distanceToEnemy = (currentEnemy.transform.position - arCamera.transform.position).sqrMagnitude; Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * L_8 = V_8; NullCheck(L_8); Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * L_9; L_9 = Component_get_transform_mE8496EBC45BEB1BADB5F314960F1DF1C952FA11F(L_8, /*hidden argument*/NULL); NullCheck(L_9); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_10; L_10 = Transform_get_position_m40A8A9895568D56FFC687B57F30E8D53CB5EA341(L_9, /*hidden argument*/NULL); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_11 = V_4; NullCheck(L_11); Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * L_12; L_12 = GameObject_get_transform_m16A80BB92B6C8C5AB696E447014D45EDF1E4DE34(L_11, /*hidden argument*/NULL); NullCheck(L_12); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_13; L_13 = Transform_get_position_m40A8A9895568D56FFC687B57F30E8D53CB5EA341(L_12, /*hidden argument*/NULL); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_14; L_14 = Vector3_op_Subtraction_m2725C96965D5C0B1F9715797E51762B13A5FED58_inline(L_10, L_13, /*hidden argument*/NULL); V_10 = L_14; float L_15; L_15 = Vector3_get_sqrMagnitude_mC567EE6DF411501A8FE1F23A0038862630B88249((Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E *)(&V_10), /*hidden argument*/NULL); V_9 = L_15; // if (distanceToEnemy < distanceToClosestEnemy) { float L_16 = V_9; float L_17 = V_0; if ((!(((float)L_16) < ((float)L_17)))) { goto IL_006b; } } { // distanceToClosestEnemy = distanceToEnemy; float L_18 = V_9; V_0 = L_18; // closestEnemy = currentEnemy; Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * L_19 = V_8; V_1 = L_19; } IL_006b: { int32_t L_20 = V_7; V_7 = ((int32_t)il2cpp_codegen_add((int32_t)L_20, (int32_t)1)); } IL_0071: { // foreach (Enemy currentEnemy in allEnemies) { int32_t L_21 = V_7; EnemyU5BU5D_t180C2C49BE2837412479DBB2D25E1D9C57C21CB0* L_22 = V_6; NullCheck(L_22); if ((((int32_t)L_21) < ((int32_t)((int32_t)((int32_t)(((RuntimeArray*)L_22)->max_length)))))) { goto IL_0031; } } { // if (closestEnemy != null) { Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * L_23 = V_1; IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); bool L_24; L_24 = Object_op_Inequality_mE1F187520BD83FB7D86A6D850710C4D42B864E90(L_23, (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A *)NULL, /*hidden argument*/NULL); if (!L_24) { goto IL_00c9; } } { // Debug.Log (closestEnemy.name); Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * L_25 = V_1; NullCheck(L_25); String_t* L_26; L_26 = Object_get_name_m0C7BC870ED2F0DC5A2FB09628136CD7D1CB82CFB(L_25, /*hidden argument*/NULL); IL2CPP_RUNTIME_CLASS_INIT(Debug_tEB68BCBEB8EFD60F8043C67146DC05E7F50F374B_il2cpp_TypeInfo_var); Debug_Log_mC26E5AD0D8D156C7FFD173AA15827F69225E9DB8(L_26, /*hidden argument*/NULL); // postcardInfo = GameObject.Find(closestEnemy.name).GetComponent<MakePostcard>(); Enemy_tF0E5C8811BC93A523814C562C545DB3C1A755627 * L_27 = V_1; NullCheck(L_27); String_t* L_28; L_28 = Object_get_name_m0C7BC870ED2F0DC5A2FB09628136CD7D1CB82CFB(L_27, /*hidden argument*/NULL); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_29; L_29 = GameObject_Find_m20157C941F1A9DA0E33E0ACA1324FAA41C2B199B(L_28, /*hidden argument*/NULL); NullCheck(L_29); MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * L_30; L_30 = GameObject_GetComponent_TisMakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF_m0CB94270367E249EACBB0933F846EFF09FFEF5F6(L_29, /*hidden argument*/GameObject_GetComponent_TisMakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF_m0CB94270367E249EACBB0933F846EFF09FFEF5F6_RuntimeMethod_var); // name = postcardInfo.PostcardName; MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * L_31 = L_30; NullCheck(L_31); String_t* L_32 = L_31->get_PostcardName_4(); V_2 = L_32; // description = postcardInfo.PostcardDescription; MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * L_33 = L_31; NullCheck(L_33); String_t* L_34 = L_33->get_PostcardDescription_5(); V_3 = L_34; // link = postcardInfo.PostcardLink; NullCheck(L_33); String_t* L_35 = L_33->get_PostcardLink_6(); // infoPanel.text = "<b>" + name + "</b>" + "\n" + description; Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * L_36 = V_5; String_t* L_37 = V_2; String_t* L_38 = V_3; String_t* L_39; L_39 = String_Concat_m37A5BF26F8F8F1892D60D727303B23FB604FEE78(_stringLiteral116273CD5D8FA85B2B09F79802D1EDD0C11FFC66, L_37, _stringLiteralB15C3B1E5301A454B1F6EF3D4C8C3CA94F73285F, L_38, /*hidden argument*/NULL); NullCheck(L_36); VirtActionInvoker1< String_t* >::Invoke(75 /* System.Void UnityEngine.UI.Text::set_text(System.String) */, L_36, L_39); } IL_00c9: { // } return; } } // System.Void FindClosest::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void FindClosest__ctor_m8C499E052A84E8DBDA319C9092E7E3E0684B631C (FindClosest_t502181BF1D570545238207A41095AF8DCF41E819 * __this, const RuntimeMethod* method) { { MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED(__this, /*hidden argument*/NULL); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void ImageTracking::Awake() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ImageTracking_Awake_m7579999A12E8E8610888695D73FF7CF1071BE29E (ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Dictionary_2_Add_m6D23729A58240291FAD0B2A484D107C5D06B8A78_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_FindObjectOfType_TisARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2_m660417E625FD0A66345200E2670A25DD17AA6A22_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_Instantiate_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_m81B599A0051F8F4543E5C73A11585E96E940943B_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); s_Il2CppMethodInitialized = true; } GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* V_0 = NULL; int32_t V_1 = 0; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * V_2 = NULL; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * V_3 = NULL; { // trackedImageManager = FindObjectOfType<ARTrackedImageManager>(); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * L_0; L_0 = Object_FindObjectOfType_TisARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2_m660417E625FD0A66345200E2670A25DD17AA6A22(/*hidden argument*/Object_FindObjectOfType_TisARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2_m660417E625FD0A66345200E2670A25DD17AA6A22_RuntimeMethod_var); __this->set_trackedImageManager_6(L_0); // foreach(GameObject prefab in placeablePrefabs) GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* L_1 = __this->get_placeablePrefabs_4(); V_0 = L_1; V_1 = 0; goto IL_0054; } IL_0016: { // foreach(GameObject prefab in placeablePrefabs) GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* L_2 = V_0; int32_t L_3 = V_1; NullCheck(L_2); int32_t L_4 = L_3; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_5 = (L_2)->GetAt(static_cast<il2cpp_array_size_t>(L_4)); V_2 = L_5; // GameObject newPrefab = Instantiate(prefab, Vector3.zero, Quaternion.identity); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_6 = V_2; Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_7; L_7 = Vector3_get_zero_m1A8F7993167785F750B6B01762D22C2597C84EF6(/*hidden argument*/NULL); Quaternion_t6D28618CF65156D4A0AD747370DDFD0C514A31B4 L_8; L_8 = Quaternion_get_identity_mF2E565DBCE793A1AE6208056D42CA7C59D83A702(/*hidden argument*/NULL); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_9; L_9 = Object_Instantiate_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_m81B599A0051F8F4543E5C73A11585E96E940943B(L_6, L_7, L_8, /*hidden argument*/Object_Instantiate_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_m81B599A0051F8F4543E5C73A11585E96E940943B_RuntimeMethod_var); V_3 = L_9; // newPrefab.name = prefab.name; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_10 = V_3; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_11 = V_2; NullCheck(L_11); String_t* L_12; L_12 = Object_get_name_m0C7BC870ED2F0DC5A2FB09628136CD7D1CB82CFB(L_11, /*hidden argument*/NULL); NullCheck(L_10); Object_set_name_m87C4006618ADB325ABE5439DF159E10DD8DD0781(L_10, L_12, /*hidden argument*/NULL); // newPrefab.SetActive(false); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_13 = V_3; NullCheck(L_13); GameObject_SetActive_mCF1EEF2A314F3AE85DA581FF52EB06ACEF2FFF86(L_13, (bool)0, /*hidden argument*/NULL); // spawnedPrefabs.Add(prefab.name, newPrefab); Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * L_14 = __this->get_spawnedPrefabs_5(); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_15 = V_2; NullCheck(L_15); String_t* L_16; L_16 = Object_get_name_m0C7BC870ED2F0DC5A2FB09628136CD7D1CB82CFB(L_15, /*hidden argument*/NULL); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_17 = V_3; NullCheck(L_14); Dictionary_2_Add_m6D23729A58240291FAD0B2A484D107C5D06B8A78(L_14, L_16, L_17, /*hidden argument*/Dictionary_2_Add_m6D23729A58240291FAD0B2A484D107C5D06B8A78_RuntimeMethod_var); int32_t L_18 = V_1; V_1 = ((int32_t)il2cpp_codegen_add((int32_t)L_18, (int32_t)1)); } IL_0054: { // foreach(GameObject prefab in placeablePrefabs) int32_t L_19 = V_1; GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* L_20 = V_0; NullCheck(L_20); if ((((int32_t)L_19) < ((int32_t)((int32_t)((int32_t)(((RuntimeArray*)L_20)->max_length)))))) { goto IL_0016; } } { // } return; } } // System.Void ImageTracking::OnEnable() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ImageTracking_OnEnable_mEB753A2871A1DF507D551E5A0682842D0504ED53 (ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&ImageTracking_ImageChanged_mF71CEAFEC17C56EA45ED003E88C0A51609B8105A_RuntimeMethod_var); s_Il2CppMethodInitialized = true; } { // trackedImageManager.trackedImagesChanged += ImageChanged; ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * L_0 = __this->get_trackedImageManager_6(); Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * L_1 = (Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 *)il2cpp_codegen_object_new(Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032_il2cpp_TypeInfo_var); Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3(L_1, __this, (intptr_t)((intptr_t)ImageTracking_ImageChanged_mF71CEAFEC17C56EA45ED003E88C0A51609B8105A_RuntimeMethod_var), /*hidden argument*/Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3_RuntimeMethod_var); NullCheck(L_0); ARTrackedImageManager_add_trackedImagesChanged_m72C17C9ECEEFADD229EA80CD20ED1254336F3D76(L_0, L_1, /*hidden argument*/NULL); // } return; } } // System.Void ImageTracking::OnDisable() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ImageTracking_OnDisable_m640C232F4C65D8615D282F2923905C730937E07C (ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&ImageTracking_ImageChanged_mF71CEAFEC17C56EA45ED003E88C0A51609B8105A_RuntimeMethod_var); s_Il2CppMethodInitialized = true; } { // trackedImageManager.trackedImagesChanged -= ImageChanged; ARTrackedImageManager_tB916E34D053E6712190F2BAE46E21D76A0882FF2 * L_0 = __this->get_trackedImageManager_6(); Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 * L_1 = (Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032 *)il2cpp_codegen_object_new(Action_1_t19910F5D681EFD1901DBD0F742BD502089B49032_il2cpp_TypeInfo_var); Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3(L_1, __this, (intptr_t)((intptr_t)ImageTracking_ImageChanged_mF71CEAFEC17C56EA45ED003E88C0A51609B8105A_RuntimeMethod_var), /*hidden argument*/Action_1__ctor_m478435EC913232FA753676196AF119F5001564B3_RuntimeMethod_var); NullCheck(L_0); ARTrackedImageManager_remove_trackedImagesChanged_mE28AE7C3CD3F208C9891976125E8A0ED3641EDAF(L_0, L_1, /*hidden argument*/NULL); // } return; } } // System.Void ImageTracking::ImageChanged(UnityEngine.XR.ARFoundation.ARTrackedImagesChangedEventArgs) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ImageTracking_ImageChanged_mF71CEAFEC17C56EA45ED003E88C0A51609B8105A (ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 * __this, ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C ___eventArgs0, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86_RuntimeMethod_var); s_Il2CppMethodInitialized = true; } Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 V_0; memset((&V_0), 0, sizeof(V_0)); ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * V_1 = NULL; ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * V_2 = NULL; Exception_t * __last_unhandled_exception = 0; il2cpp::utils::ExceptionSupportStack<int32_t, 3> __leave_targets; { // foreach(ARTrackedImage trackedImage in eventArgs.added) List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * L_0; L_0 = ARTrackedImagesChangedEventArgs_get_added_m0E81E3C161242C2508B90BCC73605F551AD53B4E_inline((ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C *)(&___eventArgs0), /*hidden argument*/NULL); NullCheck(L_0); Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 L_1; L_1 = List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86(L_0, /*hidden argument*/List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86_RuntimeMethod_var); V_0 = L_1; } IL_000d: try { // begin try (depth: 1) { goto IL_001e; } IL_000f: { // foreach(ARTrackedImage trackedImage in eventArgs.added) ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * L_2; L_2 = Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_inline((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_RuntimeMethod_var); V_1 = L_2; // UpdateImage(trackedImage); ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * L_3 = V_1; ImageTracking_UpdateImage_m6EA667E6284B239584418E7AA908EE43D6403BE2(__this, L_3, /*hidden argument*/NULL); } IL_001e: { // foreach(ARTrackedImage trackedImage in eventArgs.added) bool L_4; L_4 = Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7_RuntimeMethod_var); if (L_4) { goto IL_000f; } } IL_0027: { IL2CPP_LEAVE(0x37, FINALLY_0029); } } // end try (depth: 1) catch(Il2CppExceptionWrapper& e) { __last_unhandled_exception = (Exception_t *)e.ex; goto FINALLY_0029; } FINALLY_0029: { // begin finally (depth: 1) Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C_RuntimeMethod_var); IL2CPP_END_FINALLY(41) } // end finally (depth: 1) IL2CPP_CLEANUP(41) { IL2CPP_RETHROW_IF_UNHANDLED(Exception_t *) IL2CPP_JUMP_TBL(0x37, IL_0037) } IL_0037: { // foreach(ARTrackedImage trackedImage in eventArgs.updated) List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * L_5; L_5 = ARTrackedImagesChangedEventArgs_get_updated_mBEB295B97B6C25E4DC4447383F529C9E475E4041_inline((ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C *)(&___eventArgs0), /*hidden argument*/NULL); NullCheck(L_5); Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 L_6; L_6 = List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86(L_5, /*hidden argument*/List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86_RuntimeMethod_var); V_0 = L_6; } IL_0044: try { // begin try (depth: 1) { goto IL_0055; } IL_0046: { // foreach(ARTrackedImage trackedImage in eventArgs.updated) ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * L_7; L_7 = Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_inline((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_RuntimeMethod_var); V_2 = L_7; // UpdateImage(trackedImage); ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * L_8 = V_2; ImageTracking_UpdateImage_m6EA667E6284B239584418E7AA908EE43D6403BE2(__this, L_8, /*hidden argument*/NULL); } IL_0055: { // foreach(ARTrackedImage trackedImage in eventArgs.updated) bool L_9; L_9 = Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7_RuntimeMethod_var); if (L_9) { goto IL_0046; } } IL_005e: { IL2CPP_LEAVE(0x6E, FINALLY_0060); } } // end try (depth: 1) catch(Il2CppExceptionWrapper& e) { __last_unhandled_exception = (Exception_t *)e.ex; goto FINALLY_0060; } FINALLY_0060: { // begin finally (depth: 1) Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C_RuntimeMethod_var); IL2CPP_END_FINALLY(96) } // end finally (depth: 1) IL2CPP_CLEANUP(96) { IL2CPP_RETHROW_IF_UNHANDLED(Exception_t *) IL2CPP_JUMP_TBL(0x6E, IL_006e) } IL_006e: { // foreach(ARTrackedImage trackedImage in eventArgs.removed) List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * L_10; L_10 = ARTrackedImagesChangedEventArgs_get_removed_mF4C9906743C7270B1AAD4B43E74CDB9CB5208E57_inline((ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C *)(&___eventArgs0), /*hidden argument*/NULL); NullCheck(L_10); Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 L_11; L_11 = List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86(L_10, /*hidden argument*/List_1_GetEnumerator_m364FE8EB7E663EEC71E574FD554BE600FD5A0D86_RuntimeMethod_var); V_0 = L_11; } IL_007b: try { // begin try (depth: 1) { goto IL_0085; } IL_007d: { // foreach(ARTrackedImage trackedImage in eventArgs.removed) ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * L_12; L_12 = Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_inline((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_get_Current_m8F54706BF35C304C986CE96C30148CF4911A9374_RuntimeMethod_var); } IL_0085: { // foreach(ARTrackedImage trackedImage in eventArgs.removed) bool L_13; L_13 = Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_MoveNext_m89255A16DAE894CEA174A88A674162B09592C8C7_RuntimeMethod_var); if (L_13) { goto IL_007d; } } IL_008e: { IL2CPP_LEAVE(0x9E, FINALLY_0090); } } // end try (depth: 1) catch(Il2CppExceptionWrapper& e) { __last_unhandled_exception = (Exception_t *)e.ex; goto FINALLY_0090; } FINALLY_0090: { // begin finally (depth: 1) Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C((Enumerator_t38DCEDBB06600CDABFF1967A5F011738638CE8F4 *)(&V_0), /*hidden argument*/Enumerator_Dispose_m037FDB6FB9E61ECDB0D7F5AB2373A57E01AE500C_RuntimeMethod_var); IL2CPP_END_FINALLY(144) } // end finally (depth: 1) IL2CPP_CLEANUP(144) { IL2CPP_RETHROW_IF_UNHANDLED(Exception_t *) IL2CPP_JUMP_TBL(0x9E, IL_009e) } IL_009e: { // } return; } } // System.Void ImageTracking::UpdateImage(UnityEngine.XR.ARFoundation.ARTrackedImage) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ImageTracking_UpdateImage_m6EA667E6284B239584418E7AA908EE43D6403BE2 (ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 * __this, ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * ___trackedImage0, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Dictionary_2_get_Item_mC4E467FB6129C74774CC33C4A8E3B1F00A73E15A_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Dictionary_2_get_Values_mCE27229BD2853EB5DD18823A44CB838915891AF5_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Enumerator_Dispose_mA7C5E1105681D1F3AEFE0B3D8F403231775794CC_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Enumerator_MoveNext_mCB1E114B7C949E2BE0521FAB1DCD32D836AA838E_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Enumerator_get_Current_mD4B9742F53CF6579D470CB4824D954C4590A53B0_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&ValueCollection_GetEnumerator_m4F21A422DA7CBC55B4596D04154835F270B15957_RuntimeMethod_var); s_Il2CppMethodInitialized = true; } String_t* V_0 = NULL; Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E V_1; memset((&V_1), 0, sizeof(V_1)); XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 V_2; memset((&V_2), 0, sizeof(V_2)); Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 V_3; memset((&V_3), 0, sizeof(V_3)); Exception_t * __last_unhandled_exception = 0; il2cpp::utils::ExceptionSupportStack<int32_t, 1> __leave_targets; { // string name = trackedImage.referenceImage.name; ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * L_0 = ___trackedImage0; NullCheck(L_0); XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 L_1; L_1 = ARTrackedImage_get_referenceImage_m6061DE2D46F8060065B64EF3860A0B0085B569E4_inline(L_0, /*hidden argument*/NULL); V_2 = L_1; String_t* L_2; L_2 = XRReferenceImage_get_name_mE8F3368C2587552333AB78EA72A02E5B73E355C7_inline((XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 *)(&V_2), /*hidden argument*/NULL); V_0 = L_2; // Vector3 position = trackedImage.transform.position; ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * L_3 = ___trackedImage0; NullCheck(L_3); Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * L_4; L_4 = Component_get_transform_mE8496EBC45BEB1BADB5F314960F1DF1C952FA11F(L_3, /*hidden argument*/NULL); NullCheck(L_4); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_5; L_5 = Transform_get_position_m40A8A9895568D56FFC687B57F30E8D53CB5EA341(L_4, /*hidden argument*/NULL); V_1 = L_5; // GameObject prefab = spawnedPrefabs[name]; Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * L_6 = __this->get_spawnedPrefabs_5(); String_t* L_7 = V_0; NullCheck(L_6); GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_8; L_8 = Dictionary_2_get_Item_mC4E467FB6129C74774CC33C4A8E3B1F00A73E15A(L_6, L_7, /*hidden argument*/Dictionary_2_get_Item_mC4E467FB6129C74774CC33C4A8E3B1F00A73E15A_RuntimeMethod_var); // prefab.transform.position = position; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_9 = L_8; NullCheck(L_9); Transform_tA8193BB29D4D2C7EC04918F3ED1816345186C3F1 * L_10; L_10 = GameObject_get_transform_m16A80BB92B6C8C5AB696E447014D45EDF1E4DE34(L_9, /*hidden argument*/NULL); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_11 = V_1; NullCheck(L_10); Transform_set_position_mB169E52D57EEAC1E3F22C5395968714E4F00AC91(L_10, L_11, /*hidden argument*/NULL); // prefab.SetActive(true); NullCheck(L_9); GameObject_SetActive_mCF1EEF2A314F3AE85DA581FF52EB06ACEF2FFF86(L_9, (bool)1, /*hidden argument*/NULL); // foreach(GameObject go in spawnedPrefabs.Values) Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * L_12 = __this->get_spawnedPrefabs_5(); NullCheck(L_12); ValueCollection_t3097E4BDF610B6DB0329348D39114BC4584B7B59 * L_13; L_13 = Dictionary_2_get_Values_mCE27229BD2853EB5DD18823A44CB838915891AF5(L_12, /*hidden argument*/Dictionary_2_get_Values_mCE27229BD2853EB5DD18823A44CB838915891AF5_RuntimeMethod_var); NullCheck(L_13); Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 L_14; L_14 = ValueCollection_GetEnumerator_m4F21A422DA7CBC55B4596D04154835F270B15957(L_13, /*hidden argument*/ValueCollection_GetEnumerator_m4F21A422DA7CBC55B4596D04154835F270B15957_RuntimeMethod_var); V_3 = L_14; } IL_004a: try { // begin try (depth: 1) { goto IL_005f; } IL_004c: { // foreach(GameObject go in spawnedPrefabs.Values) GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_15; L_15 = Enumerator_get_Current_mD4B9742F53CF6579D470CB4824D954C4590A53B0_inline((Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 *)(&V_3), /*hidden argument*/Enumerator_get_Current_mD4B9742F53CF6579D470CB4824D954C4590A53B0_RuntimeMethod_var); // if(go.name != name) { NullCheck(L_15); String_t* L_16; L_16 = Object_get_name_m0C7BC870ED2F0DC5A2FB09628136CD7D1CB82CFB(L_15, /*hidden argument*/NULL); String_t* L_17 = V_0; bool L_18; L_18 = String_op_Inequality_mDDA2DDED3E7EF042987EB7180EE3E88105F0AAE2(L_16, L_17, /*hidden argument*/NULL); } IL_005f: { // foreach(GameObject go in spawnedPrefabs.Values) bool L_19; L_19 = Enumerator_MoveNext_mCB1E114B7C949E2BE0521FAB1DCD32D836AA838E((Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 *)(&V_3), /*hidden argument*/Enumerator_MoveNext_mCB1E114B7C949E2BE0521FAB1DCD32D836AA838E_RuntimeMethod_var); if (L_19) { goto IL_004c; } } IL_0068: { IL2CPP_LEAVE(0x78, FINALLY_006a); } } // end try (depth: 1) catch(Il2CppExceptionWrapper& e) { __last_unhandled_exception = (Exception_t *)e.ex; goto FINALLY_006a; } FINALLY_006a: { // begin finally (depth: 1) Enumerator_Dispose_mA7C5E1105681D1F3AEFE0B3D8F403231775794CC((Enumerator_t9330D3C8A357E733C46B4B643654B35F1B83DC56 *)(&V_3), /*hidden argument*/Enumerator_Dispose_mA7C5E1105681D1F3AEFE0B3D8F403231775794CC_RuntimeMethod_var); IL2CPP_END_FINALLY(106) } // end finally (depth: 1) IL2CPP_CLEANUP(106) { IL2CPP_RETHROW_IF_UNHANDLED(Exception_t *) IL2CPP_JUMP_TBL(0x78, IL_0078) } IL_0078: { // } return; } } // System.Void ImageTracking::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void ImageTracking__ctor_m38B2704678FE908B59FA0336C39D8DBBA47EA1F2 (ImageTracking_t06C356D3B06EA642613D7FC66E71B6D57A5AFF80 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Dictionary_2__ctor_m627A706D7F24292D51368C749EB140EFE869376A_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C_il2cpp_TypeInfo_var); s_Il2CppMethodInitialized = true; } { // private Dictionary<string, GameObject> spawnedPrefabs = new Dictionary<string, GameObject>(); Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C * L_0 = (Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C *)il2cpp_codegen_object_new(Dictionary_2_tADDBF4C67A82C92CD16099CD166D7F72E8DCB13C_il2cpp_TypeInfo_var); Dictionary_2__ctor_m627A706D7F24292D51368C749EB140EFE869376A(L_0, /*hidden argument*/Dictionary_2__ctor_m627A706D7F24292D51368C749EB140EFE869376A_RuntimeMethod_var); __this->set_spawnedPrefabs_5(L_0); MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED(__this, /*hidden argument*/NULL); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void MakePostcard::Start() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MakePostcard_Start_m9CFAD0AA2BA96A8607EBF65D92280847B604878F (MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * __this, const RuntimeMethod* method) { { // } return; } } // System.Void MakePostcard::Update() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MakePostcard_Update_mE80927385F0C052709DC3D7DD363C42BE7E4B481 (MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * __this, const RuntimeMethod* method) { { // } return; } } // System.Void MakePostcard::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MakePostcard__ctor_mE7D49637F44B5773B79C978850FD5A31E7054741 (MakePostcard_t663BEC5BFEE2931A863F54F589A34FBDE658FCFF * __this, const RuntimeMethod* method) { { MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED(__this, /*hidden argument*/NULL); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void MenuControl::Start() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MenuControl_Start_m6EAD8C065DABD2EBBDF61DE842C9586F6D7AB8E6 (MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_FindObjectsOfType_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_mA1495EFEECA7BF44DA43D9813F575C92968F0B4F_RuntimeMethod_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&RuntimeManager_t87723E19BD688665EF5E4375DDA0AC4C1762F48A_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&SceneManager_tEC9D10ECC0377F8AE5AEEB5A789FFD24364440FA_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral5A350421A6B211C96799ECB935A49263F4151989); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral97F6A0D5A49A9E5B5967996FDDA9C89F1DB3C249); s_Il2CppMethodInitialized = true; } { // activeScene = SceneManager.GetActiveScene(); IL2CPP_RUNTIME_CLASS_INIT(SceneManager_tEC9D10ECC0377F8AE5AEEB5A789FFD24364440FA_il2cpp_TypeInfo_var); Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE L_0; L_0 = SceneManager_GetActiveScene_mB9A5037FFB576B2432D0BFEF6A161B7C4C1921A4(/*hidden argument*/NULL); __this->set_activeScene_4(L_0); // sceneName = activeScene.name; Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE * L_1 = __this->get_address_of_activeScene_4(); String_t* L_2; L_2 = Scene_get_name_m38F195D7CA6417FED310C23E4D8E86150C7835B8((Scene_t5495AD2FDC587DB2E94D9BDE2B85868BFB9A92EE *)L_1, /*hidden argument*/NULL); __this->set_sceneName_5(L_2); // masterBus = FMODUnity.RuntimeManager.GetBus("Bus:/"); IL2CPP_RUNTIME_CLASS_INIT(RuntimeManager_t87723E19BD688665EF5E4375DDA0AC4C1762F48A_il2cpp_TypeInfo_var); Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F L_3; L_3 = RuntimeManager_GetBus_mB8F90AC016A626B013743C59CCCAC9918ED79A2C(_stringLiteral5A350421A6B211C96799ECB935A49263F4151989, /*hidden argument*/NULL); __this->set_masterBus_6(L_3); // objects = (FindObjectsOfType<GameObject>() as GameObject[]); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* L_4; L_4 = Object_FindObjectsOfType_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_mA1495EFEECA7BF44DA43D9813F575C92968F0B4F(/*hidden argument*/Object_FindObjectsOfType_TisGameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319_mA1495EFEECA7BF44DA43D9813F575C92968F0B4F_RuntimeMethod_var); __this->set_objects_7(L_4); // audioInstances = GameObject.FindGameObjectsWithTag("AudioInstance"); GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* L_5; L_5 = GameObject_FindGameObjectsWithTag_m0948320611DC82590D59A36D1C57155B1B6CE186(_stringLiteral97F6A0D5A49A9E5B5967996FDDA9C89F1DB3C249, /*hidden argument*/NULL); __this->set_audioInstances_8(L_5); // } return; } } // System.Void MenuControl::Update() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MenuControl_Update_mC9F17D162B8313983320471517C35AE914F5A59D (MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778 * __this, const RuntimeMethod* method) { { // } return; } } // System.Void MenuControl::Play() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MenuControl_Play_m5EE93195576A6635BADA098D61B3224D84BA9543 (MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&SceneManager_tEC9D10ECC0377F8AE5AEEB5A789FFD24364440FA_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralAFD6B8CE125A895141C64EC9E3F8A30B4AC588B4); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralD7A59EABF0C51AF863757F81CFC978C0C90E24B3); s_Il2CppMethodInitialized = true; } int32_t V_0 = 0; { // if (sceneName == "Intro") { String_t* L_0 = __this->get_sceneName_5(); bool L_1; L_1 = String_op_Equality_m2B91EE68355F142F67095973D32EB5828B7B73CB(L_0, _stringLiteralD7A59EABF0C51AF863757F81CFC978C0C90E24B3, /*hidden argument*/NULL); if (!L_1) { goto IL_001c; } } { // SceneManager.LoadScene("ImageTracker"); IL2CPP_RUNTIME_CLASS_INIT(SceneManager_tEC9D10ECC0377F8AE5AEEB5A789FFD24364440FA_il2cpp_TypeInfo_var); SceneManager_LoadScene_m7DAF30213E99396ECBDB1BD40CC34CCF36902092(_stringLiteralAFD6B8CE125A895141C64EC9E3F8A30B4AC588B4, /*hidden argument*/NULL); } IL_001c: { // if (sceneName == "ImageTracker") { String_t* L_2 = __this->get_sceneName_5(); bool L_3; L_3 = String_op_Equality_m2B91EE68355F142F67095973D32EB5828B7B73CB(L_2, _stringLiteralAFD6B8CE125A895141C64EC9E3F8A30B4AC588B4, /*hidden argument*/NULL); if (!L_3) { goto IL_0065; } } { // for (int i = 0; i < audioInstances.Length; i++) V_0 = 0; goto IL_0043; } IL_0032: { // Destroy(audioInstances[i]); GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* L_4 = __this->get_audioInstances_8(); int32_t L_5 = V_0; NullCheck(L_4); int32_t L_6 = L_5; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_7 = (L_4)->GetAt(static_cast<il2cpp_array_size_t>(L_6)); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); Object_Destroy_m3EEDB6ECD49A541EC826EA8E1C8B599F7AF67D30(L_7, /*hidden argument*/NULL); // for (int i = 0; i < audioInstances.Length; i++) int32_t L_8 = V_0; V_0 = ((int32_t)il2cpp_codegen_add((int32_t)L_8, (int32_t)1)); } IL_0043: { // for (int i = 0; i < audioInstances.Length; i++) int32_t L_9 = V_0; GameObjectU5BU5D_tA88FC1A1FC9D4D73D0B3984D4B0ECE88F4C47642* L_10 = __this->get_audioInstances_8(); NullCheck(L_10); if ((((int32_t)L_9) < ((int32_t)((int32_t)((int32_t)(((RuntimeArray*)L_10)->max_length)))))) { goto IL_0032; } } { // masterBus.stopAllEvents(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F * L_11 = __this->get_address_of_masterBus_6(); int32_t L_12; L_12 = Bus_stopAllEvents_mCCFEB7E04F9EC684896881E001E6B457FD5AE4BB((Bus_t9C95DD5AFC1D463568500C31E5A5F883FD3CA75F *)L_11, 0, /*hidden argument*/NULL); // SceneManager.LoadScene("Intro"); IL2CPP_RUNTIME_CLASS_INIT(SceneManager_tEC9D10ECC0377F8AE5AEEB5A789FFD24364440FA_il2cpp_TypeInfo_var); SceneManager_LoadScene_m7DAF30213E99396ECBDB1BD40CC34CCF36902092(_stringLiteralD7A59EABF0C51AF863757F81CFC978C0C90E24B3, /*hidden argument*/NULL); } IL_0065: { // } return; } } // System.Void MenuControl::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void MenuControl__ctor_m41FDDED87EF02E950C6268EA0AD453CA34825398 (MenuControl_tD6B61EA950F8DF6E5A76C458AAA2E71D25654778 * __this, const RuntimeMethod* method) { { MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED(__this, /*hidden argument*/NULL); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void TrackingState::Awake() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void TrackingState_Awake_m98CCC2FA02CC5EC82578845F06D65471B47FEEBD (TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralDA39A3EE5E6B4B0D3255BFEF95601890AFD80709); s_Il2CppMethodInitialized = true; } { // if (m_Session != null) ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B * L_0 = __this->get_m_Session_4(); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); bool L_1; L_1 = Object_op_Inequality_mE1F187520BD83FB7D86A6D850710C4D42B864E90(L_0, (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A *)NULL, /*hidden argument*/NULL); if (!L_1) { goto IL_001a; } } { // m_Session.enabled = false; ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B * L_2 = __this->get_m_Session_4(); NullCheck(L_2); Behaviour_set_enabled_mDE415591B28853D1CD764C53CB499A2142247F32(L_2, (bool)0, /*hidden argument*/NULL); } IL_001a: { // if (m_Text != null) Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * L_3 = __this->get_m_Text_5(); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); bool L_4; L_4 = Object_op_Inequality_mE1F187520BD83FB7D86A6D850710C4D42B864E90(L_3, (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A *)NULL, /*hidden argument*/NULL); if (!L_4) { goto IL_0038; } } { // m_Text.text = ""; Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * L_5 = __this->get_m_Text_5(); NullCheck(L_5); VirtActionInvoker1< String_t* >::Invoke(75 /* System.Void UnityEngine.UI.Text::set_text(System.String) */, L_5, _stringLiteralDA39A3EE5E6B4B0D3255BFEF95601890AFD80709); } IL_0038: { // } return; } } // System.Collections.IEnumerator TrackingState::Start() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject* TrackingState_Start_m4EADB8957B25128D4FDC306306051850276D1038 (TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2_il2cpp_TypeInfo_var); s_Il2CppMethodInitialized = true; } { U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * L_0 = (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 *)il2cpp_codegen_object_new(U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2_il2cpp_TypeInfo_var); U3CStartU3Ed__3__ctor_m57C016DC249E940ECD9801A22FD4DE9E94442806(L_0, 0, /*hidden argument*/NULL); U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * L_1 = L_0; NullCheck(L_1); L_1->set_U3CU3E4__this_2(__this); return L_1; } } // System.Void TrackingState::Update() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void TrackingState_Update_mF0333B9EE0B1C5EB290049737CADFFF61DF2212B (TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral05F29CE2C3E06492FAFE36672D97EF781FABE332); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral23AF701FF440280F9BDD61B514BB41F48690A8DA); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral4772D75F86FF8033EF18BEB5A2555DE7B32A6367); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral509C084586320A910444D73ACF5386F77869E8FB); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral75DC5674555374787C274EE541661679A3633A2A); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteral76EEBE76F86A4AA251CB82FFE984B55CE979F8B0); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralBE26ADEBA1E2A48086FCB0B8D271B53D826E6CD1); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralC3B453E9F0C07BDDAE29F036F419A22466145753); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralD0B41CA0013533DCFC7C034949701DA4C558A039); il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&_stringLiteralDA39A3EE5E6B4B0D3255BFEF95601890AFD80709); s_Il2CppMethodInitialized = true; } String_t* V_0 = NULL; int32_t V_1 = 0; { // string text = ""; V_0 = _stringLiteralDA39A3EE5E6B4B0D3255BFEF95601890AFD80709; // if (m_Session == null) ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B * L_0 = __this->get_m_Session_4(); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); bool L_1; L_1 = Object_op_Equality_mEE9EC7EB5C7DC3E95B94AB904E1986FC4D566D54(L_0, (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A *)NULL, /*hidden argument*/NULL); if (!L_1) { goto IL_002c; } } { // text = "ARSession not found on " + this.gameObject.name; GameObject_tC000A2E1A7CF1E10FD7BA08863287C072207C319 * L_2; L_2 = Component_get_gameObject_m55DC35B149AFB9157582755383BA954655FE0C5B(__this, /*hidden argument*/NULL); NullCheck(L_2); String_t* L_3; L_3 = Object_get_name_m0C7BC870ED2F0DC5A2FB09628136CD7D1CB82CFB(L_2, /*hidden argument*/NULL); String_t* L_4; L_4 = String_Concat_m4B4AB72618348C5DFBFBA8DED84B9E2EBDB55E1B(_stringLiteralC3B453E9F0C07BDDAE29F036F419A22466145753, L_3, /*hidden argument*/NULL); V_0 = L_4; // } goto IL_0098; } IL_002c: { // switch (ARSession.state) int32_t L_5; L_5 = ARSession_get_state_m623161F1E2E5BA2752C821DD409880E6647CA130_inline(/*hidden argument*/NULL); V_1 = L_5; int32_t L_6 = V_1; switch (L_6) { case 0: { goto IL_005a; } case 1: { goto IL_0062; } case 2: { goto IL_006a; } case 3: { goto IL_0072; } case 4: { goto IL_007a; } case 5: { goto IL_0082; } case 6: { goto IL_008a; } case 7: { goto IL_0092; } } } { goto IL_0098; } IL_005a: { // text = "Sorry, AR is not currently working on this device and we're not sure why."; V_0 = _stringLiteralD0B41CA0013533DCFC7C034949701DA4C558A039; // break; goto IL_0098; } IL_0062: { // text = "Sorry, AR is not supported on this device."; V_0 = _stringLiteral509C084586320A910444D73ACF5386F77869E8FB; // break; goto IL_0098; } IL_006a: { // text = "Checking the availability of AR on this device."; V_0 = _stringLiteral76EEBE76F86A4AA251CB82FFE984B55CE979F8B0; // break; goto IL_0098; } IL_0072: { // text = "AR requires an additional install on this device."; V_0 = _stringLiteral05F29CE2C3E06492FAFE36672D97EF781FABE332; // break; goto IL_0098; } IL_007a: { // text = "AR software is being installed"; V_0 = _stringLiteralBE26ADEBA1E2A48086FCB0B8D271B53D826E6CD1; // break; goto IL_0098; } IL_0082: { // text = "AR is supported and ready"; V_0 = _stringLiteral75DC5674555374787C274EE541661679A3633A2A; // break; goto IL_0098; } IL_008a: { // text = "Please do not obscure your device's camera and ensure area is well lit."; V_0 = _stringLiteral23AF701FF440280F9BDD61B514BB41F48690A8DA; // break; goto IL_0098; } IL_0092: { // text = "Point your camera at your AR Sound Postcards to hear the exhibits."; V_0 = _stringLiteral4772D75F86FF8033EF18BEB5A2555DE7B32A6367; } IL_0098: { // if (m_Text != null) Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * L_7 = __this->get_m_Text_5(); IL2CPP_RUNTIME_CLASS_INIT(Object_tF2F3778131EFF286AF62B7B013A170F95A91571A_il2cpp_TypeInfo_var); bool L_8; L_8 = Object_op_Inequality_mE1F187520BD83FB7D86A6D850710C4D42B864E90(L_7, (Object_tF2F3778131EFF286AF62B7B013A170F95A91571A *)NULL, /*hidden argument*/NULL); if (!L_8) { goto IL_00b2; } } { // m_Text.text = text; Text_t6A2339DA6C05AE2646FC1A6C8FCC127391BE7FA1 * L_9 = __this->get_m_Text_5(); String_t* L_10 = V_0; NullCheck(L_9); VirtActionInvoker1< String_t* >::Invoke(75 /* System.Void UnityEngine.UI.Text::set_text(System.String) */, L_9, L_10); } IL_00b2: { // } return; } } // System.Void TrackingState::.ctor() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void TrackingState__ctor_m6359C53C8CF786D4DA5FC8869ED61272742ABBA3 (TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * __this, const RuntimeMethod* method) { { MonoBehaviour__ctor_mC0995D847F6A95B1A553652636C38A2AA8B13BED(__this, /*hidden argument*/NULL); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void TrackingState/<Start>d__3::.ctor(System.Int32) IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void U3CStartU3Ed__3__ctor_m57C016DC249E940ECD9801A22FD4DE9E94442806 (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * __this, int32_t ___U3CU3E1__state0, const RuntimeMethod* method) { { Object__ctor_m88880E0413421D13FD95325EDCE231707CE1F405(__this, /*hidden argument*/NULL); int32_t L_0 = ___U3CU3E1__state0; __this->set_U3CU3E1__state_0(L_0); return; } } // System.Void TrackingState/<Start>d__3::System.IDisposable.Dispose() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void U3CStartU3Ed__3_System_IDisposable_Dispose_mE70C4379945C05E5D128FB55E63ED51A2567524C (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * __this, const RuntimeMethod* method) { { return; } } // System.Boolean TrackingState/<Start>d__3::MoveNext() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR bool U3CStartU3Ed__3_MoveNext_m1F1297DB06B5FAB2E18B994305973762B671B1A8 (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * __this, const RuntimeMethod* method) { int32_t V_0 = 0; TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * V_1 = NULL; { int32_t L_0 = __this->get_U3CU3E1__state_0(); V_0 = L_0; TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * L_1 = __this->get_U3CU3E4__this_2(); V_1 = L_1; int32_t L_2 = V_0; if (!L_2) { goto IL_0017; } } { int32_t L_3 = V_0; if ((((int32_t)L_3) == ((int32_t)1))) { goto IL_0041; } } { return (bool)0; } IL_0017: { __this->set_U3CU3E1__state_0((-1)); // if ((ARSession.state == ARSessionState.None) || // (ARSession.state == ARSessionState.CheckingAvailability)) int32_t L_4; L_4 = ARSession_get_state_m623161F1E2E5BA2752C821DD409880E6647CA130_inline(/*hidden argument*/NULL); if (!L_4) { goto IL_002d; } } { int32_t L_5; L_5 = ARSession_get_state_m623161F1E2E5BA2752C821DD409880E6647CA130_inline(/*hidden argument*/NULL); if ((!(((uint32_t)L_5) == ((uint32_t)2)))) { goto IL_0048; } } IL_002d: { // yield return ARSession.CheckAvailability(); RuntimeObject* L_6; L_6 = ARSession_CheckAvailability_mCC906561CCCE269C11B69D2216C39120563F00FD(/*hidden argument*/NULL); __this->set_U3CU3E2__current_1(L_6); __this->set_U3CU3E1__state_0(1); return (bool)1; } IL_0041: { __this->set_U3CU3E1__state_0((-1)); } IL_0048: { // if (ARSession.state == ARSessionState.Unsupported) int32_t L_7; L_7 = ARSession_get_state_m623161F1E2E5BA2752C821DD409880E6647CA130_inline(/*hidden argument*/NULL); if ((((int32_t)L_7) == ((int32_t)1))) { goto IL_005c; } } { // m_Session.enabled = true; TrackingState_tAA20CD18FC0884B91A2406448CC90080E8CDEFBD * L_8 = V_1; NullCheck(L_8); ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B * L_9 = L_8->get_m_Session_4(); NullCheck(L_9); Behaviour_set_enabled_mDE415591B28853D1CD764C53CB499A2142247F32(L_9, (bool)1, /*hidden argument*/NULL); } IL_005c: { // } return (bool)0; } } // System.Object TrackingState/<Start>d__3::System.Collections.Generic.IEnumerator<System.Object>.get_Current() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject * U3CStartU3Ed__3_System_Collections_Generic_IEnumeratorU3CSystem_ObjectU3E_get_Current_m07BE4678EF086AC2F8193921AFE507AE449083F2 (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * __this, const RuntimeMethod* method) { { RuntimeObject * L_0 = __this->get_U3CU3E2__current_1(); return L_0; } } // System.Void TrackingState/<Start>d__3::System.Collections.IEnumerator.Reset() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR void U3CStartU3Ed__3_System_Collections_IEnumerator_Reset_m8E7D19A65210DCE4B77F291C0736EF58E854BC4D (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * __this, const RuntimeMethod* method) { { NotSupportedException_tB9D89F0E9470A2C423D239D7C68EE0CFD77F9339 * L_0 = (NotSupportedException_tB9D89F0E9470A2C423D239D7C68EE0CFD77F9339 *)il2cpp_codegen_object_new(((RuntimeClass*)il2cpp_codegen_initialize_runtime_metadata_inline((uintptr_t*)&NotSupportedException_tB9D89F0E9470A2C423D239D7C68EE0CFD77F9339_il2cpp_TypeInfo_var))); NotSupportedException__ctor_m3EA81A5B209A87C3ADA47443F2AFFF735E5256EE(L_0, /*hidden argument*/NULL); IL2CPP_RAISE_MANAGED_EXCEPTION(L_0, ((RuntimeMethod*)il2cpp_codegen_initialize_runtime_metadata_inline((uintptr_t*)&U3CStartU3Ed__3_System_Collections_IEnumerator_Reset_m8E7D19A65210DCE4B77F291C0736EF58E854BC4D_RuntimeMethod_var))); } } // System.Object TrackingState/<Start>d__3::System.Collections.IEnumerator.get_Current() IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR RuntimeObject * U3CStartU3Ed__3_System_Collections_IEnumerator_get_Current_mE4CDFBB4133359E847660AF05B80588F1E5B4AFF (U3CStartU3Ed__3_tF5669CDA1618D4AB9049200286394982CD0649A2 * __this, const RuntimeMethod* method) { { RuntimeObject * L_0 = __this->get_U3CU3E2__current_1(); return L_0; } } #ifdef __clang__ #pragma clang diagnostic pop #endif IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E Vector3_op_Subtraction_m2725C96965D5C0B1F9715797E51762B13A5FED58_inline (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___a0, Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E ___b1, const RuntimeMethod* method) { Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E V_0; memset((&V_0), 0, sizeof(V_0)); { Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_0 = ___a0; float L_1 = L_0.get_x_2(); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_2 = ___b1; float L_3 = L_2.get_x_2(); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_4 = ___a0; float L_5 = L_4.get_y_3(); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_6 = ___b1; float L_7 = L_6.get_y_3(); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_8 = ___a0; float L_9 = L_8.get_z_4(); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_10 = ___b1; float L_11 = L_10.get_z_4(); Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_12; memset((&L_12), 0, sizeof(L_12)); Vector3__ctor_m57495F692C6CE1CEF278CAD9A98221165D37E636_inline((&L_12), ((float)il2cpp_codegen_subtract((float)L_1, (float)L_3)), ((float)il2cpp_codegen_subtract((float)L_5, (float)L_7)), ((float)il2cpp_codegen_subtract((float)L_9, (float)L_11)), /*hidden argument*/NULL); V_0 = L_12; goto IL_0030; } IL_0030: { Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E L_13 = V_0; return L_13; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ARTrackedImagesChangedEventArgs_get_added_m0E81E3C161242C2508B90BCC73605F551AD53B4E_inline (ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C * __this, const RuntimeMethod* method) { { // public List<ARTrackedImage> added { get; private set; } List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * L_0 = __this->get_U3CaddedU3Ek__BackingField_0(); return L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ARTrackedImagesChangedEventArgs_get_updated_mBEB295B97B6C25E4DC4447383F529C9E475E4041_inline (ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C * __this, const RuntimeMethod* method) { { // public List<ARTrackedImage> updated { get; private set; } List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * L_0 = __this->get_U3CupdatedU3Ek__BackingField_1(); return L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * ARTrackedImagesChangedEventArgs_get_removed_mF4C9906743C7270B1AAD4B43E74CDB9CB5208E57_inline (ARTrackedImagesChangedEventArgs_t6EA8225CE7DB5A2148855F99D437DFA5786A1B7C * __this, const RuntimeMethod* method) { { // public List<ARTrackedImage> removed { get; private set; } List_1_t2922678FB1CE71E23AD351AE6FAEC20D68F8984F * L_0 = __this->get_U3CremovedU3Ek__BackingField_2(); return L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 ARTrackedImage_get_referenceImage_m6061DE2D46F8060065B64EF3860A0B0085B569E4_inline (ARTrackedImage_t32B829A81320BCDF3A743DCD4DC4383BA266C5B7 * __this, const RuntimeMethod* method) { { // public XRReferenceImage referenceImage { get; internal set; } XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 L_0 = __this->get_U3CreferenceImageU3Ek__BackingField_7(); return L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR String_t* XRReferenceImage_get_name_mE8F3368C2587552333AB78EA72A02E5B73E355C7_inline (XRReferenceImage_tB1803A72EB581FB35B2CA944973679132A1D4467 * __this, const RuntimeMethod* method) { { // public string name => m_Name; String_t* L_0 = __this->get_m_Name_4(); return L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR int32_t ARSession_get_state_m623161F1E2E5BA2752C821DD409880E6647CA130_inline (const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_runtime_metadata((uintptr_t*)&ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_il2cpp_TypeInfo_var); s_Il2CppMethodInitialized = true; } { // get => s_State; int32_t L_0 = ((ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_StaticFields*)il2cpp_codegen_static_fields_for(ARSession_t0ECAFEF41CF9183D33E40174F849B07943DC5D3B_il2cpp_TypeInfo_var))->get_s_State_11(); return L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR RuntimeObject * Enumerator_get_Current_m9C4EBBD2108B51885E750F927D7936290C8E20EE_gshared_inline (Enumerator_tB6009981BD4E3881E3EC83627255A24198F902D6 * __this, const RuntimeMethod* method) { { RuntimeObject * L_0 = (RuntimeObject *)__this->get_current_3(); return (RuntimeObject *)L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR RuntimeObject * Enumerator_get_Current_m5EAB60888D4E661A01C7F32AD890D785F8B6225B_gshared_inline (Enumerator_t125181DA94FAAEC346371E0582D50084E0B602E2 * __this, const RuntimeMethod* method) { { RuntimeObject * L_0 = (RuntimeObject *)__this->get_currentValue_3(); return (RuntimeObject *)L_0; } } IL2CPP_MANAGED_FORCE_INLINE IL2CPP_METHOD_ATTR void Vector3__ctor_m57495F692C6CE1CEF278CAD9A98221165D37E636_inline (Vector3_t65B972D6A585A0A5B63153CF1177A90D3C90D65E * __this, float ___x0, float ___y1, float ___z2, const RuntimeMethod* method) { { float L_0 = ___x0; __this->set_x_2(L_0); float L_1 = ___y1; __this->set_y_3(L_1); float L_2 = ___z2; __this->set_z_4(L_2); return; } }
52.210112
410
0.84664
[ "mesh", "object", "transform" ]
a670a443aabf615d93089e80b0c166bfe41c904b
5,132
cpp
C++
main.cpp
xaddee/LFA-Homework-3
adacaea54cba3bec6ad7a6b20ce4232411d2c79e
[ "MIT" ]
null
null
null
main.cpp
xaddee/LFA-Homework-3
adacaea54cba3bec6ad7a6b20ce4232411d2c79e
[ "MIT" ]
null
null
null
main.cpp
xaddee/LFA-Homework-3
adacaea54cba3bec6ad7a6b20ce4232411d2c79e
[ "MIT" ]
null
null
null
#include <fstream> #include <vector> #include <stack> #include "State.h" #include "Edge.h" bool PDA(std::string word, State start_of_edge, Edge **edges, int current_letter_index, std::stack<std::string>& stack) { if (current_letter_index == word.length() + 1 && start_of_edge.showFinal() && stack.empty()) return true; if (current_letter_index == word.length() + 1 && !start_of_edge.showFinal() && stack.empty()) return false; for (int i = 0; i < start_of_edge.showNumberOfEdges(); i++) { if(current_letter_index == word.length() && edges[start_of_edge.showIndex()][i].showLetter()[0] == '#') { if(stack.empty()) return false; stack.pop(); if(PDA(word, edges[start_of_edge.showIndex()][i].showNextState(), edges, current_letter_index + 1 , stack)) return true; } if (edges[start_of_edge.showIndex()][i].showLetter()[0] == word[current_letter_index]) { if(edges[start_of_edge.showIndex()][i].showPop() && !stack.empty()) { for(int j = 0; j < edges[start_of_edge.showIndex()][i].showTimesToPop(); j++) if(!stack.empty()) stack.pop(); } else if (edges[start_of_edge.showIndex()][i].showPop() && stack.empty()) return false; if(edges[start_of_edge.showIndex()][i].showPush()) { std::vector<LetterToPush> letters; letters = edges[start_of_edge.showIndex()][i].showLettersToPush(); for( LetterToPush current : letters) { for(int k = 0; k < current.times; k++) stack.push(current.letter); } } if (PDA(word, edges[start_of_edge.showIndex()][i].showNextState(), edges, current_letter_index + 1, stack)) return true; } } return false; } // empty word is '#' int main() { std::ifstream f("../date.txt"); unsigned int number_of_states = 0; f >> number_of_states; std::vector<State> states; states.resize(number_of_states); std::stack<std::string> stack; stack.push("s"); for(int current_state = 0; current_state < number_of_states; current_state++) { states[current_state].setIndex(current_state); bool is_final; f >> is_final; states[current_state].setFinal(is_final); } Edge **edges; edges = new Edge*[number_of_states]; for(int current_state = 0; current_state < number_of_states; current_state++) { int number_of_edges; f >> number_of_edges; states[current_state].setNumberOfEdges(number_of_edges); edges[current_state] = new Edge[number_of_edges]; } for(int current_state = 0; current_state < number_of_states; current_state++) { for(int current_edge = 0; current_edge < states[current_state].showNumberOfEdges(); current_edge++) { //Citire si setare litera std::string letter; f >> letter; edges[current_state][current_edge].setLetter(letter); edges[current_state][current_edge].setCurrentState(states[current_state]); int next_state_index; f >> next_state_index; edges[current_state][current_edge].setNextState(states[next_state_index]); bool pop,push; f >> pop; f >> push; edges[current_state][current_edge].setPop(pop); edges[current_state][current_edge].setPush(push); if(pop) { int times_to_pop = 1; f >> times_to_pop; edges[current_state][current_edge].setTimesToPop(times_to_pop); } if(push) { unsigned int how_many_letters = 0; f >> how_many_letters; edges[current_state][current_edge].setHowManyLetters(how_many_letters); std::vector<LetterToPush> letters; letters.resize(how_many_letters); for (int i = 0; i < how_many_letters; i++) { f >> letters[i].letter; f >> letters[i].times; } edges[current_state][current_edge].setPushLetters(letters); } std::cout << edges[current_state][current_edge].showCurrentState().showIndex() << " "; std::cout << edges[current_state][current_edge].showLetter() << " "; std::cout << edges[current_state][current_edge].showNextState().showIndex()<< "\n"; } } std::string word; f >> word; if (word == "#") { if (states[0].showFinal()) std::cout << "Cuvantul apartine alfabetului"; else std::cout << "Cuvantul nu apartine alfabetului"; } else { if (PDA(word, states[0], edges, 0, stack)) std::cout << " Cuvantul apartine alfabetului"; else std::cout << "Cuvantul nu apartine alfabetului"; } for(int i = 0; i < number_of_states; i++) delete[] edges[i]; delete[] edges; return 0; }
32.897436
132
0.570148
[ "vector" ]
a672d072a2eef73732bb13798cec7d6a5cdae332
57,054
cpp
C++
systray/qrc_systray.cpp
stephaneAG/Qt_tests_Mac
06eca49531521ac6a75e5f828b6fd97c8ef452c5
[ "MIT" ]
null
null
null
systray/qrc_systray.cpp
stephaneAG/Qt_tests_Mac
06eca49531521ac6a75e5f828b6fd97c8ef452c5
[ "MIT" ]
null
null
null
systray/qrc_systray.cpp
stephaneAG/Qt_tests_Mac
06eca49531521ac6a75e5f828b6fd97c8ef452c5
[ "MIT" ]
null
null
null
/**************************************************************************** ** Resource object code ** ** Created by: The Resource Compiler for Qt version 4.8.5 ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include <QtCore/qglobal.h> static const unsigned char qt_resource_data[] = { // /Users/stephaneadamgarnier/dev__Qt/systray/images/heart.svg 0x0,0x0,0xf,0x56, 0x3c, 0x3f,0x78,0x6d,0x6c,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3d,0x22,0x31,0x2e, 0x30,0x22,0x20,0x65,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x3d,0x22,0x55,0x54,0x46, 0x2d,0x38,0x22,0x20,0x73,0x74,0x61,0x6e,0x64,0x61,0x6c,0x6f,0x6e,0x65,0x3d,0x22, 0x6e,0x6f,0x22,0x3f,0x3e,0xa,0x20,0x3c,0x21,0x2d,0x2d,0x20,0x43,0x72,0x65,0x61, 0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x49,0x6e,0x6b,0x73,0x63,0x61,0x70, 0x65,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x69,0x6e, 0x6b,0x73,0x63,0x61,0x70,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x29,0x20,0x2d,0x2d,0x3e, 0x3c,0x73,0x76,0x67,0x20,0x76,0x69,0x65,0x77,0x42,0x6f,0x78,0x3d,0x22,0x31,0x30, 0x30,0x20,0x32,0x30,0x30,0x20,0x35,0x35,0x30,0x20,0x35,0x30,0x30,0x22,0x20,0x68, 0x65,0x69,0x67,0x68,0x74,0x3d,0x22,0x35,0x39,0x35,0x2e,0x32,0x37,0x35,0x35,0x39, 0x70,0x74,0x22,0x20,0x69,0x64,0x3d,0x22,0x73,0x76,0x67,0x31,0x22,0x20,0x69,0x6e, 0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3d,0x22, 0x30,0x2e,0x34,0x30,0x2b,0x63,0x76,0x73,0x22,0x20,0x73,0x6f,0x64,0x69,0x70,0x6f, 0x64,0x69,0x3a,0x64,0x6f,0x63,0x62,0x61,0x73,0x65,0x3d,0x22,0x43,0x3a,0x5c,0x44, 0x6f,0x63,0x75,0x6d,0x65,0x6e,0x74,0x73,0x20,0x61,0x6e,0x64,0x20,0x53,0x65,0x74, 0x74,0x69,0x6e,0x67,0x73,0x5c,0x4a,0x6f,0x6e,0x20,0x50,0x68,0x69,0x6c,0x6c,0x69, 0x70,0x73,0x5c,0x4d,0x79,0x20,0x44,0x6f,0x63,0x75,0x6d,0x65,0x6e,0x74,0x73,0x5c, 0x70,0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x5c,0x63,0x6c,0x69,0x70,0x61,0x72,0x74, 0x2d,0x70,0x72,0x6f,0x6a,0x65,0x63,0x74,0x5c,0x73,0x75,0x62,0x6d,0x69,0x73,0x73, 0x69,0x6f,0x6e,0x73,0x22,0x20,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x3a,0x64, 0x6f,0x63,0x6e,0x61,0x6d,0x65,0x3d,0x22,0x68,0x65,0x61,0x72,0x74,0x2d,0x6c,0x65, 0x66,0x74,0x2d,0x68,0x69,0x67,0x68,0x6c,0x69,0x67,0x68,0x74,0x2e,0x73,0x76,0x67, 0x22,0x20,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x3a,0x76,0x65,0x72,0x73,0x69, 0x6f,0x6e,0x3d,0x22,0x30,0x2e,0x33,0x32,0x22,0x20,0x77,0x69,0x64,0x74,0x68,0x3d, 0x22,0x35,0x39,0x35,0x2e,0x32,0x37,0x35,0x35,0x39,0x70,0x74,0x22,0x20,0x78,0x6d, 0x6c,0x6e,0x73,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e, 0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x32,0x30,0x30,0x30,0x2f,0x73,0x76,0x67,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x63,0x63,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a, 0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f, 0x72,0x67,0x2f,0x63,0x63,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x64,0x63, 0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x70,0x75,0x72,0x6c,0x2e,0x6f,0x72, 0x67,0x2f,0x64,0x63,0x2f,0x65,0x6c,0x65,0x6d,0x65,0x6e,0x74,0x73,0x2f,0x31,0x2e, 0x31,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x69,0x6e,0x6b,0x73,0x63,0x61, 0x70,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x69, 0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x6e,0x61,0x6d,0x65, 0x73,0x70,0x61,0x63,0x65,0x73,0x2f,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x72,0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70, 0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x31,0x39, 0x39,0x39,0x2f,0x30,0x32,0x2f,0x32,0x32,0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e, 0x74,0x61,0x78,0x2d,0x6e,0x73,0x23,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x73, 0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f, 0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x2e,0x73,0x6f,0x75,0x72,0x63,0x65,0x66, 0x6f,0x72,0x67,0x65,0x2e,0x6e,0x65,0x74,0x2f,0x44,0x54,0x44,0x2f,0x73,0x6f,0x64, 0x69,0x70,0x6f,0x64,0x69,0x2d,0x30,0x2e,0x64,0x74,0x64,0x22,0x20,0x78,0x6d,0x6c, 0x6e,0x73,0x3a,0x73,0x76,0x67,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77, 0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x32,0x30,0x30,0x30,0x2f,0x73, 0x76,0x67,0x22,0x3e,0xa,0x20,0x3c,0x6d,0x65,0x74,0x61,0x64,0x61,0x74,0x61,0x3e, 0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x52,0x44,0x46,0x20,0x78,0x6d,0x6c,0x6e,0x73, 0x3a,0x63,0x63,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e, 0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f, 0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x64,0x63,0x3d,0x22,0x68,0x74,0x74,0x70, 0x3a,0x2f,0x2f,0x70,0x75,0x72,0x6c,0x2e,0x6f,0x72,0x67,0x2f,0x64,0x63,0x2f,0x65, 0x6c,0x65,0x6d,0x65,0x6e,0x74,0x73,0x2f,0x31,0x2e,0x31,0x2f,0x22,0x20,0x78,0x6d, 0x6c,0x6e,0x73,0x3a,0x72,0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f, 0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x31,0x39,0x39,0x39,0x2f, 0x30,0x32,0x2f,0x32,0x32,0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e,0x74,0x61,0x78, 0x2d,0x6e,0x73,0x23,0x22,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x57,0x6f,0x72,0x6b, 0x20,0x72,0x64,0x66,0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x22,0x3e,0xa,0x20, 0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x48,0x65,0x61,0x72,0x74,0x20, 0x4c,0x65,0x66,0x74,0x2d,0x48,0x69,0x67,0x68,0x6c,0x69,0x67,0x68,0x74,0x3c,0x2f, 0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x64, 0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0x54,0x68,0x69,0x73,0x20, 0x69,0x73,0x20,0x61,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x76,0x61,0x6c,0x65, 0x6e,0x74,0x69,0x6e,0x65,0x73,0x20,0x64,0x61,0x79,0x20,0x68,0x65,0x61,0x72,0x74, 0x2e,0x3c,0x2f,0x64,0x63,0x3a,0x64,0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f, 0x6e,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x73,0x75,0x62,0x6a,0x65,0x63,0x74,0x3e, 0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x42,0x61,0x67,0x3e,0xa,0x20,0x3c,0x72,0x64, 0x66,0x3a,0x6c,0x69,0x3e,0x68,0x6f,0x6c,0x69,0x64,0x61,0x79,0x3c,0x2f,0x72,0x64, 0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x76, 0x61,0x6c,0x65,0x6e,0x74,0x69,0x6e,0x65,0x73,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c, 0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x3c,0x2f,0x72,0x64, 0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x76, 0x61,0x6c,0x65,0x6e,0x74,0x69,0x6e,0x65,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69, 0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x68,0x61,0x73,0x68,0x28, 0x30,0x78,0x38,0x61,0x30,0x39,0x31,0x63,0x30,0x29,0x3c,0x2f,0x72,0x64,0x66,0x3a, 0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x68,0x61,0x73, 0x68,0x28,0x30,0x78,0x38,0x61,0x30,0x39,0x31,0x36,0x63,0x29,0x3c,0x2f,0x72,0x64, 0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x73, 0x69,0x67,0x6e,0x73,0x5f,0x61,0x6e,0x64,0x5f,0x73,0x79,0x6d,0x62,0x6f,0x6c,0x73, 0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a, 0x6c,0x69,0x3e,0x68,0x61,0x73,0x68,0x28,0x30,0x78,0x38,0x61,0x30,0x39,0x31,0x66, 0x30,0x29,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64, 0x66,0x3a,0x6c,0x69,0x3e,0x64,0x61,0x79,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69, 0x3e,0xa,0x20,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x42,0x61,0x67,0x3e,0xa,0x20,0x3c, 0x2f,0x64,0x63,0x3a,0x73,0x75,0x62,0x6a,0x65,0x63,0x74,0x3e,0xa,0x20,0x3c,0x64, 0x63,0x3a,0x70,0x75,0x62,0x6c,0x69,0x73,0x68,0x65,0x72,0x3e,0xa,0x20,0x3c,0x63, 0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x20,0x72,0x64,0x66,0x3a,0x61,0x62,0x6f,0x75, 0x74,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x6f,0x70, 0x65,0x6e,0x63,0x6c,0x69,0x70,0x61,0x72,0x74,0x2e,0x6f,0x72,0x67,0x22,0x3e,0xa, 0x20,0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x4a,0x6f,0x6e,0x20,0x50, 0x68,0x69,0x6c,0x6c,0x69,0x70,0x73,0x3c,0x2f,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c, 0x65,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa, 0x20,0x3c,0x2f,0x64,0x63,0x3a,0x70,0x75,0x62,0x6c,0x69,0x73,0x68,0x65,0x72,0x3e, 0xa,0x20,0x3c,0x64,0x63,0x3a,0x63,0x72,0x65,0x61,0x74,0x6f,0x72,0x3e,0xa,0x20, 0x3c,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a, 0x74,0x69,0x74,0x6c,0x65,0x3e,0x4a,0x6f,0x6e,0x20,0x50,0x68,0x69,0x6c,0x6c,0x69, 0x70,0x73,0x3c,0x2f,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c, 0x2f,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20,0x3c,0x2f,0x64,0x63, 0x3a,0x63,0x72,0x65,0x61,0x74,0x6f,0x72,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x72, 0x69,0x67,0x68,0x74,0x73,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e, 0x74,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x4a,0x6f, 0x6e,0x20,0x50,0x68,0x69,0x6c,0x6c,0x69,0x70,0x73,0x3c,0x2f,0x64,0x63,0x3a,0x74, 0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e, 0x74,0x3e,0xa,0x20,0x3c,0x2f,0x64,0x63,0x3a,0x72,0x69,0x67,0x68,0x74,0x73,0x3e, 0xa,0x20,0x3c,0x64,0x63,0x3a,0x64,0x61,0x74,0x65,0x3e,0x3c,0x2f,0x64,0x63,0x3a, 0x64,0x61,0x74,0x65,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x66,0x6f,0x72,0x6d,0x61, 0x74,0x3e,0x69,0x6d,0x61,0x67,0x65,0x2f,0x73,0x76,0x67,0x2b,0x78,0x6d,0x6c,0x3c, 0x2f,0x64,0x63,0x3a,0x66,0x6f,0x72,0x6d,0x61,0x74,0x3e,0xa,0x20,0x3c,0x64,0x63, 0x3a,0x74,0x79,0x70,0x65,0x20,0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72, 0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x70,0x75,0x72,0x6c,0x2e, 0x6f,0x72,0x67,0x2f,0x64,0x63,0x2f,0x64,0x63,0x6d,0x69,0x74,0x79,0x70,0x65,0x2f, 0x53,0x74,0x69,0x6c,0x6c,0x49,0x6d,0x61,0x67,0x65,0x22,0x2f,0x3e,0xa,0x20,0x3c, 0x63,0x63,0x3a,0x6c,0x69,0x63,0x65,0x6e,0x73,0x65,0x20,0x72,0x64,0x66,0x3a,0x72, 0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f, 0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67, 0x2f,0x63,0x63,0x2f,0x50,0x75,0x62,0x6c,0x69,0x63,0x44,0x6f,0x6d,0x61,0x69,0x6e, 0x22,0x2f,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x6c,0x61,0x6e,0x67,0x75,0x61,0x67, 0x65,0x3e,0x65,0x6e,0x3c,0x2f,0x64,0x63,0x3a,0x6c,0x61,0x6e,0x67,0x75,0x61,0x67, 0x65,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x57,0x6f,0x72,0x6b,0x3e,0xa,0x20, 0x3c,0x63,0x63,0x3a,0x4c,0x69,0x63,0x65,0x6e,0x73,0x65,0x20,0x72,0x64,0x66,0x3a, 0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65, 0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63, 0x63,0x2f,0x50,0x75,0x62,0x6c,0x69,0x63,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x22,0x3e, 0xa,0x20,0x3c,0x63,0x63,0x3a,0x70,0x65,0x72,0x6d,0x69,0x74,0x73,0x20,0x72,0x64, 0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70, 0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e, 0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x52,0x65,0x70,0x72,0x6f,0x64,0x75,0x63,0x74, 0x69,0x6f,0x6e,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x70,0x65,0x72,0x6d, 0x69,0x74,0x73,0x20,0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65, 0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73, 0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x44,0x69,0x73, 0x74,0x72,0x69,0x62,0x75,0x74,0x69,0x6f,0x6e,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x63, 0x63,0x3a,0x70,0x65,0x72,0x6d,0x69,0x74,0x73,0x20,0x72,0x64,0x66,0x3a,0x72,0x65, 0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77, 0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f, 0x63,0x63,0x2f,0x44,0x65,0x72,0x69,0x76,0x61,0x74,0x69,0x76,0x65,0x57,0x6f,0x72, 0x6b,0x73,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x4c,0x69,0x63,0x65, 0x6e,0x73,0x65,0x3e,0xa,0x20,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x52,0x44,0x46,0x3e, 0xa,0x20,0x3c,0x2f,0x6d,0x65,0x74,0x61,0x64,0x61,0x74,0x61,0x3e,0xa,0x20,0x3c, 0x64,0x65,0x66,0x73,0x20,0x69,0x64,0x3d,0x22,0x64,0x65,0x66,0x73,0x33,0x22,0x2f, 0x3e,0xa,0x20,0x3c,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x3a,0x6e,0x61,0x6d, 0x65,0x64,0x76,0x69,0x65,0x77,0x20,0x62,0x6f,0x72,0x64,0x65,0x72,0x63,0x6f,0x6c, 0x6f,0x72,0x3d,0x22,0x23,0x36,0x36,0x36,0x36,0x36,0x36,0x22,0x20,0x62,0x6f,0x72, 0x64,0x65,0x72,0x6f,0x70,0x61,0x63,0x69,0x74,0x79,0x3d,0x22,0x31,0x2e,0x30,0x22, 0x20,0x69,0x64,0x3d,0x22,0x62,0x61,0x73,0x65,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63, 0x61,0x70,0x65,0x3a,0x63,0x75,0x72,0x72,0x65,0x6e,0x74,0x2d,0x6c,0x61,0x79,0x65, 0x72,0x3d,0x22,0x6c,0x61,0x79,0x65,0x72,0x31,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63, 0x61,0x70,0x65,0x3a,0x63,0x78,0x3d,0x22,0x35,0x34,0x39,0x2e,0x34,0x30,0x36,0x37, 0x34,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x63,0x79,0x3d,0x22, 0x35,0x39,0x36,0x2e,0x30,0x30,0x31,0x35,0x39,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63, 0x61,0x70,0x65,0x3a,0x64,0x6f,0x63,0x75,0x6d,0x65,0x6e,0x74,0x2d,0x75,0x6e,0x69, 0x74,0x73,0x3d,0x22,0x70,0x78,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65, 0x3a,0x67,0x75,0x69,0x64,0x65,0x2d,0x62,0x62,0x6f,0x78,0x3d,0x22,0x74,0x72,0x75, 0x65,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x70,0x61,0x67,0x65, 0x6f,0x70,0x61,0x63,0x69,0x74,0x79,0x3d,0x22,0x30,0x2e,0x30,0x22,0x20,0x69,0x6e, 0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x70,0x61,0x67,0x65,0x73,0x68,0x61,0x64,0x6f, 0x77,0x3d,0x22,0x32,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x77, 0x69,0x6e,0x64,0x6f,0x77,0x2d,0x68,0x65,0x69,0x67,0x68,0x74,0x3d,0x22,0x36,0x31, 0x35,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x77,0x69,0x6e,0x64, 0x6f,0x77,0x2d,0x77,0x69,0x64,0x74,0x68,0x3d,0x22,0x38,0x36,0x36,0x22,0x20,0x69, 0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x77,0x69,0x6e,0x64,0x6f,0x77,0x2d,0x78, 0x3d,0x22,0x38,0x38,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x77, 0x69,0x6e,0x64,0x6f,0x77,0x2d,0x79,0x3d,0x22,0x31,0x31,0x36,0x22,0x20,0x69,0x6e, 0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x7a,0x6f,0x6f,0x6d,0x3d,0x22,0x30,0x2e,0x33, 0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x22,0x20,0x70,0x61,0x67,0x65,0x63,0x6f,0x6c, 0x6f,0x72,0x3d,0x22,0x23,0x66,0x66,0x66,0x66,0x66,0x66,0x22,0x20,0x73,0x68,0x6f, 0x77,0x67,0x75,0x69,0x64,0x65,0x73,0x3d,0x22,0x74,0x72,0x75,0x65,0x22,0x2f,0x3e, 0xa,0x20,0x3c,0x67,0x20,0x69,0x64,0x3d,0x22,0x6c,0x61,0x79,0x65,0x72,0x31,0x22, 0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x67,0x72,0x6f,0x75,0x70,0x6d, 0x6f,0x64,0x65,0x3d,0x22,0x6c,0x61,0x79,0x65,0x72,0x22,0x20,0x69,0x6e,0x6b,0x73, 0x63,0x61,0x70,0x65,0x3a,0x6c,0x61,0x62,0x65,0x6c,0x3d,0x22,0x4c,0x61,0x79,0x65, 0x72,0x20,0x31,0x22,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22, 0x4d,0x20,0x32,0x36,0x33,0x2e,0x34,0x31,0x35,0x37,0x30,0x2c,0x32,0x33,0x35,0x2e, 0x31,0x34,0x35,0x38,0x38,0x20,0x43,0x20,0x31,0x39,0x37,0x2e,0x31,0x37,0x35,0x37, 0x30,0x2c,0x32,0x33,0x35,0x2e,0x31,0x34,0x35,0x38,0x38,0x20,0x31,0x34,0x33,0x2e, 0x34,0x31,0x35,0x37,0x35,0x2c,0x32,0x38,0x38,0x2e,0x39,0x30,0x35,0x38,0x37,0x20, 0x31,0x34,0x33,0x2e,0x34,0x31,0x35,0x37,0x35,0x2c,0x33,0x35,0x35,0x2e,0x31,0x34, 0x35,0x38,0x38,0x20,0x43,0x20,0x31,0x34,0x33,0x2e,0x34,0x31,0x35,0x37,0x35,0x2c, 0x34,0x38,0x39,0x2e,0x39,0x30,0x31,0x33,0x39,0x20,0x32,0x37,0x39,0x2e,0x33,0x34, 0x38,0x39,0x30,0x2c,0x35,0x32,0x35,0x2e,0x32,0x33,0x33,0x31,0x38,0x20,0x33,0x37, 0x31,0x2e,0x39,0x37,0x38,0x32,0x30,0x2c,0x36,0x35,0x38,0x2e,0x34,0x35,0x33,0x39, 0x32,0x20,0x43,0x20,0x34,0x35,0x39,0x2e,0x35,0x35,0x32,0x34,0x34,0x2c,0x35,0x32, 0x36,0x2e,0x30,0x35,0x30,0x35,0x36,0x20,0x36,0x30,0x30,0x2e,0x35,0x34,0x30,0x37, 0x30,0x2c,0x34,0x38,0x35,0x2e,0x35,0x39,0x39,0x33,0x32,0x20,0x36,0x30,0x30,0x2e, 0x35,0x34,0x30,0x37,0x30,0x2c,0x33,0x35,0x35,0x2e,0x31,0x34,0x35,0x38,0x38,0x20, 0x43,0x20,0x36,0x30,0x30,0x2e,0x35,0x34,0x30,0x37,0x30,0x2c,0x32,0x38,0x38,0x2e, 0x39,0x30,0x35,0x38,0x38,0x20,0x35,0x34,0x36,0x2e,0x37,0x38,0x30,0x38,0x30,0x2c, 0x32,0x33,0x35,0x2e,0x31,0x34,0x35,0x38,0x37,0x20,0x34,0x38,0x30,0x2e,0x35,0x34, 0x30,0x37,0x30,0x2c,0x32,0x33,0x35,0x2e,0x31,0x34,0x35,0x38,0x38,0x20,0x43,0x20, 0x34,0x33,0x32,0x2e,0x34,0x39,0x32,0x38,0x30,0x2c,0x32,0x33,0x35,0x2e,0x31,0x34, 0x35,0x38,0x38,0x20,0x33,0x39,0x31,0x2e,0x31,0x33,0x39,0x31,0x30,0x2c,0x32,0x36, 0x33,0x2e,0x35,0x31,0x36,0x33,0x31,0x20,0x33,0x37,0x31,0x2e,0x39,0x37,0x38,0x32, 0x30,0x2c,0x33,0x30,0x34,0x2e,0x33,0x33,0x33,0x33,0x38,0x20,0x43,0x20,0x33,0x35, 0x32,0x2e,0x38,0x31,0x37,0x34,0x30,0x2c,0x32,0x36,0x33,0x2e,0x35,0x31,0x36,0x33, 0x30,0x20,0x33,0x31,0x31,0x2e,0x34,0x36,0x33,0x37,0x30,0x2c,0x32,0x33,0x35,0x2e, 0x31,0x34,0x35,0x38,0x37,0x20,0x32,0x36,0x33,0x2e,0x34,0x31,0x35,0x37,0x30,0x2c, 0x32,0x33,0x35,0x2e,0x31,0x34,0x35,0x38,0x38,0x20,0x7a,0x20,0x22,0x20,0x69,0x64, 0x3d,0x22,0x70,0x61,0x74,0x68,0x37,0x22,0x20,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64, 0x69,0x3a,0x6e,0x6f,0x64,0x65,0x74,0x79,0x70,0x65,0x73,0x3d,0x22,0x63,0x63,0x63, 0x63,0x63,0x63,0x63,0x22,0x20,0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x66,0x69,0x6c, 0x6c,0x3a,0x23,0x65,0x36,0x30,0x30,0x30,0x30,0x3b,0x66,0x69,0x6c,0x6c,0x2d,0x6f, 0x70,0x61,0x63,0x69,0x74,0x79,0x3a,0x31,0x2e,0x30,0x30,0x30,0x30,0x30,0x30,0x30, 0x3b,0x73,0x74,0x72,0x6f,0x6b,0x65,0x3a,0x23,0x30,0x30,0x30,0x30,0x30,0x30,0x3b, 0x73,0x74,0x72,0x6f,0x6b,0x65,0x2d,0x77,0x69,0x64,0x74,0x68,0x3a,0x31,0x38,0x2e, 0x37,0x30,0x30,0x30,0x30,0x31,0x3b,0x73,0x74,0x72,0x6f,0x6b,0x65,0x2d,0x6d,0x69, 0x74,0x65,0x72,0x6c,0x69,0x6d,0x69,0x74,0x3a,0x34,0x2e,0x30,0x30,0x30,0x30,0x30, 0x30,0x30,0x3b,0x73,0x74,0x72,0x6f,0x6b,0x65,0x2d,0x6f,0x70,0x61,0x63,0x69,0x74, 0x79,0x3a,0x31,0x2e,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x22,0x2f,0x3e,0xa,0x20, 0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d,0x20,0x32,0x36,0x35,0x2e,0x30, 0x30,0x30,0x30,0x30,0x2c,0x32,0x35,0x33,0x2e,0x35,0x39,0x33,0x37,0x35,0x20,0x43, 0x20,0x32,0x30,0x37,0x2e,0x30,0x34,0x30,0x33,0x33,0x2c,0x32,0x35,0x33,0x2e,0x35, 0x39,0x33,0x37,0x35,0x20,0x31,0x36,0x30,0x2e,0x30,0x30,0x30,0x30,0x30,0x2c,0x33, 0x30,0x30,0x2e,0x36,0x33,0x34,0x30,0x37,0x20,0x31,0x36,0x30,0x2e,0x30,0x30,0x30, 0x30,0x30,0x2c,0x33,0x35,0x38,0x2e,0x35,0x39,0x33,0x37,0x35,0x20,0x43,0x20,0x31, 0x36,0x30,0x2e,0x30,0x30,0x30,0x30,0x30,0x2c,0x34,0x37,0x36,0x2e,0x35,0x30,0x34, 0x31,0x35,0x20,0x32,0x37,0x38,0x2e,0x39,0x31,0x38,0x35,0x37,0x2c,0x35,0x30,0x37, 0x2e,0x34,0x33,0x32,0x35,0x31,0x20,0x33,0x35,0x39,0x2e,0x39,0x36,0x38,0x37,0x35, 0x2c,0x36,0x32,0x34,0x2e,0x30,0x30,0x30,0x30,0x30,0x20,0x43,0x20,0x33,0x36,0x36, 0x2e,0x35,0x32,0x38,0x36,0x38,0x2c,0x36,0x31,0x34,0x2e,0x30,0x38,0x32,0x30,0x35, 0x20,0x32,0x32,0x30,0x2e,0x30,0x30,0x30,0x30,0x30,0x2c,0x34,0x37,0x38,0x2e,0x34, 0x37,0x33,0x30,0x39,0x20,0x32,0x32,0x30,0x2e,0x30,0x30,0x30,0x30,0x30,0x2c,0x33, 0x37,0x38,0x2e,0x35,0x39,0x33,0x37,0x35,0x20,0x43,0x20,0x32,0x32,0x30,0x2e,0x30, 0x30,0x30,0x30,0x30,0x2c,0x33,0x32,0x30,0x2e,0x36,0x33,0x34,0x30,0x37,0x20,0x32, 0x36,0x37,0x2e,0x30,0x34,0x30,0x33,0x33,0x2c,0x32,0x37,0x33,0x2e,0x35,0x39,0x33, 0x37,0x35,0x20,0x33,0x32,0x35,0x2e,0x30,0x30,0x30,0x30,0x30,0x2c,0x32,0x37,0x33, 0x2e,0x35,0x39,0x33,0x37,0x35,0x20,0x43,0x20,0x33,0x32,0x35,0x2e,0x35,0x30,0x34, 0x35,0x33,0x2c,0x32,0x37,0x33,0x2e,0x35,0x39,0x33,0x37,0x35,0x20,0x33,0x32,0x35, 0x2e,0x39,0x39,0x37,0x31,0x38,0x2c,0x32,0x37,0x33,0x2e,0x36,0x34,0x39,0x31,0x32, 0x20,0x33,0x32,0x36,0x2e,0x35,0x30,0x30,0x30,0x30,0x2c,0x32,0x37,0x33,0x2e,0x36, 0x35,0x36,0x32,0x35,0x20,0x43,0x20,0x33,0x30,0x39,0x2e,0x32,0x32,0x34,0x33,0x36, 0x2c,0x32,0x36,0x31,0x2e,0x30,0x37,0x32,0x38,0x36,0x20,0x32,0x38,0x38,0x2e,0x30, 0x30,0x35,0x35,0x37,0x2c,0x32,0x35,0x33,0x2e,0x35,0x39,0x33,0x37,0x34,0x20,0x32, 0x36,0x35,0x2e,0x30,0x30,0x30,0x30,0x30,0x2c,0x32,0x35,0x33,0x2e,0x35,0x39,0x33, 0x37,0x35,0x20,0x7a,0x20,0x22,0x20,0x69,0x64,0x3d,0x22,0x70,0x61,0x74,0x68,0x32, 0x32,0x30,0x22,0x20,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x3a,0x6e,0x6f,0x64, 0x65,0x74,0x79,0x70,0x65,0x73,0x3d,0x22,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x22, 0x20,0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x66,0x69,0x6c,0x6c,0x3a,0x23,0x65,0x36, 0x65,0x36,0x65,0x36,0x3b,0x66,0x69,0x6c,0x6c,0x2d,0x6f,0x70,0x61,0x63,0x69,0x74, 0x79,0x3a,0x30,0x2e,0x36,0x34,0x35,0x35,0x36,0x39,0x36,0x32,0x3b,0x73,0x74,0x72, 0x6f,0x6b,0x65,0x3a,0x6e,0x6f,0x6e,0x65,0x3b,0x73,0x74,0x72,0x6f,0x6b,0x65,0x2d, 0x77,0x69,0x64,0x74,0x68,0x3a,0x31,0x38,0x2e,0x37,0x30,0x30,0x30,0x30,0x31,0x3b, 0x73,0x74,0x72,0x6f,0x6b,0x65,0x2d,0x6d,0x69,0x74,0x65,0x72,0x6c,0x69,0x6d,0x69, 0x74,0x3a,0x34,0x2e,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3b,0x73,0x74,0x72,0x6f, 0x6b,0x65,0x2d,0x6f,0x70,0x61,0x63,0x69,0x74,0x79,0x3a,0x31,0x2e,0x30,0x30,0x30, 0x30,0x30,0x30,0x30,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x2f,0x67,0x3e,0xa,0x20,0x3c, 0x2f,0x73,0x76,0x67,0x3e, // /Users/stephaneadamgarnier/dev__Qt/systray/images/bad.svg 0x0,0x0,0xd,0x6c, 0x3c, 0x3f,0x78,0x6d,0x6c,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3d,0x22,0x31,0x2e, 0x30,0x22,0x20,0x65,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x3d,0x22,0x55,0x54,0x46, 0x2d,0x38,0x22,0x20,0x73,0x74,0x61,0x6e,0x64,0x61,0x6c,0x6f,0x6e,0x65,0x3d,0x22, 0x6e,0x6f,0x22,0x3f,0x3e,0xa,0x20,0x3c,0x21,0x44,0x4f,0x43,0x54,0x59,0x50,0x45, 0x20,0x73,0x76,0x67,0x20,0x50,0x55,0x42,0x4c,0x49,0x43,0x20,0x22,0x2d,0x2f,0x2f, 0x57,0x33,0x43,0x2f,0x2f,0x44,0x54,0x44,0x20,0x53,0x56,0x47,0x20,0x32,0x30,0x30, 0x31,0x30,0x39,0x30,0x34,0x2f,0x2f,0x45,0x4e,0x22,0xa,0x20,0x22,0x68,0x74,0x74, 0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x54, 0x52,0x2f,0x32,0x30,0x30,0x31,0x2f,0x52,0x45,0x43,0x2d,0x53,0x56,0x47,0x2d,0x32, 0x30,0x30,0x31,0x30,0x39,0x30,0x34,0x2f,0x44,0x54,0x44,0x2f,0x73,0x76,0x67,0x31, 0x30,0x2e,0x64,0x74,0x64,0x22,0x3e,0xa,0x20,0x3c,0x73,0x76,0x67,0x20,0x76,0x69, 0x65,0x77,0x42,0x6f,0x78,0x3d,0x22,0x2d,0x31,0x30,0x20,0x2d,0x31,0x30,0x20,0x31, 0x37,0x38,0x20,0x31,0x37,0x38,0x22,0x20,0x68,0x65,0x69,0x67,0x68,0x74,0x3d,0x22, 0x31,0x37,0x37,0x2e,0x35,0x32,0x33,0x22,0x20,0x69,0x64,0x3d,0x22,0x73,0x76,0x67, 0x31,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x76,0x65,0x72,0x73, 0x69,0x6f,0x6e,0x3d,0x22,0x30,0x2e,0x34,0x30,0x22,0x20,0x73,0x6f,0x64,0x69,0x70, 0x6f,0x64,0x69,0x3a,0x64,0x6f,0x63,0x62,0x61,0x73,0x65,0x3d,0x22,0x2f,0x6d,0x6e, 0x74,0x2f,0x64,0x6f,0x6e,0x6e,0x65,0x65,0x73,0x2f,0x30,0x39,0x2d,0x4d,0x65,0x73, 0x5f,0x69,0x6d,0x61,0x67,0x65,0x73,0x2f,0x54,0x72,0x61,0x76,0x61,0x75,0x78,0x2f, 0x54,0x72,0x61,0x76,0x61,0x75,0x78,0x20,0x76,0x65,0x63,0x74,0x6f,0x72,0x69,0x65, 0x6c,0x2f,0x70,0x69,0x63,0x74,0x6f,0x67,0x72,0x61,0x6d,0x6d,0x65,0x73,0x2f,0x73, 0x8e,0x63,0x75,0x20,0x53,0x56,0x47,0x2f,0x70,0x72,0x6f,0x64,0x75,0x69,0x74,0x73, 0x20,0x63,0x68,0x69,0x6d,0x69,0x71,0x75,0x65,0x73,0x22,0x20,0x73,0x6f,0x64,0x69, 0x70,0x6f,0x64,0x69,0x3a,0x64,0x6f,0x63,0x6e,0x61,0x6d,0x65,0x3d,0x22,0x58,0x69, 0x49,0x72,0x72,0x69,0x74,0x61,0x6e,0x74,0x2e,0x73,0x76,0x67,0x22,0x20,0x73,0x6f, 0x64,0x69,0x70,0x6f,0x64,0x69,0x3a,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3d,0x22, 0x30,0x2e,0x33,0x32,0x22,0x20,0x77,0x69,0x64,0x74,0x68,0x3d,0x22,0x31,0x35,0x35, 0x2e,0x39,0x33,0x32,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3d,0x22,0x68,0x74,0x74, 0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x32, 0x30,0x30,0x30,0x2f,0x73,0x76,0x67,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x63, 0x63,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65, 0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x22,0x20, 0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x64,0x63,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f, 0x2f,0x70,0x75,0x72,0x6c,0x2e,0x6f,0x72,0x67,0x2f,0x64,0x63,0x2f,0x65,0x6c,0x65, 0x6d,0x65,0x6e,0x74,0x73,0x2f,0x31,0x2e,0x31,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e, 0x73,0x3a,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3d,0x22,0x68,0x74,0x74,0x70, 0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x2e, 0x6f,0x72,0x67,0x2f,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x73,0x2f,0x69, 0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x72, 0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77, 0x33,0x2e,0x6f,0x72,0x67,0x2f,0x31,0x39,0x39,0x39,0x2f,0x30,0x32,0x2f,0x32,0x32, 0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e,0x74,0x61,0x78,0x2d,0x6e,0x73,0x23,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x3d, 0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69, 0x2e,0x73,0x6f,0x75,0x72,0x63,0x65,0x66,0x6f,0x72,0x67,0x65,0x2e,0x6e,0x65,0x74, 0x2f,0x44,0x54,0x44,0x2f,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x2d,0x30,0x2e, 0x64,0x74,0x64,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x78,0x6c,0x69,0x6e,0x6b, 0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e, 0x6f,0x72,0x67,0x2f,0x31,0x39,0x39,0x39,0x2f,0x78,0x6c,0x69,0x6e,0x6b,0x22,0x3e, 0xa,0x20,0x3c,0x6d,0x65,0x74,0x61,0x64,0x61,0x74,0x61,0x3e,0xa,0x20,0x3c,0x72, 0x64,0x66,0x3a,0x52,0x44,0x46,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x63,0x63,0x3d, 0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f, 0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x22,0x20,0x78,0x6d, 0x6c,0x6e,0x73,0x3a,0x64,0x63,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x70, 0x75,0x72,0x6c,0x2e,0x6f,0x72,0x67,0x2f,0x64,0x63,0x2f,0x65,0x6c,0x65,0x6d,0x65, 0x6e,0x74,0x73,0x2f,0x31,0x2e,0x31,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a, 0x72,0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e, 0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x31,0x39,0x39,0x39,0x2f,0x30,0x32,0x2f,0x32, 0x32,0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e,0x74,0x61,0x78,0x2d,0x6e,0x73,0x23, 0x22,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x57,0x6f,0x72,0x6b,0x20,0x72,0x64,0x66, 0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x22,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a, 0x74,0x69,0x74,0x6c,0x65,0x3e,0x49,0x72,0x72,0x69,0x74,0x61,0x6e,0x74,0x3c,0x2f, 0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x64, 0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0x70,0x72,0x6f,0x64,0x75, 0x69,0x74,0x20,0x63,0x68,0x69,0x6d,0x69,0x71,0x75,0x65,0x3c,0x2f,0x64,0x63,0x3a, 0x64,0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0xa,0x20,0x3c,0x64, 0x63,0x3a,0x73,0x75,0x62,0x6a,0x65,0x63,0x74,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66, 0x3a,0x42,0x61,0x67,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x3c, 0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c, 0x69,0x3e,0x73,0x79,0x6d,0x62,0x6f,0x6c,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69, 0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x73,0x69,0x67,0x6e,0x73, 0x5f,0x61,0x6e,0x64,0x5f,0x73,0x79,0x6d,0x62,0x6f,0x6c,0x73,0x3c,0x2f,0x72,0x64, 0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x42,0x61,0x67, 0x3e,0xa,0x20,0x3c,0x2f,0x64,0x63,0x3a,0x73,0x75,0x62,0x6a,0x65,0x63,0x74,0x3e, 0xa,0x20,0x3c,0x64,0x63,0x3a,0x70,0x75,0x62,0x6c,0x69,0x73,0x68,0x65,0x72,0x3e, 0xa,0x20,0x3c,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x20,0x72,0x64,0x66,0x3a, 0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77, 0x77,0x2e,0x6f,0x70,0x65,0x6e,0x63,0x6c,0x69,0x70,0x61,0x72,0x74,0x2e,0x6f,0x72, 0x67,0x22,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x79, 0x76,0x65,0x73,0x20,0x47,0x55,0x49,0x4c,0x4c,0x4f,0x55,0x3c,0x2f,0x64,0x63,0x3a, 0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x41,0x67,0x65, 0x6e,0x74,0x3e,0xa,0x20,0x3c,0x2f,0x64,0x63,0x3a,0x70,0x75,0x62,0x6c,0x69,0x73, 0x68,0x65,0x72,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x63,0x72,0x65,0x61,0x74,0x6f, 0x72,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20, 0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x79,0x76,0x65,0x73,0x20,0x47, 0x55,0x49,0x4c,0x4c,0x4f,0x55,0x3c,0x2f,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65, 0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20, 0x3c,0x2f,0x64,0x63,0x3a,0x63,0x72,0x65,0x61,0x74,0x6f,0x72,0x3e,0xa,0x20,0x3c, 0x64,0x63,0x3a,0x72,0x69,0x67,0x68,0x74,0x73,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a, 0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c, 0x65,0x3e,0x79,0x76,0x65,0x73,0x20,0x47,0x55,0x49,0x4c,0x4c,0x4f,0x55,0x3c,0x2f, 0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a, 0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20,0x3c,0x2f,0x64,0x63,0x3a,0x72,0x69,0x67, 0x68,0x74,0x73,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x64,0x61,0x74,0x65,0x3e,0x3c, 0x2f,0x64,0x63,0x3a,0x64,0x61,0x74,0x65,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x66, 0x6f,0x72,0x6d,0x61,0x74,0x3e,0x69,0x6d,0x61,0x67,0x65,0x2f,0x73,0x76,0x67,0x2b, 0x78,0x6d,0x6c,0x3c,0x2f,0x64,0x63,0x3a,0x66,0x6f,0x72,0x6d,0x61,0x74,0x3e,0xa, 0x20,0x3c,0x64,0x63,0x3a,0x74,0x79,0x70,0x65,0x20,0x72,0x64,0x66,0x3a,0x72,0x65, 0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x70, 0x75,0x72,0x6c,0x2e,0x6f,0x72,0x67,0x2f,0x64,0x63,0x2f,0x64,0x63,0x6d,0x69,0x74, 0x79,0x70,0x65,0x2f,0x53,0x74,0x69,0x6c,0x6c,0x49,0x6d,0x61,0x67,0x65,0x22,0x2f, 0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x6c,0x69,0x63,0x65,0x6e,0x73,0x65,0x20,0x72, 0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74, 0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65, 0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x50,0x75,0x62,0x6c,0x69,0x63,0x44,0x6f, 0x6d,0x61,0x69,0x6e,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x6c,0x61,0x6e, 0x67,0x75,0x61,0x67,0x65,0x3e,0x65,0x6e,0x3c,0x2f,0x64,0x63,0x3a,0x6c,0x61,0x6e, 0x67,0x75,0x61,0x67,0x65,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x57,0x6f,0x72, 0x6b,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x4c,0x69,0x63,0x65,0x6e,0x73,0x65,0x20, 0x72,0x64,0x66,0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a, 0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f, 0x72,0x67,0x2f,0x63,0x63,0x2f,0x50,0x75,0x62,0x6c,0x69,0x63,0x44,0x6f,0x6d,0x61, 0x69,0x6e,0x22,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x70,0x65,0x72,0x6d,0x69,0x74, 0x73,0x20,0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22, 0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75, 0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x52,0x65,0x70,0x72,0x6f, 0x64,0x75,0x63,0x74,0x69,0x6f,0x6e,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a, 0x70,0x65,0x72,0x6d,0x69,0x74,0x73,0x20,0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f, 0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62, 0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63, 0x2f,0x44,0x69,0x73,0x74,0x72,0x69,0x62,0x75,0x74,0x69,0x6f,0x6e,0x22,0x2f,0x3e, 0xa,0x20,0x3c,0x63,0x63,0x3a,0x70,0x65,0x72,0x6d,0x69,0x74,0x73,0x20,0x72,0x64, 0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70, 0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e, 0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x44,0x65,0x72,0x69,0x76,0x61,0x74,0x69,0x76, 0x65,0x57,0x6f,0x72,0x6b,0x73,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a, 0x4c,0x69,0x63,0x65,0x6e,0x73,0x65,0x3e,0xa,0x20,0x3c,0x2f,0x72,0x64,0x66,0x3a, 0x52,0x44,0x46,0x3e,0xa,0x20,0x3c,0x2f,0x6d,0x65,0x74,0x61,0x64,0x61,0x74,0x61, 0x3e,0xa,0x20,0x3c,0x73,0x6f,0x64,0x69,0x70,0x6f,0x64,0x69,0x3a,0x6e,0x61,0x6d, 0x65,0x64,0x76,0x69,0x65,0x77,0x20,0x62,0x6f,0x72,0x64,0x65,0x72,0x63,0x6f,0x6c, 0x6f,0x72,0x3d,0x22,0x23,0x36,0x36,0x36,0x36,0x36,0x36,0x22,0x20,0x62,0x6f,0x72, 0x64,0x65,0x72,0x6f,0x70,0x61,0x63,0x69,0x74,0x79,0x3d,0x22,0x31,0x2e,0x30,0x22, 0x20,0x69,0x64,0x3d,0x22,0x62,0x61,0x73,0x65,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63, 0x61,0x70,0x65,0x3a,0x63,0x75,0x72,0x72,0x65,0x6e,0x74,0x2d,0x6c,0x61,0x79,0x65, 0x72,0x3d,0x22,0x73,0x76,0x67,0x31,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70, 0x65,0x3a,0x63,0x78,0x3d,0x22,0x36,0x32,0x2e,0x33,0x37,0x32,0x38,0x30,0x35,0x22, 0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x63,0x79,0x3d,0x22,0x33,0x34, 0x2e,0x38,0x36,0x34,0x35,0x33,0x37,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70, 0x65,0x3a,0x70,0x61,0x67,0x65,0x6f,0x70,0x61,0x63,0x69,0x74,0x79,0x3d,0x22,0x30, 0x2e,0x30,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x70,0x61,0x67, 0x65,0x73,0x68,0x61,0x64,0x6f,0x77,0x3d,0x22,0x32,0x22,0x20,0x69,0x6e,0x6b,0x73, 0x63,0x61,0x70,0x65,0x3a,0x77,0x69,0x6e,0x64,0x6f,0x77,0x2d,0x68,0x65,0x69,0x67, 0x68,0x74,0x3d,0x22,0x31,0x31,0x32,0x31,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61, 0x70,0x65,0x3a,0x77,0x69,0x6e,0x64,0x6f,0x77,0x2d,0x77,0x69,0x64,0x74,0x68,0x3d, 0x22,0x31,0x35,0x39,0x30,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a, 0x77,0x69,0x6e,0x64,0x6f,0x77,0x2d,0x78,0x3d,0x22,0x32,0x30,0x30,0x22,0x20,0x69, 0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x77,0x69,0x6e,0x64,0x6f,0x77,0x2d,0x79, 0x3d,0x22,0x30,0x22,0x20,0x69,0x6e,0x6b,0x73,0x63,0x61,0x70,0x65,0x3a,0x7a,0x6f, 0x6f,0x6d,0x3d,0x22,0x36,0x2e,0x36,0x33,0x39,0x39,0x38,0x34,0x39,0x22,0x20,0x70, 0x61,0x67,0x65,0x63,0x6f,0x6c,0x6f,0x72,0x3d,0x22,0x23,0x66,0x66,0x66,0x66,0x66, 0x66,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x64,0x65,0x66,0x73,0x20,0x69,0x64,0x3d,0x22, 0x64,0x65,0x66,0x73,0x32,0x22,0x3e,0xa,0x20,0x3c,0x6d,0x61,0x72,0x6b,0x65,0x72, 0x20,0x69,0x64,0x3d,0x22,0x41,0x72,0x72,0x6f,0x77,0x45,0x6e,0x64,0x22,0x20,0x6d, 0x61,0x72,0x6b,0x65,0x72,0x48,0x65,0x69,0x67,0x68,0x74,0x3d,0x22,0x33,0x22,0x20, 0x6d,0x61,0x72,0x6b,0x65,0x72,0x55,0x6e,0x69,0x74,0x73,0x3d,0x22,0x73,0x74,0x72, 0x6f,0x6b,0x65,0x57,0x69,0x64,0x74,0x68,0x22,0x20,0x6d,0x61,0x72,0x6b,0x65,0x72, 0x57,0x69,0x64,0x74,0x68,0x3d,0x22,0x34,0x22,0x20,0x6f,0x72,0x69,0x65,0x6e,0x74, 0x3d,0x22,0x61,0x75,0x74,0x6f,0x22,0x20,0x72,0x65,0x66,0x58,0x3d,0x22,0x30,0x22, 0x20,0x72,0x65,0x66,0x59,0x3d,0x22,0x35,0x22,0x20,0x76,0x69,0x65,0x77,0x42,0x6f, 0x78,0x3d,0x22,0x30,0x20,0x30,0x20,0x31,0x30,0x20,0x31,0x30,0x22,0x3e,0xa,0x20, 0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d,0x20,0x30,0x20,0x30,0x20,0x4c, 0x20,0x31,0x30,0x20,0x35,0x20,0x4c,0x20,0x30,0x20,0x31,0x30,0x20,0x7a,0x22,0x20, 0x69,0x64,0x3d,0x22,0x70,0x61,0x74,0x68,0x34,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x2f, 0x6d,0x61,0x72,0x6b,0x65,0x72,0x3e,0xa,0x20,0x3c,0x6d,0x61,0x72,0x6b,0x65,0x72, 0x20,0x69,0x64,0x3d,0x22,0x41,0x72,0x72,0x6f,0x77,0x53,0x74,0x61,0x72,0x74,0x22, 0x20,0x6d,0x61,0x72,0x6b,0x65,0x72,0x48,0x65,0x69,0x67,0x68,0x74,0x3d,0x22,0x33, 0x22,0x20,0x6d,0x61,0x72,0x6b,0x65,0x72,0x55,0x6e,0x69,0x74,0x73,0x3d,0x22,0x73, 0x74,0x72,0x6f,0x6b,0x65,0x57,0x69,0x64,0x74,0x68,0x22,0x20,0x6d,0x61,0x72,0x6b, 0x65,0x72,0x57,0x69,0x64,0x74,0x68,0x3d,0x22,0x34,0x22,0x20,0x6f,0x72,0x69,0x65, 0x6e,0x74,0x3d,0x22,0x61,0x75,0x74,0x6f,0x22,0x20,0x72,0x65,0x66,0x58,0x3d,0x22, 0x31,0x30,0x22,0x20,0x72,0x65,0x66,0x59,0x3d,0x22,0x35,0x22,0x20,0x76,0x69,0x65, 0x77,0x42,0x6f,0x78,0x3d,0x22,0x30,0x20,0x30,0x20,0x31,0x30,0x20,0x31,0x30,0x22, 0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d,0x20,0x31,0x30, 0x20,0x30,0x20,0x4c,0x20,0x30,0x20,0x35,0x20,0x4c,0x20,0x31,0x30,0x20,0x31,0x30, 0x20,0x7a,0x22,0x20,0x69,0x64,0x3d,0x22,0x70,0x61,0x74,0x68,0x36,0x22,0x2f,0x3e, 0xa,0x20,0x3c,0x2f,0x6d,0x61,0x72,0x6b,0x65,0x72,0x3e,0xa,0x20,0x3c,0x2f,0x64, 0x65,0x66,0x73,0x3e,0xa,0x20,0x3c,0x67,0x20,0x69,0x64,0x3d,0x22,0x67,0x37,0x22, 0x3e,0xa,0x20,0x3c,0x67,0x20,0x69,0x64,0x3d,0x22,0x67,0x38,0x22,0x3e,0xa,0x20, 0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d,0x20,0x31,0x35,0x35,0x2e,0x39, 0x33,0x32,0x20,0x31,0x35,0x35,0x2e,0x39,0x33,0x32,0x4c,0x20,0x31,0x35,0x35,0x2e, 0x39,0x33,0x32,0x20,0x30,0x4c,0x20,0x30,0x20,0x30,0x4c,0x20,0x30,0x20,0x31,0x35, 0x35,0x2e,0x39,0x33,0x32,0x4c,0x20,0x31,0x35,0x35,0x2e,0x39,0x33,0x32,0x20,0x31, 0x35,0x35,0x2e,0x39,0x33,0x32,0x7a,0x22,0x20,0x69,0x64,0x3d,0x22,0x70,0x61,0x74, 0x68,0x39,0x22,0x20,0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x73,0x74,0x72,0x6f,0x6b, 0x65,0x3a,0x6e,0x6f,0x6e,0x65,0x3b,0x20,0x66,0x69,0x6c,0x6c,0x3a,0x23,0x30,0x30, 0x30,0x30,0x30,0x30,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68,0x20,0x64, 0x3d,0x22,0x4d,0x20,0x31,0x35,0x30,0x2e,0x38,0x33,0x20,0x31,0x35,0x30,0x2e,0x38, 0x33,0x4c,0x20,0x31,0x35,0x30,0x2e,0x38,0x33,0x20,0x35,0x2e,0x31,0x30,0x31,0x31, 0x4c,0x20,0x35,0x2e,0x31,0x30,0x31,0x31,0x20,0x35,0x2e,0x31,0x30,0x31,0x31,0x4c, 0x20,0x35,0x2e,0x31,0x30,0x31,0x31,0x20,0x31,0x35,0x30,0x2e,0x38,0x33,0x4c,0x20, 0x31,0x35,0x30,0x2e,0x38,0x33,0x20,0x31,0x35,0x30,0x2e,0x38,0x33,0x7a,0x22,0x20, 0x69,0x64,0x3d,0x22,0x70,0x61,0x74,0x68,0x31,0x30,0x22,0x20,0x73,0x74,0x79,0x6c, 0x65,0x3d,0x22,0x73,0x74,0x72,0x6f,0x6b,0x65,0x3a,0x6e,0x6f,0x6e,0x65,0x3b,0x20, 0x66,0x69,0x6c,0x6c,0x3a,0x23,0x66,0x66,0x39,0x39,0x30,0x30,0x22,0x2f,0x3e,0xa, 0x20,0x3c,0x2f,0x67,0x3e,0xa,0x20,0x3c,0x67,0x20,0x69,0x64,0x3d,0x22,0x67,0x31, 0x31,0x22,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d,0x20, 0x31,0x34,0x30,0x2e,0x38,0x32,0x33,0x20,0x31,0x31,0x31,0x2e,0x37,0x38,0x33,0x4c, 0x20,0x34,0x34,0x2e,0x33,0x36,0x37,0x37,0x20,0x31,0x34,0x2e,0x30,0x37,0x37,0x31, 0x4c,0x20,0x31,0x35,0x2e,0x31,0x30,0x38,0x34,0x20,0x34,0x34,0x2e,0x31,0x34,0x38, 0x39,0x4c,0x20,0x31,0x31,0x31,0x2e,0x35,0x36,0x34,0x20,0x31,0x34,0x31,0x2e,0x38, 0x35,0x34,0x4c,0x20,0x31,0x34,0x30,0x2e,0x38,0x32,0x33,0x20,0x31,0x31,0x31,0x2e, 0x37,0x38,0x33,0x7a,0x22,0x20,0x69,0x64,0x3d,0x22,0x70,0x61,0x74,0x68,0x31,0x32, 0x22,0x20,0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x73,0x74,0x72,0x6f,0x6b,0x65,0x3a, 0x6e,0x6f,0x6e,0x65,0x3b,0x20,0x66,0x69,0x6c,0x6c,0x3a,0x23,0x30,0x30,0x30,0x30, 0x30,0x30,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22, 0x4d,0x20,0x31,0x31,0x31,0x2e,0x37,0x38,0x33,0x20,0x31,0x35,0x2e,0x31,0x30,0x38, 0x34,0x4c,0x20,0x31,0x34,0x2e,0x30,0x37,0x37,0x31,0x20,0x31,0x31,0x31,0x2e,0x35, 0x36,0x34,0x4c,0x20,0x34,0x34,0x2e,0x31,0x34,0x38,0x39,0x20,0x31,0x34,0x30,0x2e, 0x38,0x32,0x33,0x4c,0x20,0x31,0x34,0x31,0x2e,0x38,0x35,0x35,0x20,0x34,0x34,0x2e, 0x33,0x36,0x37,0x37,0x4c,0x20,0x31,0x31,0x31,0x2e,0x37,0x38,0x33,0x20,0x31,0x35, 0x2e,0x31,0x30,0x38,0x34,0x7a,0x22,0x20,0x69,0x64,0x3d,0x22,0x70,0x61,0x74,0x68, 0x31,0x33,0x22,0x20,0x73,0x74,0x79,0x6c,0x65,0x3d,0x22,0x73,0x74,0x72,0x6f,0x6b, 0x65,0x3a,0x6e,0x6f,0x6e,0x65,0x3b,0x20,0x66,0x69,0x6c,0x6c,0x3a,0x23,0x30,0x30, 0x30,0x30,0x30,0x30,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x2f,0x67,0x3e,0xa,0x20,0x3c, 0x2f,0x67,0x3e,0xa,0x20,0x3c,0x2f,0x73,0x76,0x67,0x3e, // /Users/stephaneadamgarnier/dev__Qt/systray/images/trash.svg 0x0,0x0,0xc,0x78, 0x3c, 0x3f,0x78,0x6d,0x6c,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3d,0x22,0x31,0x2e, 0x30,0x22,0x20,0x65,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x3d,0x22,0x75,0x74,0x66, 0x2d,0x38,0x22,0x3f,0x3e,0xa,0x20,0x3c,0x21,0x2d,0x2d,0x20,0x47,0x65,0x6e,0x65, 0x72,0x61,0x74,0x6f,0x72,0x3a,0x20,0x41,0x64,0x6f,0x62,0x65,0x20,0x49,0x6c,0x6c, 0x75,0x73,0x74,0x72,0x61,0x74,0x6f,0x72,0x20,0x31,0x30,0x2c,0x20,0x53,0x56,0x47, 0x20,0x45,0x78,0x70,0x6f,0x72,0x74,0x20,0x50,0x6c,0x75,0x67,0x2d,0x49,0x6e,0x20, 0x2e,0x20,0x53,0x56,0x47,0x20,0x56,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3a,0x20,0x33, 0x2e,0x30,0x2e,0x30,0x20,0x42,0x75,0x69,0x6c,0x64,0x20,0x37,0x36,0x29,0x20,0x20, 0x2d,0x2d,0x3e,0x3c,0x73,0x76,0x67,0x20,0x65,0x6e,0x61,0x62,0x6c,0x65,0x2d,0x62, 0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3d,0x22,0x6e,0x65,0x77,0x20,0x30, 0x20,0x30,0x20,0x33,0x34,0x37,0x20,0x33,0x34,0x38,0x22,0x20,0x68,0x65,0x69,0x67, 0x68,0x74,0x3d,0x22,0x33,0x34,0x38,0x22,0x20,0x69,0x3a,0x70,0x61,0x67,0x65,0x42, 0x6f,0x75,0x6e,0x64,0x73,0x3d,0x22,0x30,0x20,0x37,0x39,0x32,0x20,0x36,0x31,0x32, 0x20,0x30,0x22,0x20,0x69,0x3a,0x72,0x75,0x6c,0x65,0x72,0x4f,0x72,0x69,0x67,0x69, 0x6e,0x3d,0x22,0x30,0x20,0x30,0x22,0x20,0x69,0x3a,0x76,0x69,0x65,0x77,0x4f,0x72, 0x69,0x67,0x69,0x6e,0x3d,0x22,0x31,0x33,0x31,0x20,0x35,0x36,0x37,0x22,0x20,0x6f, 0x76,0x65,0x72,0x66,0x6c,0x6f,0x77,0x3d,0x22,0x76,0x69,0x73,0x69,0x62,0x6c,0x65, 0x22,0x20,0x73,0x70,0x61,0x63,0x65,0x3d,0x22,0x70,0x72,0x65,0x73,0x65,0x72,0x76, 0x65,0x22,0x20,0x76,0x69,0x65,0x77,0x42,0x6f,0x78,0x3d,0x22,0x2d,0x32,0x30,0x20, 0x2d,0x32,0x30,0x20,0x33,0x38,0x37,0x20,0x33,0x38,0x38,0x22,0x20,0x77,0x69,0x64, 0x74,0x68,0x3d,0x22,0x33,0x34,0x37,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3d,0x22, 0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72, 0x67,0x2f,0x32,0x30,0x30,0x30,0x2f,0x73,0x76,0x67,0x22,0x20,0x78,0x6d,0x6c,0x6e, 0x73,0x3a,0x61,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,0x2e,0x61, 0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,0x2f,0x41,0x64,0x6f,0x62,0x65,0x53,0x56, 0x47,0x56,0x69,0x65,0x77,0x65,0x72,0x45,0x78,0x74,0x65,0x6e,0x73,0x69,0x6f,0x6e, 0x73,0x2f,0x33,0x2e,0x30,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x67,0x72, 0x61,0x70,0x68,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,0x2e,0x61, 0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,0x2f,0x47,0x72,0x61,0x70,0x68,0x73,0x2f, 0x31,0x2e,0x30,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x69,0x3d,0x22,0x68, 0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,0x2e,0x61,0x64,0x6f,0x62,0x65,0x2e,0x63, 0x6f,0x6d,0x2f,0x41,0x64,0x6f,0x62,0x65,0x49,0x6c,0x6c,0x75,0x73,0x74,0x72,0x61, 0x74,0x6f,0x72,0x2f,0x31,0x30,0x2e,0x30,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73, 0x3a,0x78,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,0x2e,0x61,0x64, 0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,0x2f,0x45,0x78,0x74,0x65,0x6e,0x73,0x69,0x62, 0x69,0x6c,0x69,0x74,0x79,0x2f,0x31,0x2e,0x30,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e, 0x73,0x3a,0x78,0x6c,0x69,0x6e,0x6b,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f, 0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x31,0x39,0x39,0x39,0x2f, 0x78,0x6c,0x69,0x6e,0x6b,0x22,0x3e,0xa,0x20,0x3c,0x6d,0x65,0x74,0x61,0x64,0x61, 0x74,0x61,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x52,0x44,0x46,0x20,0x78,0x6d, 0x6c,0x6e,0x73,0x3a,0x63,0x63,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77, 0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f, 0x63,0x63,0x2f,0x22,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x64,0x63,0x3d,0x22,0x68, 0x74,0x74,0x70,0x3a,0x2f,0x2f,0x70,0x75,0x72,0x6c,0x2e,0x6f,0x72,0x67,0x2f,0x64, 0x63,0x2f,0x65,0x6c,0x65,0x6d,0x65,0x6e,0x74,0x73,0x2f,0x31,0x2e,0x31,0x2f,0x22, 0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x72,0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70, 0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,0x67,0x2f,0x31,0x39, 0x39,0x39,0x2f,0x30,0x32,0x2f,0x32,0x32,0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e, 0x74,0x61,0x78,0x2d,0x6e,0x73,0x23,0x22,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x57, 0x6f,0x72,0x6b,0x20,0x72,0x64,0x66,0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x22, 0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x4b,0x65,0x65, 0x70,0x20,0x54,0x69,0x64,0x79,0x20,0x49,0x6e,0x73,0x69,0x64,0x65,0x3c,0x2f,0x64, 0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x64,0x65, 0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0x3c,0x2f,0x64,0x63,0x3a,0x64, 0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0xa,0x20,0x3c,0x64,0x63, 0x3a,0x73,0x75,0x62,0x6a,0x65,0x63,0x74,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a, 0x42,0x61,0x67,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x3c,0x2f, 0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69, 0x3e,0x73,0x79,0x6d,0x62,0x6f,0x6c,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e, 0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x62,0x69,0x6e,0x3c,0x2f,0x72, 0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e, 0x73,0x69,0x67,0x6e,0x73,0x5f,0x61,0x6e,0x64,0x5f,0x73,0x79,0x6d,0x62,0x6f,0x6c, 0x73,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66, 0x3a,0x6c,0x69,0x3e,0x63,0x6c,0x65,0x61,0x6e,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c, 0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x72,0x75,0x62,0x69, 0x73,0x68,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64, 0x66,0x3a,0x6c,0x69,0x3e,0x74,0x72,0x61,0x73,0x68,0x3c,0x2f,0x72,0x64,0x66,0x3a, 0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0x69,0x6e,0x73, 0x69,0x64,0x65,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72, 0x64,0x66,0x3a,0x6c,0x69,0x3e,0x67,0x61,0x72,0x62,0x61,0x67,0x65,0x3c,0x2f,0x72, 0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e, 0x73,0x69,0x67,0x6e,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x6c,0x69,0x3e,0xa,0x20,0x3c, 0x2f,0x72,0x64,0x66,0x3a,0x42,0x61,0x67,0x3e,0xa,0x20,0x3c,0x2f,0x64,0x63,0x3a, 0x73,0x75,0x62,0x6a,0x65,0x63,0x74,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x70,0x75, 0x62,0x6c,0x69,0x73,0x68,0x65,0x72,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x41,0x67, 0x65,0x6e,0x74,0x20,0x72,0x64,0x66,0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x68, 0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x6f,0x70,0x65,0x6e,0x63,0x6c, 0x69,0x70,0x61,0x72,0x74,0x2e,0x6f,0x72,0x67,0x22,0x3e,0xa,0x20,0x3c,0x64,0x63, 0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x4d,0x61,0x72,0x74,0x69,0x6e,0x20,0x4f,0x77, 0x65,0x6e,0x73,0x3c,0x2f,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20, 0x3c,0x2f,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20,0x3c,0x2f,0x64, 0x63,0x3a,0x70,0x75,0x62,0x6c,0x69,0x73,0x68,0x65,0x72,0x3e,0xa,0x20,0x3c,0x64, 0x63,0x3a,0x63,0x72,0x65,0x61,0x74,0x6f,0x72,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a, 0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c, 0x65,0x3e,0x4d,0x61,0x72,0x74,0x69,0x6e,0x20,0x4f,0x77,0x65,0x6e,0x73,0x3c,0x2f, 0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a, 0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20,0x3c,0x2f,0x64,0x63,0x3a,0x63,0x72,0x65, 0x61,0x74,0x6f,0x72,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x72,0x69,0x67,0x68,0x74, 0x73,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20, 0x3c,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65,0x3e,0x4d,0x61,0x72,0x74,0x69,0x6e, 0x20,0x4f,0x77,0x65,0x6e,0x73,0x3c,0x2f,0x64,0x63,0x3a,0x74,0x69,0x74,0x6c,0x65, 0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x41,0x67,0x65,0x6e,0x74,0x3e,0xa,0x20, 0x3c,0x2f,0x64,0x63,0x3a,0x72,0x69,0x67,0x68,0x74,0x73,0x3e,0xa,0x20,0x3c,0x64, 0x63,0x3a,0x64,0x61,0x74,0x65,0x3e,0x3c,0x2f,0x64,0x63,0x3a,0x64,0x61,0x74,0x65, 0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x66,0x6f,0x72,0x6d,0x61,0x74,0x3e,0x69,0x6d, 0x61,0x67,0x65,0x2f,0x73,0x76,0x67,0x2b,0x78,0x6d,0x6c,0x3c,0x2f,0x64,0x63,0x3a, 0x66,0x6f,0x72,0x6d,0x61,0x74,0x3e,0xa,0x20,0x3c,0x64,0x63,0x3a,0x74,0x79,0x70, 0x65,0x20,0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22, 0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x70,0x75,0x72,0x6c,0x2e,0x6f,0x72,0x67,0x2f, 0x64,0x63,0x2f,0x64,0x63,0x6d,0x69,0x74,0x79,0x70,0x65,0x2f,0x53,0x74,0x69,0x6c, 0x6c,0x49,0x6d,0x61,0x67,0x65,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x6c, 0x69,0x63,0x65,0x6e,0x73,0x65,0x20,0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75, 0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e, 0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f, 0x50,0x75,0x62,0x6c,0x69,0x63,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x22,0x2f,0x3e,0xa, 0x20,0x3c,0x64,0x63,0x3a,0x6c,0x61,0x6e,0x67,0x75,0x61,0x67,0x65,0x3e,0x65,0x6e, 0x3c,0x2f,0x64,0x63,0x3a,0x6c,0x61,0x6e,0x67,0x75,0x61,0x67,0x65,0x3e,0xa,0x20, 0x3c,0x2f,0x63,0x63,0x3a,0x57,0x6f,0x72,0x6b,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a, 0x4c,0x69,0x63,0x65,0x6e,0x73,0x65,0x20,0x72,0x64,0x66,0x3a,0x61,0x62,0x6f,0x75, 0x74,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65, 0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x50,0x75, 0x62,0x6c,0x69,0x63,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x22,0x3e,0xa,0x20,0x3c,0x63, 0x63,0x3a,0x70,0x65,0x72,0x6d,0x69,0x74,0x73,0x20,0x72,0x64,0x66,0x3a,0x72,0x65, 0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77, 0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f, 0x63,0x63,0x2f,0x52,0x65,0x70,0x72,0x6f,0x64,0x75,0x63,0x74,0x69,0x6f,0x6e,0x22, 0x2f,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x70,0x65,0x72,0x6d,0x69,0x74,0x73,0x20, 0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x3d,0x22,0x68,0x74, 0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72,0x65,0x73,0x6f,0x75,0x72,0x63, 0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x44,0x69,0x73,0x74,0x72,0x69,0x62, 0x75,0x74,0x69,0x6f,0x6e,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x63,0x63,0x3a,0x70,0x65, 0x72,0x6d,0x69,0x74,0x73,0x20,0x72,0x64,0x66,0x3a,0x72,0x65,0x73,0x6f,0x75,0x72, 0x63,0x65,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x65,0x62,0x2e,0x72, 0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x2e,0x6f,0x72,0x67,0x2f,0x63,0x63,0x2f,0x44, 0x65,0x72,0x69,0x76,0x61,0x74,0x69,0x76,0x65,0x57,0x6f,0x72,0x6b,0x73,0x22,0x2f, 0x3e,0xa,0x20,0x3c,0x2f,0x63,0x63,0x3a,0x4c,0x69,0x63,0x65,0x6e,0x73,0x65,0x3e, 0xa,0x20,0x3c,0x2f,0x72,0x64,0x66,0x3a,0x52,0x44,0x46,0x3e,0xa,0x20,0x3c,0x2f, 0x6d,0x65,0x74,0x61,0x64,0x61,0x74,0x61,0x3e,0xa,0x20,0x3c,0x67,0x20,0x69,0x3a, 0x64,0x69,0x6d,0x6d,0x65,0x64,0x50,0x65,0x72,0x63,0x65,0x6e,0x74,0x3d,0x22,0x35, 0x30,0x22,0x20,0x69,0x3a,0x6b,0x6e,0x6f,0x63,0x6b,0x6f,0x75,0x74,0x3d,0x22,0x4f, 0x66,0x66,0x22,0x20,0x69,0x3a,0x6c,0x61,0x79,0x65,0x72,0x3d,0x22,0x79,0x65,0x73, 0x22,0x20,0x69,0x3a,0x72,0x67,0x62,0x54,0x72,0x69,0x6f,0x3d,0x22,0x23,0x34,0x46, 0x30,0x30,0x38,0x30,0x30,0x30,0x46,0x46,0x46,0x46,0x22,0x20,0x69,0x64,0x3d,0x22, 0x4c,0x61,0x79,0x65,0x72,0x5f,0x31,0x22,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68, 0x20,0x64,0x3d,0x22,0x4d,0x33,0x34,0x37,0x2c,0x31,0x37,0x34,0x63,0x30,0x2c,0x39, 0x36,0x2e,0x30,0x39,0x38,0x2d,0x37,0x37,0x2e,0x36,0x37,0x39,0x2c,0x31,0x37,0x34, 0x2d,0x31,0x37,0x33,0x2e,0x35,0x2c,0x31,0x37,0x34,0x43,0x37,0x37,0x2e,0x36,0x37, 0x39,0x2c,0x33,0x34,0x38,0x2c,0x30,0x2c,0x32,0x37,0x30,0x2e,0x30,0x39,0x38,0x2c, 0x30,0x2c,0x31,0x37,0x34,0x20,0x20,0x20,0x20,0x43,0x30,0x2c,0x37,0x37,0x2e,0x39, 0x30,0x32,0x2c,0x37,0x37,0x2e,0x36,0x37,0x39,0x2c,0x30,0x2c,0x31,0x37,0x33,0x2e, 0x35,0x2c,0x30,0x43,0x32,0x36,0x39,0x2e,0x33,0x32,0x31,0x2c,0x30,0x2c,0x33,0x34, 0x37,0x2c,0x37,0x37,0x2e,0x39,0x30,0x32,0x2c,0x33,0x34,0x37,0x2c,0x31,0x37,0x34, 0x7a,0x22,0x20,0x66,0x69,0x6c,0x6c,0x3d,0x22,0x23,0x31,0x30,0x41,0x30,0x34,0x30, 0x22,0x20,0x69,0x3a,0x6b,0x6e,0x6f,0x63,0x6b,0x6f,0x75,0x74,0x3d,0x22,0x4f,0x66, 0x66,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d, 0x32,0x33,0x38,0x2c,0x35,0x33,0x63,0x30,0x2c,0x31,0x33,0x2e,0x38,0x30,0x37,0x2d, 0x31,0x31,0x2e,0x38,0x36,0x34,0x2c,0x32,0x35,0x2d,0x32,0x36,0x2e,0x35,0x2c,0x32, 0x35,0x53,0x31,0x38,0x35,0x2c,0x36,0x36,0x2e,0x38,0x30,0x37,0x2c,0x31,0x38,0x35, 0x2c,0x35,0x33,0x73,0x31,0x31,0x2e,0x38,0x36,0x34,0x2d,0x32,0x35,0x2c,0x32,0x36, 0x2e,0x35,0x2d,0x32,0x35,0x20,0x20,0x20,0x20,0x53,0x32,0x33,0x38,0x2c,0x33,0x39, 0x2e,0x31,0x39,0x33,0x2c,0x32,0x33,0x38,0x2c,0x35,0x33,0x7a,0x22,0x20,0x66,0x69, 0x6c,0x6c,0x3d,0x22,0x23,0x46,0x46,0x46,0x46,0x46,0x46,0x22,0x20,0x69,0x3a,0x6b, 0x6e,0x6f,0x63,0x6b,0x6f,0x75,0x74,0x3d,0x22,0x4f,0x66,0x66,0x22,0x2f,0x3e,0xa, 0x20,0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d,0x36,0x36,0x2c,0x31,0x37, 0x35,0x63,0x31,0x2e,0x30,0x35,0x35,0x2c,0x36,0x2e,0x33,0x35,0x35,0x2c,0x31,0x39, 0x2e,0x33,0x33,0x33,0x2c,0x31,0x32,0x36,0x2e,0x34,0x31,0x37,0x2c,0x31,0x39,0x2e, 0x33,0x33,0x33,0x2c,0x31,0x32,0x36,0x2e,0x34,0x31,0x37,0x68,0x36,0x38,0x2e,0x33, 0x33,0x33,0x20,0x20,0x20,0x20,0x63,0x30,0x2c,0x30,0x2c,0x31,0x34,0x2e,0x31,0x30, 0x35,0x2d,0x31,0x32,0x32,0x2e,0x35,0x32,0x34,0x2c,0x31,0x34,0x2e,0x33,0x33,0x33, 0x2d,0x31,0x32,0x36,0x2e,0x34,0x31,0x37,0x63,0x36,0x2e,0x32,0x32,0x34,0x2d,0x30, 0x2e,0x36,0x32,0x32,0x2c,0x36,0x2e,0x36,0x36,0x37,0x2d,0x31,0x33,0x2d,0x32,0x2d, 0x31,0x33,0x63,0x2d,0x31,0x32,0x2e,0x31,0x36,0x34,0x2c,0x30,0x2d,0x38,0x39,0x2e, 0x32,0x30,0x35,0x2d,0x30,0x2e,0x30,0x35,0x39,0x2d,0x39,0x38,0x2c,0x30,0x53,0x36, 0x31,0x2e,0x31,0x36,0x37,0x2c,0x31,0x37,0x34,0x2e,0x34,0x38,0x37,0x2c,0x36,0x36, 0x2c,0x31,0x37,0x35,0x7a,0x22,0x20,0x66,0x69,0x6c,0x6c,0x3d,0x22,0x23,0x46,0x46, 0x46,0x46,0x46,0x46,0x22,0x20,0x69,0x3a,0x6b,0x6e,0x6f,0x63,0x6b,0x6f,0x75,0x74, 0x3d,0x22,0x4f,0x66,0x66,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68,0x20, 0x64,0x3d,0x22,0x4d,0x37,0x38,0x2c,0x31,0x34,0x31,0x63,0x31,0x37,0x2e,0x32,0x39, 0x32,0x2d,0x35,0x2e,0x33,0x32,0x35,0x2c,0x32,0x34,0x2e,0x31,0x37,0x39,0x2d,0x32, 0x33,0x2e,0x35,0x33,0x32,0x2c,0x32,0x37,0x2d,0x33,0x31,0x63,0x31,0x34,0x2e,0x35, 0x31,0x33,0x2c,0x36,0x2e,0x35,0x39,0x36,0x2c,0x34,0x30,0x2e,0x33,0x33,0x33,0x2c, 0x31,0x32,0x2e,0x32,0x36,0x35,0x2c,0x35,0x39,0x2c,0x38,0x20,0x20,0x20,0x20,0x63, 0x33,0x2e,0x36,0x38,0x33,0x2c,0x31,0x39,0x2e,0x34,0x31,0x39,0x2d,0x32,0x38,0x2e, 0x30,0x34,0x33,0x2c,0x31,0x39,0x2e,0x33,0x31,0x2d,0x32,0x33,0x2c,0x33,0x37,0x43, 0x31,0x33,0x32,0x2e,0x35,0x37,0x37,0x2c,0x31,0x34,0x35,0x2e,0x37,0x30,0x35,0x2c, 0x38,0x39,0x2e,0x34,0x30,0x34,0x2c,0x31,0x36,0x37,0x2e,0x32,0x39,0x32,0x2c,0x37, 0x38,0x2c,0x31,0x34,0x31,0x7a,0x22,0x20,0x66,0x69,0x6c,0x6c,0x3d,0x22,0x23,0x46, 0x46,0x46,0x46,0x46,0x46,0x22,0x20,0x69,0x3a,0x6b,0x6e,0x6f,0x63,0x6b,0x6f,0x75, 0x74,0x3d,0x22,0x4f,0x66,0x66,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x70,0x61,0x74,0x68, 0x20,0x64,0x3d,0x22,0x4d,0x31,0x30,0x33,0x2c,0x38,0x32,0x6c,0x31,0x33,0x39,0x2d, 0x31,0x63,0x2d,0x30,0x2e,0x36,0x2c,0x33,0x2e,0x34,0x32,0x31,0x2c,0x33,0x33,0x2e, 0x36,0x33,0x33,0x2c,0x35,0x37,0x2e,0x34,0x39,0x37,0x2c,0x32,0x39,0x2c,0x36,0x37, 0x63,0x2d,0x34,0x2e,0x30,0x38,0x39,0x2c,0x30,0x2e,0x34,0x31,0x38,0x2d,0x36,0x37, 0x2c,0x35,0x2d,0x36,0x37,0x2c,0x35,0x20,0x20,0x20,0x20,0x63,0x36,0x2e,0x31,0x30, 0x39,0x2d,0x39,0x2e,0x33,0x37,0x39,0x2d,0x31,0x33,0x2d,0x34,0x33,0x2d,0x31,0x33, 0x2d,0x34,0x33,0x4c,0x31,0x30,0x33,0x2c,0x38,0x32,0x7a,0x22,0x20,0x66,0x69,0x6c, 0x6c,0x3d,0x22,0x23,0x46,0x46,0x46,0x46,0x46,0x46,0x22,0x20,0x69,0x3a,0x6b,0x6e, 0x6f,0x63,0x6b,0x6f,0x75,0x74,0x3d,0x22,0x4f,0x66,0x66,0x22,0x2f,0x3e,0xa,0x20, 0x3c,0x70,0x61,0x74,0x68,0x20,0x64,0x3d,0x22,0x4d,0x32,0x37,0x30,0x2c,0x31,0x35, 0x36,0x6c,0x2d,0x36,0x36,0x2d,0x33,0x63,0x30,0x2c,0x30,0x2d,0x32,0x33,0x2e,0x35, 0x36,0x35,0x2c,0x31,0x34,0x33,0x2e,0x33,0x35,0x35,0x2d,0x32,0x34,0x2c,0x31,0x34, 0x35,0x73,0x31,0x2e,0x38,0x35,0x35,0x2c,0x32,0x2e,0x35,0x33,0x36,0x2c,0x33,0x2c, 0x31,0x73,0x35,0x31,0x2d,0x38,0x32,0x2c,0x35,0x31,0x2d,0x38,0x32,0x20,0x20,0x20, 0x20,0x73,0x31,0x39,0x2e,0x37,0x35,0x34,0x2c,0x38,0x30,0x2e,0x37,0x30,0x31,0x2c, 0x32,0x30,0x2c,0x38,0x32,0x73,0x33,0x2e,0x37,0x32,0x31,0x2c,0x31,0x2e,0x32,0x30, 0x39,0x2c,0x34,0x2c,0x30,0x53,0x32,0x37,0x30,0x2c,0x31,0x35,0x36,0x2c,0x32,0x37, 0x30,0x2c,0x31,0x35,0x36,0x7a,0x22,0x20,0x66,0x69,0x6c,0x6c,0x3d,0x22,0x23,0x46, 0x46,0x46,0x46,0x46,0x46,0x22,0x20,0x69,0x3a,0x6b,0x6e,0x6f,0x63,0x6b,0x6f,0x75, 0x74,0x3d,0x22,0x4f,0x66,0x66,0x22,0x2f,0x3e,0xa,0x20,0x3c,0x2f,0x67,0x3e,0xa, 0x20,0x3c,0x2f,0x73,0x76,0x67,0x3e, }; static const unsigned char qt_resource_name[] = { // images 0x0,0x6, 0x7,0x3,0x7d,0xc3, 0x0,0x69, 0x0,0x6d,0x0,0x61,0x0,0x67,0x0,0x65,0x0,0x73, // heart.svg 0x0,0x9, 0x8,0x97,0x87,0xa7, 0x0,0x68, 0x0,0x65,0x0,0x61,0x0,0x72,0x0,0x74,0x0,0x2e,0x0,0x73,0x0,0x76,0x0,0x67, // bad.svg 0x0,0x7, 0x8,0x77,0x5a,0x7, 0x0,0x62, 0x0,0x61,0x0,0x64,0x0,0x2e,0x0,0x73,0x0,0x76,0x0,0x67, // trash.svg 0x0,0x9, 0x8,0x9b,0xad,0xc7, 0x0,0x74, 0x0,0x72,0x0,0x61,0x0,0x73,0x0,0x68,0x0,0x2e,0x0,0x73,0x0,0x76,0x0,0x67, }; static const unsigned char qt_resource_struct[] = { // : 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1, // :/images 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2, // :/images/bad.svg 0x0,0x0,0x0,0x2a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0xf,0x5a, // :/images/heart.svg 0x0,0x0,0x0,0x12,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, // :/images/trash.svg 0x0,0x0,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1c,0xca, }; QT_BEGIN_NAMESPACE extern Q_CORE_EXPORT bool qRegisterResourceData (int, const unsigned char *, const unsigned char *, const unsigned char *); extern Q_CORE_EXPORT bool qUnregisterResourceData (int, const unsigned char *, const unsigned char *, const unsigned char *); QT_END_NAMESPACE int QT_MANGLE_NAMESPACE(qInitResources_systray)() { QT_PREPEND_NAMESPACE(qRegisterResourceData) (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_systray)) int QT_MANGLE_NAMESPACE(qCleanupResources_systray)() { QT_PREPEND_NAMESPACE(qUnregisterResourceData) (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources_systray))
75.869681
82
0.766344
[ "object" ]
a67567ff7542ed0f30d2656a9df05227720c4b91
2,259
cpp
C++
src/batteries/async/mutex.test.cpp
tonyastolfi/batteries
67349930e54785f44eab84f1e56da6c78c66a5f9
[ "Apache-2.0" ]
1
2022-01-04T20:28:17.000Z
2022-01-04T20:28:17.000Z
src/batteries/async/mutex.test.cpp
mihir-thakkar/batteries
67349930e54785f44eab84f1e56da6c78c66a5f9
[ "Apache-2.0" ]
2
2020-06-04T14:02:24.000Z
2020-06-04T14:03:18.000Z
src/batteries/async/mutex.test.cpp
mihir-thakkar/batteries
67349930e54785f44eab84f1e56da6c78c66a5f9
[ "Apache-2.0" ]
1
2022-01-03T20:24:31.000Z
2022-01-03T20:24:31.000Z
// Copyright 2021 Anthony Paul Astolfi // #include <batteries/async/mutex.hpp> // #include <batteries/async/mutex.hpp> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <boost/asio/io_context.hpp> #include <mutex> #include <thread> namespace { constexpr std::size_t kIterations = 10000; constexpr std::size_t kNumThreads = 500; // constexpr std::size_t kIterations = 50; // constexpr std::size_t kNumThreads = 20; int task_line[kNumThreads + 1] = {0}; int task_progress[kNumThreads + 1] = {0}; #if 0 #define TRACE(stmt) \ task_line[batt::Task::current().id()] = __LINE__; \ stmt #else #define TRACE(stmt) stmt #endif TEST(MutexTest, ScopedLock) { (void)task_line; (void)task_progress; batt::Mutex<unsigned> count{0}; boost::asio::io_context io; auto ex = io.get_executor(); auto body = [&] { for (std::size_t i = 0; i < kIterations; ++i) { // task_progress[batt::Task::current().id()] += 1; { TRACE(auto val = count.lock()); TRACE(*val = *val + 1); } TRACE(continue); } TRACE(return ); }; std::vector<std::unique_ptr<batt::Task>> tasks(kNumThreads); for (std::size_t j = 0; j < kNumThreads; ++j) { tasks[j] = std::make_unique<batt::Task>(ex, batt::make_copy(body)); } io.run(); for (auto& t : tasks) { t->join(); } auto val = count.lock(); EXPECT_EQ(*val, kIterations * kNumThreads); } TEST(MutexTest, SystemThreads) { unsigned count_value = 0; std::mutex count_mutex; auto body = [&] { for (std::size_t i = 0; i < kIterations; ++i) { std::unique_lock<std::mutex> lock{count_mutex}; count_value = count_value + 1; } }; std::vector<std::unique_ptr<std::thread>> tasks; for (std::size_t j = 0; j < kNumThreads; ++j) { tasks.emplace_back(std::make_unique<std::thread>(batt::make_copy(body))); } for (auto& t : tasks) { t->join(); } EXPECT_EQ(count_value, kIterations * kNumThreads); } } // namespace
23.05102
110
0.547145
[ "vector" ]