blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
fc5d4570889b09197c88d392be80a6cf70a47245
6617f8aa6600b1405f6b1c208e97e62c3ddcdaa1
/source/World.cpp
623616cd4737e7c2876e376d6627f1da87a7f0a4
[]
no_license
ahrairah/sfml_learning
586272b847fe29632bd2b5979bc4135c8372ca5a
985272d5ce48693ad1fa3d90c78efd2068cd5138
refs/heads/master
2021-01-10T14:58:19.002613
2016-04-26T19:10:38
2016-04-26T19:10:38
48,184,520
0
0
null
null
null
null
UTF-8
C++
false
false
378
cpp
#include "../include/World.h" World::World(sf::RenderWindow& window): mWindow(window), mWorldView(window.getDefaultView()), mWorldBounds(0.f, 0.f, mWorldView.getSize().x, 2000.f), mSpawnPosition(mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 2.f) { loadTextures(); buildScene(); mWorldView.setCenter(mSpawnPosition); }
[ "Tony.Meyer@outlook.de" ]
Tony.Meyer@outlook.de
f9c0924577453944d8709e48606240abb6b35f6f
b4073e94cd137b6b50aee6a38746f88d8a33c3ee
/inc/C++/Identifier.hpp
e78aab7a3e0e83f8f0848e3545ade801a04c3bf3
[]
no_license
mcabioch/project_GL_uqac_automne2019
87e50e9605fe960788c9c156694bd05bc3b571c1
07f0e2f40ed85f2c969fbcdf0283cea77d6f09d2
refs/heads/Qt
2020-09-11T09:14:43.505984
2019-12-11T19:50:51
2019-12-11T19:50:51
222,016,547
0
1
null
2019-12-09T22:59:07
2019-11-15T22:57:30
C++
UTF-8
C++
false
false
1,482
hpp
/*! * * \file Identifier.hpp * \author Mathias CABIOCH-DELALANDE * \modified September, 26 2019 * */ #ifndef HEADER_CPP_IDENTIFIER #define HEADER_CPP_IDENTIFIER #include "C++/C++.hpp" namespace mcd { /*! * \class Identifier * \brief A class to store some identify datas */ class Identifier { public: /* Constructor & Destructor */ Identifier() : _username(""), _password(""), _id(0) {} virtual ~Identifier(){} /* Setters */ /*! * \brief Set the Player's username * \param[in] username The new username * * \return void */ void setUsername(const std::string& username){ _username = username; } /*! * \brief Set the Player's password * \param[in] password The new password * * \return void */ void setPassword(const std::string& password){ _password = password; } /*! * \brief Set the Player's id * \param[in] id The new id * * \return void */ void setId(size_t id){ _id = id; } /* Getters */ /*! \return Return the username */ std::string getUsername()const { return _username; } /*! \return Return the password */ std::string getPassword()const { return _password; } /*! \return Return the id */ virtual size_t getId()const { return _id; } /* Friends */ /* Others */ protected: std::string _username; std::string _password; size_t _id; }; } #endif //HEADER_CPP_IDENTIFIER
[ "mathias.cabiochdelalande@gmail.com" ]
mathias.cabiochdelalande@gmail.com
1ddbffcb04ae3fb65ff3bfae7094a18ed726c67f
35f1a2b751819d0e5741a87121cfdf2aae3e646b
/study/study/9742.cpp
6e45a525f40623c4870c76e1219a3974a80d67d0
[]
no_license
namhyo01/ForStudy
b15ec2dc8b3e659509b93604b4468fbd7460bed8
fa7b8f6279a02f1ed261a209fefccc96a4ef4752
refs/heads/master
2022-03-20T15:38:47.140018
2022-03-09T12:41:05
2022-03-09T12:41:05
250,731,941
0
0
null
null
null
null
UTF-8
C++
false
false
554
cpp
//#include <bits/stdc++.h> // //using namespace std; // //string a; //int n; // // //int main() { // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // // while (cin >> a >> n) { // int cnt = 0; // bool check = false; // string temp = a; // do { // cnt++; // if (cnt == n) { // cout <<temp<<" "<<n<<" = "<< a << endl; // check = true; // break; // } // } while (next_permutation(a.begin(), a.end())); // if (!check) { // cout << temp << " " << n << " = No permutation" << endl; // } // } // // system("pause"); // return 0; //}
[ "namhyo01@naver.com" ]
namhyo01@naver.com
1af804ef5b80751e2b58bdf480e89d015c43b51e
3844678a0fb3b1f0838fb04bc57fd93dee6ee631
/sileecode/callCPP_C/aaa_c_connector.cpp
a55c82f36066839dc74e212ca6665b47ead7911f
[]
no_license
jeonghanlee/Work
daa9295da3af3ff6c3a68daf51fac804dd1942cd
bef817911ea29fe091547f001ac35ac3765d8258
refs/heads/master
2022-09-28T03:59:29.435017
2022-09-15T18:26:34
2022-09-15T18:26:34
91,843,357
3
0
null
2019-01-08T16:10:37
2017-05-19T20:34:36
VHDL
UTF-8
C++
false
false
780
cpp
#include <cstdlib> #include "aaa_c_connector.h" #include "aaa.h" #ifdef __cplusplus extern "C" { #endif // Inside this "extern C" block, I can implement functions in C++, which will externally // appear as C functions (which means that the function IDs will be their names, unlike // the regular C++ behavior, which allows defining multiple functions with the same name // (overloading) and hence uses function signature hashing to enforce unique IDs), static AAA *AAA_instance = NULL; void lazyAAA() { if (AAA_instance == NULL) { AAA_instance = new AAA(); } } void AAA_sayHi(const char *name) { lazyAAA(); AAA_instance->sayHi(name); } #ifdef __cplusplus } #endif //g++ -fpic -shared aaa_c_connector.cpp -L. -laaa -o libaaa_c_connector.so
[ "silee7103@gmail.com" ]
silee7103@gmail.com
09517a0c3028d8ebf392358a307db7542891f1c3
8dc84558f0058d90dfc4955e905dab1b22d12c08
/base/debug/thread_heap_usage_tracker.cc
6d00b1ccbbfdf7f5b7fc287e453eda015a3d0b95
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
meniossin/src
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
44f73f7e76119e5ab415d4593ac66485e65d700a
refs/heads/master
2022-12-16T20:17:03.747113
2020-09-03T10:43:12
2020-09-03T10:43:12
263,710,168
1
0
BSD-3-Clause
2020-05-13T18:20:09
2020-05-13T18:20:08
null
UTF-8
C++
false
false
11,407
cc
// 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 "base/debug/thread_heap_usage_tracker.h" #include <stdint.h> #include <algorithm> #include <limits> #include <new> #include <type_traits> #include "base/allocator/allocator_shim.h" #include "base/allocator/buildflags.h" #include "base/logging.h" #include "base/no_destructor.h" #include "base/threading/thread_local_storage.h" #include "build/build_config.h" #if defined(OS_MACOSX) || defined(OS_IOS) #include <malloc/malloc.h> #else #include <malloc.h> #endif namespace base { namespace debug { namespace { using base::allocator::AllocatorDispatch; const uintptr_t kSentinelMask = std::numeric_limits<uintptr_t>::max() - 1; ThreadHeapUsage* const kInitializationSentinel = reinterpret_cast<ThreadHeapUsage*>(kSentinelMask); ThreadHeapUsage* const kTeardownSentinel = reinterpret_cast<ThreadHeapUsage*>(kSentinelMask | 1); ThreadLocalStorage::Slot& ThreadAllocationUsage() { static NoDestructor<ThreadLocalStorage::Slot> thread_allocator_usage( [](void* thread_heap_usage) { // This destructor will be called twice. Once to destroy the actual // ThreadHeapUsage instance and a second time, immediately after, for // the sentinel. Re-setting the TLS slow (below) does re-initialize the // TLS slot. The ThreadLocalStorage code is designed to deal with this // use case and will re-call the destructor with the kTeardownSentinel // as arg. if (thread_heap_usage == kTeardownSentinel) return; DCHECK_NE(thread_heap_usage, kInitializationSentinel); // Deleting the ThreadHeapUsage TLS object will re-enter the shim and // hit RecordFree() (see below). The sentinel prevents RecordFree() from // re-creating another ThreadHeapUsage object. ThreadAllocationUsage().Set(kTeardownSentinel); delete static_cast<ThreadHeapUsage*>(thread_heap_usage); }); return *thread_allocator_usage; } bool g_heap_tracking_enabled = false; // Forward declared as it needs to delegate memory allocation to the next // lower shim. ThreadHeapUsage* GetOrCreateThreadUsage(); size_t GetAllocSizeEstimate(const AllocatorDispatch* next, void* ptr, void* context) { if (ptr == nullptr) return 0U; return next->get_size_estimate_function(next, ptr, context); } void RecordAlloc(const AllocatorDispatch* next, void* ptr, size_t size, void* context) { ThreadHeapUsage* usage = GetOrCreateThreadUsage(); if (usage == nullptr) return; usage->alloc_ops++; size_t estimate = GetAllocSizeEstimate(next, ptr, context); if (size && estimate) { // Only keep track of the net number of bytes allocated in the scope if the // size estimate function returns sane values, e.g. non-zero. usage->alloc_bytes += estimate; usage->alloc_overhead_bytes += estimate - size; // Record the max outstanding number of bytes, but only if the difference // is net positive (e.g. more bytes allocated than freed in the scope). if (usage->alloc_bytes > usage->free_bytes) { uint64_t allocated_bytes = usage->alloc_bytes - usage->free_bytes; if (allocated_bytes > usage->max_allocated_bytes) usage->max_allocated_bytes = allocated_bytes; } } else { usage->alloc_bytes += size; } } void RecordFree(const AllocatorDispatch* next, void* ptr, void* context) { ThreadHeapUsage* usage = GetOrCreateThreadUsage(); if (usage == nullptr) return; size_t estimate = GetAllocSizeEstimate(next, ptr, context); usage->free_ops++; usage->free_bytes += estimate; } void* AllocFn(const AllocatorDispatch* self, size_t size, void* context) { void* ret = self->next->alloc_function(self->next, size, context); if (ret != nullptr) RecordAlloc(self->next, ret, size, context); return ret; } void* AllocZeroInitializedFn(const AllocatorDispatch* self, size_t n, size_t size, void* context) { void* ret = self->next->alloc_zero_initialized_function(self->next, n, size, context); if (ret != nullptr) RecordAlloc(self->next, ret, size, context); return ret; } void* AllocAlignedFn(const AllocatorDispatch* self, size_t alignment, size_t size, void* context) { void* ret = self->next->alloc_aligned_function(self->next, alignment, size, context); if (ret != nullptr) RecordAlloc(self->next, ret, size, context); return ret; } void* ReallocFn(const AllocatorDispatch* self, void* address, size_t size, void* context) { if (address != nullptr) RecordFree(self->next, address, context); void* ret = self->next->realloc_function(self->next, address, size, context); if (ret != nullptr && size != 0) RecordAlloc(self->next, ret, size, context); return ret; } void FreeFn(const AllocatorDispatch* self, void* address, void* context) { if (address != nullptr) RecordFree(self->next, address, context); self->next->free_function(self->next, address, context); } size_t GetSizeEstimateFn(const AllocatorDispatch* self, void* address, void* context) { return self->next->get_size_estimate_function(self->next, address, context); } unsigned BatchMallocFn(const AllocatorDispatch* self, size_t size, void** results, unsigned num_requested, void* context) { unsigned count = self->next->batch_malloc_function(self->next, size, results, num_requested, context); for (unsigned i = 0; i < count; ++i) { RecordAlloc(self->next, results[i], size, context); } return count; } void BatchFreeFn(const AllocatorDispatch* self, void** to_be_freed, unsigned num_to_be_freed, void* context) { for (unsigned i = 0; i < num_to_be_freed; ++i) { if (to_be_freed[i] != nullptr) { RecordFree(self->next, to_be_freed[i], context); } } self->next->batch_free_function(self->next, to_be_freed, num_to_be_freed, context); } void FreeDefiniteSizeFn(const AllocatorDispatch* self, void* ptr, size_t size, void* context) { if (ptr != nullptr) RecordFree(self->next, ptr, context); self->next->free_definite_size_function(self->next, ptr, size, context); } // The allocator dispatch used to intercept heap operations. AllocatorDispatch allocator_dispatch = {&AllocFn, &AllocZeroInitializedFn, &AllocAlignedFn, &ReallocFn, &FreeFn, &GetSizeEstimateFn, &BatchMallocFn, &BatchFreeFn, &FreeDefiniteSizeFn, nullptr}; ThreadHeapUsage* GetOrCreateThreadUsage() { auto tls_ptr = reinterpret_cast<uintptr_t>(ThreadAllocationUsage().Get()); if ((tls_ptr & kSentinelMask) == kSentinelMask) return nullptr; // Re-entrancy case. auto* allocator_usage = reinterpret_cast<ThreadHeapUsage*>(tls_ptr); if (allocator_usage == nullptr) { // Prevent reentrancy due to the allocation below. ThreadAllocationUsage().Set(kInitializationSentinel); allocator_usage = new ThreadHeapUsage(); static_assert(std::is_pod<ThreadHeapUsage>::value, "AllocatorDispatch must be POD"); memset(allocator_usage, 0, sizeof(*allocator_usage)); ThreadAllocationUsage().Set(allocator_usage); } return allocator_usage; } } // namespace ThreadHeapUsageTracker::ThreadHeapUsageTracker() : thread_usage_(nullptr) { static_assert(std::is_pod<ThreadHeapUsage>::value, "Must be POD."); } ThreadHeapUsageTracker::~ThreadHeapUsageTracker() { DCHECK(thread_checker_.CalledOnValidThread()); if (thread_usage_ != nullptr) { // If this tracker wasn't stopped, make it inclusive so that the // usage isn't lost. Stop(false); } } void ThreadHeapUsageTracker::Start() { DCHECK(thread_checker_.CalledOnValidThread()); thread_usage_ = GetOrCreateThreadUsage(); usage_ = *thread_usage_; // Reset the stats for our current scope. // The per-thread usage instance now tracks this scope's usage, while this // instance persists the outer scope's usage stats. On destruction, this // instance will restore the outer scope's usage stats with this scope's // usage added. memset(thread_usage_, 0, sizeof(*thread_usage_)); } void ThreadHeapUsageTracker::Stop(bool usage_is_exclusive) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_NE(nullptr, thread_usage_); ThreadHeapUsage current = *thread_usage_; if (usage_is_exclusive) { // Restore the outer scope. *thread_usage_ = usage_; } else { // Update the outer scope with the accrued inner usage. if (thread_usage_->max_allocated_bytes) { uint64_t outer_net_alloc_bytes = usage_.alloc_bytes - usage_.free_bytes; thread_usage_->max_allocated_bytes = std::max(usage_.max_allocated_bytes, outer_net_alloc_bytes + thread_usage_->max_allocated_bytes); } thread_usage_->alloc_ops += usage_.alloc_ops; thread_usage_->alloc_bytes += usage_.alloc_bytes; thread_usage_->alloc_overhead_bytes += usage_.alloc_overhead_bytes; thread_usage_->free_ops += usage_.free_ops; thread_usage_->free_bytes += usage_.free_bytes; } thread_usage_ = nullptr; usage_ = current; } ThreadHeapUsage ThreadHeapUsageTracker::GetUsageSnapshot() { ThreadHeapUsage* usage = GetOrCreateThreadUsage(); DCHECK_NE(nullptr, usage); return *usage; } void ThreadHeapUsageTracker::EnableHeapTracking() { EnsureTLSInitialized(); CHECK_EQ(false, g_heap_tracking_enabled) << "No double-enabling."; g_heap_tracking_enabled = true; #if BUILDFLAG(USE_ALLOCATOR_SHIM) base::allocator::InsertAllocatorDispatch(&allocator_dispatch); #else CHECK(false) << "Can't enable heap tracking without the shim."; #endif // BUILDFLAG(USE_ALLOCATOR_SHIM) } bool ThreadHeapUsageTracker::IsHeapTrackingEnabled() { return g_heap_tracking_enabled; } void ThreadHeapUsageTracker::DisableHeapTrackingForTesting() { #if BUILDFLAG(USE_ALLOCATOR_SHIM) base::allocator::RemoveAllocatorDispatchForTesting(&allocator_dispatch); #else CHECK(false) << "Can't disable heap tracking without the shim."; #endif // BUILDFLAG(USE_ALLOCATOR_SHIM) DCHECK_EQ(true, g_heap_tracking_enabled) << "Heap tracking not enabled."; g_heap_tracking_enabled = false; } base::allocator::AllocatorDispatch* ThreadHeapUsageTracker::GetDispatchForTesting() { return &allocator_dispatch; } void ThreadHeapUsageTracker::EnsureTLSInitialized() { ignore_result(ThreadAllocationUsage()); } } // namespace debug } // namespace base
[ "arnaud@geometry.ee" ]
arnaud@geometry.ee
c0ee08290cb315d67e52fe085f418ac840af7c23
7f6c49d23b0b1d90a84f40dcba674f2543a39592
/yeonghan/baekjoon/세 용액.cpp
3154b8868ed2f836d60d4ff3c5a81ca9e50fa7d4
[]
no_license
CodeTest-StudyGroup/Code-Test-Study
76c130007b94508d72c4ac4dd2ccd7c250707e02
ef90f26c47d92ed46a512d46a043550d32369658
refs/heads/master
2023-08-03T15:52:40.487588
2022-07-11T13:20:15
2022-07-11T13:20:15
253,215,176
1,205
241
null
2023-07-26T09:06:20
2020-04-05T11:06:52
C++
UTF-8
C++
false
false
1,154
cpp
#include <iostream> #include <algorithm> #include <vector> using namespace std; int n; vector<long long> arr; long long ans[3]; bool check; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i=0 ; i<n ; i++) { long long a; cin >> a; arr.push_back(a); } sort(arr.begin(), arr.end()); long long cnt=0; for(int i=0 ; i<n-2 ; i++) { long long left = i+1, right = n-1; while(left<right) { long long sum = arr[i] + arr[left] + arr[right]; if(!check || (abs(cnt)>abs(sum))) { check = true; cnt = sum; ans[0] = arr[i]; ans[1] = arr[left]; ans[2] = arr[right]; } if(sum>0) right--; else if(sum<0) left++; else { sort(ans, ans+3); for(int i=0 ; i<3 ; i++) { cout << ans[i] << " "; } exit(0); } } } sort(ans, ans+3); for(int i=0 ; i<3 ; i++) { cout << ans[i] << " "; } return 0; }
[ "soosungp33@gmail.com" ]
soosungp33@gmail.com
85c779d76c05cd06e320baafaa8209f201327098
1c711f642328e5195cbbb61760a83f4a8ff6977a
/assets/src/poj/3107.cpp
a904fabb0e9598cd5770191042c6352abfdbaca3
[]
no_license
liuxueyang/liuxueyang.github.io
29d85b989e5938e964b70c9616a418e13003212e
86e10cb6137d930c2ac81f2ae20318eb1354f2b5
refs/heads/master
2023-03-07T13:06:17.366563
2023-03-01T14:41:41
2023-03-01T14:41:41
17,851,538
2
0
null
2023-01-31T04:00:56
2014-03-18T02:46:21
C++
UTF-8
C++
false
false
2,366
cpp
// Date: Fri Nov 5 01:05:06 2021 #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <map> #include <set> #include <algorithm> #include <utility> #include <functional> using namespace std; const int INF = 0x3f3f3f3f, MOD = 1e9 + 7; const double eps = 1e-8; const int dir[8][2] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}, }; typedef long long ll; typedef vector<int> VI; typedef pair<int, int> PII; #define LN ListNode #define LNP ListNode* #define TN TreeNode #define TNP TreeNode* #ifdef _DEBUG struct ListNode { int val; ListNode *next; ListNode() : val(0), next(nullptr) {} ListNode(int val) : val(val), next(nullptr) {} ListNode(int val, ListNode *next) : val(val), next(next) {} }; 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) {} }; #endif const int N = 50010, M = N * 2; int idx, n, h[N]; int e[M], ne[M]; bool st[N]; int ans, res[N], cnt; void Init() { idx = cnt = 0; memset(h, -1, sizeof h); memset(st, false, sizeof st); ans = INF; } void Add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; } int dfs(int u) { st[u] = true; int sum = 1, ma = 0; for (int i = h[u]; i != -1; i = ne[i]) { int j = e[i]; if (!st[j]) { int tmp = dfs(j); sum += tmp; ma = max(ma, tmp); } } ma = max(ma, n - sum); if (ma < ans) { ans = ma; cnt = 0; res[cnt++] = u; } else if (ma == ans) { res[cnt++] = u; } return sum; } int main(void) { #ifdef _DEBUG freopen("3107.in", "r", stdin); #endif // std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); scanf("%d", &n); // cin >> n; Init(); for (int i = 0; i < n - 1; ++i) { int a, b; // cin >> a >> b; scanf("%d%d", &a, &b); Add(a, b); Add(b, a); } dfs(1); sort(res, res + cnt); for (int i = 0; i < cnt; ++i) { // if (i) cout << ' ' << res[i]; // else cout << res[i]; if (i) printf(" %d", res[i]); else printf("%d", res[i]); } puts(""); // cout << endl; return 0; }
[ "liuxueyang457@gmail.com" ]
liuxueyang457@gmail.com
debf352d816ff8f7c987484a38c8c6a7aaab5fae
ee948e2bbfa08b79323cb28b99b63f09d5e39682
/old/oldcode/s10Hatch.h
5af0a8b1d23aebe78cac26cafe5998a03de5f7a5
[]
no_license
LordBlackhawk/bw-karl
6c8808cd0472a6fcf6500b03c218fcc01b76908c
20ca5958781b856c5861882cddd4c0f8838542fd
refs/heads/master
2016-09-05T23:57:30.543228
2014-11-13T20:17:50
2014-11-13T20:17:50
35,498,576
1
1
null
null
null
null
UTF-8
C++
false
false
6,484
h
#ifndef S10HATCH_h #define S10HATCH_h #include "strategie.h" #include "priorities.h" #include "basemanagertask.h" #include "buildneartask.h" #include "gathermineralstask.h" #include "gathergastask.h" #include "overlordscouttask.h" #include "overlordbuildtask.h" #include "extractortricktask.h" #include "earlyzerglingtask.h" #include "researchtask.h" #include "upgradetask.h" #include "morphbuildingtask.h" class S10HatchStrategie : public Strategie { public: Player* me; BWTA::BaseLocation* mainbase; BWTA::Region* mainregion; BWTA::BaseLocation* naturalbase; BWTA::BaseLocation* thirdbase; Task* extension_task; Task* pool_task; public: S10HatchStrategie(Task* tt) : Strategie(tt), extension_task(NULL), pool_task(NULL) { } virtual void startup() { me = BWAPI::Broodwar->self(); mainbase = BWTA::getStartLocation(me); mainregion = mainbase->getRegion(); naturalbase = findNatural(); thirdbase = findThirdBase(); // Hauptbasis verwalten: new BaseManagerTask(toptask, Priority::BaseManager, mainbase); // Overlords als Scouts verwenden: OverlordScoutTask* scout = new OverlordScoutTask(toptask, Priority::ScoutOverlord); ChokepointSet exits = mainbase->getRegion()->getChokepoints(); if (naturalbase != NULL) { ChokepointSet naturalexists = naturalbase->getRegion()->getChokepoints(); exits.insert(naturalexists.begin(), naturalexists.end()); } for (ChokepointSet::iterator it=exits.begin(), itend=exits.end(); it!=itend; ++it) scout->points.push_back((*it)->getCenter()); scout->checkStatus(); // Extraktor Trick: if (mainbase->getGeysers().size() > 0) new ExtractorTrickTask(toptask, Priority::ExtractorTrick, *(mainbase->getGeysers().begin())); } virtual void computeActions(int fcount) { if (fcount % 30 != 25) return; // Extension bauen: static bool tryextension = true; if (tryextension) { if ((naturalbase != NULL) && (extension_task == NULL) && (me->minerals() >= 130)) { tryextension = false; extension_task = new BuildAtTask(toptask, Priority::BuildHatch, UnitTypes::Zerg_Hatchery, naturalbase->getTilePosition(), true); new BaseManagerTask(toptask, Priority::BaseManager, naturalbase); } } // Hatch 3 bauen: static bool trythird = true; if (trythird) if (!tryextension && (extension_task == NULL)) { trythird = false; if (thirdbase != NULL) { new BuildAtTask(toptask, Priority::BuildThirdBase, UnitTypes::Zerg_Hatchery, thirdbase->getTilePosition()); new BaseManagerTask(toptask, Priority::BaseManager, thirdbase); } else { new BuildNearTask(toptask, Priority::BuildThirdBase, UnitTypes::Zerg_Hatchery, mainbase->getTilePosition()); } } } virtual void taskChangedStatus(Task* task) { if ((task == extension_task) && (task->status == TaskStatus::Preforming)) { static bool first_extension_started = true; if (first_extension_started) { first_extension_started = false; // Overlords bauen: new OverlordBuildTask(toptask, Priority::BuildOverlord); // Pool bauen: pool_task = new BuildNearTask(toptask, Priority::BuildPool, UnitTypes::Zerg_Spawning_Pool, mainbase->getTilePosition()); // Gas ernten in Main: BaseManagerTask* mbm = getBaseManager(mainbase); if (mbm != NULL) new GatherGasTask(mbm, Priority::GatherGas, mainbase); } } if ((task == extension_task) && (task->status == TaskStatus::Completed)) { // Gas ernten in Extension: BaseManagerTask* nbm = getBaseManager(naturalbase); if (nbm != NULL) new GatherGasTask(nbm, Priority::GatherGas, naturalbase); } if ((task == extension_task) && (task->status.isFinal())) extension_task = NULL; if ((task == pool_task) && (task->status == TaskStatus::Completed)) { //new ResearchTask(toptask, Priority::ZergSpeed, TechTypes::Infestation); new UpgradeTask(toptask, Priority::ZergSpeed, UpgradeTypes::Metabolic_Boost); // 3 mal Zergliche morphen: for (int k=0; k<3; ++k) new MorphUnitTask(toptask, Priority::FirstZerglings, UnitTypes::Zerg_Zergling); // 3 mal Colony an Natural: for (int k=0; k<3; ++k) new BuildNearTask(toptask, Priority::BuildColony, UnitTypes::Zerg_Creep_Colony, naturalbase->getTilePosition()); new EarlyZerglingTask(toptask, Priority::EarlyZergling); new MorphBuildingTask(toptask, Priority::Lair, UnitTypes::Zerg_Lair); } if ((task == pool_task) && task->status.isFinal()) pool_task = NULL; } private: bool betterBase(BWTA::BaseLocation* base1, BWTA::BaseLocation* base2) const { if (base2 == NULL) return true; int gas1 = base1->getGeysers().size(); int gas2 = base2->getGeysers().size(); if (gas1 > gas2) return true; if (gas1 < gas2) return false; double dis1 = BWTA::getGroundDistance(base1->getTilePosition(), mainbase->getTilePosition()); double dis2 = BWTA::getGroundDistance(base2->getTilePosition(), mainbase->getTilePosition()); if (dis1 < dis2) return true; return false; } BWTA::BaseLocation* findNatural() const { BWTA::Region* mainregion = mainbase->getRegion(); RegionSet neighbours = mainregion->getReachableRegions(); BaseLocationSet bases = mainregion->getBaseLocations(); for (RegionSet::iterator it=neighbours.begin(), itend=neighbours.end(); it!=itend; ++it) { BWTA::Region* n = *it; bases.insert(n->getBaseLocations().begin(), n->getBaseLocations().end()); } bases.erase(mainbase); BWTA::BaseLocation* best = NULL; for (BaseLocationSet::iterator it=bases.begin(), itend=bases.end(); it!=itend; ++it) { if (betterBase(*it, best)) best = *it; } return best; } BWTA::BaseLocation* findThirdBase() const { BaseLocationSet bases = mainregion->getBaseLocations(); BaseLocationSet bases2 = naturalbase->getRegion()->getBaseLocations(); bases.insert(bases2.begin(), bases2.end()); bases.erase(mainbase); bases.erase(naturalbase); BWTA::BaseLocation* best = NULL; for (BaseLocationSet::iterator it=bases.begin(), itend=bases.end(); it!=itend; ++it) { if (betterBase(*it, best)) best = *it; } return best; } BaseManagerTask* getBaseManager(BWTA::BaseLocation* loc) const { for (TaskSet::iterator it=toptask->subtasks.begin(), itend=toptask->subtasks.end(); it!=itend; ++it) { if ((*it)->getName() == BaseManagerTask::getNameStatic()) { BaseManagerTask* t = (BaseManagerTask*) (*it); if (t->base == loc) return t; } } return NULL; } }; #endif
[ "lordblackhawk@gmail.com" ]
lordblackhawk@gmail.com
1eb121c318e731d05544c5ae086af29fecdfe733
02e2accd33e8810cb50bd8555cdb92f2a49301e7
/cegui/src/ScriptModules/Python/bindings/output/CEGUI/ItemListbox.pypp.cpp
5040cc2abfba0f9022246ba97df13a17aa06a22b
[ "MIT" ]
permissive
cegui/cegui
fa6440e848d5aea309006496d2211ddcd41fefdf
35809470b0530608039ab89fc1ffd041cef39434
refs/heads/master
2023-08-25T18:03:36.587944
2023-08-12T15:50:41
2023-08-12T15:50:41
232,757,330
426
78
MIT
2023-08-12T15:40:02
2020-01-09T08:15:37
C++
UTF-8
C++
false
false
171,576
cpp
// This file has been generated by Py++. #include "boost/python.hpp" #include "generators/include/python_CEGUI.h" #include "ItemListbox.pypp.hpp" namespace bp = boost::python; struct ItemListbox_wrapper : CEGUI::ItemListbox, bp::wrapper< CEGUI::ItemListbox > { ItemListbox_wrapper(::CEGUI::String const & type, ::CEGUI::String const & name ) : CEGUI::ItemListbox( boost::ref(type), boost::ref(name) ) , bp::wrapper< CEGUI::ItemListbox >(){ // constructor } ::CEGUI::ItemEntry * findSelectedItem( ::size_t start_index ) const { return CEGUI::ItemListbox::findSelectedItem( start_index ); } virtual ::CEGUI::Sizef getContentSize( ) const { if( bp::override func_getContentSize = this->get_override( "getContentSize" ) ) return func_getContentSize( ); else{ return this->CEGUI::ItemListbox::getContentSize( ); } } ::CEGUI::Sizef default_getContentSize( ) const { return CEGUI::ItemListbox::getContentSize( ); } virtual bool handle_PaneChildRemoved( ::CEGUI::EventArgs const & e ){ if( bp::override func_handle_PaneChildRemoved = this->get_override( "handle_PaneChildRemoved" ) ) return func_handle_PaneChildRemoved( boost::ref(e) ); else{ return this->CEGUI::ItemListbox::handle_PaneChildRemoved( boost::ref(e) ); } } virtual bool default_handle_PaneChildRemoved( ::CEGUI::EventArgs const & e ){ return CEGUI::ItemListbox::handle_PaneChildRemoved( boost::ref(e) ); } virtual void layoutItemWidgets( ) { if( bp::override func_layoutItemWidgets = this->get_override( "layoutItemWidgets" ) ) func_layoutItemWidgets( ); else{ this->CEGUI::ItemListbox::layoutItemWidgets( ); } } void default_layoutItemWidgets( ) { CEGUI::ItemListbox::layoutItemWidgets( ); } virtual void notifyItemClicked( ::CEGUI::ItemEntry * li ) { if( bp::override func_notifyItemClicked = this->get_override( "notifyItemClicked" ) ) func_notifyItemClicked( boost::python::ptr(li) ); else{ this->CEGUI::ItemListbox::notifyItemClicked( boost::python::ptr(li) ); } } void default_notifyItemClicked( ::CEGUI::ItemEntry * li ) { CEGUI::ItemListbox::notifyItemClicked( boost::python::ptr(li) ); } virtual void notifyItemSelectState( ::CEGUI::ItemEntry * li, bool state ) { if( bp::override func_notifyItemSelectState = this->get_override( "notifyItemSelectState" ) ) func_notifyItemSelectState( boost::python::ptr(li), state ); else{ this->CEGUI::ItemListbox::notifyItemSelectState( boost::python::ptr(li), state ); } } void default_notifyItemSelectState( ::CEGUI::ItemEntry * li, bool state ) { CEGUI::ItemListbox::notifyItemSelectState( boost::python::ptr(li), state ); } virtual void onKeyDown( ::CEGUI::KeyEventArgs & e ){ if( bp::override func_onKeyDown = this->get_override( "onKeyDown" ) ) func_onKeyDown( boost::ref(e) ); else{ this->CEGUI::ItemListbox::onKeyDown( boost::ref(e) ); } } virtual void default_onKeyDown( ::CEGUI::KeyEventArgs & e ){ CEGUI::ItemListbox::onKeyDown( boost::ref(e) ); } virtual void onMultiSelectModeChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onMultiSelectModeChanged = this->get_override( "onMultiSelectModeChanged" ) ) func_onMultiSelectModeChanged( boost::ref(e) ); else{ this->CEGUI::ItemListbox::onMultiSelectModeChanged( boost::ref(e) ); } } virtual void default_onMultiSelectModeChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::ItemListbox::onMultiSelectModeChanged( boost::ref(e) ); } virtual void onSelectionChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onSelectionChanged = this->get_override( "onSelectionChanged" ) ) func_onSelectionChanged( boost::ref(e) ); else{ this->CEGUI::ItemListbox::onSelectionChanged( boost::ref(e) ); } } virtual void default_onSelectionChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::ItemListbox::onSelectionChanged( boost::ref(e) ); } virtual void addChild_impl( ::CEGUI::Element * element ){ if( bp::override func_addChild_impl = this->get_override( "addChild_impl" ) ) func_addChild_impl( boost::python::ptr(element) ); else{ this->CEGUI::Window::addChild_impl( boost::python::ptr(element) ); } } virtual void default_addChild_impl( ::CEGUI::Element * element ){ CEGUI::Window::addChild_impl( boost::python::ptr(element) ); } void addElementProperties( ){ CEGUI::Element::addElementProperties( ); } void addNamedElementProperties( ){ CEGUI::NamedElement::addNamedElementProperties( ); } void addWindowProperties( ){ CEGUI::Window::addWindowProperties( ); } void addWindowToDrawList( ::CEGUI::Window & wnd, bool at_back=false ){ CEGUI::Window::addWindowToDrawList( boost::ref(wnd), at_back ); } void allocateRenderingWindow( ){ CEGUI::Window::allocateRenderingWindow( ); } virtual void banPropertiesForAutoWindow( ){ if( bp::override func_banPropertiesForAutoWindow = this->get_override( "banPropertiesForAutoWindow" ) ) func_banPropertiesForAutoWindow( ); else{ this->CEGUI::Window::banPropertiesForAutoWindow( ); } } virtual void default_banPropertiesForAutoWindow( ){ CEGUI::Window::banPropertiesForAutoWindow( ); } virtual void beginInitialisation( ) { if( bp::override func_beginInitialisation = this->get_override( "beginInitialisation" ) ) func_beginInitialisation( ); else{ this->CEGUI::Window::beginInitialisation( ); } } void default_beginInitialisation( ) { CEGUI::Window::beginInitialisation( ); } void bufferGeometry( ::CEGUI::RenderingContext const & ctx ){ CEGUI::Window::bufferGeometry( boost::ref(ctx) ); } virtual void cleanupChildren( ){ if( bp::override func_cleanupChildren = this->get_override( "cleanupChildren" ) ) func_cleanupChildren( ); else{ this->CEGUI::Window::cleanupChildren( ); } } virtual void default_cleanupChildren( ){ CEGUI::Window::cleanupChildren( ); } virtual void cloneChildWidgetsTo( ::CEGUI::Window & target ) const { if( bp::override func_cloneChildWidgetsTo = this->get_override( "cloneChildWidgetsTo" ) ) func_cloneChildWidgetsTo( boost::ref(target) ); else{ this->CEGUI::Window::cloneChildWidgetsTo( boost::ref(target) ); } } void default_cloneChildWidgetsTo( ::CEGUI::Window & target ) const { CEGUI::Window::cloneChildWidgetsTo( boost::ref(target) ); } virtual void clonePropertiesTo( ::CEGUI::Window & target ) const { if( bp::override func_clonePropertiesTo = this->get_override( "clonePropertiesTo" ) ) func_clonePropertiesTo( boost::ref(target) ); else{ this->CEGUI::Window::clonePropertiesTo( boost::ref(target) ); } } void default_clonePropertiesTo( ::CEGUI::Window & target ) const { CEGUI::Window::clonePropertiesTo( boost::ref(target) ); } void configureScrollbars( ::CEGUI::Sizef const & doc_size ){ CEGUI::ScrolledItemListBase::configureScrollbars( boost::ref(doc_size) ); } virtual void destroy( ) { if( bp::override func_destroy = this->get_override( "destroy" ) ) func_destroy( ); else{ this->CEGUI::Window::destroy( ); } } void default_destroy( ) { CEGUI::Window::destroy( ); } virtual void drawSelf( ::CEGUI::RenderingContext const & ctx ){ if( bp::override func_drawSelf = this->get_override( "drawSelf" ) ) func_drawSelf( boost::ref(ctx) ); else{ this->CEGUI::Window::drawSelf( boost::ref(ctx) ); } } virtual void default_drawSelf( ::CEGUI::RenderingContext const & ctx ){ CEGUI::Window::drawSelf( boost::ref(ctx) ); } virtual void endInitialisation( ) { if( bp::override func_endInitialisation = this->get_override( "endInitialisation" ) ) func_endInitialisation( ); else{ this->CEGUI::ItemListBase::endInitialisation( ); } } void default_endInitialisation( ) { CEGUI::ItemListBase::endInitialisation( ); } void fireAreaChangeEvents( bool const moved, bool const sized ){ CEGUI::Element::fireAreaChangeEvents( moved, sized ); } virtual void fireEvent( ::CEGUI::String const & name, ::CEGUI::EventArgs & args, ::CEGUI::String const & eventNamespace="" ) { if( bp::override func_fireEvent = this->get_override( "fireEvent" ) ) func_fireEvent( boost::ref(name), boost::ref(args), boost::ref(eventNamespace) ); else{ this->CEGUI::EventSet::fireEvent( boost::ref(name), boost::ref(args), boost::ref(eventNamespace) ); } } void default_fireEvent( ::CEGUI::String const & name, ::CEGUI::EventArgs & args, ::CEGUI::String const & eventNamespace="" ) { CEGUI::EventSet::fireEvent( boost::ref(name), boost::ref(args), boost::ref(eventNamespace) ); } void fireEvent_impl( ::CEGUI::String const & name, ::CEGUI::EventArgs & args ){ CEGUI::EventSet::fireEvent_impl( boost::ref(name), boost::ref(args) ); } void generateAutoRepeatEvent( ::CEGUI::MouseButton button ){ CEGUI::Window::generateAutoRepeatEvent( button ); } virtual ::CEGUI::NamedElement * getChildByNamePath_impl( ::CEGUI::String const & name_path ) const { if( bp::override func_getChildByNamePath_impl = this->get_override( "getChildByNamePath_impl" ) ) return func_getChildByNamePath_impl( boost::ref(name_path) ); else{ return this->CEGUI::NamedElement::getChildByNamePath_impl( boost::ref(name_path) ); } } virtual ::CEGUI::NamedElement * default_getChildByNamePath_impl( ::CEGUI::String const & name_path ) const { return CEGUI::NamedElement::getChildByNamePath_impl( boost::ref(name_path) ); } virtual ::CEGUI::NamedElement * getChildByNameRecursive_impl( ::CEGUI::String const & name ) const { if( bp::override func_getChildByNameRecursive_impl = this->get_override( "getChildByNameRecursive_impl" ) ) return func_getChildByNameRecursive_impl( boost::ref(name) ); else{ return this->CEGUI::NamedElement::getChildByNameRecursive_impl( boost::ref(name) ); } } virtual ::CEGUI::NamedElement * default_getChildByNameRecursive_impl( ::CEGUI::String const & name ) const { return CEGUI::NamedElement::getChildByNameRecursive_impl( boost::ref(name) ); } virtual ::CEGUI::Rectf getHitTestRect_impl( ) const { if( bp::override func_getHitTestRect_impl = this->get_override( "getHitTestRect_impl" ) ) return func_getHitTestRect_impl( ); else{ return this->CEGUI::Window::getHitTestRect_impl( ); } } virtual ::CEGUI::Rectf default_getHitTestRect_impl( ) const { return CEGUI::Window::getHitTestRect_impl( ); } virtual ::CEGUI::Rectf getInnerRectClipper_impl( ) const { if( bp::override func_getInnerRectClipper_impl = this->get_override( "getInnerRectClipper_impl" ) ) return func_getInnerRectClipper_impl( ); else{ return this->CEGUI::Window::getInnerRectClipper_impl( ); } } virtual ::CEGUI::Rectf default_getInnerRectClipper_impl( ) const { return CEGUI::Window::getInnerRectClipper_impl( ); } virtual ::CEGUI::Rectf getOuterRectClipper_impl( ) const { if( bp::override func_getOuterRectClipper_impl = this->get_override( "getOuterRectClipper_impl" ) ) return func_getOuterRectClipper_impl( ); else{ return this->CEGUI::Window::getOuterRectClipper_impl( ); } } virtual ::CEGUI::Rectf default_getOuterRectClipper_impl( ) const { return CEGUI::Window::getOuterRectClipper_impl( ); } ::CEGUI::Rectf getParentElementClipIntersection( ::CEGUI::Rectf const & unclipped_area ) const { return CEGUI::Window::getParentElementClipIntersection( boost::ref(unclipped_area) ); } virtual void getRenderingContext_impl( ::CEGUI::RenderingContext & ctx ) const { if( bp::override func_getRenderingContext_impl = this->get_override( "getRenderingContext_impl" ) ) func_getRenderingContext_impl( boost::ref(ctx) ); else{ this->CEGUI::Window::getRenderingContext_impl( boost::ref(ctx) ); } } void default_getRenderingContext_impl( ::CEGUI::RenderingContext & ctx ) const { CEGUI::Window::getRenderingContext_impl( boost::ref(ctx) ); } ::CEGUI::ScriptModule * getScriptModule( ) const { return CEGUI::EventSet::getScriptModule( ); } virtual ::CEGUI::Rectf getUnclippedInnerRect_impl( bool skipAllPixelAlignment ) const { if( bp::override func_getUnclippedInnerRect_impl = this->get_override( "getUnclippedInnerRect_impl" ) ) return func_getUnclippedInnerRect_impl( skipAllPixelAlignment ); else{ return this->CEGUI::Window::getUnclippedInnerRect_impl( skipAllPixelAlignment ); } } virtual ::CEGUI::Rectf default_getUnclippedInnerRect_impl( bool skipAllPixelAlignment ) const { return CEGUI::Window::getUnclippedInnerRect_impl( skipAllPixelAlignment ); } virtual ::CEGUI::Rectf getUnclippedOuterRect_impl( bool skipAllPixelAlignment ) const { if( bp::override func_getUnclippedOuterRect_impl = this->get_override( "getUnclippedOuterRect_impl" ) ) return func_getUnclippedOuterRect_impl( skipAllPixelAlignment ); else{ return this->CEGUI::Element::getUnclippedOuterRect_impl( skipAllPixelAlignment ); } } virtual ::CEGUI::Rectf default_getUnclippedOuterRect_impl( bool skipAllPixelAlignment ) const { return CEGUI::Element::getUnclippedOuterRect_impl( skipAllPixelAlignment ); } ::CEGUI::Window const * getWindowAttachedToCommonAncestor( ::CEGUI::Window const & wnd ) const { return CEGUI::Window::getWindowAttachedToCommonAncestor( boost::ref(wnd) ); } virtual bool handleFontRenderSizeChange( ::CEGUI::EventArgs const & args ){ if( bp::override func_handleFontRenderSizeChange = this->get_override( "handleFontRenderSizeChange" ) ) return func_handleFontRenderSizeChange( boost::ref(args) ); else{ return this->CEGUI::Window::handleFontRenderSizeChange( boost::ref(args) ); } } virtual bool default_handleFontRenderSizeChange( ::CEGUI::EventArgs const & args ){ return CEGUI::Window::handleFontRenderSizeChange( boost::ref(args) ); } bool handle_HScroll( ::CEGUI::EventArgs const & e ){ return CEGUI::ScrolledItemListBase::handle_HScroll( boost::ref(e) ); } bool handle_VScroll( ::CEGUI::EventArgs const & e ){ return CEGUI::ScrolledItemListBase::handle_VScroll( boost::ref(e) ); } void initialiseClippers( ::CEGUI::RenderingContext const & ctx ){ CEGUI::Window::initialiseClippers( boost::ref(ctx) ); } virtual void initialiseComponents( ) { if( bp::override func_initialiseComponents = this->get_override( "initialiseComponents" ) ) func_initialiseComponents( ); else{ this->CEGUI::ScrolledItemListBase::initialiseComponents( ); } } void default_initialiseComponents( ) { CEGUI::ScrolledItemListBase::initialiseComponents( ); } void invalidate_impl( bool const recursive ){ CEGUI::Window::invalidate_impl( recursive ); } virtual bool isHit( ::CEGUI::Vector2f const & position, bool const allow_disabled=false ) const { if( bp::override func_isHit = this->get_override( "isHit" ) ) return func_isHit( boost::ref(position), allow_disabled ); else{ return this->CEGUI::Window::isHit( boost::ref(position), allow_disabled ); } } bool default_isHit( ::CEGUI::Vector2f const & position, bool const allow_disabled=false ) const { return CEGUI::Window::isHit( boost::ref(position), allow_disabled ); } bool isHitTargetWindow( ::CEGUI::Vector2f const & position, bool allow_disabled ) const { return CEGUI::Window::isHitTargetWindow( boost::ref(position), allow_disabled ); } bool isInnerRectSizeChanged( ) const { return CEGUI::Element::isInnerRectSizeChanged( ); } bool isPropertyAtDefault( ::CEGUI::Property const * property ) const { return CEGUI::Window::isPropertyAtDefault( boost::python::ptr(property) ); } bool isTopOfZOrder( ) const { return CEGUI::Window::isTopOfZOrder( ); } void layoutLookNFeelChildWidgets( ){ CEGUI::Window::layoutLookNFeelChildWidgets( ); } void markCachedWindowRectsInvalid( ){ CEGUI::Window::markCachedWindowRectsInvalid( ); } virtual bool moveToFront_impl( bool wasClicked ){ if( bp::override func_moveToFront_impl = this->get_override( "moveToFront_impl" ) ) return func_moveToFront_impl( wasClicked ); else{ return this->CEGUI::Window::moveToFront_impl( wasClicked ); } } virtual bool default_moveToFront_impl( bool wasClicked ){ return CEGUI::Window::moveToFront_impl( wasClicked ); } void notifyChildrenOfSizeChange( bool const non_client, bool const client ){ CEGUI::Element::notifyChildrenOfSizeChange( non_client, client ); } void notifyClippingChanged( ){ CEGUI::Window::notifyClippingChanged( ); } virtual void notifyScreenAreaChanged( bool recursive=true ) { if( bp::override func_notifyScreenAreaChanged = this->get_override( "notifyScreenAreaChanged" ) ) func_notifyScreenAreaChanged( recursive ); else{ this->CEGUI::Window::notifyScreenAreaChanged( recursive ); } } void default_notifyScreenAreaChanged( bool recursive=true ) { CEGUI::Window::notifyScreenAreaChanged( recursive ); } virtual void onActivated( ::CEGUI::ActivationEventArgs & e ){ if( bp::override func_onActivated = this->get_override( "onActivated" ) ) func_onActivated( boost::ref(e) ); else{ this->CEGUI::Window::onActivated( boost::ref(e) ); } } virtual void default_onActivated( ::CEGUI::ActivationEventArgs & e ){ CEGUI::Window::onActivated( boost::ref(e) ); } virtual void onAlphaChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onAlphaChanged = this->get_override( "onAlphaChanged" ) ) func_onAlphaChanged( boost::ref(e) ); else{ this->CEGUI::Window::onAlphaChanged( boost::ref(e) ); } } virtual void default_onAlphaChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onAlphaChanged( boost::ref(e) ); } virtual void onAlwaysOnTopChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onAlwaysOnTopChanged = this->get_override( "onAlwaysOnTopChanged" ) ) func_onAlwaysOnTopChanged( boost::ref(e) ); else{ this->CEGUI::Window::onAlwaysOnTopChanged( boost::ref(e) ); } } virtual void default_onAlwaysOnTopChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onAlwaysOnTopChanged( boost::ref(e) ); } virtual void onCaptureGained( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onCaptureGained = this->get_override( "onCaptureGained" ) ) func_onCaptureGained( boost::ref(e) ); else{ this->CEGUI::Window::onCaptureGained( boost::ref(e) ); } } virtual void default_onCaptureGained( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onCaptureGained( boost::ref(e) ); } virtual void onCaptureLost( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onCaptureLost = this->get_override( "onCaptureLost" ) ) func_onCaptureLost( boost::ref(e) ); else{ this->CEGUI::Window::onCaptureLost( boost::ref(e) ); } } virtual void default_onCaptureLost( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onCaptureLost( boost::ref(e) ); } virtual void onCharacter( ::CEGUI::KeyEventArgs & e ){ if( bp::override func_onCharacter = this->get_override( "onCharacter" ) ) func_onCharacter( boost::ref(e) ); else{ this->CEGUI::Window::onCharacter( boost::ref(e) ); } } virtual void default_onCharacter( ::CEGUI::KeyEventArgs & e ){ CEGUI::Window::onCharacter( boost::ref(e) ); } virtual void onChildAdded( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onChildAdded = this->get_override( "onChildAdded" ) ) func_onChildAdded( boost::ref(e) ); else{ this->CEGUI::Window::onChildAdded( boost::ref(e) ); } } virtual void default_onChildAdded( ::CEGUI::ElementEventArgs & e ){ CEGUI::Window::onChildAdded( boost::ref(e) ); } virtual void onChildRemoved( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onChildRemoved = this->get_override( "onChildRemoved" ) ) func_onChildRemoved( boost::ref(e) ); else{ this->CEGUI::Window::onChildRemoved( boost::ref(e) ); } } virtual void default_onChildRemoved( ::CEGUI::ElementEventArgs & e ){ CEGUI::Window::onChildRemoved( boost::ref(e) ); } virtual void onClippingChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onClippingChanged = this->get_override( "onClippingChanged" ) ) func_onClippingChanged( boost::ref(e) ); else{ this->CEGUI::Window::onClippingChanged( boost::ref(e) ); } } virtual void default_onClippingChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onClippingChanged( boost::ref(e) ); } virtual void onDeactivated( ::CEGUI::ActivationEventArgs & e ){ if( bp::override func_onDeactivated = this->get_override( "onDeactivated" ) ) func_onDeactivated( boost::ref(e) ); else{ this->CEGUI::Window::onDeactivated( boost::ref(e) ); } } virtual void default_onDeactivated( ::CEGUI::ActivationEventArgs & e ){ CEGUI::Window::onDeactivated( boost::ref(e) ); } virtual void onDestructionStarted( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onDestructionStarted = this->get_override( "onDestructionStarted" ) ) func_onDestructionStarted( boost::ref(e) ); else{ this->CEGUI::Window::onDestructionStarted( boost::ref(e) ); } } virtual void default_onDestructionStarted( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onDestructionStarted( boost::ref(e) ); } virtual void onDisabled( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onDisabled = this->get_override( "onDisabled" ) ) func_onDisabled( boost::ref(e) ); else{ this->CEGUI::Window::onDisabled( boost::ref(e) ); } } virtual void default_onDisabled( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onDisabled( boost::ref(e) ); } virtual void onDragDropItemDropped( ::CEGUI::DragDropEventArgs & e ){ if( bp::override func_onDragDropItemDropped = this->get_override( "onDragDropItemDropped" ) ) func_onDragDropItemDropped( boost::ref(e) ); else{ this->CEGUI::Window::onDragDropItemDropped( boost::ref(e) ); } } virtual void default_onDragDropItemDropped( ::CEGUI::DragDropEventArgs & e ){ CEGUI::Window::onDragDropItemDropped( boost::ref(e) ); } virtual void onDragDropItemEnters( ::CEGUI::DragDropEventArgs & e ){ if( bp::override func_onDragDropItemEnters = this->get_override( "onDragDropItemEnters" ) ) func_onDragDropItemEnters( boost::ref(e) ); else{ this->CEGUI::Window::onDragDropItemEnters( boost::ref(e) ); } } virtual void default_onDragDropItemEnters( ::CEGUI::DragDropEventArgs & e ){ CEGUI::Window::onDragDropItemEnters( boost::ref(e) ); } virtual void onDragDropItemLeaves( ::CEGUI::DragDropEventArgs & e ){ if( bp::override func_onDragDropItemLeaves = this->get_override( "onDragDropItemLeaves" ) ) func_onDragDropItemLeaves( boost::ref(e) ); else{ this->CEGUI::Window::onDragDropItemLeaves( boost::ref(e) ); } } virtual void default_onDragDropItemLeaves( ::CEGUI::DragDropEventArgs & e ){ CEGUI::Window::onDragDropItemLeaves( boost::ref(e) ); } virtual void onEnabled( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onEnabled = this->get_override( "onEnabled" ) ) func_onEnabled( boost::ref(e) ); else{ this->CEGUI::Window::onEnabled( boost::ref(e) ); } } virtual void default_onEnabled( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onEnabled( boost::ref(e) ); } virtual void onFontChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onFontChanged = this->get_override( "onFontChanged" ) ) func_onFontChanged( boost::ref(e) ); else{ this->CEGUI::Window::onFontChanged( boost::ref(e) ); } } virtual void default_onFontChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onFontChanged( boost::ref(e) ); } virtual void onHidden( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onHidden = this->get_override( "onHidden" ) ) func_onHidden( boost::ref(e) ); else{ this->CEGUI::Window::onHidden( boost::ref(e) ); } } virtual void default_onHidden( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onHidden( boost::ref(e) ); } virtual void onHorizontalAlignmentChanged( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onHorizontalAlignmentChanged = this->get_override( "onHorizontalAlignmentChanged" ) ) func_onHorizontalAlignmentChanged( boost::ref(e) ); else{ this->CEGUI::Element::onHorizontalAlignmentChanged( boost::ref(e) ); } } virtual void default_onHorizontalAlignmentChanged( ::CEGUI::ElementEventArgs & e ){ CEGUI::Element::onHorizontalAlignmentChanged( boost::ref(e) ); } virtual void onHorzScrollbarModeChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onHorzScrollbarModeChanged = this->get_override( "onHorzScrollbarModeChanged" ) ) func_onHorzScrollbarModeChanged( boost::ref(e) ); else{ this->CEGUI::ScrolledItemListBase::onHorzScrollbarModeChanged( boost::ref(e) ); } } virtual void default_onHorzScrollbarModeChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::ScrolledItemListBase::onHorzScrollbarModeChanged( boost::ref(e) ); } virtual void onIDChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onIDChanged = this->get_override( "onIDChanged" ) ) func_onIDChanged( boost::ref(e) ); else{ this->CEGUI::Window::onIDChanged( boost::ref(e) ); } } virtual void default_onIDChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onIDChanged( boost::ref(e) ); } virtual void onInheritsAlphaChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onInheritsAlphaChanged = this->get_override( "onInheritsAlphaChanged" ) ) func_onInheritsAlphaChanged( boost::ref(e) ); else{ this->CEGUI::Window::onInheritsAlphaChanged( boost::ref(e) ); } } virtual void default_onInheritsAlphaChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onInheritsAlphaChanged( boost::ref(e) ); } virtual void onInvalidated( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onInvalidated = this->get_override( "onInvalidated" ) ) func_onInvalidated( boost::ref(e) ); else{ this->CEGUI::Window::onInvalidated( boost::ref(e) ); } } virtual void default_onInvalidated( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onInvalidated( boost::ref(e) ); } virtual void onKeyUp( ::CEGUI::KeyEventArgs & e ){ if( bp::override func_onKeyUp = this->get_override( "onKeyUp" ) ) func_onKeyUp( boost::ref(e) ); else{ this->CEGUI::Window::onKeyUp( boost::ref(e) ); } } virtual void default_onKeyUp( ::CEGUI::KeyEventArgs & e ){ CEGUI::Window::onKeyUp( boost::ref(e) ); } virtual void onListContentsChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onListContentsChanged = this->get_override( "onListContentsChanged" ) ) func_onListContentsChanged( boost::ref(e) ); else{ this->CEGUI::ItemListBase::onListContentsChanged( boost::ref(e) ); } } virtual void default_onListContentsChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::ItemListBase::onListContentsChanged( boost::ref(e) ); } virtual void onMarginChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onMarginChanged = this->get_override( "onMarginChanged" ) ) func_onMarginChanged( boost::ref(e) ); else{ this->CEGUI::Window::onMarginChanged( boost::ref(e) ); } } virtual void default_onMarginChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onMarginChanged( boost::ref(e) ); } virtual void onMouseButtonDown( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseButtonDown = this->get_override( "onMouseButtonDown" ) ) func_onMouseButtonDown( boost::ref(e) ); else{ this->CEGUI::Window::onMouseButtonDown( boost::ref(e) ); } } virtual void default_onMouseButtonDown( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseButtonDown( boost::ref(e) ); } virtual void onMouseButtonUp( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseButtonUp = this->get_override( "onMouseButtonUp" ) ) func_onMouseButtonUp( boost::ref(e) ); else{ this->CEGUI::Window::onMouseButtonUp( boost::ref(e) ); } } virtual void default_onMouseButtonUp( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseButtonUp( boost::ref(e) ); } virtual void onMouseClicked( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseClicked = this->get_override( "onMouseClicked" ) ) func_onMouseClicked( boost::ref(e) ); else{ this->CEGUI::Window::onMouseClicked( boost::ref(e) ); } } virtual void default_onMouseClicked( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseClicked( boost::ref(e) ); } virtual void onMouseDoubleClicked( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseDoubleClicked = this->get_override( "onMouseDoubleClicked" ) ) func_onMouseDoubleClicked( boost::ref(e) ); else{ this->CEGUI::Window::onMouseDoubleClicked( boost::ref(e) ); } } virtual void default_onMouseDoubleClicked( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseDoubleClicked( boost::ref(e) ); } virtual void onMouseEnters( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseEnters = this->get_override( "onMouseEnters" ) ) func_onMouseEnters( boost::ref(e) ); else{ this->CEGUI::Window::onMouseEnters( boost::ref(e) ); } } virtual void default_onMouseEnters( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseEnters( boost::ref(e) ); } virtual void onMouseEntersArea( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseEntersArea = this->get_override( "onMouseEntersArea" ) ) func_onMouseEntersArea( boost::ref(e) ); else{ this->CEGUI::Window::onMouseEntersArea( boost::ref(e) ); } } virtual void default_onMouseEntersArea( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseEntersArea( boost::ref(e) ); } virtual void onMouseLeaves( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseLeaves = this->get_override( "onMouseLeaves" ) ) func_onMouseLeaves( boost::ref(e) ); else{ this->CEGUI::Window::onMouseLeaves( boost::ref(e) ); } } virtual void default_onMouseLeaves( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseLeaves( boost::ref(e) ); } virtual void onMouseLeavesArea( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseLeavesArea = this->get_override( "onMouseLeavesArea" ) ) func_onMouseLeavesArea( boost::ref(e) ); else{ this->CEGUI::Window::onMouseLeavesArea( boost::ref(e) ); } } virtual void default_onMouseLeavesArea( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseLeavesArea( boost::ref(e) ); } virtual void onMouseMove( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseMove = this->get_override( "onMouseMove" ) ) func_onMouseMove( boost::ref(e) ); else{ this->CEGUI::Window::onMouseMove( boost::ref(e) ); } } virtual void default_onMouseMove( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseMove( boost::ref(e) ); } virtual void onMouseTripleClicked( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseTripleClicked = this->get_override( "onMouseTripleClicked" ) ) func_onMouseTripleClicked( boost::ref(e) ); else{ this->CEGUI::Window::onMouseTripleClicked( boost::ref(e) ); } } virtual void default_onMouseTripleClicked( ::CEGUI::MouseEventArgs & e ){ CEGUI::Window::onMouseTripleClicked( boost::ref(e) ); } virtual void onMouseWheel( ::CEGUI::MouseEventArgs & e ){ if( bp::override func_onMouseWheel = this->get_override( "onMouseWheel" ) ) func_onMouseWheel( boost::ref(e) ); else{ this->CEGUI::ScrolledItemListBase::onMouseWheel( boost::ref(e) ); } } virtual void default_onMouseWheel( ::CEGUI::MouseEventArgs & e ){ CEGUI::ScrolledItemListBase::onMouseWheel( boost::ref(e) ); } virtual void onMoved( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onMoved = this->get_override( "onMoved" ) ) func_onMoved( boost::ref(e) ); else{ this->CEGUI::Window::onMoved( boost::ref(e) ); } } virtual void default_onMoved( ::CEGUI::ElementEventArgs & e ){ CEGUI::Window::onMoved( boost::ref(e) ); } virtual void onNameChanged( ::CEGUI::NamedElementEventArgs & e ){ if( bp::override func_onNameChanged = this->get_override( "onNameChanged" ) ) func_onNameChanged( boost::ref(e) ); else{ this->CEGUI::NamedElement::onNameChanged( boost::ref(e) ); } } virtual void default_onNameChanged( ::CEGUI::NamedElementEventArgs & e ){ CEGUI::NamedElement::onNameChanged( boost::ref(e) ); } virtual void onNonClientChanged( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onNonClientChanged = this->get_override( "onNonClientChanged" ) ) func_onNonClientChanged( boost::ref(e) ); else{ this->CEGUI::Element::onNonClientChanged( boost::ref(e) ); } } virtual void default_onNonClientChanged( ::CEGUI::ElementEventArgs & e ){ CEGUI::Element::onNonClientChanged( boost::ref(e) ); } virtual void onParentDestroyChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onParentDestroyChanged = this->get_override( "onParentDestroyChanged" ) ) func_onParentDestroyChanged( boost::ref(e) ); else{ this->CEGUI::Window::onParentDestroyChanged( boost::ref(e) ); } } virtual void default_onParentDestroyChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onParentDestroyChanged( boost::ref(e) ); } virtual void onParentSized( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onParentSized = this->get_override( "onParentSized" ) ) func_onParentSized( boost::ref(e) ); else{ this->CEGUI::ItemListBase::onParentSized( boost::ref(e) ); } } virtual void default_onParentSized( ::CEGUI::ElementEventArgs & e ){ CEGUI::ItemListBase::onParentSized( boost::ref(e) ); } virtual void onRenderingEnded( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onRenderingEnded = this->get_override( "onRenderingEnded" ) ) func_onRenderingEnded( boost::ref(e) ); else{ this->CEGUI::Window::onRenderingEnded( boost::ref(e) ); } } virtual void default_onRenderingEnded( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onRenderingEnded( boost::ref(e) ); } virtual void onRenderingStarted( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onRenderingStarted = this->get_override( "onRenderingStarted" ) ) func_onRenderingStarted( boost::ref(e) ); else{ this->CEGUI::Window::onRenderingStarted( boost::ref(e) ); } } virtual void default_onRenderingStarted( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onRenderingStarted( boost::ref(e) ); } virtual void onRotated( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onRotated = this->get_override( "onRotated" ) ) func_onRotated( boost::ref(e) ); else{ this->CEGUI::Window::onRotated( boost::ref(e) ); } } virtual void default_onRotated( ::CEGUI::ElementEventArgs & e ){ CEGUI::Window::onRotated( boost::ref(e) ); } virtual void onShown( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onShown = this->get_override( "onShown" ) ) func_onShown( boost::ref(e) ); else{ this->CEGUI::Window::onShown( boost::ref(e) ); } } virtual void default_onShown( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onShown( boost::ref(e) ); } virtual void onSized( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onSized = this->get_override( "onSized" ) ) func_onSized( boost::ref(e) ); else{ this->CEGUI::Window::onSized( boost::ref(e) ); } } virtual void default_onSized( ::CEGUI::ElementEventArgs & e ){ CEGUI::Window::onSized( boost::ref(e) ); } virtual void onSortEnabledChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onSortEnabledChanged = this->get_override( "onSortEnabledChanged" ) ) func_onSortEnabledChanged( boost::ref(e) ); else{ this->CEGUI::ItemListBase::onSortEnabledChanged( boost::ref(e) ); } } virtual void default_onSortEnabledChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::ItemListBase::onSortEnabledChanged( boost::ref(e) ); } virtual void onSortModeChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onSortModeChanged = this->get_override( "onSortModeChanged" ) ) func_onSortModeChanged( boost::ref(e) ); else{ this->CEGUI::ItemListBase::onSortModeChanged( boost::ref(e) ); } } virtual void default_onSortModeChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::ItemListBase::onSortModeChanged( boost::ref(e) ); } virtual void onTextChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onTextChanged = this->get_override( "onTextChanged" ) ) func_onTextChanged( boost::ref(e) ); else{ this->CEGUI::Window::onTextChanged( boost::ref(e) ); } } virtual void default_onTextChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onTextChanged( boost::ref(e) ); } virtual void onTextParsingChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onTextParsingChanged = this->get_override( "onTextParsingChanged" ) ) func_onTextParsingChanged( boost::ref(e) ); else{ this->CEGUI::Window::onTextParsingChanged( boost::ref(e) ); } } virtual void default_onTextParsingChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onTextParsingChanged( boost::ref(e) ); } virtual void onVertScrollbarModeChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onVertScrollbarModeChanged = this->get_override( "onVertScrollbarModeChanged" ) ) func_onVertScrollbarModeChanged( boost::ref(e) ); else{ this->CEGUI::ScrolledItemListBase::onVertScrollbarModeChanged( boost::ref(e) ); } } virtual void default_onVertScrollbarModeChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::ScrolledItemListBase::onVertScrollbarModeChanged( boost::ref(e) ); } virtual void onVerticalAlignmentChanged( ::CEGUI::ElementEventArgs & e ){ if( bp::override func_onVerticalAlignmentChanged = this->get_override( "onVerticalAlignmentChanged" ) ) func_onVerticalAlignmentChanged( boost::ref(e) ); else{ this->CEGUI::Element::onVerticalAlignmentChanged( boost::ref(e) ); } } virtual void default_onVerticalAlignmentChanged( ::CEGUI::ElementEventArgs & e ){ CEGUI::Element::onVerticalAlignmentChanged( boost::ref(e) ); } virtual void onWindowRendererAttached( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onWindowRendererAttached = this->get_override( "onWindowRendererAttached" ) ) func_onWindowRendererAttached( boost::ref(e) ); else{ this->CEGUI::Window::onWindowRendererAttached( boost::ref(e) ); } } virtual void default_onWindowRendererAttached( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onWindowRendererAttached( boost::ref(e) ); } virtual void onWindowRendererDetached( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onWindowRendererDetached = this->get_override( "onWindowRendererDetached" ) ) func_onWindowRendererDetached( boost::ref(e) ); else{ this->CEGUI::Window::onWindowRendererDetached( boost::ref(e) ); } } virtual void default_onWindowRendererDetached( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onWindowRendererDetached( boost::ref(e) ); } virtual void onZChange_impl( ){ if( bp::override func_onZChange_impl = this->get_override( "onZChange_impl" ) ) func_onZChange_impl( ); else{ this->CEGUI::Window::onZChange_impl( ); } } virtual void default_onZChange_impl( ){ CEGUI::Window::onZChange_impl( ); } virtual void onZChanged( ::CEGUI::WindowEventArgs & e ){ if( bp::override func_onZChanged = this->get_override( "onZChanged" ) ) func_onZChanged( boost::ref(e) ); else{ this->CEGUI::Window::onZChanged( boost::ref(e) ); } } virtual void default_onZChanged( ::CEGUI::WindowEventArgs & e ){ CEGUI::Window::onZChanged( boost::ref(e) ); } virtual void performChildWindowLayout( bool nonclient_sized_hint=false, bool client_sized_hint=false ) { if( bp::override func_performChildWindowLayout = this->get_override( "performChildWindowLayout" ) ) func_performChildWindowLayout( nonclient_sized_hint, client_sized_hint ); else{ this->CEGUI::ItemListBase::performChildWindowLayout( nonclient_sized_hint, client_sized_hint ); } } void default_performChildWindowLayout( bool nonclient_sized_hint=false, bool client_sized_hint=false ) { CEGUI::ItemListBase::performChildWindowLayout( nonclient_sized_hint, client_sized_hint ); } virtual bool performCopy( ::CEGUI::Clipboard & clipboard ) { if( bp::override func_performCopy = this->get_override( "performCopy" ) ) return func_performCopy( boost::ref(clipboard) ); else{ return this->CEGUI::Window::performCopy( boost::ref(clipboard) ); } } bool default_performCopy( ::CEGUI::Clipboard & clipboard ) { return CEGUI::Window::performCopy( boost::ref(clipboard) ); } virtual bool performCut( ::CEGUI::Clipboard & clipboard ) { if( bp::override func_performCut = this->get_override( "performCut" ) ) return func_performCut( boost::ref(clipboard) ); else{ return this->CEGUI::Window::performCut( boost::ref(clipboard) ); } } bool default_performCut( ::CEGUI::Clipboard & clipboard ) { return CEGUI::Window::performCut( boost::ref(clipboard) ); } virtual bool performPaste( ::CEGUI::Clipboard & clipboard ) { if( bp::override func_performPaste = this->get_override( "performPaste" ) ) return func_performPaste( boost::ref(clipboard) ); else{ return this->CEGUI::Window::performPaste( boost::ref(clipboard) ); } } bool default_performPaste( ::CEGUI::Clipboard & clipboard ) { return CEGUI::Window::performPaste( boost::ref(clipboard) ); } virtual void populateGeometryBuffer( ){ if( bp::override func_populateGeometryBuffer = this->get_override( "populateGeometryBuffer" ) ) func_populateGeometryBuffer( ); else{ this->CEGUI::Window::populateGeometryBuffer( ); } } virtual void default_populateGeometryBuffer( ){ CEGUI::Window::populateGeometryBuffer( ); } void queueGeometry( ::CEGUI::RenderingContext const & ctx ){ CEGUI::Window::queueGeometry( boost::ref(ctx) ); } void releaseRenderingWindow( ){ CEGUI::Window::releaseRenderingWindow( ); } virtual void removeChild_impl( ::CEGUI::Element * element ){ if( bp::override func_removeChild_impl = this->get_override( "removeChild_impl" ) ) func_removeChild_impl( boost::python::ptr(element) ); else{ this->CEGUI::Window::removeChild_impl( boost::python::ptr(element) ); } } virtual void default_removeChild_impl( ::CEGUI::Element * element ){ CEGUI::Window::removeChild_impl( boost::python::ptr(element) ); } void removeWindowFromDrawList( ::CEGUI::Window const & wnd ){ CEGUI::Window::removeWindowFromDrawList( boost::ref(wnd) ); } bool resetList_impl( ){ return CEGUI::ItemListBase::resetList_impl( ); } virtual void setArea( ::CEGUI::UVector2 const & pos, ::CEGUI::USize const & size ) { if( bp::override func_setArea = this->get_override( "setArea" ) ) func_setArea( boost::ref(pos), boost::ref(size) ); else{ this->CEGUI::Element::setArea( boost::ref(pos), boost::ref(size) ); } } void default_setArea( ::CEGUI::UVector2 const & pos, ::CEGUI::USize const & size ) { CEGUI::Element::setArea( boost::ref(pos), boost::ref(size) ); } virtual void setArea_impl( ::CEGUI::UVector2 const & pos, ::CEGUI::USize const & size, bool topLeftSizing=false, bool fireEvents=true ){ if( bp::override func_setArea_impl = this->get_override( "setArea_impl" ) ) func_setArea_impl( boost::ref(pos), boost::ref(size), topLeftSizing, fireEvents ); else{ this->CEGUI::Window::setArea_impl( boost::ref(pos), boost::ref(size), topLeftSizing, fireEvents ); } } virtual void default_setArea_impl( ::CEGUI::UVector2 const & pos, ::CEGUI::USize const & size, bool topLeftSizing=false, bool fireEvents=true ){ CEGUI::Window::setArea_impl( boost::ref(pos), boost::ref(size), topLeftSizing, fireEvents ); } virtual void setHorizontalAlignment( ::CEGUI::HorizontalAlignment const alignment ) { if( bp::override func_setHorizontalAlignment = this->get_override( "setHorizontalAlignment" ) ) func_setHorizontalAlignment( alignment ); else{ this->CEGUI::Element::setHorizontalAlignment( alignment ); } } void default_setHorizontalAlignment( ::CEGUI::HorizontalAlignment const alignment ) { CEGUI::Element::setHorizontalAlignment( alignment ); } virtual void setLookNFeel( ::CEGUI::String const & look ) { if( bp::override func_setLookNFeel = this->get_override( "setLookNFeel" ) ) func_setLookNFeel( boost::ref(look) ); else{ this->CEGUI::Window::setLookNFeel( boost::ref(look) ); } } void default_setLookNFeel( ::CEGUI::String const & look ) { CEGUI::Window::setLookNFeel( boost::ref(look) ); } virtual void setMargin( ::CEGUI::UBox const & margin ) { if( bp::override func_setMargin = this->get_override( "setMargin" ) ) func_setMargin( boost::ref(margin) ); else{ this->CEGUI::Window::setMargin( boost::ref(margin) ); } } void default_setMargin( ::CEGUI::UBox const & margin ) { CEGUI::Window::setMargin( boost::ref(margin) ); } virtual void setName( ::CEGUI::String const & name ) { if( bp::override func_setName = this->get_override( "setName" ) ) func_setName( boost::ref(name) ); else{ this->CEGUI::NamedElement::setName( boost::ref(name) ); } } void default_setName( ::CEGUI::String const & name ) { CEGUI::NamedElement::setName( boost::ref(name) ); } virtual void setParent( ::CEGUI::Element * parent ){ if( bp::override func_setParent = this->get_override( "setParent" ) ) func_setParent( boost::python::ptr(parent) ); else{ this->CEGUI::Window::setParent( boost::python::ptr(parent) ); } } virtual void default_setParent( ::CEGUI::Element * parent ){ CEGUI::Window::setParent( boost::python::ptr(parent) ); } virtual void setVerticalAlignment( ::CEGUI::VerticalAlignment const alignment ) { if( bp::override func_setVerticalAlignment = this->get_override( "setVerticalAlignment" ) ) func_setVerticalAlignment( alignment ); else{ this->CEGUI::Element::setVerticalAlignment( alignment ); } } void default_setVerticalAlignment( ::CEGUI::VerticalAlignment const alignment ) { CEGUI::Element::setVerticalAlignment( alignment ); } virtual void sizeToContent( ) { if( bp::override func_sizeToContent = this->get_override( "sizeToContent" ) ) func_sizeToContent( ); else{ this->CEGUI::ItemListBase::sizeToContent( ); } } void default_sizeToContent( ) { CEGUI::ItemListBase::sizeToContent( ); } virtual void sizeToContent_impl( ){ if( bp::override func_sizeToContent_impl = this->get_override( "sizeToContent_impl" ) ) func_sizeToContent_impl( ); else{ this->CEGUI::ItemListBase::sizeToContent_impl( ); } } virtual void default_sizeToContent_impl( ){ CEGUI::ItemListBase::sizeToContent_impl( ); } virtual ::CEGUI::RefCounted< CEGUI::BoundSlot > subscribeScriptedEvent( ::CEGUI::String const & name, ::CEGUI::String const & subscriber_name ) { if( bp::override func_subscribeScriptedEvent = this->get_override( "subscribeScriptedEvent" ) ) return func_subscribeScriptedEvent( boost::ref(name), boost::ref(subscriber_name) ); else{ return this->CEGUI::EventSet::subscribeScriptedEvent( boost::ref(name), boost::ref(subscriber_name) ); } } ::CEGUI::RefCounted< CEGUI::BoundSlot > default_subscribeScriptedEvent( ::CEGUI::String const & name, ::CEGUI::String const & subscriber_name ) { return CEGUI::EventSet::subscribeScriptedEvent( boost::ref(name), boost::ref(subscriber_name) ); } virtual ::CEGUI::RefCounted< CEGUI::BoundSlot > subscribeScriptedEvent( ::CEGUI::String const & name, unsigned int group, ::CEGUI::String const & subscriber_name ) { if( bp::override func_subscribeScriptedEvent = this->get_override( "subscribeScriptedEvent" ) ) return func_subscribeScriptedEvent( boost::ref(name), group, boost::ref(subscriber_name) ); else{ return this->CEGUI::EventSet::subscribeScriptedEvent( boost::ref(name), group, boost::ref(subscriber_name) ); } } ::CEGUI::RefCounted< CEGUI::BoundSlot > default_subscribeScriptedEvent( ::CEGUI::String const & name, unsigned int group, ::CEGUI::String const & subscriber_name ) { return CEGUI::EventSet::subscribeScriptedEvent( boost::ref(name), group, boost::ref(subscriber_name) ); } void transferChildSurfaces( ){ CEGUI::Window::transferChildSurfaces( ); } virtual void update( float elapsed ) { if( bp::override func_update = this->get_override( "update" ) ) func_update( elapsed ); else{ this->CEGUI::Window::update( elapsed ); } } void default_update( float elapsed ) { CEGUI::Window::update( elapsed ); } void updateGeometryRenderSettings( ){ CEGUI::Window::updateGeometryRenderSettings( ); } virtual void updateSelf( float elapsed ){ if( bp::override func_updateSelf = this->get_override( "updateSelf" ) ) func_updateSelf( elapsed ); else{ this->CEGUI::Window::updateSelf( elapsed ); } } virtual void default_updateSelf( float elapsed ){ CEGUI::Window::updateSelf( elapsed ); } virtual bool validateWindowRenderer( ::CEGUI::WindowRenderer const * renderer ) const { if( bp::override func_validateWindowRenderer = this->get_override( "validateWindowRenderer" ) ) return func_validateWindowRenderer( boost::python::ptr(renderer) ); else{ return this->CEGUI::ItemListBase::validateWindowRenderer( boost::python::ptr(renderer) ); } } virtual bool default_validateWindowRenderer( ::CEGUI::WindowRenderer const * renderer ) const { return CEGUI::ItemListBase::validateWindowRenderer( boost::python::ptr(renderer) ); } virtual bool writeAutoChildWindowXML( ::CEGUI::XMLSerializer & xml_stream ) const { if( bp::override func_writeAutoChildWindowXML = this->get_override( "writeAutoChildWindowXML" ) ) return func_writeAutoChildWindowXML( boost::ref(xml_stream) ); else{ return this->CEGUI::Window::writeAutoChildWindowXML( boost::ref(xml_stream) ); } } virtual bool default_writeAutoChildWindowXML( ::CEGUI::XMLSerializer & xml_stream ) const { return CEGUI::Window::writeAutoChildWindowXML( boost::ref(xml_stream) ); } virtual int writeChildWindowsXML( ::CEGUI::XMLSerializer & xml_stream ) const { if( bp::override func_writeChildWindowsXML = this->get_override( "writeChildWindowsXML" ) ) return func_writeChildWindowsXML( boost::ref(xml_stream) ); else{ return this->CEGUI::Window::writeChildWindowsXML( boost::ref(xml_stream) ); } } virtual int default_writeChildWindowsXML( ::CEGUI::XMLSerializer & xml_stream ) const { return CEGUI::Window::writeChildWindowsXML( boost::ref(xml_stream) ); } virtual int writePropertiesXML( ::CEGUI::XMLSerializer & xml_stream ) const { if( bp::override func_writePropertiesXML = this->get_override( "writePropertiesXML" ) ) return func_writePropertiesXML( boost::ref(xml_stream) ); else{ return this->CEGUI::Window::writePropertiesXML( boost::ref(xml_stream) ); } } virtual int default_writePropertiesXML( ::CEGUI::XMLSerializer & xml_stream ) const { return CEGUI::Window::writePropertiesXML( boost::ref(xml_stream) ); } virtual void writeXMLToStream( ::CEGUI::XMLSerializer & xml_stream ) const { if( bp::override func_writeXMLToStream = this->get_override( "writeXMLToStream" ) ) func_writeXMLToStream( boost::ref(xml_stream) ); else{ this->CEGUI::Window::writeXMLToStream( boost::ref(xml_stream) ); } } void default_writeXMLToStream( ::CEGUI::XMLSerializer & xml_stream ) const { CEGUI::Window::writeXMLToStream( boost::ref(xml_stream) ); } }; void register_ItemListbox_class(){ { //::CEGUI::ItemListbox typedef bp::class_< ItemListbox_wrapper, bp::bases< CEGUI::ScrolledItemListBase >, boost::noncopyable > ItemListbox_exposer_t; ItemListbox_exposer_t ItemListbox_exposer = ItemListbox_exposer_t( "ItemListbox", "*!\n\ \n\ ItemListbox window class\n\ *\n", bp::init< CEGUI::String const &, CEGUI::String const & >(( bp::arg("type"), bp::arg("name") ), "************************************************************************\n\ Object Construction and Destruction\n\ *************************************************************************\n\ *!\n\ \n\ Constructor for the ItemListbox base class constructor.\n\ *\n") ); bp::scope ItemListbox_scope( ItemListbox_exposer ); { //::CEGUI::ItemListbox::clearAllSelections typedef void ( ::CEGUI::ItemListbox::*clearAllSelections_function_type )( ) ; ItemListbox_exposer.def( "clearAllSelections" , clearAllSelections_function_type( &::CEGUI::ItemListbox::clearAllSelections ) , "*!\n\ \n\ Clears all selections.\n\ *\n" ); } { //::CEGUI::ItemListbox::findSelectedItem typedef ::CEGUI::ItemEntry * ( ItemListbox_wrapper::*findSelectedItem_function_type )( ::size_t ) const; ItemListbox_exposer.def( "findSelectedItem" , findSelectedItem_function_type( &ItemListbox_wrapper::findSelectedItem ) , ( bp::arg("start_index") ) , bp::return_value_policy< bp::reference_existing_object >() , "************************************************************************\n\ Protected implementation functions\n\ ************************************************************************\n\ *!\n\ \n\ Returns a pointer to the first selected item starting the search\n\ from start_index\n\ \n\ @param start_index\n\ The index where the search should begin (inclusive)\n\ \n\ @return\n\ A pointer to the first selected item in the listbox found\n\ If no item is selected the return value is 0\n\ If start_index is out of bounds the return value is 0\n\ \n\ \note\n\ This function advances the internal counter and is made for\n\ getFirstSelectedItem and getNextSelectedItem\n\ *\n" ); } { //::CEGUI::ItemListbox::getContentSize typedef ::CEGUI::Sizef ( ::CEGUI::ItemListbox::*getContentSize_function_type )( ) const; typedef ::CEGUI::Sizef ( ItemListbox_wrapper::*default_getContentSize_function_type )( ) const; ItemListbox_exposer.def( "getContentSize" , getContentSize_function_type(&::CEGUI::ItemListbox::getContentSize) , default_getContentSize_function_type(&ItemListbox_wrapper::default_getContentSize) ); } { //::CEGUI::ItemListbox::getFirstSelectedItem typedef ::CEGUI::ItemEntry * ( ::CEGUI::ItemListbox::*getFirstSelectedItem_function_type )( ::size_t ) const; ItemListbox_exposer.def( "getFirstSelectedItem" , getFirstSelectedItem_function_type( &::CEGUI::ItemListbox::getFirstSelectedItem ) , ( bp::arg("start_index")=(::size_t)(0) ) , bp::return_value_policy< bp::reference_existing_object >() , "*!\n\ \n\ Returns a pointer to the first selected item\n\ \n\ @param start_index\n\ The index where the search should begin. If omitted the search will\n\ begin with the first item.\n\ \n\ @return\n\ A pointer to the first selected item in the listbox.\n\ If no item is selected the return value is 0.\n\ If start_index is out of bounds the return value is 0.\n\ \n\ \note\n\ If multiselect is disabled then this does the equivalent of calling\n\ getLastSelectedItem.\n\ If multiselect is enabled it will search the array starting at start_index\n\ *\n" ); } { //::CEGUI::ItemListbox::getLastSelectedItem typedef ::CEGUI::ItemEntry * ( ::CEGUI::ItemListbox::*getLastSelectedItem_function_type )( ) const; ItemListbox_exposer.def( "getLastSelectedItem" , getLastSelectedItem_function_type( &::CEGUI::ItemListbox::getLastSelectedItem ) , bp::return_value_policy< bp::reference_existing_object >() , "*!\n\ \n\ Returns a pointer to the last selected item.\n\ \n\ @return\n\ A pointer to the last selected item, 0 is none.\n\ *\n" ); } { //::CEGUI::ItemListbox::getNextSelectedItem typedef ::CEGUI::ItemEntry * ( ::CEGUI::ItemListbox::*getNextSelectedItem_function_type )( ) const; ItemListbox_exposer.def( "getNextSelectedItem" , getNextSelectedItem_function_type( &::CEGUI::ItemListbox::getNextSelectedItem ) , bp::return_value_policy< bp::reference_existing_object >() , "*!\n\ \n\ Returns a pointer to the next seleced item relative to a previous call to\n\ getFirstSelectedItem or getNextSelectedItem.\n\ \n\ @return\n\ A pointer to the next seleced item. If there are no further selected items\n\ the return value is 0.\n\ If multiselect is disabled the return value is 0.\n\ \n\ \note\n\ This member function will take on from where the last call to\n\ getFirstSelectedItem or getNextSelectedItem returned. So be sure to start with a\n\ call to getFirstSelectedItem.\n\ \n\ This member function should be preferred over getNextSelectedItemAfter as it will\n\ perform better, especially on large lists.\n\ *\n" ); } { //::CEGUI::ItemListbox::getNextSelectedItemAfter typedef ::CEGUI::ItemEntry * ( ::CEGUI::ItemListbox::*getNextSelectedItemAfter_function_type )( ::CEGUI::ItemEntry const * ) const; ItemListbox_exposer.def( "getNextSelectedItemAfter" , getNextSelectedItemAfter_function_type( &::CEGUI::ItemListbox::getNextSelectedItemAfter ) , ( bp::arg("start_item") ) , bp::return_value_policy< bp::reference_existing_object >() , "*!\n\ \n\ Returns a pointer to the next selected item after the item 'start_item' given.\n\ \n\ \note\n\ This member function will search the array from the beginning and will be slow\n\ for large lists, it will not advance the internal counter used by\n\ getFirstSelectedItem and getNextSelectedItem either.\n\ *\n" ); } { //::CEGUI::ItemListbox::getSelectedCount typedef ::size_t ( ::CEGUI::ItemListbox::*getSelectedCount_function_type )( ) const; ItemListbox_exposer.def( "getSelectedCount" , getSelectedCount_function_type( &::CEGUI::ItemListbox::getSelectedCount ) , "************************************************************************\n\ Accessors\n\ *************************************************************************\n\ *!\n\ \n\ Returns the number of selected items in this ItemListbox.\n\ *\n" ); } { //::CEGUI::ItemListbox::handle_PaneChildRemoved typedef bool ( ItemListbox_wrapper::*handle_PaneChildRemoved_function_type )( ::CEGUI::EventArgs const & ) ; ItemListbox_exposer.def( "handle_PaneChildRemoved" , handle_PaneChildRemoved_function_type( &ItemListbox_wrapper::default_handle_PaneChildRemoved ) , ( bp::arg("e") ) , "overridden from ItemListBase\n" ); } { //::CEGUI::ItemListbox::isItemSelected typedef bool ( ::CEGUI::ItemListbox::*isItemSelected_function_type )( ::size_t ) const; ItemListbox_exposer.def( "isItemSelected" , isItemSelected_function_type( &::CEGUI::ItemListbox::isItemSelected ) , ( bp::arg("index") ) , "*!\n\ \n\ Returns 'true' if the item at the given index is selectable and currently selected.\n\ *\n" ); } { //::CEGUI::ItemListbox::isMultiSelectEnabled typedef bool ( ::CEGUI::ItemListbox::*isMultiSelectEnabled_function_type )( ) const; ItemListbox_exposer.def( "isMultiSelectEnabled" , isMultiSelectEnabled_function_type( &::CEGUI::ItemListbox::isMultiSelectEnabled ) , "*!\n\ \n\ Returns 'true' if multiple selections are allowed. 'false' if not.\n\ *\n" ); } { //::CEGUI::ItemListbox::layoutItemWidgets typedef void ( ::CEGUI::ItemListbox::*layoutItemWidgets_function_type )( ) ; typedef void ( ItemListbox_wrapper::*default_layoutItemWidgets_function_type )( ) ; ItemListbox_exposer.def( "layoutItemWidgets" , layoutItemWidgets_function_type(&::CEGUI::ItemListbox::layoutItemWidgets) , default_layoutItemWidgets_function_type(&ItemListbox_wrapper::default_layoutItemWidgets) ); } { //::CEGUI::ItemListbox::notifyItemClicked typedef void ( ::CEGUI::ItemListbox::*notifyItemClicked_function_type )( ::CEGUI::ItemEntry * ) ; typedef void ( ItemListbox_wrapper::*default_notifyItemClicked_function_type )( ::CEGUI::ItemEntry * ) ; ItemListbox_exposer.def( "notifyItemClicked" , notifyItemClicked_function_type(&::CEGUI::ItemListbox::notifyItemClicked) , default_notifyItemClicked_function_type(&ItemListbox_wrapper::default_notifyItemClicked) , ( bp::arg("li") ) ); } { //::CEGUI::ItemListbox::notifyItemSelectState typedef void ( ::CEGUI::ItemListbox::*notifyItemSelectState_function_type )( ::CEGUI::ItemEntry *,bool ) ; typedef void ( ItemListbox_wrapper::*default_notifyItemSelectState_function_type )( ::CEGUI::ItemEntry *,bool ) ; ItemListbox_exposer.def( "notifyItemSelectState" , notifyItemSelectState_function_type(&::CEGUI::ItemListbox::notifyItemSelectState) , default_notifyItemSelectState_function_type(&ItemListbox_wrapper::default_notifyItemSelectState) , ( bp::arg("li"), bp::arg("state") ) ); } { //::CEGUI::ItemListbox::onKeyDown typedef void ( ItemListbox_wrapper::*onKeyDown_function_type )( ::CEGUI::KeyEventArgs & ) ; ItemListbox_exposer.def( "onKeyDown" , onKeyDown_function_type( &ItemListbox_wrapper::default_onKeyDown ) , ( bp::arg("e") ) , "************************************************************************\n\ Overridden event handlers\n\ ************************************************************************\n" ); } { //::CEGUI::ItemListbox::onMultiSelectModeChanged typedef void ( ItemListbox_wrapper::*onMultiSelectModeChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onMultiSelectModeChanged" , onMultiSelectModeChanged_function_type( &ItemListbox_wrapper::default_onMultiSelectModeChanged ) , ( bp::arg("e") ) , "************************************************************************\n\ New event handlers\n\ ************************************************************************\n" ); } { //::CEGUI::ItemListbox::onSelectionChanged typedef void ( ItemListbox_wrapper::*onSelectionChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onSelectionChanged" , onSelectionChanged_function_type( &ItemListbox_wrapper::default_onSelectionChanged ) , ( bp::arg("e") ) , "************************************************************************\n\ New event handlers\n\ ************************************************************************\n" ); } { //::CEGUI::ItemListbox::selectAllItems typedef void ( ::CEGUI::ItemListbox::*selectAllItems_function_type )( ) ; ItemListbox_exposer.def( "selectAllItems" , selectAllItems_function_type( &::CEGUI::ItemListbox::selectAllItems ) , "*!\n\ \n\ Select all items.\n\ Does nothing if multiselect is disabled.\n\ *\n" ); } { //::CEGUI::ItemListbox::selectRange typedef void ( ::CEGUI::ItemListbox::*selectRange_function_type )( ::size_t,::size_t ) ; ItemListbox_exposer.def( "selectRange" , selectRange_function_type( &::CEGUI::ItemListbox::selectRange ) , ( bp::arg("a"), bp::arg("z") ) , "*!\n\ \n\ Select a range of items.\n\ \n\ @param a\n\ Start item. (inclusive)\n\ \n\ @param z\n\ End item. (inclusive)\n\ *\n" ); } { //::CEGUI::ItemListbox::setMultiSelectEnabled typedef void ( ::CEGUI::ItemListbox::*setMultiSelectEnabled_function_type )( bool ) ; ItemListbox_exposer.def( "setMultiSelectEnabled" , setMultiSelectEnabled_function_type( &::CEGUI::ItemListbox::setMultiSelectEnabled ) , ( bp::arg("state") ) , "************************************************************************\n\ Manipulators\n\ *************************************************************************\n\ *!\n\ \n\ Set whether or not multiple selections should be allowed.\n\ *\n" ); } ItemListbox_exposer.add_static_property( "EventMultiSelectModeChanged" , bp::make_getter( &CEGUI::ItemListbox::EventMultiSelectModeChanged , bp::return_value_policy< bp::return_by_value >() ) ); ItemListbox_exposer.add_static_property( "EventSelectionChanged" , bp::make_getter( &CEGUI::ItemListbox::EventSelectionChanged , bp::return_value_policy< bp::return_by_value >() ) ); { //::CEGUI::Window::addChild_impl typedef void ( ItemListbox_wrapper::*addChild_impl_function_type )( ::CEGUI::Element * ) ; ItemListbox_exposer.def( "addChild_impl" , addChild_impl_function_type( &ItemListbox_wrapper::default_addChild_impl ) , ( bp::arg("element") ) , "*!\n\ opydoc Element.addChild_impl\n\ *\n" ); } { //::CEGUI::Element::addElementProperties typedef void ( ItemListbox_wrapper::*addElementProperties_function_type )( ) ; ItemListbox_exposer.def( "addElementProperties" , addElementProperties_function_type( &ItemListbox_wrapper::addElementProperties ) , "*!\n\ \n\ Add standard CEGUI.Element properties.\n\ *\n" ); } { //::CEGUI::NamedElement::addNamedElementProperties typedef void ( ItemListbox_wrapper::*addNamedElementProperties_function_type )( ) ; ItemListbox_exposer.def( "addNamedElementProperties" , addNamedElementProperties_function_type( &ItemListbox_wrapper::addNamedElementProperties ) , "*!\n\ Add standard CEGUI.NamedElement properties.\n\ *\n" ); } { //::CEGUI::Window::addWindowProperties typedef void ( ItemListbox_wrapper::*addWindowProperties_function_type )( ) ; ItemListbox_exposer.def( "addWindowProperties" , addWindowProperties_function_type( &ItemListbox_wrapper::addWindowProperties ) , "*!\n\ \n\ Add standard CEGUI.Window properties.\n\ *\n" ); } { //::CEGUI::Window::addWindowToDrawList typedef void ( ItemListbox_wrapper::*addWindowToDrawList_function_type )( ::CEGUI::Window &,bool ) ; ItemListbox_exposer.def( "addWindowToDrawList" , addWindowToDrawList_function_type( &ItemListbox_wrapper::addWindowToDrawList ) , ( bp::arg("wnd"), bp::arg("at_back")=(bool)(false) ) , "*!\n\ \n\ Add the given window to the drawing list at an appropriate position for\n\ it's settings and the required direction. Basically, when at_back\n\ is false, the window will appear in front of all other windows with the\n\ same 'always on top' setting. When at_back is true, the window will\n\ appear behind all other windows wih the same 'always on top' setting.\n\ \n\ @param wnd\n\ Window object to be added to the drawing list.\n\ \n\ @param at_back\n\ Indicates whether the window should be placed at the back of other\n\ windows in the same group. If this is false, the window is placed in\n\ front of other windows in the group.\n\ \n\ @return\n\ Nothing.\n\ *\n" ); } { //::CEGUI::Window::allocateRenderingWindow typedef void ( ItemListbox_wrapper::*allocateRenderingWindow_function_type )( ) ; ItemListbox_exposer.def( "allocateRenderingWindow" , allocateRenderingWindow_function_type( &ItemListbox_wrapper::allocateRenderingWindow ) , "! helper to create and setup the auto RenderingWindow surface\n" ); } { //::CEGUI::Window::banPropertiesForAutoWindow typedef void ( ItemListbox_wrapper::*banPropertiesForAutoWindow_function_type )( ) ; ItemListbox_exposer.def( "banPropertiesForAutoWindow" , banPropertiesForAutoWindow_function_type( &ItemListbox_wrapper::default_banPropertiesForAutoWindow ) ); } { //::CEGUI::Window::beginInitialisation typedef void ( ::CEGUI::Window::*beginInitialisation_function_type )( ) ; typedef void ( ItemListbox_wrapper::*default_beginInitialisation_function_type )( ) ; ItemListbox_exposer.def( "beginInitialisation" , beginInitialisation_function_type(&::CEGUI::Window::beginInitialisation) , default_beginInitialisation_function_type(&ItemListbox_wrapper::default_beginInitialisation) ); } { //::CEGUI::Window::bufferGeometry typedef void ( ItemListbox_wrapper::*bufferGeometry_function_type )( ::CEGUI::RenderingContext const & ) ; ItemListbox_exposer.def( "bufferGeometry" , bufferGeometry_function_type( &ItemListbox_wrapper::bufferGeometry ) , ( bp::arg("ctx") ) , "*!\n\ \n\ Perform drawing operations concerned with generating and buffering\n\ window geometry.\n\ \n\ \note\n\ This function is a sub-function of drawSelf; it is provided to make it\n\ easier to override drawSelf without needing to duplicate large sections\n\ of the code from the default implementation.\n\ *\n" ); } { //::CEGUI::Window::cleanupChildren typedef void ( ItemListbox_wrapper::*cleanupChildren_function_type )( ) ; ItemListbox_exposer.def( "cleanupChildren" , cleanupChildren_function_type( &ItemListbox_wrapper::default_cleanupChildren ) , "*!\n\ \n\ Cleanup child windows\n\ *\n" ); } { //::CEGUI::Window::cloneChildWidgetsTo typedef void ( ::CEGUI::Window::*cloneChildWidgetsTo_function_type )( ::CEGUI::Window & ) const; typedef void ( ItemListbox_wrapper::*default_cloneChildWidgetsTo_function_type )( ::CEGUI::Window & ) const; ItemListbox_exposer.def( "cloneChildWidgetsTo" , cloneChildWidgetsTo_function_type(&::CEGUI::Window::cloneChildWidgetsTo) , default_cloneChildWidgetsTo_function_type(&ItemListbox_wrapper::default_cloneChildWidgetsTo) , ( bp::arg("target") ) ); } { //::CEGUI::Window::clonePropertiesTo typedef void ( ::CEGUI::Window::*clonePropertiesTo_function_type )( ::CEGUI::Window & ) const; typedef void ( ItemListbox_wrapper::*default_clonePropertiesTo_function_type )( ::CEGUI::Window & ) const; ItemListbox_exposer.def( "clonePropertiesTo" , clonePropertiesTo_function_type(&::CEGUI::Window::clonePropertiesTo) , default_clonePropertiesTo_function_type(&ItemListbox_wrapper::default_clonePropertiesTo) , ( bp::arg("target") ) ); } { //::CEGUI::ScrolledItemListBase::configureScrollbars typedef void ( ItemListbox_wrapper::*configureScrollbars_function_type )( ::CEGUI::Sizef const & ) ; ItemListbox_exposer.def( "configureScrollbars" , configureScrollbars_function_type( &ItemListbox_wrapper::configureScrollbars ) , ( bp::arg("doc_size") ) , "************************************************************************\n\ Implementation functions\n\ ************************************************************************\n\ *!\n\ \n\ Configure scrollbars\n\ *\n" ); } { //::CEGUI::Window::destroy typedef void ( ::CEGUI::Window::*destroy_function_type )( ) ; typedef void ( ItemListbox_wrapper::*default_destroy_function_type )( ) ; ItemListbox_exposer.def( "destroy" , destroy_function_type(&::CEGUI::Window::destroy) , default_destroy_function_type(&ItemListbox_wrapper::default_destroy) ); } { //::CEGUI::Window::drawSelf typedef void ( ItemListbox_wrapper::*drawSelf_function_type )( ::CEGUI::RenderingContext const & ) ; ItemListbox_exposer.def( "drawSelf" , drawSelf_function_type( &ItemListbox_wrapper::default_drawSelf ) , ( bp::arg("ctx") ) , "*!\n\ \n\ Perform the actual rendering for this Window.\n\ \n\ @param ctx\n\ RenderingContext holding the details of the RenderingSurface to be\n\ used for the Window rendering operations.\n\ \n\ @return\n\ Nothing\n\ *\n" ); } { //::CEGUI::ItemListBase::endInitialisation typedef void ( ::CEGUI::ItemListBase::*endInitialisation_function_type )( ) ; typedef void ( ItemListbox_wrapper::*default_endInitialisation_function_type )( ) ; ItemListbox_exposer.def( "endInitialisation" , endInitialisation_function_type(&::CEGUI::ItemListBase::endInitialisation) , default_endInitialisation_function_type(&ItemListbox_wrapper::default_endInitialisation) ); } { //::CEGUI::Element::fireAreaChangeEvents typedef void ( ItemListbox_wrapper::*fireAreaChangeEvents_function_type )( bool const,bool const ) ; ItemListbox_exposer.def( "fireAreaChangeEvents" , fireAreaChangeEvents_function_type( &ItemListbox_wrapper::fireAreaChangeEvents ) , ( bp::arg("moved"), bp::arg("sized") ) , "! helper to fire events based on changes to area rect\n" ); } { //::CEGUI::EventSet::fireEvent typedef void ( ::CEGUI::EventSet::*fireEvent_function_type )( ::CEGUI::String const &,::CEGUI::EventArgs &,::CEGUI::String const & ) ; typedef void ( ItemListbox_wrapper::*default_fireEvent_function_type )( ::CEGUI::String const &,::CEGUI::EventArgs &,::CEGUI::String const & ) ; ItemListbox_exposer.def( "fireEvent" , fireEvent_function_type(&::CEGUI::EventSet::fireEvent) , default_fireEvent_function_type(&ItemListbox_wrapper::default_fireEvent) , ( bp::arg("name"), bp::arg("args"), bp::arg("eventNamespace")="" ) ); } { //::CEGUI::EventSet::fireEvent_impl typedef void ( ItemListbox_wrapper::*fireEvent_impl_function_type )( ::CEGUI::String const &,::CEGUI::EventArgs & ) ; ItemListbox_exposer.def( "fireEvent_impl" , fireEvent_impl_function_type( &ItemListbox_wrapper::fireEvent_impl ) , ( bp::arg("name"), bp::arg("args") ) , "! Implementation event firing member\n" ); } { //::CEGUI::Window::generateAutoRepeatEvent typedef void ( ItemListbox_wrapper::*generateAutoRepeatEvent_function_type )( ::CEGUI::MouseButton ) ; ItemListbox_exposer.def( "generateAutoRepeatEvent" , generateAutoRepeatEvent_function_type( &ItemListbox_wrapper::generateAutoRepeatEvent ) , ( bp::arg("button") ) , "*!\n\ \n\ Fires off a repeated mouse button down event for this window.\n\ *\n" ); } { //::CEGUI::NamedElement::getChildByNamePath_impl typedef ::CEGUI::NamedElement * ( ItemListbox_wrapper::*getChildByNamePath_impl_function_type )( ::CEGUI::String const & ) const; ItemListbox_exposer.def( "getChildByNamePath_impl" , getChildByNamePath_impl_function_type( &ItemListbox_wrapper::default_getChildByNamePath_impl ) , ( bp::arg("name_path") ) , bp::return_value_policy< bp::reference_existing_object >() , "*!\n\ Retrieves a child at name_path or 0 if none such exists\n\ *\n" ); } { //::CEGUI::NamedElement::getChildByNameRecursive_impl typedef ::CEGUI::NamedElement * ( ItemListbox_wrapper::*getChildByNameRecursive_impl_function_type )( ::CEGUI::String const & ) const; ItemListbox_exposer.def( "getChildByNameRecursive_impl" , getChildByNameRecursive_impl_function_type( &ItemListbox_wrapper::default_getChildByNameRecursive_impl ) , ( bp::arg("name") ) , bp::return_value_policy< bp::reference_existing_object >() , "*!\n\ Finds a child by name or 0 if none such exists\n\ *\n" ); } { //::CEGUI::Element::getClientChildContentArea typedef ::CEGUI::Element::CachedRectf const & ( ::CEGUI::Element::*getClientChildContentArea_function_type )( ) const; ItemListbox_exposer.def( "getClientChildContentArea" , getClientChildContentArea_function_type(&::CEGUI::Element::getClientChildContentArea) , bp::return_value_policy< bp::copy_const_reference >() ); } { //::CEGUI::Window::getHitTestRect_impl typedef ::CEGUI::Rectf ( ItemListbox_wrapper::*getHitTestRect_impl_function_type )( ) const; ItemListbox_exposer.def( "getHitTestRect_impl" , getHitTestRect_impl_function_type( &ItemListbox_wrapper::default_getHitTestRect_impl ) , "! Default implementation of function to return Window inner clipper area.\n\ ! Default implementation of function to return Window hit-test area.\n" ); } { //::CEGUI::Window::getInnerRectClipper_impl typedef ::CEGUI::Rectf ( ItemListbox_wrapper::*getInnerRectClipper_impl_function_type )( ) const; ItemListbox_exposer.def( "getInnerRectClipper_impl" , getInnerRectClipper_impl_function_type( &ItemListbox_wrapper::default_getInnerRectClipper_impl ) , "! Default implementation of function to return Window outer clipper area.\n\ ! Default implementation of function to return Window inner clipper area.\n" ); } { //::CEGUI::Element::getNonClientChildContentArea typedef ::CEGUI::Element::CachedRectf const & ( ::CEGUI::Element::*getNonClientChildContentArea_function_type )( ) const; ItemListbox_exposer.def( "getNonClientChildContentArea" , getNonClientChildContentArea_function_type(&::CEGUI::Element::getNonClientChildContentArea) , bp::return_value_policy< bp::copy_const_reference >() ); } { //::CEGUI::Window::getOuterRectClipper_impl typedef ::CEGUI::Rectf ( ItemListbox_wrapper::*getOuterRectClipper_impl_function_type )( ) const; ItemListbox_exposer.def( "getOuterRectClipper_impl" , getOuterRectClipper_impl_function_type( &ItemListbox_wrapper::default_getOuterRectClipper_impl ) , "! Default implementation of function to return Window outer clipper area.\n" ); } { //::CEGUI::Window::getParentElementClipIntersection typedef ::CEGUI::Rectf ( ItemListbox_wrapper::*getParentElementClipIntersection_function_type )( ::CEGUI::Rectf const & ) const; ItemListbox_exposer.def( "getParentElementClipIntersection" , getParentElementClipIntersection_function_type( &ItemListbox_wrapper::getParentElementClipIntersection ) , ( bp::arg("unclipped_area") ) , "! helper function for calculating clipping rectangles.\n" ); } { //::CEGUI::Window::getRenderedStringParser typedef ::CEGUI::RenderedStringParser & ( ::CEGUI::Window::*getRenderedStringParser_function_type )( ) const; ItemListbox_exposer.def( "getRenderedStringParser" , getRenderedStringParser_function_type(&::CEGUI::Window::getRenderedStringParser) , bp::return_value_policy< bp::reference_existing_object >() ); } { //::CEGUI::Window::getRenderingContext_impl typedef void ( ::CEGUI::Window::*getRenderingContext_impl_function_type )( ::CEGUI::RenderingContext & ) const; typedef void ( ItemListbox_wrapper::*default_getRenderingContext_impl_function_type )( ::CEGUI::RenderingContext & ) const; ItemListbox_exposer.def( "getRenderingContext_impl" , getRenderingContext_impl_function_type(&::CEGUI::Window::getRenderingContext_impl) , default_getRenderingContext_impl_function_type(&ItemListbox_wrapper::default_getRenderingContext_impl) , ( bp::arg("ctx") ) ); } { //::CEGUI::Window::getRootContainerSize typedef ::CEGUI::Sizef const & ( ::CEGUI::Window::*getRootContainerSize_function_type )( ) const; ItemListbox_exposer.def( "getRootContainerSize" , getRootContainerSize_function_type(&::CEGUI::Window::getRootContainerSize) , bp::return_value_policy< bp::copy_const_reference >() ); } { //::CEGUI::EventSet::getScriptModule typedef ::CEGUI::ScriptModule * ( ItemListbox_wrapper::*getScriptModule_function_type )( ) const; ItemListbox_exposer.def( "getScriptModule" , getScriptModule_function_type( &ItemListbox_wrapper::getScriptModule ) , bp::return_value_policy< bp::reference_existing_object >() , "! Implementation event firing member\n\ ! Helper to return the script module pointer or throw.\n" ); } { //::CEGUI::Window::getUnclippedInnerRect_impl typedef ::CEGUI::Rectf ( ItemListbox_wrapper::*getUnclippedInnerRect_impl_function_type )( bool ) const; ItemListbox_exposer.def( "getUnclippedInnerRect_impl" , getUnclippedInnerRect_impl_function_type( &ItemListbox_wrapper::default_getUnclippedInnerRect_impl ) , ( bp::arg("skipAllPixelAlignment") ) ); } { //::CEGUI::Element::getUnclippedOuterRect_impl typedef ::CEGUI::Rectf ( ItemListbox_wrapper::*getUnclippedOuterRect_impl_function_type )( bool ) const; ItemListbox_exposer.def( "getUnclippedOuterRect_impl" , getUnclippedOuterRect_impl_function_type( &ItemListbox_wrapper::default_getUnclippedOuterRect_impl ) , ( bp::arg("skipAllPixelAlignment") ) , "! Default implementation of function to return Element's outer rect area.\n" ); } { //::CEGUI::Window::getWindowAttachedToCommonAncestor typedef ::CEGUI::Window const * ( ItemListbox_wrapper::*getWindowAttachedToCommonAncestor_function_type )( ::CEGUI::Window const & ) const; ItemListbox_exposer.def( "getWindowAttachedToCommonAncestor" , getWindowAttachedToCommonAncestor_function_type( &ItemListbox_wrapper::getWindowAttachedToCommonAncestor ) , ( bp::arg("wnd") ) , bp::return_value_policy< bp::reference_existing_object >() , "*!\n\ \n\ Helper function to return the ancestor Window of a wnd that is attached\n\ as a child to a window that is also an ancestor of a this. Returns 0\n\ if a wnd and a this are not part of the same hierachy.\n\ *\n" ); } { //::CEGUI::Window::handleFontRenderSizeChange typedef bool ( ItemListbox_wrapper::*handleFontRenderSizeChange_function_type )( ::CEGUI::EventArgs const & ) ; ItemListbox_exposer.def( "handleFontRenderSizeChange" , handleFontRenderSizeChange_function_type( &ItemListbox_wrapper::default_handleFontRenderSizeChange ) , ( bp::arg("args") ) , "! handler function for when font render size changes.\n" ); } { //::CEGUI::ScrolledItemListBase::handle_HScroll typedef bool ( ItemListbox_wrapper::*handle_HScroll_function_type )( ::CEGUI::EventArgs const & ) ; ItemListbox_exposer.def( "handle_HScroll" , handle_HScroll_function_type( &ItemListbox_wrapper::handle_HScroll ) , ( bp::arg("e") ) , "************************************************************************\n\ Event subscribers\n\ ************************************************************************\n" ); } { //::CEGUI::ScrolledItemListBase::handle_VScroll typedef bool ( ItemListbox_wrapper::*handle_VScroll_function_type )( ::CEGUI::EventArgs const & ) ; ItemListbox_exposer.def( "handle_VScroll" , handle_VScroll_function_type( &ItemListbox_wrapper::handle_VScroll ) , ( bp::arg("e") ) , "************************************************************************\n\ Event subscribers\n\ ************************************************************************\n" ); } { //::CEGUI::Window::initialiseClippers typedef void ( ItemListbox_wrapper::*initialiseClippers_function_type )( ::CEGUI::RenderingContext const & ) ; ItemListbox_exposer.def( "initialiseClippers" , initialiseClippers_function_type( &ItemListbox_wrapper::initialiseClippers ) , ( bp::arg("ctx") ) , "! Helper to intialise the needed clipping for geometry and render surface.\n" ); } { //::CEGUI::ScrolledItemListBase::initialiseComponents typedef void ( ::CEGUI::ScrolledItemListBase::*initialiseComponents_function_type )( ) ; typedef void ( ItemListbox_wrapper::*default_initialiseComponents_function_type )( ) ; ItemListbox_exposer.def( "initialiseComponents" , initialiseComponents_function_type(&::CEGUI::ScrolledItemListBase::initialiseComponents) , default_initialiseComponents_function_type(&ItemListbox_wrapper::default_initialiseComponents) ); } { //::CEGUI::Window::invalidate_impl typedef void ( ItemListbox_wrapper::*invalidate_impl_function_type )( bool const ) ; ItemListbox_exposer.def( "invalidate_impl" , invalidate_impl_function_type( &ItemListbox_wrapper::invalidate_impl ) , ( bp::arg("recursive") ) , "! helper function to invalidate window and optionally child windows.\n" ); } { //::CEGUI::Window::isHit typedef bool ( ::CEGUI::Window::*isHit_function_type )( ::CEGUI::Vector2f const &,bool const ) const; typedef bool ( ItemListbox_wrapper::*default_isHit_function_type )( ::CEGUI::Vector2f const &,bool const ) const; ItemListbox_exposer.def( "isHit" , isHit_function_type(&::CEGUI::Window::isHit) , default_isHit_function_type(&ItemListbox_wrapper::default_isHit) , ( bp::arg("position"), bp::arg("allow_disabled")=(bool const)(false) ) ); } { //::CEGUI::Window::isHitTargetWindow typedef bool ( ItemListbox_wrapper::*isHitTargetWindow_function_type )( ::CEGUI::Vector2f const &,bool ) const; ItemListbox_exposer.def( "isHitTargetWindow" , isHitTargetWindow_function_type( &ItemListbox_wrapper::isHitTargetWindow ) , ( bp::arg("position"), bp::arg("allow_disabled") ) ); } { //::CEGUI::Element::isInnerRectSizeChanged typedef bool ( ItemListbox_wrapper::*isInnerRectSizeChanged_function_type )( ) const; ItemListbox_exposer.def( "isInnerRectSizeChanged" , isInnerRectSizeChanged_function_type( &ItemListbox_wrapper::isInnerRectSizeChanged ) , "! helper to return whether the inner rect size has changed\n" ); } { //::CEGUI::Window::isPropertyAtDefault typedef bool ( ItemListbox_wrapper::*isPropertyAtDefault_function_type )( ::CEGUI::Property const * ) const; ItemListbox_exposer.def( "isPropertyAtDefault" , isPropertyAtDefault_function_type( &ItemListbox_wrapper::isPropertyAtDefault ) , ( bp::arg("property") ) , "*!\n\ \n\ Returns whether a property is at it's default value.\n\ This function is different from Property.isDefatult as it takes the assigned look'n'feel\n\ (if the is one) into account.\n\ *\n" ); } { //::CEGUI::Window::isTopOfZOrder typedef bool ( ItemListbox_wrapper::*isTopOfZOrder_function_type )( ) const; ItemListbox_exposer.def( "isTopOfZOrder" , isTopOfZOrder_function_type( &ItemListbox_wrapper::isTopOfZOrder ) , "*!\n\ \n\ Return whether the window is at the top of the Z-Order. This will\n\ correctly take into account 'Always on top' windows as needed.\n\ \n\ @return\n\ - true if the Window is at the top of the z-order in relation to sibling\n\ windows with the same 'always on top' setting.\n\ - false if the Window is not at the top of the z-order in relation to\n\ sibling windows with the same 'always on top' setting.\n\ *\n" ); } { //::CEGUI::Window::layoutLookNFeelChildWidgets typedef void ( ItemListbox_wrapper::*layoutLookNFeelChildWidgets_function_type )( ) ; ItemListbox_exposer.def( "layoutLookNFeelChildWidgets" , layoutLookNFeelChildWidgets_function_type( &ItemListbox_wrapper::layoutLookNFeelChildWidgets ) , "mark the rect caches defined on Window invalid (does not affect Element)\n" ); } { //::CEGUI::Window::markCachedWindowRectsInvalid typedef void ( ItemListbox_wrapper::*markCachedWindowRectsInvalid_function_type )( ) ; ItemListbox_exposer.def( "markCachedWindowRectsInvalid" , markCachedWindowRectsInvalid_function_type( &ItemListbox_wrapper::markCachedWindowRectsInvalid ) , "mark the rect caches defined on Window invalid (does not affect Element)\n" ); } { //::CEGUI::Window::moveToFront_impl typedef bool ( ItemListbox_wrapper::*moveToFront_impl_function_type )( bool ) ; ItemListbox_exposer.def( "moveToFront_impl" , moveToFront_impl_function_type( &ItemListbox_wrapper::default_moveToFront_impl ) , ( bp::arg("wasClicked") ) , "*!\n\ \n\ Implements move to front behavior.\n\ \n\ @return\n\ Should return true if some action was taken, or false if there was\n\ nothing to be done.\n\ *\n" ); } { //::CEGUI::Element::notifyChildrenOfSizeChange typedef void ( ItemListbox_wrapper::*notifyChildrenOfSizeChange_function_type )( bool const,bool const ) ; ItemListbox_exposer.def( "notifyChildrenOfSizeChange" , notifyChildrenOfSizeChange_function_type( &ItemListbox_wrapper::notifyChildrenOfSizeChange ) , ( bp::arg("non_client"), bp::arg("client") ) ); } { //::CEGUI::Window::notifyClippingChanged typedef void ( ItemListbox_wrapper::*notifyClippingChanged_function_type )( ) ; ItemListbox_exposer.def( "notifyClippingChanged" , notifyClippingChanged_function_type( &ItemListbox_wrapper::notifyClippingChanged ) , "*!\n\ \n\ Recursively inform all children that the clipping has changed and screen rects\n\ needs to be recached.\n\ *\n" ); } { //::CEGUI::Window::notifyScreenAreaChanged typedef void ( ::CEGUI::Window::*notifyScreenAreaChanged_function_type )( bool ) ; typedef void ( ItemListbox_wrapper::*default_notifyScreenAreaChanged_function_type )( bool ) ; ItemListbox_exposer.def( "notifyScreenAreaChanged" , notifyScreenAreaChanged_function_type(&::CEGUI::Window::notifyScreenAreaChanged) , default_notifyScreenAreaChanged_function_type(&ItemListbox_wrapper::default_notifyScreenAreaChanged) , ( bp::arg("recursive")=(bool)(true) ) ); } { //::CEGUI::Window::onActivated typedef void ( ItemListbox_wrapper::*onActivated_function_type )( ::CEGUI::ActivationEventArgs & ) ; ItemListbox_exposer.def( "onActivated" , onActivated_function_type( &ItemListbox_wrapper::default_onActivated ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when this window has become the active window.\n\ \n\ @param e\n\ ActivationEventArgs class whose 'otherWindow' field is set to the window\n\ that previously was active, or NULL for none.\n\ *\n" ); } { //::CEGUI::Window::onAlphaChanged typedef void ( ItemListbox_wrapper::*onAlphaChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onAlphaChanged" , onAlphaChanged_function_type( &ItemListbox_wrapper::default_onAlphaChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's alpha blend value is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onAlwaysOnTopChanged typedef void ( ItemListbox_wrapper::*onAlwaysOnTopChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onAlwaysOnTopChanged" , onAlwaysOnTopChanged_function_type( &ItemListbox_wrapper::default_onAlwaysOnTopChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's always-on-top setting is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onCaptureGained typedef void ( ItemListbox_wrapper::*onCaptureGained_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onCaptureGained" , onCaptureGained_function_type( &ItemListbox_wrapper::default_onCaptureGained ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when this window gains capture of mouse inputs.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onCaptureLost typedef void ( ItemListbox_wrapper::*onCaptureLost_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onCaptureLost" , onCaptureLost_function_type( &ItemListbox_wrapper::default_onCaptureLost ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when this window loses capture of mouse inputs.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onCharacter typedef void ( ItemListbox_wrapper::*onCharacter_function_type )( ::CEGUI::KeyEventArgs & ) ; ItemListbox_exposer.def( "onCharacter" , onCharacter_function_type( &ItemListbox_wrapper::default_onCharacter ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a character-key has been pressed while this window\n\ has input focus.\n\ \n\ @param e\n\ KeyEventArgs object whose 'codepoint' field is set to the Unicode code\n\ point (encoded as utf32) for the character typed, and whose 'sysKeys'\n\ field represents the combination of SystemKey that were active when the\n\ event was generated. All other fields should be considered as 'junk'.\n\ *\n" ); } { //::CEGUI::Window::onChildAdded typedef void ( ItemListbox_wrapper::*onChildAdded_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onChildAdded" , onChildAdded_function_type( &ItemListbox_wrapper::default_onChildAdded ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a child window is added to this window.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that has been added.\n\ *\n" ); } { //::CEGUI::Window::onChildRemoved typedef void ( ItemListbox_wrapper::*onChildRemoved_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onChildRemoved" , onChildRemoved_function_type( &ItemListbox_wrapper::default_onChildRemoved ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a child window is removed from this window.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set the window\n\ that has been removed.\n\ *\n" ); } { //::CEGUI::Window::onClippingChanged typedef void ( ItemListbox_wrapper::*onClippingChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onClippingChanged" , onClippingChanged_function_type( &ItemListbox_wrapper::default_onClippingChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's setting for being clipped by it's\n\ parent is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onDeactivated typedef void ( ItemListbox_wrapper::*onDeactivated_function_type )( ::CEGUI::ActivationEventArgs & ) ; ItemListbox_exposer.def( "onDeactivated" , onDeactivated_function_type( &ItemListbox_wrapper::default_onDeactivated ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when this window has lost input focus and has been\n\ deactivated.\n\ \n\ @param e\n\ ActivationEventArgs object whose 'otherWindow' field is set to the\n\ window that has now become active, or NULL for none.\n\ *\n" ); } { //::CEGUI::Window::onDestructionStarted typedef void ( ItemListbox_wrapper::*onDestructionStarted_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onDestructionStarted" , onDestructionStarted_function_type( &ItemListbox_wrapper::default_onDestructionStarted ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when this window's destruction sequence has begun.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onDisabled typedef void ( ItemListbox_wrapper::*onDisabled_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onDisabled" , onDisabled_function_type( &ItemListbox_wrapper::default_onDisabled ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window is disabled.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onDragDropItemDropped typedef void ( ItemListbox_wrapper::*onDragDropItemDropped_function_type )( ::CEGUI::DragDropEventArgs & ) ; ItemListbox_exposer.def( "onDragDropItemDropped" , onDragDropItemDropped_function_type( &ItemListbox_wrapper::default_onDragDropItemDropped ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a DragContainer is dragged over this window.\n\ \n\ @param e\n\ DragDropEventArgs object initialised as follows:\n\ - window field is normaly set to point to 'this' window.\n\ - dragDropItem is a pointer to a DragContainer window that triggered\n\ the event.\n\ *\n" ); } { //::CEGUI::Window::onDragDropItemEnters typedef void ( ItemListbox_wrapper::*onDragDropItemEnters_function_type )( ::CEGUI::DragDropEventArgs & ) ; ItemListbox_exposer.def( "onDragDropItemEnters" , onDragDropItemEnters_function_type( &ItemListbox_wrapper::default_onDragDropItemEnters ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a DragContainer is dragged over this window.\n\ \n\ @param e\n\ DragDropEventArgs object initialised as follows:\n\ - window field is normaly set to point to 'this' window.\n\ - dragDropItem is a pointer to a DragContainer window that triggered\n\ the event.\n\ *\n" ); } { //::CEGUI::Window::onDragDropItemLeaves typedef void ( ItemListbox_wrapper::*onDragDropItemLeaves_function_type )( ::CEGUI::DragDropEventArgs & ) ; ItemListbox_exposer.def( "onDragDropItemLeaves" , onDragDropItemLeaves_function_type( &ItemListbox_wrapper::default_onDragDropItemLeaves ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a DragContainer is dragged over this window.\n\ \n\ @param e\n\ DragDropEventArgs object initialised as follows:\n\ - window field is normaly set to point to 'this' window.\n\ - dragDropItem is a pointer to a DragContainer window that triggered\n\ the event.\n\ *\n" ); } { //::CEGUI::Window::onEnabled typedef void ( ItemListbox_wrapper::*onEnabled_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onEnabled" , onEnabled_function_type( &ItemListbox_wrapper::default_onEnabled ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window is enabled.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onFontChanged typedef void ( ItemListbox_wrapper::*onFontChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onFontChanged" , onFontChanged_function_type( &ItemListbox_wrapper::default_onFontChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's font is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onHidden typedef void ( ItemListbox_wrapper::*onHidden_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onHidden" , onHidden_function_type( &ItemListbox_wrapper::default_onHidden ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window is hidden.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Element::onHorizontalAlignmentChanged typedef void ( ItemListbox_wrapper::*onHorizontalAlignmentChanged_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onHorizontalAlignmentChanged" , onHorizontalAlignmentChanged_function_type( &ItemListbox_wrapper::default_onHorizontalAlignmentChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the horizontal alignment setting for the element is\n\ changed.\n\ \n\ @param e\n\ ElementEventArgs object initialised as follows:\n\ - element field is set to point to the element object who's alignment has\n\ changed (typically 'this').\n\ *\n" ); } { //::CEGUI::ScrolledItemListBase::onHorzScrollbarModeChanged typedef void ( ItemListbox_wrapper::*onHorzScrollbarModeChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onHorzScrollbarModeChanged" , onHorzScrollbarModeChanged_function_type( &ItemListbox_wrapper::default_onHorzScrollbarModeChanged ) , ( bp::arg("e") ) , "************************************************************************\n\ New event handlers\n\ ************************************************************************\n" ); } { //::CEGUI::Window::onIDChanged typedef void ( ItemListbox_wrapper::*onIDChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onIDChanged" , onIDChanged_function_type( &ItemListbox_wrapper::default_onIDChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's client assigned ID is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onInheritsAlphaChanged typedef void ( ItemListbox_wrapper::*onInheritsAlphaChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onInheritsAlphaChanged" , onInheritsAlphaChanged_function_type( &ItemListbox_wrapper::default_onInheritsAlphaChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's setting for inheriting alpha-blending\n\ is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onInvalidated typedef void ( ItemListbox_wrapper::*onInvalidated_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onInvalidated" , onInvalidated_function_type( &ItemListbox_wrapper::default_onInvalidated ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when this window gets invalidated.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onKeyUp typedef void ( ItemListbox_wrapper::*onKeyUp_function_type )( ::CEGUI::KeyEventArgs & ) ; ItemListbox_exposer.def( "onKeyUp" , onKeyUp_function_type( &ItemListbox_wrapper::default_onKeyUp ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a key as been released while this window has input\n\ focus.\n\ \n\ @param e\n\ KeyEventArgs object whose 'scancode' field is set to the Key.Scan value\n\ representing the key that was released, and whose 'sysKeys' field\n\ represents the combination of SystemKey that were active when the event\n\ was generated. All other fields should be considered as 'junk'.\n\ *\n" ); } { //::CEGUI::ItemListBase::onListContentsChanged typedef void ( ItemListbox_wrapper::*onListContentsChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onListContentsChanged" , onListContentsChanged_function_type( &ItemListbox_wrapper::default_onListContentsChanged ) , ( bp::arg("e") ) , "*************************************************************************\n\ New event handlers\n\ *************************************************************************\n\ *!\n\ \n\ Handler called internally when the list contents are changed\n\ *\n" ); } { //::CEGUI::Window::onMarginChanged typedef void ( ItemListbox_wrapper::*onMarginChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onMarginChanged" , onMarginChanged_function_type( &ItemListbox_wrapper::default_onMarginChanged ) , ( bp::arg("e") ) ); } { //::CEGUI::Window::onMouseButtonDown typedef void ( ItemListbox_wrapper::*onMouseButtonDown_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseButtonDown" , onMouseButtonDown_function_type( &ItemListbox_wrapper::default_onMouseButtonDown ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a mouse button has been depressed within this\n\ window's area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::Window::onMouseButtonUp typedef void ( ItemListbox_wrapper::*onMouseButtonUp_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseButtonUp" , onMouseButtonUp_function_type( &ItemListbox_wrapper::default_onMouseButtonUp ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a mouse button has been released within this\n\ window's area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::Window::onMouseClicked typedef void ( ItemListbox_wrapper::*onMouseClicked_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseClicked" , onMouseClicked_function_type( &ItemListbox_wrapper::default_onMouseClicked ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a mouse button has been clicked (that is depressed\n\ and then released, within a specified time) within this window's area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::Window::onMouseDoubleClicked typedef void ( ItemListbox_wrapper::*onMouseDoubleClicked_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseDoubleClicked" , onMouseDoubleClicked_function_type( &ItemListbox_wrapper::default_onMouseDoubleClicked ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a mouse button has been double-clicked within this\n\ window's area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::Window::onMouseEnters typedef void ( ItemListbox_wrapper::*onMouseEnters_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseEnters" , onMouseEnters_function_type( &ItemListbox_wrapper::default_onMouseEnters ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the mouse cursor has entered this window's area and\n\ is actually over some part of this windows surface and not, for\n\ instance over a child window - even though technically in those cases\n\ the mouse is also within this Window's area, the handler will not be\n\ called.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ \n\ @see\n\ Window.onMouseEntersArea\n\ *\n" ); } { //::CEGUI::Window::onMouseEntersArea typedef void ( ItemListbox_wrapper::*onMouseEntersArea_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseEntersArea" , onMouseEntersArea_function_type( &ItemListbox_wrapper::default_onMouseEntersArea ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the mouse cursor has entered this window's area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::Window::onMouseLeaves typedef void ( ItemListbox_wrapper::*onMouseLeaves_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseLeaves" , onMouseLeaves_function_type( &ItemListbox_wrapper::default_onMouseLeaves ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the mouse cursor is no longer over this window's\n\ surface area. This will be called when the mouse is not over a part\n\ of this Window's actual surface - even though technically the mouse is\n\ still within the Window's area, for example if the mouse moves over a\n\ child window.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ \n\ @see\n\ Window.onMouseLeavesArea\n\ *\n" ); } { //::CEGUI::Window::onMouseLeavesArea typedef void ( ItemListbox_wrapper::*onMouseLeavesArea_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseLeavesArea" , onMouseLeavesArea_function_type( &ItemListbox_wrapper::default_onMouseLeavesArea ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the mouse cursor has left this window's area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::Window::onMouseMove typedef void ( ItemListbox_wrapper::*onMouseMove_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseMove" , onMouseMove_function_type( &ItemListbox_wrapper::default_onMouseMove ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the mouse cursor has been moved within this window's\n\ area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::Window::onMouseTripleClicked typedef void ( ItemListbox_wrapper::*onMouseTripleClicked_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseTripleClicked" , onMouseTripleClicked_function_type( &ItemListbox_wrapper::default_onMouseTripleClicked ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a mouse button has been triple-clicked within this\n\ window's area.\n\ \n\ @param e\n\ MouseEventArgs object. All fields are valid.\n\ *\n" ); } { //::CEGUI::ScrolledItemListBase::onMouseWheel typedef void ( ItemListbox_wrapper::*onMouseWheel_function_type )( ::CEGUI::MouseEventArgs & ) ; ItemListbox_exposer.def( "onMouseWheel" , onMouseWheel_function_type( &ItemListbox_wrapper::default_onMouseWheel ) , ( bp::arg("e") ) , "************************************************************************\n\ Overridden event handlers\n\ ************************************************************************\n" ); } { //::CEGUI::Window::onMoved typedef void ( ItemListbox_wrapper::*onMoved_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onMoved" , onMoved_function_type( &ItemListbox_wrapper::default_onMoved ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's position changes.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::NamedElement::onNameChanged typedef void ( ItemListbox_wrapper::*onNameChanged_function_type )( ::CEGUI::NamedElementEventArgs & ) ; ItemListbox_exposer.def( "onNameChanged" , onNameChanged_function_type( &ItemListbox_wrapper::default_onNameChanged ) , ( bp::arg("e") ) , "*!\n\ Handler called when the element's name changes.\n\ \n\ @param e\n\ NamedElementEventArgs object whose 'element' pointer field is set to the element\n\ that triggered the event. For this event the trigger element is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Element::onNonClientChanged typedef void ( ItemListbox_wrapper::*onNonClientChanged_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onNonClientChanged" , onNonClientChanged_function_type( &ItemListbox_wrapper::default_onNonClientChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the element's non-client setting, affecting it's\n\ position and size relative to it's parent is changed.\n\ \n\ @param e\n\ ElementEventArgs object whose 'element' pointer field is set to the element\n\ that triggered the event. For this event the trigger element is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onParentDestroyChanged typedef void ( ItemListbox_wrapper::*onParentDestroyChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onParentDestroyChanged" , onParentDestroyChanged_function_type( &ItemListbox_wrapper::default_onParentDestroyChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's setting for being destroyed\n\ automatically be it's parent is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::ItemListBase::onParentSized typedef void ( ItemListbox_wrapper::*onParentSized_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onParentSized" , onParentSized_function_type( &ItemListbox_wrapper::default_onParentSized ) , ( bp::arg("e") ) , "*************************************************************************\n\ Overridden Event handlers\n\ *************************************************************************\n" ); } { //::CEGUI::Window::onRenderingEnded typedef void ( ItemListbox_wrapper::*onRenderingEnded_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onRenderingEnded" , onRenderingEnded_function_type( &ItemListbox_wrapper::default_onRenderingEnded ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when rendering for this window has ended.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onRenderingStarted typedef void ( ItemListbox_wrapper::*onRenderingStarted_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onRenderingStarted" , onRenderingStarted_function_type( &ItemListbox_wrapper::default_onRenderingStarted ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when rendering for this window has started.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onRotated typedef void ( ItemListbox_wrapper::*onRotated_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onRotated" , onRotated_function_type( &ItemListbox_wrapper::default_onRotated ) , ( bp::arg("e") ) ); } { //::CEGUI::Window::onShown typedef void ( ItemListbox_wrapper::*onShown_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onShown" , onShown_function_type( &ItemListbox_wrapper::default_onShown ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window is shown (made visible).\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onSized typedef void ( ItemListbox_wrapper::*onSized_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onSized" , onSized_function_type( &ItemListbox_wrapper::default_onSized ) , ( bp::arg("e") ) , "*************************************************************************\n\ Event trigger methods\n\ *************************************************************************\n\ *!\n\ \n\ Handler called when the window's size changes.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::ItemListBase::onSortEnabledChanged typedef void ( ItemListbox_wrapper::*onSortEnabledChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onSortEnabledChanged" , onSortEnabledChanged_function_type( &ItemListbox_wrapper::default_onSortEnabledChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called internally when sorting gets enabled.\n\ *\n" ); } { //::CEGUI::ItemListBase::onSortModeChanged typedef void ( ItemListbox_wrapper::*onSortModeChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onSortModeChanged" , onSortModeChanged_function_type( &ItemListbox_wrapper::default_onSortModeChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called internally when the sorting mode is changed.\n\ *\n" ); } { //::CEGUI::Window::onTextChanged typedef void ( ItemListbox_wrapper::*onTextChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onTextChanged" , onTextChanged_function_type( &ItemListbox_wrapper::default_onTextChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's text is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::Window::onTextParsingChanged typedef void ( ItemListbox_wrapper::*onTextParsingChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onTextParsingChanged" , onTextParsingChanged_function_type( &ItemListbox_wrapper::default_onTextParsingChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the window's setting for whether text parsing is\n\ enabled is changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::ScrolledItemListBase::onVertScrollbarModeChanged typedef void ( ItemListbox_wrapper::*onVertScrollbarModeChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onVertScrollbarModeChanged" , onVertScrollbarModeChanged_function_type( &ItemListbox_wrapper::default_onVertScrollbarModeChanged ) , ( bp::arg("e") ) , "************************************************************************\n\ New event handlers\n\ ************************************************************************\n" ); } { //::CEGUI::Element::onVerticalAlignmentChanged typedef void ( ItemListbox_wrapper::*onVerticalAlignmentChanged_function_type )( ::CEGUI::ElementEventArgs & ) ; ItemListbox_exposer.def( "onVerticalAlignmentChanged" , onVerticalAlignmentChanged_function_type( &ItemListbox_wrapper::default_onVerticalAlignmentChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the vertical alignment setting for the element is\n\ changed.\n\ \n\ @param e\n\ ElementEventArgs object initialised as follows:\n\ - element field is set to point to the element object who's alignment has\n\ changed (typically 'this').\n\ *\n" ); } { //::CEGUI::Window::onWindowRendererAttached typedef void ( ItemListbox_wrapper::*onWindowRendererAttached_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onWindowRendererAttached" , onWindowRendererAttached_function_type( &ItemListbox_wrapper::default_onWindowRendererAttached ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when a new window renderer object is attached.\n\ \n\ @param e\n\ WindowEventArgs object initialised as follows:\n\ - window field is set to point to the Window object that just got a new\n\ window renderer attached. (typically 'this').\n\ *\n" ); } { //::CEGUI::Window::onWindowRendererDetached typedef void ( ItemListbox_wrapper::*onWindowRendererDetached_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onWindowRendererDetached" , onWindowRendererDetached_function_type( &ItemListbox_wrapper::default_onWindowRendererDetached ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the currently attached window renderer object is detached.\n\ \n\ @param e\n\ WindowEventArgs object initialised as follows:\n\ - window field is set to point to the Window object that just got lost its\n\ window renderer. (typically 'this').\n\ *\n" ); } { //::CEGUI::Window::onZChange_impl typedef void ( ItemListbox_wrapper::*onZChange_impl_function_type )( ) ; ItemListbox_exposer.def( "onZChange_impl" , onZChange_impl_function_type( &ItemListbox_wrapper::default_onZChange_impl ) , "*!\n\ \n\ Notify 'this' and all siblings of a ZOrder change event\n\ *\n" ); } { //::CEGUI::Window::onZChanged typedef void ( ItemListbox_wrapper::*onZChanged_function_type )( ::CEGUI::WindowEventArgs & ) ; ItemListbox_exposer.def( "onZChanged" , onZChanged_function_type( &ItemListbox_wrapper::default_onZChanged ) , ( bp::arg("e") ) , "*!\n\ \n\ Handler called when the z-order position of this window has changed.\n\ \n\ @param e\n\ WindowEventArgs object whose 'window' pointer field is set to the window\n\ that triggered the event. For this event the trigger window is always\n\ 'this'.\n\ *\n" ); } { //::CEGUI::ItemListBase::performChildWindowLayout typedef void ( ::CEGUI::ItemListBase::*performChildWindowLayout_function_type )( bool,bool ) ; typedef void ( ItemListbox_wrapper::*default_performChildWindowLayout_function_type )( bool,bool ) ; ItemListbox_exposer.def( "performChildWindowLayout" , performChildWindowLayout_function_type(&::CEGUI::ItemListBase::performChildWindowLayout) , default_performChildWindowLayout_function_type(&ItemListbox_wrapper::default_performChildWindowLayout) , ( bp::arg("nonclient_sized_hint")=(bool)(false), bp::arg("client_sized_hint")=(bool)(false) ) ); } { //::CEGUI::Window::performCopy typedef bool ( ::CEGUI::Window::*performCopy_function_type )( ::CEGUI::Clipboard & ) ; typedef bool ( ItemListbox_wrapper::*default_performCopy_function_type )( ::CEGUI::Clipboard & ) ; ItemListbox_exposer.def( "performCopy" , performCopy_function_type(&::CEGUI::Window::performCopy) , default_performCopy_function_type(&ItemListbox_wrapper::default_performCopy) , ( bp::arg("clipboard") ) ); } { //::CEGUI::Window::performCut typedef bool ( ::CEGUI::Window::*performCut_function_type )( ::CEGUI::Clipboard & ) ; typedef bool ( ItemListbox_wrapper::*default_performCut_function_type )( ::CEGUI::Clipboard & ) ; ItemListbox_exposer.def( "performCut" , performCut_function_type(&::CEGUI::Window::performCut) , default_performCut_function_type(&ItemListbox_wrapper::default_performCut) , ( bp::arg("clipboard") ) ); } { //::CEGUI::Window::performPaste typedef bool ( ::CEGUI::Window::*performPaste_function_type )( ::CEGUI::Clipboard & ) ; typedef bool ( ItemListbox_wrapper::*default_performPaste_function_type )( ::CEGUI::Clipboard & ) ; ItemListbox_exposer.def( "performPaste" , performPaste_function_type(&::CEGUI::Window::performPaste) , default_performPaste_function_type(&ItemListbox_wrapper::default_performPaste) , ( bp::arg("clipboard") ) ); } { //::CEGUI::Window::populateGeometryBuffer typedef void ( ItemListbox_wrapper::*populateGeometryBuffer_function_type )( ) ; ItemListbox_exposer.def( "populateGeometryBuffer" , populateGeometryBuffer_function_type( &ItemListbox_wrapper::default_populateGeometryBuffer ) , "*!\n\ \n\ Update the rendering cache.\n\ \n\ Populates the Window's GeometryBuffer ready for rendering.\n\ *\n" ); } { //::CEGUI::Window::queueGeometry typedef void ( ItemListbox_wrapper::*queueGeometry_function_type )( ::CEGUI::RenderingContext const & ) ; ItemListbox_exposer.def( "queueGeometry" , queueGeometry_function_type( &ItemListbox_wrapper::queueGeometry ) , ( bp::arg("ctx") ) , "*!\n\ \n\ Perform drawing operations concerned with positioning, clipping and\n\ queueing of window geometry to RenderingSurfaces.\n\ \n\ \note\n\ This function is a sub-function of drawSelf and is provided to make it\n\ easier to override drawSelf without needing to duplicate large sections\n\ of the code from the default implementation.\n\ *\n" ); } { //::CEGUI::Window::releaseRenderingWindow typedef void ( ItemListbox_wrapper::*releaseRenderingWindow_function_type )( ) ; ItemListbox_exposer.def( "releaseRenderingWindow" , releaseRenderingWindow_function_type( &ItemListbox_wrapper::releaseRenderingWindow ) , "! helper to clean up the auto RenderingWindow surface\n" ); } { //::CEGUI::Window::removeChild_impl typedef void ( ItemListbox_wrapper::*removeChild_impl_function_type )( ::CEGUI::Element * ) ; ItemListbox_exposer.def( "removeChild_impl" , removeChild_impl_function_type( &ItemListbox_wrapper::default_removeChild_impl ) , ( bp::arg("element") ) , "*!\n\ opydoc Element.removeChild_impl\n\ *\n" ); } { //::CEGUI::Window::removeWindowFromDrawList typedef void ( ItemListbox_wrapper::*removeWindowFromDrawList_function_type )( ::CEGUI::Window const & ) ; ItemListbox_exposer.def( "removeWindowFromDrawList" , removeWindowFromDrawList_function_type( &ItemListbox_wrapper::removeWindowFromDrawList ) , ( bp::arg("wnd") ) , "*!\n\ \n\ Removes the window from the drawing list. If the window is not attached\n\ to the drawing list then nothing happens.\n\ \n\ @param wnd\n\ Window object to be removed from the drawing list.\n\ \n\ @return\n\ Nothing.\n\ *\n" ); } { //::CEGUI::ItemListBase::resetList_impl typedef bool ( ItemListbox_wrapper::*resetList_impl_function_type )( ) ; ItemListbox_exposer.def( "resetList_impl" , resetList_impl_function_type( &ItemListbox_wrapper::resetList_impl ) , "*************************************************************************\n\ Implementation Functions\n\ *************************************************************************\n\ *!\n\ \n\ Remove all items from the list.\n\ \n\ \note\n\ Note that this will cause items with the 'DestroyedByParent' property set to 'true', to be\ deleted.\n\ \n\ @return\n\ - true if the list contents were changed.\n\ - false if the list contents were not changed (list already empty).\n\ *\n" ); } { //::CEGUI::Element::setArea typedef void ( ::CEGUI::Element::*setArea_function_type )( ::CEGUI::UVector2 const &,::CEGUI::USize const & ) ; typedef void ( ItemListbox_wrapper::*default_setArea_function_type )( ::CEGUI::UVector2 const &,::CEGUI::USize const & ) ; ItemListbox_exposer.def( "setArea" , setArea_function_type(&::CEGUI::Element::setArea) , default_setArea_function_type(&ItemListbox_wrapper::default_setArea) , ( bp::arg("pos"), bp::arg("size") ) ); } { //::CEGUI::Element::setArea typedef void ( ::CEGUI::Element::*setArea_function_type )( ::CEGUI::UDim const &,::CEGUI::UDim const &,::CEGUI::UDim const &,::CEGUI::UDim const & ) ; ItemListbox_exposer.def( "setArea" , setArea_function_type( &::CEGUI::Element::setArea ) , ( bp::arg("xpos"), bp::arg("ypos"), bp::arg("width"), bp::arg("height") ) , "! overload\n" ); } { //::CEGUI::Element::setArea typedef void ( ::CEGUI::Element::*setArea_function_type )( ::CEGUI::URect const & ) ; ItemListbox_exposer.def( "setArea" , setArea_function_type( &::CEGUI::Element::setArea ) , ( bp::arg("area") ) , "! overload\n" ); } { //::CEGUI::Window::setArea_impl typedef void ( ItemListbox_wrapper::*setArea_impl_function_type )( ::CEGUI::UVector2 const &,::CEGUI::USize const &,bool,bool ) ; ItemListbox_exposer.def( "setArea_impl" , setArea_impl_function_type( &ItemListbox_wrapper::default_setArea_impl ) , ( bp::arg("pos"), bp::arg("size"), bp::arg("topLeftSizing")=(bool)(false), bp::arg("fireEvents")=(bool)(true) ) , "! opydoc Element.setArea_impl\n" ); } { //::CEGUI::Element::setHorizontalAlignment typedef void ( ::CEGUI::Element::*setHorizontalAlignment_function_type )( ::CEGUI::HorizontalAlignment const ) ; typedef void ( ItemListbox_wrapper::*default_setHorizontalAlignment_function_type )( ::CEGUI::HorizontalAlignment const ) ; ItemListbox_exposer.def( "setHorizontalAlignment" , setHorizontalAlignment_function_type(&::CEGUI::Element::setHorizontalAlignment) , default_setHorizontalAlignment_function_type(&ItemListbox_wrapper::default_setHorizontalAlignment) , ( bp::arg("alignment") ) ); } { //::CEGUI::Window::setLookNFeel typedef void ( ::CEGUI::Window::*setLookNFeel_function_type )( ::CEGUI::String const & ) ; typedef void ( ItemListbox_wrapper::*default_setLookNFeel_function_type )( ::CEGUI::String const & ) ; ItemListbox_exposer.def( "setLookNFeel" , setLookNFeel_function_type(&::CEGUI::Window::setLookNFeel) , default_setLookNFeel_function_type(&ItemListbox_wrapper::default_setLookNFeel) , ( bp::arg("look") ) ); } { //::CEGUI::Window::setMargin typedef void ( ::CEGUI::Window::*setMargin_function_type )( ::CEGUI::UBox const & ) ; typedef void ( ItemListbox_wrapper::*default_setMargin_function_type )( ::CEGUI::UBox const & ) ; ItemListbox_exposer.def( "setMargin" , setMargin_function_type(&::CEGUI::Window::setMargin) , default_setMargin_function_type(&ItemListbox_wrapper::default_setMargin) , ( bp::arg("margin") ) ); } { //::CEGUI::NamedElement::setName typedef void ( ::CEGUI::NamedElement::*setName_function_type )( ::CEGUI::String const & ) ; typedef void ( ItemListbox_wrapper::*default_setName_function_type )( ::CEGUI::String const & ) ; ItemListbox_exposer.def( "setName" , setName_function_type(&::CEGUI::NamedElement::setName) , default_setName_function_type(&ItemListbox_wrapper::default_setName) , ( bp::arg("name") ) ); } { //::CEGUI::Window::setParent typedef void ( ItemListbox_wrapper::*setParent_function_type )( ::CEGUI::Element * ) ; ItemListbox_exposer.def( "setParent" , setParent_function_type( &ItemListbox_wrapper::default_setParent ) , ( bp::arg("parent") ) , "*!\n\ \n\ Set the parent window for this window object.\n\ \n\ @param parent\n\ Pointer to a Window object that is to be assigned as the parent to this\n\ Window.\n\ \n\ @return\n\ Nothing\n\ *\n" ); } { //::CEGUI::Element::setVerticalAlignment typedef void ( ::CEGUI::Element::*setVerticalAlignment_function_type )( ::CEGUI::VerticalAlignment const ) ; typedef void ( ItemListbox_wrapper::*default_setVerticalAlignment_function_type )( ::CEGUI::VerticalAlignment const ) ; ItemListbox_exposer.def( "setVerticalAlignment" , setVerticalAlignment_function_type(&::CEGUI::Element::setVerticalAlignment) , default_setVerticalAlignment_function_type(&ItemListbox_wrapper::default_setVerticalAlignment) , ( bp::arg("alignment") ) ); } { //::CEGUI::ItemListBase::sizeToContent typedef void ( ::CEGUI::ItemListBase::*sizeToContent_function_type )( ) ; typedef void ( ItemListbox_wrapper::*default_sizeToContent_function_type )( ) ; ItemListbox_exposer.def( "sizeToContent" , sizeToContent_function_type(&::CEGUI::ItemListBase::sizeToContent) , default_sizeToContent_function_type(&ItemListbox_wrapper::default_sizeToContent) ); } { //::CEGUI::ItemListBase::sizeToContent_impl typedef void ( ItemListbox_wrapper::*sizeToContent_impl_function_type )( ) ; ItemListbox_exposer.def( "sizeToContent_impl" , sizeToContent_impl_function_type( &ItemListbox_wrapper::default_sizeToContent_impl ) , "*************************************************************************\n\ Abstract Implementation Functions (must be provided by derived class)\n\ *************************************************************************\n\ *!\n\ \n\ Resize the ItemListBase to exactly fit the content that is attached to it.\n\ Return a Rect object describing, in un-clipped pixels, the window relative area\n\ that is to be used for rendering items.\n\ \n\ @return\n\ Nothing\n\ *\n" ); } { //::CEGUI::EventSet::subscribeScriptedEvent typedef ::CEGUI::RefCounted< CEGUI::BoundSlot > ( ::CEGUI::EventSet::*subscribeScriptedEvent_function_type )( ::CEGUI::String const &,::CEGUI::String const & ) ; typedef ::CEGUI::RefCounted< CEGUI::BoundSlot > ( ItemListbox_wrapper::*default_subscribeScriptedEvent_function_type )( ::CEGUI::String const &,::CEGUI::String const & ) ; ItemListbox_exposer.def( "subscribeScriptedEvent" , subscribeScriptedEvent_function_type(&::CEGUI::EventSet::subscribeScriptedEvent) , default_subscribeScriptedEvent_function_type(&ItemListbox_wrapper::default_subscribeScriptedEvent) , ( bp::arg("name"), bp::arg("subscriber_name") ) ); } { //::CEGUI::EventSet::subscribeScriptedEvent typedef ::CEGUI::RefCounted< CEGUI::BoundSlot > ( ::CEGUI::EventSet::*subscribeScriptedEvent_function_type )( ::CEGUI::String const &,unsigned int,::CEGUI::String const & ) ; typedef ::CEGUI::RefCounted< CEGUI::BoundSlot > ( ItemListbox_wrapper::*default_subscribeScriptedEvent_function_type )( ::CEGUI::String const &,unsigned int,::CEGUI::String const & ) ; ItemListbox_exposer.def( "subscribeScriptedEvent" , subscribeScriptedEvent_function_type(&::CEGUI::EventSet::subscribeScriptedEvent) , default_subscribeScriptedEvent_function_type(&ItemListbox_wrapper::default_subscribeScriptedEvent) , ( bp::arg("name"), bp::arg("group"), bp::arg("subscriber_name") ) ); } { //::CEGUI::Window::transferChildSurfaces typedef void ( ItemListbox_wrapper::*transferChildSurfaces_function_type )( ) ; ItemListbox_exposer.def( "transferChildSurfaces" , transferChildSurfaces_function_type( &ItemListbox_wrapper::transferChildSurfaces ) , "! transfer RenderingSurfaces to be owned by our target RenderingSurface.\n" ); } { //::CEGUI::Window::update typedef void ( ::CEGUI::Window::*update_function_type )( float ) ; typedef void ( ItemListbox_wrapper::*default_update_function_type )( float ) ; ItemListbox_exposer.def( "update" , update_function_type(&::CEGUI::Window::update) , default_update_function_type(&ItemListbox_wrapper::default_update) , ( bp::arg("elapsed") ) ); } { //::CEGUI::Window::updateGeometryRenderSettings typedef void ( ItemListbox_wrapper::*updateGeometryRenderSettings_function_type )( ) ; ItemListbox_exposer.def( "updateGeometryRenderSettings" , updateGeometryRenderSettings_function_type( &ItemListbox_wrapper::updateGeometryRenderSettings ) , "*!\n\ \n\ Update position and clip region on this Windows geometry rendering\n\ surface.\n\ *\n" ); } { //::CEGUI::Window::updateSelf typedef void ( ItemListbox_wrapper::*updateSelf_function_type )( float ) ; ItemListbox_exposer.def( "updateSelf" , updateSelf_function_type( &ItemListbox_wrapper::default_updateSelf ) , ( bp::arg("elapsed") ) , "*************************************************************************\n\ Implementation Functions\n\ *************************************************************************\n\ *!\n\ \n\ Perform actual update processing for this Window.\n\ \n\ @param elapsed\n\ float value indicating the number of seconds elapsed since the last\n\ update call.\n\ \n\ @return\n\ Nothing.\n\ *\n" ); } { //::CEGUI::ItemListBase::validateWindowRenderer typedef bool ( ItemListbox_wrapper::*validateWindowRenderer_function_type )( ::CEGUI::WindowRenderer const * ) const; ItemListbox_exposer.def( "validateWindowRenderer" , validateWindowRenderer_function_type( &ItemListbox_wrapper::default_validateWindowRenderer ) , ( bp::arg("renderer") ) , "validate window renderer\n" ); } { //::CEGUI::Window::writeAutoChildWindowXML typedef bool ( ItemListbox_wrapper::*writeAutoChildWindowXML_function_type )( ::CEGUI::XMLSerializer & ) const; ItemListbox_exposer.def( "writeAutoChildWindowXML" , writeAutoChildWindowXML_function_type( &ItemListbox_wrapper::default_writeAutoChildWindowXML ) , ( bp::arg("xml_stream") ) ); } { //::CEGUI::Window::writeChildWindowsXML typedef int ( ItemListbox_wrapper::*writeChildWindowsXML_function_type )( ::CEGUI::XMLSerializer & ) const; ItemListbox_exposer.def( "writeChildWindowsXML" , writeChildWindowsXML_function_type( &ItemListbox_wrapper::default_writeChildWindowsXML ) , ( bp::arg("xml_stream") ) ); } { //::CEGUI::Window::writePropertiesXML typedef int ( ItemListbox_wrapper::*writePropertiesXML_function_type )( ::CEGUI::XMLSerializer & ) const; ItemListbox_exposer.def( "writePropertiesXML" , writePropertiesXML_function_type( &ItemListbox_wrapper::default_writePropertiesXML ) , ( bp::arg("xml_stream") ) ); } { //::CEGUI::Window::writeXMLToStream typedef void ( ::CEGUI::Window::*writeXMLToStream_function_type )( ::CEGUI::XMLSerializer & ) const; typedef void ( ItemListbox_wrapper::*default_writeXMLToStream_function_type )( ::CEGUI::XMLSerializer & ) const; ItemListbox_exposer.def( "writeXMLToStream" , writeXMLToStream_function_type(&::CEGUI::Window::writeXMLToStream) , default_writeXMLToStream_function_type(&ItemListbox_wrapper::default_writeXMLToStream) , ( bp::arg("xml_stream") ) ); } } }
[ "Nickenstein79@localhost" ]
Nickenstein79@localhost
2d003e1cb31d631bed6049f07ae1906658cfb02e
5f6006bb25a4fef4a5fa7b1a866ae6fa3b0c3f62
/mlib/ccext/android/MIAPTaskGooglePlay.cpp
022ff2d2b2bb2f0ea9fb32d44ee7054ea7d1d533
[]
no_license
xu561865/demo_2
b6c0c2fa72105f63b816d21d49353ad544b17706
4a221eaf427065be344b1e21b26a9594a7fe6878
refs/heads/master
2021-01-10T01:20:33.160496
2016-04-11T03:33:31
2016-04-11T03:33:52
55,936,998
0
0
null
null
null
null
UTF-8
C++
false
false
258
cpp
#include "MIAPTask.h" MLIB_NS_BEGIN MIAPTask * MIAPTask::createWithProductId(const std::string &pid) { return nullptr; } std::vector<MIAPTransaction> MIAPTask::getFinishedTransactions() { std::vector<MIAPTransaction> ret; return ret; } MLIB_NS_END
[ "xuyi561865@sina.com" ]
xuyi561865@sina.com
0ae92e249b7a4805d639e5f3a32434ccf52c9e24
536656cd89e4fa3a92b5dcab28657d60d1d244bd
/components/metrics/gpu/gpu_metrics_provider.cc
a1b1bba39f574c0548186af12edadbcb4c7f406e
[ "BSD-3-Clause" ]
permissive
ECS-251-W2020/chromium
79caebf50443f297557d9510620bf8d44a68399a
ac814e85cb870a6b569e184c7a60a70ff3cb19f9
refs/heads/master
2022-08-19T17:42:46.887573
2020-03-18T06:08:44
2020-03-18T06:08:44
248,141,336
7
8
BSD-3-Clause
2022-07-06T20:32:48
2020-03-18T04:52:18
null
UTF-8
C++
false
false
1,174
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/metrics/gpu/gpu_metrics_provider.h" #include "content/public/browser/gpu_data_manager.h" #include "gpu/config/gpu_info.h" #include "third_party/metrics_proto/system_profile.pb.h" namespace metrics { GPUMetricsProvider::GPUMetricsProvider() { } GPUMetricsProvider::~GPUMetricsProvider() { } void GPUMetricsProvider::ProvideSystemProfileMetrics( SystemProfileProto* system_profile_proto) { SystemProfileProto::Hardware* hardware = system_profile_proto->mutable_hardware(); const gpu::GPUInfo& gpu_info = content::GpuDataManager::GetInstance()->GetGPUInfo(); const gpu::GPUInfo::GPUDevice& active_gpu = gpu_info.active_gpu(); SystemProfileProto::Hardware::Graphics* gpu = hardware->mutable_gpu(); gpu->set_vendor_id(active_gpu.vendor_id); gpu->set_device_id(active_gpu.device_id); gpu->set_driver_version(active_gpu.driver_version); gpu->set_gl_vendor(gpu_info.gl_vendor); gpu->set_gl_renderer(gpu_info.gl_renderer); } } // namespace metrics
[ "pcding@ucdavis.edu" ]
pcding@ucdavis.edu
a34d8761a59399ab926a760d0f2a53ce722490a7
7fc78506b40be661adbec6322ab69ed27e4adbbc
/week_05/day_02/green-fox/Cohort.h
2118aa246ba7a39c0c0b9493742c56c802a594f1
[]
no_license
green-fox-academy/aronb0201
d774b7bdad3b034ce7c514d66981693e2e68682e
5dfd5ea33de4ec1e2f53459735ef67ae8babeec5
refs/heads/master
2020-04-02T17:22:04.619024
2019-01-06T15:09:26
2019-01-06T15:09:26
154,655,032
0
0
null
null
null
null
UTF-8
C++
false
false
451
h
// // Created by Titkos on 20/11/2018. // #ifndef GREEN_FOX_COHORT_H #define GREEN_FOX_COHORT_H #include <vector> #include "Student.h" #include "Mentor.h" class Cohort { public: Cohort(std::string name); void addStudent(Student *student); void addMentor(Mentor *mentor); void info(); private: std::string _name; std::vector<Student *> _students; std::vector<Mentor *> _mentors; }; #endif //GREEN_FOX_COHORT_H
[ "aron.baracs@gmail.com" ]
aron.baracs@gmail.com
ca46eefb420bdac7086dd18481e65fd50393297d
7cd65aa9c59b9746ce5577f123189a36fcd9fcda
/src/sounds/operators/Inverser.h
2703aba8c95ef65e5bcdb835eef41c343242f105
[]
no_license
Phirxian/sacred-fractal
119274a16fad510c7a452cbf12e75a28601bae59
626d95e33602c14b93897b715a18639f9b6a6f4e
refs/heads/main
2023-01-11T21:02:46.003008
2020-11-16T20:39:31
2020-11-16T20:39:31
313,420,730
0
1
null
null
null
null
UTF-8
C++
false
false
676
h
#ifndef __SACRED_INVERSER__ #define __SACRED_INVERSER__ /** * @file Inverser.h * @brief Declares the Inverser class * * @author Adrien Grosjean * @version 1.1 * @date April 27 2017 **/ #include "../SignalSource.h" namespace sacred { namespace sounds { /** * @class Inverser * @brief SignalSource that inverts the signal **/ class Inverser : public SignalSource { public: Inverser(); virtual ~Inverser(); virtual const char* getTypeName() const { return "Inversser"; } void process() noexcept override; }; } } #endif
[ "phirxian@gmail.com" ]
phirxian@gmail.com
1597a71b9c68e2cafe465dca2ce359b93694a5dc
3d8c640243d36f77c31022cc7341fae49fdb0411
/Media/Image/MhWEBP.cpp
2dec5e85a2d35b3ee7fecf7293b1040505db9ac7
[]
no_license
Metalhead33/CK3-Pheno-Comporator
ffc06aa76522c87e6ccf1078ea9495d9c8de1343
dcedf2140d21c123911cf1920281997cd44ee8e3
refs/heads/main
2023-06-15T11:12:32.494360
2021-07-14T18:02:42
2021-07-14T18:02:42
386,031,519
1
0
null
null
null
null
UTF-8
C++
false
false
8,097
cpp
#include "MhWEBP.hpp" #include <webp/decode.h> #include <webp/encode.h> #include <webp/demux.h> #include <cmath> #include <limits> #include <cstring> #include <memory> #include <stdexcept> namespace MH33 { namespace GFX { namespace WEBP { bool decode(const Util::Buffer &srcBuffer, DecodeTarget &target) { if(srcBuffer.empty()) return false; int width,height; if(!WebPGetInfo(reinterpret_cast<const uint8_t*>(srcBuffer.data()),srcBuffer.size(),&width,&height)) return false; int stride = width*byteSize(target.format); target.isAnimated = false; target.frames.resize(1); target.frames[0].imageData.resize(stride*height); switch (target.format) { case Format::BGR8U: return WebPDecodeBGRInto(reinterpret_cast<const uint8_t*>(srcBuffer.data()),srcBuffer.size(), reinterpret_cast<uint8_t*>(target.frames[0].imageData.data()),target.frames[0].imageData.size(),stride) != nullptr; case Format::BGRA8U: return WebPDecodeBGRAInto(reinterpret_cast<const uint8_t*>(srcBuffer.data()),srcBuffer.size(), reinterpret_cast<uint8_t*>(target.frames[0].imageData.data()),target.frames[0].imageData.size(),stride) != nullptr; case Format::RGB8U: return WebPDecodeRGBInto(reinterpret_cast<const uint8_t*>(srcBuffer.data()),srcBuffer.size(), reinterpret_cast<uint8_t*>(target.frames[0].imageData.data()),target.frames[0].imageData.size(),stride) != nullptr; case Format::RGBA8U: return WebPDecodeRGBAInto(reinterpret_cast<const uint8_t*>(srcBuffer.data()),srcBuffer.size(), reinterpret_cast<uint8_t*>(target.frames[0].imageData.data()),target.frames[0].imageData.size(),stride) != nullptr; case Format::ARGB8U: return WebPDecodeARGBInto(reinterpret_cast<const uint8_t*>(srcBuffer.data()),srcBuffer.size(), reinterpret_cast<uint8_t*>(target.frames[0].imageData.data()),target.frames[0].imageData.size(),stride) != nullptr; default: target.format = Format::RGBA8U; return WebPDecodeRGBAInto(reinterpret_cast<const uint8_t*>(srcBuffer.data()),srcBuffer.size(), reinterpret_cast<uint8_t*>(target.frames[0].imageData.data()),target.frames[0].imageData.size(),stride) != nullptr; } } bool decode(Io::Device &iodev, DecodeTarget &target) { auto buff = iodev.readAll(); return decode(buff,target); } size_t encode(const uint8_t* pixdat, int width, int height, int stride, Format format, float compressionLevel, uint8_t** ptr) { if(compressionLevel <= std::numeric_limits<float>::epsilon()) { // Lossless switch (format) { case Format::BGR8U: return WebPEncodeLosslessBGR(pixdat,width,height,stride,ptr); case Format::BGRA8U: return WebPEncodeLosslessBGRA(pixdat,width,height,stride,ptr); case Format::RGB8U: return WebPEncodeLosslessRGB(pixdat,width,height,stride,ptr); case Format::RGBA8U: return WebPEncodeLosslessRGBA(pixdat,width,height,stride,ptr); default: return 0; } } else { const float quality_factor = (1.0f-std::clamp(compressionLevel,0.0f,1.0f))*100.f; switch (format) { case Format::BGR8U: return WebPEncodeBGR(pixdat,width,height,stride,quality_factor,ptr); case Format::BGRA8U: return WebPEncodeBGRA(pixdat,width,height,stride,quality_factor,ptr); case Format::RGB8U: return WebPEncodeRGB(pixdat,width,height,stride,quality_factor,ptr); case Format::RGBA8U: return WebPEncodeRGBA(pixdat,width,height,stride,quality_factor,ptr); default: return 0; } } } bool encode(const Util::Buffer &srcBuffer, int width, int height, int stride, Format format, float compressionLevel, Util::Buffer &dstBuffer) { if(srcBuffer.empty()) return false; uint8_t* out; auto encoded = encode(reinterpret_cast<const uint8_t*>(srcBuffer.data()),width,height,stride,format,compressionLevel,&out); if(!encoded) return false; dstBuffer.resize(encoded); std::memcpy(dstBuffer.data(),out,encoded); WebPFree(out); return true; } bool encode(const Util::Buffer &srcBuffer, int width, int height, int stride, Format format, float compressionLevel, Io::Device &dst) { if(srcBuffer.empty()) return false; uint8_t* out; auto encoded = encode(reinterpret_cast<const uint8_t*>(srcBuffer.data()),width,height,stride,format,compressionLevel,&out); if(!encoded) return false; dst.write(out,encoded); WebPFree(out); return true; } bool demux(const Util::Buffer &srcBuffer, DecodeTarget &target) { if(srcBuffer.empty()) return false; typedef std::unique_ptr<WebPDemuxer,decltype (&WebPDemuxDelete)> Configuration; WebPData riff; riff.bytes = reinterpret_cast<const uint8_t*>(srcBuffer.data()); riff.size = srcBuffer.size(); Configuration config = Configuration(WebPDemux(&riff),WebPDemuxDelete); if(!config) return false; uint32_t width = WebPDemuxGetI(config.get(), WEBP_FF_CANVAS_WIDTH); uint32_t height = WebPDemuxGetI(config.get(), WEBP_FF_CANVAS_HEIGHT); //uint32_t flags = WebPDemuxGetI(config.get(), WEBP_FF_FORMAT_FLAGS); //uint32_t frameCount = WebPDemuxGetI(config.get(), WEBP_FF_FRAME_COUNT); WebPIterator iter; if (WebPDemuxGetFrame(config.get(), 1, &iter)) { do { int stride = width*byteSize(target.format); int targetSize = stride*height; target.frames.push_back(Frame()); target.frames.back().imageData.resize(targetSize); target.frames.back().width = width; target.frames.back().height = height; target.frames.back().stride = stride; uint8_t* data = nullptr; switch (target.format) { /*case Format::BGR8U: data = WebPDecodeBGR(iter.fragment.bytes,iter.fragment.size,nullptr,nullptr); break;*/ case Format::BGR8U: WebPDecodeBGRInto(iter.fragment.bytes,iter.fragment.size, reinterpret_cast<uint8_t*>(target.frames.back().imageData.data()),target.frames.back().imageData.size(),stride); break; case Format::BGRA8U: WebPDecodeBGRAInto(iter.fragment.bytes,iter.fragment.size, reinterpret_cast<uint8_t*>(target.frames.back().imageData.data()),target.frames.back().imageData.size(),stride); break; case Format::RGB8U: WebPDecodeRGBInto(iter.fragment.bytes,iter.fragment.size, reinterpret_cast<uint8_t*>(target.frames.back().imageData.data()),target.frames.back().imageData.size(),stride); break; case Format::RGBA8U: WebPDecodeRGBAInto(iter.fragment.bytes,iter.fragment.size, reinterpret_cast<uint8_t*>(target.frames.back().imageData.data()),target.frames.back().imageData.size(),stride); break; case Format::ARGB8U: WebPDecodeARGBInto(iter.fragment.bytes,iter.fragment.size, reinterpret_cast<uint8_t*>(target.frames.back().imageData.data()),target.frames.back().imageData.size(),stride); break; default: target.format = Format::RGB8U; stride = width*byteSize(target.format); target.frames.back().stride = stride; targetSize = width*stride; target.frames.back().imageData.resize(targetSize); WebPDecodeRGBInto(iter.fragment.bytes,iter.fragment.size, reinterpret_cast<uint8_t*>(target.frames.back().imageData.data()),target.frames.back().imageData.size(),stride); break; } } while (WebPDemuxNextFrame(&iter)); WebPDemuxReleaseIterator(&iter); } if(target.frames.size() > 1) target.isAnimated = true; else target.isAnimated = false; return true; } bool demux(Io::Device &iodev, DecodeTarget &target) { auto buff = iodev.readAll(); return demux(buff,target); } void decode(Io::System &iosys, const char *path, DecodeTarget &destination) { std::unique_ptr<Io::Device> iodev(iosys.open(path,Io::Mode::READ)); if(iodev) { decode(*iodev,destination); } } void decode(Io::System &iosys, const std::string &path, DecodeTarget &destination) { std::unique_ptr<Io::Device> iodev(iosys.open(path,Io::Mode::READ)); if(iodev) { decode(*iodev,destination); } } void demux(Io::System &iosys, const char *path, DecodeTarget &destination) { std::unique_ptr<Io::Device> iodev(iosys.open(path,Io::Mode::READ)); if(iodev) { demux(*iodev,destination); } } void demux(Io::System &iosys, const std::string &path, DecodeTarget &destination) { std::unique_ptr<Io::Device> iodev(iosys.open(path,Io::Mode::READ)); if(iodev) { demux(*iodev,destination); } } } } }
[ "waysofdarkness@gmail.com" ]
waysofdarkness@gmail.com
f52e1384de55527ffdadc2bbad87531b51bad645
e2ac77e6bb5fc9e2169f1b4f827d3108550078d1
/Educational/C++/OOPFinalRev/allocator.h
cd6280fc7c821603faea9fcae1824e185f3f40c4
[]
no_license
Rajmirukula/programming
c2ab4dbe5ee6ca78be6661800eb6e334c71501ee
2801e8c641b101494ee8586ca28f50116dffb261
refs/heads/master
2020-07-03T16:42:06.104576
2016-10-02T23:12:14
2016-10-02T23:12:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,921
h
/* this should use NESTED CLASSES just 'cause that's another thing on his list of things to know yeesh I can't remember this stuff AT ALL! how about creating a linked-list with an allocator that uses nested classes? surely this will take a few hours */ #include <memory> /* allocator */ #include <cstddef> /* size_t */ /* TODO how do I make this into a proper ALLOCATOR? */ template <typename T> class linked_list_allocator { public: struct node { T item; node* next; }; /* allocator methods */ T* allocate(size_t n) { for (size_t i = 0; i < n; i++) { } return nullptr; } void construct(T* p, const T& v) { } void deallocate(T* p, size_t s) { } void destroy(T* p) { } private: node head; }; template <typename AllocT, typename ArrT> void my_destroy(AllocT& alloc, ArrT arr, ArrT arrEnd) { while (arr != arrEnd) alloc.destroy(&*(arr++)); } template <typename AllocT, typename ToFillT, typename ValT> void my_uninitialized_fill(AllocT& alloc, ToFillT first, ToFillT end, ValT value) { ToFillT copied_ptr = first; try { while (copied_ptr != end) alloc.construct(&*(copied_ptr++), value); } catch (...) { my_destroy(alloc, first, copied_ptr); throw; } } template <typename T, typename A = std::allocator<T> > class my_vector { public: my_vector(std::size_t sz = 0, const T& v = T(), const A& a = A()) : the_allocator(a), arr_size(sz), _arr(the_allocator.allocate(sz)) { my_uninitialized_fill(the_allocator, _arr, _arr+sz, v); } T& operator [](std::size_t idx) const { return _arr[idx]; }; ~my_vector() { my_destroy(the_allocator, _arr, _arr+arr_size); the_allocator.deallocate(_arr, arr_size); } private: A the_allocator; std::size_t arr_size; T* const _arr; };
[ "ethanp@utexas.edu" ]
ethanp@utexas.edu
0df3cc4f35bb71b7a4cb7c9e1235ce9beccf5227
948f4e13af6b3014582909cc6d762606f2a43365
/testcases/juliet_test_suite/testcases/CWE590_Free_Memory_Not_on_Heap/s03/CWE590_Free_Memory_Not_on_Heap__delete_struct_placement_new_34.cpp
5c51e3045ffd7334a8bc26398084f8ba16fd9714
[]
no_license
junxzm1990/ASAN--
0056a341b8537142e10373c8417f27d7825ad89b
ca96e46422407a55bed4aa551a6ad28ec1eeef4e
refs/heads/master
2022-08-02T15:38:56.286555
2022-06-16T22:19:54
2022-06-16T22:19:54
408,238,453
74
13
null
2022-06-16T22:19:55
2021-09-19T21:14:59
null
UTF-8
C++
false
false
3,103
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE590_Free_Memory_Not_on_Heap__delete_struct_placement_new_34.cpp Label Definition File: CWE590_Free_Memory_Not_on_Heap__delete.pointer.label.xml Template File: sources-sink-34.tmpl.cpp */ /* * @description * CWE: 590 Free Memory Not on Heap * BadSource: placement_new Data buffer is declared on the stack * GoodSource: Allocate memory on the heap * Sinks: * BadSink : Print then free data * Flow Variant: 34 Data flow: use of a union containing two methods of accessing the same data (within the same function) * * */ #include "std_testcase.h" #include <wchar.h> namespace CWE590_Free_Memory_Not_on_Heap__delete_struct_placement_new_34 { typedef union { twoIntsStruct * unionFirst; twoIntsStruct * unionSecond; } unionType; #ifndef OMITBAD void bad() { twoIntsStruct * data; unionType myUnion; data = NULL; /* Initialize data */ { /* FLAW: data is allocated on the stack and deallocated in the BadSink */ char buffer[sizeof(twoIntsStruct)]; twoIntsStruct * dataBuffer = new(buffer) twoIntsStruct; dataBuffer->intOne = 1; dataBuffer->intTwo = 1; data = dataBuffer; } myUnion.unionFirst = data; { twoIntsStruct * data = myUnion.unionSecond; printStructLine(data); /* POTENTIAL FLAW: Possibly deallocating memory allocated on the stack */ delete data; } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2B() { twoIntsStruct * data; unionType myUnion; data = NULL; /* Initialize data */ { /* FIX: data is allocated on the heap and deallocated in the BadSink */ twoIntsStruct * dataBuffer = new twoIntsStruct; dataBuffer->intOne = 1; dataBuffer->intTwo = 1; data = dataBuffer; } myUnion.unionFirst = data; { twoIntsStruct * data = myUnion.unionSecond; printStructLine(data); /* POTENTIAL FLAW: Possibly deallocating memory allocated on the stack */ delete data; } } void good() { goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE590_Free_Memory_Not_on_Heap__delete_struct_placement_new_34; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "yzhang0701@gmail.com" ]
yzhang0701@gmail.com
5f9b7a4008d8467f7d23735be28e686d043fe8f2
49c3e9001a914e057552435ba5bc5aa1f4e412a3
/source/exporting/TextFile.cpp
288304fad3ed8bc4802c28da9f629d070975f804
[ "MIT" ]
permissive
alijenabi/ConfigurationExporter
92dda2205165c4fd19144c08aea3f60fa0a56b10
de8150d601ab2033a494396c89c80b624d82de0c
refs/heads/master
2023-01-08T12:59:27.716315
2020-11-08T02:42:20
2020-11-08T02:42:20
280,744,775
2
1
null
null
null
null
UTF-8
C++
false
false
1,368
cpp
// // TextFile.cpp // Relation-Based Simulator (RBS) // // Created by Ali Jenabidehkordi on 16.04.18. // Copyright © 2020 Ali Jenabidehkordi. All rights reserved. // #include "file_system/FileRegistar.h" #include "TextFile.h" namespace exporting { using SingleFile = file_system::SingleFile; TextFile::TextFile(const std::string &name, const std::string &extension) : SingleFile(name, extension) { } TextFile::TextFile(const std::string &path, const std::string &name, const std::string &extension) : SingleFile(path, name, extension) { } TextFile::CharCount TextFile::append(const char *c_str) { if(!isOpen()) open(false); return std::fputs(c_str, filePtr()); } TextFile::CharCount TextFile::append(const std::string &str) { return append(str.c_str()); } bool TextFile::appendFileContent(const std::string &filePath) { unsigned long addedChars = 0; char buffer[1024]; auto otherFile = file_system::FileRegistar::current().open(filePath.c_str(), "r"); if (!isOpen()) open(false); if (otherFile) while (std::fgets(buffer, sizeof(buffer), otherFile)) addedChars += std::fputs(buffer, filePtr()); file_system::FileRegistar::current().close(otherFile); return addedChars; } bool TextFile::nextLine() { return static_cast<bool>(append("\n")); } } // namespace exporting
[ "ali.jenabi@gmail.com" ]
ali.jenabi@gmail.com
cf455149a36a65bf5e87df76316a13b0bfeb0a4b
0b9f6534a99ff551f0006df78a24e8af30340580
/Source/BackupFiles/CryptoMargin/Common/SMClient.cpp
55869141ca8ee3350e4e0a140780af0034aaa428
[]
no_license
jayirum/ChartProjSvr
9bac49865d1e081de0cbd7559d0d2cbdd26279c2
d69edfcb3ac3698e1bdfcf5862d5e63bb305cb52
refs/heads/master
2020-03-24T03:22:18.176911
2019-07-05T01:38:03
2019-07-05T01:38:03
142,416,528
1
1
null
null
null
null
UHC
C++
false
false
6,136
cpp
#include "SMClient.h" #include <stdio.h> #include <string.h> #include <Windows.h> #include "../../IRUM_UTIL/Util.h" CSMClient::CSMClient() { m_pSendBuff = NULL; } CSMClient::~CSMClient() { delete[] m_pSendBuff; } VOID CSMClient::SetDestination(char* psDest) { strcpy(m_zDestination, psDest); } VOID CSMClient::SetMsg(char* psMsgKey, char* psMsg) { strcpy(m_zMsgKey, psMsgKey); strcpy(m_zMsgData, psMsg); } VOID CSMClient::SetData(char* psDataKey, char* pData, FIELD_TYPE DataType, int nDataSize) { strcpy(m_zDataKey, psDataKey); m_pData = pData; m_DataType = DataType; m_nDataSize = nDataSize; } VOID CSMClient::SetDelieveryMode(TDeliveryMode mode) { if (mode == Delivery_RR) m_Tr = ctDestRRSend; else if (mode == Delivery_RR_Response) m_Tr = ctDestRRSendResponse; else m_Tr = ctDestPushSend; } char* CSMClient::GetSendData(_Out_ int *pnSendSize) { __try { GetSendDataFn(pnSendSize); } __except (ReportException(GetExceptionCode(), "GetSendData", m_zErrMsg)) { return NULL; } return m_pSendBuff; } char* CSMClient::GetSendDataFn(_Out_ int *pnSendSize) { int nBufferSize = 0; int nLen = CalcDataSize(m_zMsgKey, TYPE_STRING, m_zMsgData, strlen(m_zMsgData)); nBufferSize += nLen; nLen = CalcDataSize(m_zDataKey, m_DataType, m_pData, m_nDataSize); nBufferSize += nLen; // total sending size int nHeadSize = sizeof(SHM_HEAD); int nDestPos = sizeof(WORD); int nDestLen = strlen(m_zDestination); m_nSendSize = nHeadSize + nDestPos + nDestLen + nBufferSize; *pnSendSize = m_nSendSize; // create send buffer //m_pSendBuff = new char[m_nSendSize]; //int iPos; //iPos = nHeadSize + nDestPos + nDestLen; //iPos = SetFieldData_Msg(iPos, Buffer, m_zMsgKey, m_zMsgData); //iPos = SetFieldData_Data(iPos, Buffer, m_zDataKey, m_pData, m_nDataSize); //SHM_HEAD* pH = (SHM_HEAD*)Buffer; //pH->TR = (BYTE)m_Tr; //pH->DataLen = m_nSendSize - nHeadSize; //Buffer[nHeadSize] = (WORD)(nDestLen); //CopyMemory(&Buffer[nHeadSize + nDestPos], m_zDestination, nDestLen); m_pSendBuff = new char[m_nSendSize]; ZeroMemory(m_pSendBuff, m_nSendSize); int iPos; iPos = nHeadSize + nDestPos + nDestLen; iPos = SetFieldData_Msg(iPos, m_pSendBuff, m_zMsgKey, m_zMsgData); iPos = SetFieldData_Data(iPos, m_pSendBuff, m_zDataKey, m_pData, m_nDataSize); SHM_HEAD* pH = (SHM_HEAD*)m_pSendBuff; pH->TR = (BYTE)m_Tr; pH->DataLen = m_nSendSize - nHeadSize; m_pSendBuff[nHeadSize] = (WORD)(nDestLen); CopyMemory(&m_pSendBuff[nHeadSize + nDestPos], m_zDestination, nDestLen); return m_pSendBuff; } int CSMClient::GetByteSize(int nLen) { int nResult = 0; if (nLen <= 255) nResult = sizeof(BYTE); else if (nLen <= 65535) nResult = sizeof(WORD); else if (nLen <= 2147483647) nResult = sizeof(int); return nResult; } int CSMClient::CalcDataSize(char* pKey, FIELD_TYPE type, char* pData, int nDataSize) { int iLen, Result; Result = 0; ///////////////////////////////////////// // FieldName 정보 Result++;; // Data Info (1Byte), 길이를 표현하기 위해 필요한 바이트수 iLen = strlen(pKey); Result += GetByteSize(iLen); Result += iLen; // Data Len ///////////////////////////////////////// // Data 정보 Result++; // Data Info (1Byte) if (type == TYPE_INT) //(IT^.Data) ^ .MsgFieldType = mfInteger then Result += sizeof(long); else if (type == TYPE_DOUBLE) //PFieldData(IT^.Data) ^ .MsgFieldType = mfDouble then Result += sizeof(double); else if (type == TYPE_STRING) //PFieldData(IT^.Data) ^ .MsgFieldType = mfString then { iLen = strlen(pData); Result += GetByteSize(iLen); Result += iLen; } else if (type==TYPE_BINARY) //PFieldData(IT^.Data) ^ .MsgFieldType = mfBinary then { iLen = nDataSize; // : = PFieldData(IT^.Data) ^ .Bin.FLen; Result += GetByteSize(iLen); Result += iLen; } return Result; } int CSMClient::SetFieldData_Msg(int iPos, char* Buffer, char* pKey, char* pData) { //char Buffer[1024] = { 0, }; int iDataHead, iKey, iData, iByteCnt; iDataHead = iPos; Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_FIELD; Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_BYTE_1; // Byte(Buffer[iDataHead]) := Byte(Buffer[iDataHead]) or SM_DATA_BYTE_1; // MSG 저장 - KEY iPos++; iKey = strlen(pKey); iByteCnt = GetByteSize(iKey); // 255 미만이다. Buffer[iPos] = iKey; iPos += iByteCnt; CopyMemory(Buffer + iPos, pKey, iKey); iPos += iKey; // MSG 저장 - DATA iDataHead = iPos; Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_STRING; Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_BYTE_1; // Byte(Buffer[iDataHead]) := Byte(Buffer[iDataHead]) or SM_DATA_BYTE_1; iData = strlen(pData); iByteCnt = GetByteSize(iData); // 255 미만이다. iPos++; Buffer[iPos] = iData; // data length iPos += iByteCnt; CopyMemory(Buffer + iPos, pData, iData); iPos += iData; //CopyMemory(pBuffer, Buffer, iPos); return iPos; } int CSMClient::SetFieldData_Data(int iPos, char* Buffer, char* pKey, char* pData, int nDataSize) { //char Buffer[1024] = { 0, }; //int nStart = iPos; int iDataHead, iKey, iData, iByteCnt; iDataHead = iPos; Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_FIELD; Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_BYTE_1; // Byte(Buffer[iDataHead]) := Byte(Buffer[iDataHead]) or SM_DATA_BYTE_1; // DATA 저장 - KEY iPos++; iKey = strlen(pKey); iByteCnt = GetByteSize(iKey); // 255 미만이다. Buffer[iPos] = iKey; iPos += iByteCnt; CopyMemory(Buffer + iPos, pKey, iKey); iPos += iKey; // MSG 저장 - DATA iDataHead = iPos; Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_BINARY; iData = nDataSize; iByteCnt = GetByteSize(iData); // if (iByteCnt == 1) Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_BYTE_1; else if (iByteCnt == 2) Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_BYTE_2; if (iByteCnt == 4) Buffer[iDataHead] = ((BYTE)Buffer[iDataHead]) | SM_DATA_BYTE_4; iPos++; Buffer[iPos] = iData; iPos += iByteCnt; CopyMemory(Buffer + iPos, pData, iData); iPos += iData; //CopyMemory(pBuffer, Buffer + nStart, iPos - nStart); return iPos; }
[ "jay.bwkim@gmail.com" ]
jay.bwkim@gmail.com
892afd5b83033e75fc6bc267c3a685d8fdd48faa
862aea3ca42b6a99d12755937638792ee6d819a5
/Assignments/Inheritance/multiple.cpp
74b90b36298c68ddb362f6e127638eeb4cbe6ec8
[]
no_license
Malisha-Maharjan/cpp_projects
95c9f8f926efe0f904257613fac74d060a92c35e
03ed4fdb792fce1a698d876209b840279b91ee9e
refs/heads/main
2023-07-19T05:38:53.732164
2021-09-14T11:36:11
2021-09-14T11:36:11
366,620,037
0
0
null
null
null
null
UTF-8
C++
false
false
1,439
cpp
#include <iostream> using namespace std; class Genre { protected: char g[50]; public: Genre() { cout << "Genre: "; cin.getline(g, 50); } void displayGenre() { cout << "Genre: " << g << endl; } // ~Genre() destructor. // { // cout << "Genre: " << g << endl; // } }; class Writter { protected: char name[30]; public: Writter() { cout << "Name of the Writter: "; cin.getline(name,30); } void displayWritter() { cout << "Written by: " << name << endl; } // ~Writter() destructor // { // cout << "Written by: " << name << endl; // } }; class Book: public Genre, public Writter { protected: char book_name[50]; public: Book() { cout << "Name of the Book: "; cin.getline(book_name, 50); } void displayBook() { cout << "Name of the book: " << book_name << endl; } }; int main() { Book book1; book1.displayBook(); book1.displayGenre(); book1.displayWritter(); return 0; } //Note::-> Parent class ko construtor paila call hunxa. // -> Destructor chai sabbai class ko constructor call vaye vani call hunxa. // -> Destructor ma chai last in first out wala principle lagxa. // -> Jun class ko constructor last ma call hunxa tesko destructor first ma call hunxa.
[ "malishamaharjan00@gmail.com" ]
malishamaharjan00@gmail.com
3ac05c81c7402fbb109bc56ecdc4f1af9c86268f
87980b1766297af1ee520faca19a4f795b7fd3f3
/cocos2d-x-3.0alpha0/extensions/GUI/CCEditBox/CCEditBoxImplTizen.h
84e1ae11f1b6683f245625e6bdc4e1b89236b424
[]
no_license
yasuhiro-matsuda/ichi_okuman_yen
9cc9fb4ab61c8a990fc0fb2d3c01ff84feebe977
621e12aef76f5c5b1b88ddfa8b0d1b5b48e0a26c
refs/heads/master
2021-01-01T05:49:21.292931
2013-10-13T13:33:12
2013-10-13T13:33:12
13,150,852
2
0
null
null
null
null
UTF-8
C++
false
false
3,481
h
/**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2012 James Chen Copyright (c) 2013 Lee, Jae-Hong http://www.cocos2d-x.org 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 __CCEDITBOXIMPLTIZEN_H__ #define __CCEDITBOXIMPLTIZEN_H__ #include "cocos2d.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) #include "ExtensionMacros.h" #include "CCEditBoxImpl.h" NS_CC_EXT_BEGIN class EditBox; class EditBoxImplTizen : public EditBoxImpl { public: /** * @js NA */ EditBoxImplTizen(EditBox* pEditText); /** * @js NA * @lua NA */ virtual ~EditBoxImplTizen(); virtual bool initWithSize(const Size& size); virtual void setFont(const char* pFontName, int fontSize); virtual void setFontColor(const Color3B& color); virtual void setPlaceholderFont(const char* pFontName, int fontSize); virtual void setPlaceholderFontColor(const Color3B& color); virtual void setInputMode(EditBox::InputMode inputMode); virtual void setInputFlag(EditBox::InputFlag inputFlag); virtual void setMaxLength(int maxLength); virtual int getMaxLength(); virtual void setReturnType(EditBox::KeyboardReturnType returnType); virtual bool isEditing(); virtual void setText(const char* pText); virtual const char* getText(void); virtual void setPlaceHolder(const char* pText); virtual void setPosition(const Point& pos); virtual void setVisible(bool visible); virtual void setContentSize(const Size& size); virtual void setAnchorPoint(const Point& anchorPoint); /** * @js NA * @lua NA */ virtual void visit(void); /** * @js NA * @lua NA */ virtual void onEnter(void); virtual void doAnimationWhenKeyboardMove(float duration, float distance); virtual void openKeyboard(); virtual void closeKeyboard(); private: LabelTTF* _label; LabelTTF* _labelPlaceHolder; EditBox::InputMode _editBoxInputMode; EditBox::InputFlag _editBoxInputFlag; EditBox::KeyboardReturnType _keyboardReturnType; std::string _text; std::string _placeHolder; Color3B _colText; Color3B _colPlaceHolder; int _maxLength; Size _editSize; }; NS_CC_EXT_END #endif /* #if (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) */ #endif /* __CCEDITBOXIMPLTIZEN_H__ */
[ "ichi.okuman.yen@gmail.com" ]
ichi.okuman.yen@gmail.com
2423ac9a174a122119c9f962499166656102849d
7a90eabd633658652c7d530a096df7742640f0b3
/tools/obj2yaml/.svn/text-base/coff2yaml.cpp.svn-base
48462f69fc5da73139d5340ababf2a472a0a74c1
[ "NCSA" ]
permissive
rigelgjomemo/csfv
46bf61cecfebe127e13ecf79527187bccb1a0f69
888d71272d2674b1e6c3f5d71c3399f654c0b1e2
refs/heads/master
2016-09-05T19:21:48.773153
2014-12-05T20:08:05
2014-12-05T20:08:05
21,575,975
2
0
null
2014-08-20T16:50:37
2014-07-07T15:35:14
C++
UTF-8
C++
false
false
7,964
//===------ utils/obj2yaml.cpp - obj2yaml conversion tool -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "obj2yaml.h" #include "llvm/Object/COFF.h" #include "llvm/Object/COFFYAML.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/YAMLTraits.h" using namespace llvm; namespace { class COFFDumper { const object::COFFObjectFile &Obj; COFFYAML::Object YAMLObj; void dumpHeader(const object::coff_file_header *Header); void dumpSections(unsigned numSections); void dumpSymbols(unsigned numSymbols); public: COFFDumper(const object::COFFObjectFile &Obj); COFFYAML::Object &getYAMLObj(); }; } static void check(std::error_code ec) { if (ec) report_fatal_error(ec.message()); } COFFDumper::COFFDumper(const object::COFFObjectFile &Obj) : Obj(Obj) { const object::coff_file_header *Header; check(Obj.getCOFFHeader(Header)); dumpHeader(Header); dumpSections(Header->NumberOfSections); dumpSymbols(Header->NumberOfSymbols); } void COFFDumper::dumpHeader(const object::coff_file_header *Header) { YAMLObj.Header.Machine = Header->Machine; YAMLObj.Header.Characteristics = Header->Characteristics; } void COFFDumper::dumpSections(unsigned NumSections) { std::vector<COFFYAML::Section> &Sections = YAMLObj.Sections; for (const auto &Section : Obj.sections()) { const object::coff_section *Sect = Obj.getCOFFSection(Section); COFFYAML::Section Sec; Sec.Name = Sect->Name; // FIXME: check the null termination! uint32_t Characteristics = Sect->Characteristics; Sec.Header.Characteristics = Characteristics; Sec.Alignment = 1 << (((Characteristics >> 20) & 0xf) - 1); ArrayRef<uint8_t> sectionData; Obj.getSectionContents(Sect, sectionData); Sec.SectionData = object::yaml::BinaryRef(sectionData); std::vector<COFFYAML::Relocation> Relocations; for (const auto &Reloc : Section.relocations()) { const object::coff_relocation *reloc = Obj.getCOFFRelocation(Reloc); COFFYAML::Relocation Rel; object::symbol_iterator Sym = Reloc.getSymbol(); Sym->getName(Rel.SymbolName); Rel.VirtualAddress = reloc->VirtualAddress; Rel.Type = reloc->Type; Relocations.push_back(Rel); } Sec.Relocations = Relocations; Sections.push_back(Sec); } } static void dumpFunctionDefinition(COFFYAML::Symbol *Sym, const object::coff_aux_function_definition *ObjFD) { COFF::AuxiliaryFunctionDefinition YAMLFD; YAMLFD.TagIndex = ObjFD->TagIndex; YAMLFD.TotalSize = ObjFD->TotalSize; YAMLFD.PointerToLinenumber = ObjFD->PointerToLinenumber; YAMLFD.PointerToNextFunction = ObjFD->PointerToNextFunction; Sym->FunctionDefinition = YAMLFD; } static void dumpbfAndEfLineInfo(COFFYAML::Symbol *Sym, const object::coff_aux_bf_and_ef_symbol *ObjBES) { COFF::AuxiliarybfAndefSymbol YAMLAAS; YAMLAAS.Linenumber = ObjBES->Linenumber; YAMLAAS.PointerToNextFunction = ObjBES->PointerToNextFunction; Sym->bfAndefSymbol = YAMLAAS; } static void dumpWeakExternal(COFFYAML::Symbol *Sym, const object::coff_aux_weak_external *ObjWE) { COFF::AuxiliaryWeakExternal YAMLWE; YAMLWE.TagIndex = ObjWE->TagIndex; YAMLWE.Characteristics = ObjWE->Characteristics; Sym->WeakExternal = YAMLWE; } static void dumpSectionDefinition(COFFYAML::Symbol *Sym, const object::coff_aux_section_definition *ObjSD) { COFF::AuxiliarySectionDefinition YAMLASD; YAMLASD.Length = ObjSD->Length; YAMLASD.NumberOfRelocations = ObjSD->NumberOfRelocations; YAMLASD.NumberOfLinenumbers = ObjSD->NumberOfLinenumbers; YAMLASD.CheckSum = ObjSD->CheckSum; YAMLASD.Number = ObjSD->Number; YAMLASD.Selection = ObjSD->Selection; Sym->SectionDefinition = YAMLASD; } static void dumpCLRTokenDefinition(COFFYAML::Symbol *Sym, const object::coff_aux_clr_token *ObjCLRToken) { COFF::AuxiliaryCLRToken YAMLCLRToken; YAMLCLRToken.AuxType = ObjCLRToken->AuxType; YAMLCLRToken.SymbolTableIndex = ObjCLRToken->SymbolTableIndex; Sym->CLRToken = YAMLCLRToken; } void COFFDumper::dumpSymbols(unsigned NumSymbols) { std::vector<COFFYAML::Symbol> &Symbols = YAMLObj.Symbols; for (const auto &S : Obj.symbols()) { const object::coff_symbol *Symbol = Obj.getCOFFSymbol(S); COFFYAML::Symbol Sym; Obj.getSymbolName(Symbol, Sym.Name); Sym.SimpleType = COFF::SymbolBaseType(Symbol->getBaseType()); Sym.ComplexType = COFF::SymbolComplexType(Symbol->getComplexType()); Sym.Header.StorageClass = Symbol->StorageClass; Sym.Header.Value = Symbol->Value; Sym.Header.SectionNumber = Symbol->SectionNumber; Sym.Header.NumberOfAuxSymbols = Symbol->NumberOfAuxSymbols; if (Symbol->NumberOfAuxSymbols > 0) { ArrayRef<uint8_t> AuxData = Obj.getSymbolAuxData(Symbol); if (Symbol->isFunctionDefinition()) { // This symbol represents a function definition. assert(Symbol->NumberOfAuxSymbols == 1 && "Expected a single aux symbol to describe this function!"); const object::coff_aux_function_definition *ObjFD = reinterpret_cast<const object::coff_aux_function_definition *>( AuxData.data()); dumpFunctionDefinition(&Sym, ObjFD); } else if (Symbol->isFunctionLineInfo()) { // This symbol describes function line number information. assert(Symbol->NumberOfAuxSymbols == 1 && "Exepected a single aux symbol to describe this section!"); const object::coff_aux_bf_and_ef_symbol *ObjBES = reinterpret_cast<const object::coff_aux_bf_and_ef_symbol *>( AuxData.data()); dumpbfAndEfLineInfo(&Sym, ObjBES); } else if (Symbol->isWeakExternal()) { // This symbol represents a weak external definition. assert(Symbol->NumberOfAuxSymbols == 1 && "Exepected a single aux symbol to describe this section!"); const object::coff_aux_weak_external *ObjWE = reinterpret_cast<const object::coff_aux_weak_external *>( AuxData.data()); dumpWeakExternal(&Sym, ObjWE); } else if (Symbol->isFileRecord()) { // This symbol represents a file record. Sym.File = StringRef(reinterpret_cast<const char *>(AuxData.data()), Symbol->NumberOfAuxSymbols * COFF::SymbolSize) .rtrim(StringRef("\0", /*length=*/1)); } else if (Symbol->isSectionDefinition()) { // This symbol represents a section definition. assert(Symbol->NumberOfAuxSymbols == 1 && "Expected a single aux symbol to describe this section!"); const object::coff_aux_section_definition *ObjSD = reinterpret_cast<const object::coff_aux_section_definition *>( AuxData.data()); dumpSectionDefinition(&Sym, ObjSD); } else if (Symbol->isCLRToken()) { // This symbol represents a CLR token definition. assert(Symbol->NumberOfAuxSymbols == 1 && "Expected a single aux symbol to describe this CLR Token"); const object::coff_aux_clr_token *ObjCLRToken = reinterpret_cast<const object::coff_aux_clr_token *>( AuxData.data()); dumpCLRTokenDefinition(&Sym, ObjCLRToken); } else { llvm_unreachable("Unhandled auxiliary symbol!"); } } Symbols.push_back(Sym); } } COFFYAML::Object &COFFDumper::getYAMLObj() { return YAMLObj; } std::error_code coff2yaml(raw_ostream &Out, const object::COFFObjectFile &Obj) { COFFDumper Dumper(Obj); yaml::Output Yout(Out); Yout << Dumper.getYAMLObj(); return object::object_error::success; }
[ "rgjome1@uic.edu" ]
rgjome1@uic.edu
5866c50d769141fb40c515c695cedd0c905eb2a0
dd6147bf9433298a64bbceb7fdccaa4cc477fba6
/7381/Azhenilok_Vlad/lab1/oop1.cpp
48e5e15245c64fe3623be89984b83f229aa79634
[]
no_license
moevm/oop
64a89677879341a3e8e91ba6d719ab598dcabb49
faffa7e14003b13c658ccf8853d6189b51ee30e6
refs/heads/master
2023-03-16T15:48:35.226647
2020-06-08T16:16:31
2020-06-08T16:16:31
85,785,460
42
304
null
2023-03-06T23:46:08
2017-03-22T04:37:01
C++
UTF-8
C++
false
false
2,231
cpp
#include <iostream> #include <assert.h> #include <algorithm> // std::copy #include <cstddef> // size_t template<typename T> class Array { public: // (default) constructor Array(const size_t size = 0) : m_size(size) , m_array(m_size ? new T[m_size]() : nullptr) { std::cout << "def" << std::endl; } //copy constructor Array(const Array &other) : m_size(other.m_size) , m_array(m_size ? new T[m_size]() : nullptr) { std::cout << "copy constr" << std::endl; std::copy(other.m_array, other.m_array+other.m_size, m_array); } //copy assigment operator Array& operator=(const Array& other) { std::cout << "copy assigment operator" << std::endl; if(this==&other) return *this; Array buf(other.m_size); std::copy(other.m_array, other.m_array + other.m_size, buf.m_array); delete []m_array; m_size = buf.m_size; m_array = m_size ? new T[m_size]() : nullptr; std::copy(buf.m_array, buf.m_array + buf.m_size, m_array); return *this; } //move constructor Array(Array&& other) : m_array(other.m_array) , m_size(other.m_size) { std::cout << "move constr" << std::endl; other.m_array = nullptr; other.m_size = 0; } //move assingnment operator Array& operator=(Array&& other) { std::cout << "move assigment operator" << std::endl; if(&other==this) return *this; delete [] m_array; m_array = other.m_array; m_size = other.m_size; other.m_array = nullptr; other.m_size = 0; return *this; } ~Array(){ delete[] m_array; // std::cout << "des" << std::endl; } const size_t size() const{ return m_size; } T& operator [](const size_t index){ assert(index < m_size); return m_array[index]; } private: size_t m_size; T* m_array; }; int main(){ Array <int>a = Array <int>(4); Array <int> b(6); a = b; a = Array <int> (8); // Array <int> c = Array <int> (5); Array <int> c = a; Array <int> d = std::move(a); return 0; }
[ "vlad.azhenilok@mail.ru" ]
vlad.azhenilok@mail.ru
6060609c318daaeb2afb806a65ccac1b2f36dfcf
b524c8603161eeec6574838d33b9266cf90df739
/google/cloud/storage/object_access_control.h
31d18544aced56155485625a688daab0e2b03323
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
NettyH/google-cloud-cpp
1b83d7464dbf16031c79c2e3eac3f42373b29050
dc32d71c3ebc2212e5eb7c580d1120793ed7b358
refs/heads/master
2020-04-08T16:58:24.253925
2019-01-15T15:20:09
2019-01-15T15:20:09
159,544,502
0
0
null
2018-11-28T18:08:54
2018-11-28T18:08:54
null
UTF-8
C++
false
false
4,632
h
// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_ACCESS_CONTROL_H_ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_ACCESS_CONTROL_H_ #include "google/cloud/status_or.h" #include "google/cloud/storage/internal/access_control_common.h" #include "google/cloud/storage/internal/common_metadata.h" #include "google/cloud/storage/internal/nljson.h" #include "google/cloud/storage/internal/patch_builder.h" namespace google { namespace cloud { namespace storage { inline namespace STORAGE_CLIENT_NS { /** * Wraps the objectAccessControl resource in Google Cloud Storage. * * objectAccessControl describes the access to a bucket for a single entity, * where the entity might be a user, group, or other role. * * @see * https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls for * an authoritative source of field definitions. */ class ObjectAccessControl : private internal::AccessControlCommon { public: ObjectAccessControl() : generation_(0) {} static StatusOr<ObjectAccessControl> ParseFromJson( internal::nl::json const& json); static StatusOr<ObjectAccessControl> ParseFromString( std::string const& payload); using AccessControlCommon::ROLE_OWNER; using AccessControlCommon::ROLE_READER; using AccessControlCommon::TEAM_EDITORS; using AccessControlCommon::TEAM_OWNERS; using AccessControlCommon::TEAM_VIEWERS; using AccessControlCommon::bucket; using AccessControlCommon::domain; using AccessControlCommon::email; using AccessControlCommon::entity; ObjectAccessControl& set_entity(std::string v) { AccessControlCommon::set_entity(std::move(v)); return *this; } using AccessControlCommon::entity_id; using AccessControlCommon::etag; using AccessControlCommon::has_project_team; using AccessControlCommon::id; using AccessControlCommon::kind; using AccessControlCommon::project_team; using AccessControlCommon::project_team_as_optional; using AccessControlCommon::role; ObjectAccessControl& set_role(std::string v) { AccessControlCommon::set_role(std::move(v)); return *this; } using AccessControlCommon::self_link; std::int64_t generation() const { return generation_; } std::string const& object() const { return object_; } bool operator==(ObjectAccessControl const& rhs) const; bool operator!=(ObjectAccessControl const& rhs) const { return not(*this == rhs); } private: std::int64_t generation_; std::string object_; }; std::ostream& operator<<(std::ostream& os, ObjectAccessControl const& rhs); /** * Prepares a patch for an ObjectAccessControl resource. * * The ObjectAccessControl resource only has two modifiable fields: entity * and role. This class allows application developers to setup a PATCH message, * note that some of the possible PATCH messages may result in errors from the * server, for example: while it is possible to express "change the value of the * entity field" with a PATCH request, the server rejects such changes. * * @see * https://cloud.google.com/storage/docs/json_api/v1/how-tos/performance#patch * for general information on PATCH requests for the Google Cloud Storage * JSON API. */ class ObjectAccessControlPatchBuilder { public: ObjectAccessControlPatchBuilder() = default; std::string BuildPatch() const { return impl_.ToString(); } ObjectAccessControlPatchBuilder& set_entity(std::string const& v) { impl_.SetStringField("entity", v); return *this; } ObjectAccessControlPatchBuilder& delete_entity() { impl_.RemoveField("entity"); return *this; } ObjectAccessControlPatchBuilder& set_role(std::string const& v) { impl_.SetStringField("role", v); return *this; } ObjectAccessControlPatchBuilder& delete_role() { impl_.RemoveField("role"); return *this; } private: internal::PatchBuilder impl_; }; } // namespace STORAGE_CLIENT_NS } // namespace storage } // namespace cloud } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_ACCESS_CONTROL_H_
[ "noreply@github.com" ]
noreply@github.com
5014745f43a9feedd85d37b6d080a9277b0ecfb6
baebbcb371f322ba3e52321f54d6dd7e615f39f4
/src/sksl/SkSLHCodeGenerator.h
fa4a3f3782ffb2d7c800a15ee1f31f0a63b4bc90
[ "BSD-3-Clause" ]
permissive
ragingwind/skia
08616a6d09fbdbee13f9a14d56dc4867d9e7482e
046828f2395246a3cfd7d7c3accaeb78ea33e23b
refs/heads/master
2023-01-03T02:25:14.399226
2020-09-19T14:18:59
2020-09-19T14:53:43
296,988,604
0
0
NOASSERTION
2020-09-20T02:38:33
2020-09-20T02:38:32
null
UTF-8
C++
false
false
2,831
h
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SKSL_HCODEGENERATOR #define SKSL_HCODEGENERATOR #include "src/sksl/SkSLCodeGenerator.h" #include "src/sksl/SkSLSectionAndParameterHelper.h" #include "src/sksl/ir/SkSLType.h" #include "src/sksl/ir/SkSLVariable.h" #include <cctype> #if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS) constexpr const char* kFragmentProcessorHeader = R"( /************************************************************************************************** *** This file was autogenerated from %s.fp; do not modify. **************************************************************************************************/ )"; namespace SkSL { class HCodeGenerator : public CodeGenerator { public: HCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors, String name, OutputStream* out); bool generateCode() override; static String ParameterType(const Context& context, const Type& type, const Layout& layout); static Layout::CType ParameterCType(const Context& context, const Type& type, const Layout& layout); static String FieldType(const Context& context, const Type& type, const Layout& layout); // Either the field type, or a const reference of the field type if the field type is complex. static String AccessType(const Context& context, const Type& type, const Layout& layout); static String FieldName(const char* varName) { return String(varName); } static String CoordTransformName(const String& arg, int index) { if (arg.size()) { return HCodeGenerator::FieldName(arg.c_str()) + "CoordTransform"; } return "fCoordTransform" + to_string(index); } static String GetHeader(const Program& program, ErrorReporter& errors); private: void writef(const char* s, va_list va) SKSL_PRINTF_LIKE(2, 0); void writef(const char* s, ...) SKSL_PRINTF_LIKE(2, 3); bool writeSection(const char* name, const char* prefix = ""); // given a @constructorParams section of e.g. 'int x, float y', writes out "<separator>x, y". // Writes nothing (not even the separator) if there is no @constructorParams section. void writeExtraConstructorParams(const char* separator); void writeMake(); void writeConstructor(); void writeFields(); void failOnSection(const char* section, const char* msg); const Context& fContext; String fName; String fFullName; SectionAndParameterHelper fSectionAndParameterHelper; using INHERITED = CodeGenerator; }; } // namespace SkSL #endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS) #endif // SKSL_HCODEGENERATOR
[ "skia-commit-bot@chromium.org" ]
skia-commit-bot@chromium.org
2e70bd3a86572b6e3b9961351cdbce9cfdf66ad4
b852e928230a6a085b229c1cbd305ef4beb1d765
/newedgeform.h
d14516b98b23f2be15f0026cb608dc3567943afe
[]
no_license
yashmalai/KommivoyagerQt
a156472153c53368432ac65a3994dfd991d85af9
f69de72faf387b3da4322e47cf7b4d84c0c3573c
refs/heads/main
2023-04-21T21:04:42.342042
2021-05-21T17:48:56
2021-05-21T17:48:56
369,613,017
0
0
null
null
null
null
UTF-8
C++
false
false
469
h
#ifndef NEWEDGEFORM_H #define NEWEDGEFORM_H #include <QDialog> namespace Ui { class NewEdgeForm; } class NewEdgeForm : public QDialog { Q_OBJECT public: explicit NewEdgeForm(QWidget *parent = nullptr); ~NewEdgeForm(); int max_kol; int source, target, weight; bool isSaved = false; void check_max(); private slots: void on_button_clicked(); private: Ui::NewEdgeForm *ui; }; #endif // NEWEDGEFORM_H
[ "noreply@github.com" ]
noreply@github.com
22169f8a6152f361a5fd4bb0bab0e8a488e54f72
97d4cf4e9f19fff61e020703274519677d301a6e
/week9/1/7.cpp
84a9a477d06316d083198069014d8b31073aedd1
[]
no_license
askarakshabayev/PP1-2018
77a8610d364ad4c0e6678ac9cba469bc49f000a3
94951afcd0abbdabea62dad864e60de1bf5066be
refs/heads/master
2020-03-27T13:45:04.579828
2018-11-27T06:13:48
2018-11-27T06:13:48
146,626,390
1
0
null
null
null
null
UTF-8
C++
false
false
386
cpp
#include <iostream> using namespace std; // 1 -> 2 // 1 -> 3 // 2 -> 3 // 1 -> 2 // 3 -> 1 // 3 -> 2 // 1 -> 2 void f(int n, int a, int b, int c) { if (n == 1) { cout << a << "->" << b << endl; return; } f(n - 1, a, c, b); cout << a << "->" << b << endl; f(n - 1, c, b, a); } int main() { int n; cin >> n; f(n, 1, 2, 3); return 0; }
[ "askar.akshabayev@gmail.com" ]
askar.akshabayev@gmail.com
b59de5664952b168cfde4167f4c0003e0c328161
718a6ae98c390992f76e158599418142d51422ab
/test/resqml2_0_1test/StratigraphicUnitInterpretationTest.h
3183582a4919b4ae92c1f8d337e68a37cfd1ddd4
[ "GPL-1.0-or-later", "LicenseRef-scancode-proprietary-license", "BSL-1.0", "Apache-2.0" ]
permissive
ringmesh/fesapi
36f6716a976cb30dd10a8ca6d13998d8ab057a75
0b518e71f805f35679a65c78332b5cb64ed97830
refs/heads/master
2020-03-19T13:28:02.031783
2018-08-21T15:49:44
2018-08-21T15:49:44
136,580,789
0
0
Apache-2.0
2018-08-21T15:49:45
2018-06-08T07:09:52
C++
UTF-8
C++
false
false
2,359
h
/*----------------------------------------------------------------------- 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. -----------------------------------------------------------------------*/ #pragma once #include "resqml2_0_1test/AbstractFeatureInterpretationTest.h" namespace COMMON_NS { class EpcDocument; } namespace resqml2_0_1test { class StratigraphicUnitInterpretationTest : public AbstractFeatureInterpretationTest { public: static const char* defaultUuid; static const char* defaultTitle; /** * Creation of a testing object from an EPC document path. At serialize() call, * exising .epc file will be erased. * @param epcDocPath the path of the .epc file (including .epc extension) */ StratigraphicUnitInterpretationTest(const std::string & epcDocPath); StratigraphicUnitInterpretationTest(const std::string & epcDocPath, const std::string & uuid, const std::string & title, const std::string & uuidFeature, const std::string & titleFeature); /** * Creation of a testing object from an existing EPC document. * @param epcDoc an existing EPC document * @param init true if this object is created for initialization purpose else false if it is * created for reading purpose. According to init value a iniEpcDoc() or readEpcDoc() is called. */ StratigraphicUnitInterpretationTest(COMMON_NS::EpcDocument* epcDoc, bool init); StratigraphicUnitInterpretationTest(COMMON_NS::EpcDocument* epcDoc, const std::string & uuid, const std::string & title, const std::string & uuidFeature, const std::string & titleFeature, bool init); protected: void initEpcDocHandler(); void readEpcDocHandler(); }; }
[ "noreply@github.com" ]
noreply@github.com
2926edb34e4588ddd64282d736cd5f8cf30bb260
319a97d5113bcaeafc90f643c4026d94564b93cc
/shell/fullview.h
046edacedfa59d6eed9f8e012a23214612acb9d1
[]
no_license
aleixpol/sal-qml
bceef52520cd8b438bf4cdeb39c24f4c4f5e4786
65a2f5ba3cdda3f48cd5a32c3f23cd567bb236fc
refs/heads/master
2021-01-16T20:07:44.764969
2012-05-15T16:12:04
2012-05-15T16:12:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,944
h
/* * Copyright 2007 Aaron Seigo <aseigo@kde.org * Copyright (C) 2012 Shaun Reich <shaun.reich@blue-systems.com> * * 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 THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FULLVIEW_H #define FULLVIEW_H #include <QDeclarativeView> class FullView : public QDeclarativeView { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.salViewer") public: FullView(); ~FullView(); public Q_SLOTS: void toggle(int screen); void updateGeometry(); protected: virtual void focusInEvent(QFocusEvent *event); virtual void focusOutEvent(QFocusEvent *event); virtual void keyPressEvent(QKeyEvent *event); virtual void closeEvent(QCloseEvent *event); virtual void resizeEvent(QResizeEvent *event); }; #endif
[ "agateau@kde.org" ]
agateau@kde.org
1865cef01d1ee43167baf957580dfcdc49892eea
1a8f5d5fb51498859bb06d0287ad6c38e9bb8f70
/opt/type-erasure/ClassAssemblingUtils.cpp
dde8933265f8115ab2c3a6238bb1890a1a7d62f3
[ "MIT" ]
permissive
willpyshan13/redex
a5c3109734626bb647e2dfcd49c7d38075ab3553
0bb6a6ca434c4f57e825f0c3e0d47d7f1388529f
refs/heads/master
2022-04-15T07:19:18.825412
2020-04-15T01:25:03
2020-04-15T01:27:58
255,777,262
1
0
MIT
2020-04-15T01:57:46
2020-04-15T01:57:45
null
UTF-8
C++
false
false
13,054
cpp
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include "ClassAssemblingUtils.h" #include <boost/algorithm/string.hpp> #include "Creators.h" #include "DexStoreUtil.h" #include "DexUtil.h" #include "Model.h" namespace { void patch_iget_for_int_like_types(DexMethod* meth, const IRList::iterator& it, IRInstruction* convert) { auto insn = it->insn; auto move_result_it = std::next(it); auto src_dest = move_result_it->insn->dest(); convert->set_src(0, src_dest)->set_dest(src_dest); meth->get_code()->insert_after(move_result_it, convert); insn->set_opcode(OPCODE_IGET); } /** * Change the super class of a given class. The assumption is the new super * class has only one ctor and it shares the same signature with the old super * ctor. */ void change_super_class(DexClass* cls, DexType* super_type) { always_assert(cls); DexClass* super_cls = type_class(super_type); DexClass* old_super_cls = type_class(cls->get_super_class()); always_assert(super_cls); always_assert(old_super_cls); auto super_ctors = super_cls->get_ctors(); auto old_super_ctors = old_super_cls->get_ctors(); // Assume that both the old and the new super only have one ctor always_assert(super_ctors.size() == 1); always_assert(old_super_ctors.size() == 1); // Fix calls to super_ctor in its ctors. // NOTE: we are not parallelizing this since the ctor is very short. size_t num_insn_fixed = 0; for (auto ctor : cls->get_ctors()) { TRACE(TERA, 5, "Fixing ctor: %s", SHOW(ctor)); auto code = ctor->get_code(); for (auto& mie : InstructionIterable(code)) { auto insn = mie.insn; if (!is_invoke_direct(insn->opcode()) || !insn->has_method()) { continue; } // Replace "invoke_direct v0, old_super_type;.<init>:()V" with // "invoke_direct v0, super_type;.<init>:()V" if (insn->get_method() == old_super_ctors[0]) { TRACE(TERA, 9, " - Replacing call: %s with", SHOW(insn)); insn->set_method(super_ctors[0]); TRACE(TERA, 9, " %s", SHOW(insn)); num_insn_fixed++; } } } TRACE(TERA, 5, "Fixed %ld instructions", num_insn_fixed); cls->set_super_class(super_type); TRACE(TERA, 5, "Added super class %s to %s", SHOW(super_type), SHOW(cls)); } std::string get_merger_package_name(const DexType* type) { auto pkg_name = type::get_package_name(type); // Avoid an Android OS like package name, which might confuse the custom class // loader. if (boost::starts_with(pkg_name, "Landroid") || boost::starts_with(pkg_name, "Ldalvik")) { return "Lcom/facebook/redex/"; } return pkg_name; } DexType* create_empty_base_type(const ModelSpec& spec, const DexType* interface_root, const Scope& scope, const DexStoresVector& stores) { auto cls = type_class(interface_root); if (cls == nullptr) { return nullptr; } if (!is_interface(cls)) { TRACE(TERA, 1, "root %s is not an interface!", SHOW(interface_root)); return nullptr; } ClassHierarchy ch = build_type_hierarchy(scope); InterfaceMap intf_map = build_interface_map(ch); std::unordered_map<const DexType*, TypeSet> implements; for (const auto& pair : intf_map) { for (const auto& type : pair.second) { implements[type].emplace(pair.first); } } // Create an empty base and add to the scope. Put the base class in the same // package as the root interface. auto base_type = DexType::make_type( DexString::make_string("L" + spec.class_name_prefix + "EmptyBase;")); auto base_class = create_class(base_type, type::java_lang_Object(), get_merger_package_name(interface_root), std::vector<DexField*>(), TypeSet(), true); TRACE(TERA, 3, "Created an empty base class %s for interface %s.", SHOW(cls), SHOW(interface_root)); // Set it as the super class of implementors. size_t num = 0; XStoreRefs xstores(stores); for (auto impl_type : get_all_implementors(intf_map, interface_root)) { if (type_class(impl_type)->is_external()) { TRACE(TERA, 3, "Skip external implementer %s", SHOW(impl_type)); continue; } auto& ifcs = implements.at(impl_type); // Add an empty base class to qualified implementors auto impl_cls = type_class(impl_type); if (ifcs.size() == 1 && impl_cls && impl_cls->get_super_class() == type::java_lang_Object() && !is_in_non_root_store(impl_type, stores, xstores, spec.include_primary_dex)) { change_super_class(impl_cls, base_type); num++; } } return num > 0 ? base_type : nullptr; } } // namespace DexClass* create_class(const DexType* type, const DexType* super_type, const std::string& pkg_name, const std::vector<DexField*>& fields, const TypeSet& interfaces, bool with_default_ctor, DexAccessFlags access) { DexType* t = const_cast<DexType*>(type); always_assert(!pkg_name.empty()); auto name = std::string(type->get_name()->c_str()); name = pkg_name + name.substr(1); t->set_name(DexString::make_string(name)); // Create class. ClassCreator creator(t); creator.set_access(access); always_assert(super_type != nullptr); creator.set_super(const_cast<DexType*>(super_type)); for (const auto& itf : interfaces) { creator.add_interface(const_cast<DexType*>(itf)); } for (const auto& field : fields) { creator.add_field(field); } auto cls = creator.create(); // Keeping type-erasure generated classes from being renamed. cls->rstate.set_keepnames(); if (!with_default_ctor) { return cls; } // Create ctor. auto super_ctors = type_class(super_type)->get_ctors(); for (auto super_ctor : super_ctors) { auto mc = new MethodCreator(t, DexString::make_string("<init>"), super_ctor->get_proto(), ACC_PUBLIC | ACC_CONSTRUCTOR); // Call to super.<init> std::vector<Location> args; size_t args_size = super_ctor->get_proto()->get_args()->size(); for (size_t arg_loc = 0; arg_loc < args_size + 1; ++arg_loc) { args.push_back(mc->get_local(arg_loc)); } auto mb = mc->get_main_block(); mb->invoke(OPCODE_INVOKE_DIRECT, super_ctor, args); mb->ret_void(); auto ctor = mc->create(); TRACE(TERA, 4, " default ctor created %s", SHOW(ctor)); cls->add_method(ctor); } return cls; } std::vector<DexField*> create_merger_fields( const DexType* owner, const std::vector<DexField*>& mergeable_fields) { std::vector<DexField*> res; size_t cnt = 0; for (const auto f : mergeable_fields) { auto type = f->get_type(); std::string name; if (type == type::_byte() || type == type::_char() || type == type::_short() || type == type::_int()) { type = type::_int(); name = "i"; } else if (type == type::_boolean()) { type = type::_boolean(); name = "z"; } else if (type == type::_long()) { type = type::_long(); name = "j"; } else if (type == type::_float()) { type = type::_float(); name = "f"; } else if (type == type::_double()) { type = type::_double(); name = "d"; } else { static DexType* string_type = DexType::make_type("Ljava/lang/String;"); if (type == string_type) { type = string_type; name = "s"; } else { char t = type::type_shorty(type); always_assert(t == 'L' || t == '['); type = type::java_lang_Object(); name = "l"; } } name = name + std::to_string(cnt); auto field = DexField::make_field(owner, DexString::make_string(name), type) ->make_concrete(ACC_PUBLIC); res.push_back(field); cnt++; } TRACE(TERA, 8, " created merger fields %d ", res.size()); return res; } void cook_merger_fields_lookup( const std::vector<DexField*>& new_fields, const FieldsMap& fields_map, std::unordered_map<DexField*, DexField*>& merger_fields_lookup) { for (const auto& fmap : fields_map) { const auto& old_fields = fmap.second; always_assert(new_fields.size() == old_fields.size()); for (size_t i = 0; i < new_fields.size(); i++) { if (old_fields.at(i) != nullptr) { merger_fields_lookup[old_fields.at(i)] = new_fields.at(i); } } } } DexClass* create_merger_class(const DexType* type, const DexType* super_type, const std::vector<DexField*>& merger_fields, const TypeSet& interfaces, bool add_type_tag_field, bool with_default_ctor /* false */) { always_assert(type && super_type); std::vector<DexField*> fields; if (add_type_tag_field) { auto type_tag_field = DexField::make_field( type, DexString::make_string(INTERNAL_TYPE_TAG_FIELD_NAME), type::_int()) ->make_concrete(ACC_PUBLIC | ACC_FINAL); fields.push_back(type_tag_field); } for (auto f : merger_fields) { fields.push_back(f); } // Put merger class in the same package as super_type. auto pkg_name = get_merger_package_name(super_type); auto cls = create_class(type, super_type, pkg_name, fields, interfaces, with_default_ctor); TRACE(TERA, 3, " created merger class w/ fields %s ", SHOW(cls)); return cls; } void patch_iput(const IRList::iterator& it) { auto insn = it->insn; const auto op = insn->opcode(); always_assert(is_iput(op)); switch (op) { case OPCODE_IPUT_BYTE: case OPCODE_IPUT_CHAR: case OPCODE_IPUT_SHORT: insn->set_opcode(OPCODE_IPUT); break; default: break; } }; void patch_iget(DexMethod* meth, const IRList::iterator& it, DexType* original_field_type) { auto insn = it->insn; const auto op = insn->opcode(); always_assert(is_iget(op)); switch (op) { case OPCODE_IGET_OBJECT: { auto dest = std::next(it)->insn->dest(); auto cast = ModelMethodMerger::make_check_cast(original_field_type, dest); meth->get_code()->insert_after(insn, cast); break; } case OPCODE_IGET_BYTE: { always_assert(original_field_type == type::_byte()); auto int_to_byte = new IRInstruction(OPCODE_INT_TO_BYTE); patch_iget_for_int_like_types(meth, it, int_to_byte); break; } case OPCODE_IGET_CHAR: { always_assert(original_field_type == type::_char()); auto int_to_char = new IRInstruction(OPCODE_INT_TO_CHAR); patch_iget_for_int_like_types(meth, it, int_to_char); break; } case OPCODE_IGET_SHORT: { always_assert(original_field_type == type::_short()); auto int_to_short = new IRInstruction(OPCODE_INT_TO_SHORT); patch_iget_for_int_like_types(meth, it, int_to_short); break; } default: break; } }; void add_class(DexClass* new_cls, Scope& scope, DexStoresVector& stores) { always_assert(new_cls != nullptr); scope.push_back(new_cls); TRACE(TERA, 4, " TERA Adding class %s to scope %d ", SHOW(new_cls), scope.size()); // TODO(emmasevastian): Handle this case in a better way. if (!stores.empty()) { DexClassesVector& root_store = stores.front().get_dexen(); // Add the class to the last dex. root_store.back().emplace_back(new_cls); } } /** * In some limited cases we can do type erasure on an interface when * implementors of the interface only implement that interface and have no * parent class other than java.lang.Object. We create a base class for those * implementors and use the new base class as root, and proceed with type * erasure as usual. */ void handle_interface_as_root(ModelSpec& spec, Scope& scope, DexStoresVector& stores) { TypeSet interface_roots; for (const auto root : spec.roots) { if (is_interface(type_class(root))) { interface_roots.insert(root); } } for (const auto interface_root : interface_roots) { auto empty_base = create_empty_base_type(spec, interface_root, scope, stores); if (empty_base != nullptr) { TRACE(TERA, 3, "Changing the root from %s to %s.", SHOW(interface_root), SHOW(empty_base)); spec.roots.insert(empty_base); add_class(type_class(empty_base), scope, stores); } // Remove interface roots regardless of whether an empty base was added. spec.roots.erase(interface_root); } }
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
eb7c0bfe18daf4b29e287f3260be8b6f3d8053ea
04251e142abab46720229970dab4f7060456d361
/lib/rosetta/source/src/protocols/simple_filters/JumpNrEvaluatorCreator.cc
82b037f51d83b3c45d0c0cc1485f452d1eae1e89
[]
no_license
sailfish009/binding_affinity_calculator
216257449a627d196709f9743ca58d8764043f12
7af9ce221519e373aa823dadc2005de7a377670d
refs/heads/master
2022-12-29T11:15:45.164881
2020-10-22T09:35:32
2020-10-22T09:35:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,471
cc
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington CoMotion, email: license@uw.edu. /// @file protocols/simple_filters/JumpNrEvaluatorCreator.hh /// @brief Header for JumpNrEvaluatorCreator /// @author Matthew O'Meara // Unit Headers #include <protocols/simple_filters/JumpNrEvaluatorCreator.hh> // Package Headers #include <protocols/evaluation/EvaluatorCreator.hh> // Package Headers #include <protocols/evaluation/PoseEvaluator.fwd.hh> #include <protocols/evaluation/PoseEvaluator.hh> #include <protocols/simple_filters/JumpEvaluator.hh> #include <core/io/silent/silent.fwd.hh> // ObjexxFCL Headers #include <ObjexxFCL/string.functions.hh> // Utility headers #include <utility/VirtualBase.hh> #include <utility/vector1.hh> #include <utility/file/FileName.hh> #include <basic/options/option.hh> #include <basic/Tracer.hh> // due to template function #include <core/io/silent/SilentStruct.hh> // option key includes #include <basic/options/option_macros.hh> #include <basic/options/keys/evaluation.OptionKeys.gen.hh> #include <utility/vector0.hh> //Auto Headers #ifdef WIN32 #include <core/scoring/constraints/Constraint.hh> #endif static basic::Tracer tr( "protocols.evalution.JumpNrEvaluatorCreator" ); namespace protocols { namespace simple_filters { JumpNrEvaluatorCreator::~JumpNrEvaluatorCreator() = default; void JumpNrEvaluatorCreator::register_options() { using namespace basic::options; if ( options_registered_ ) return; options_registered_ = true; OPT( evaluation::jump_nr ); } void JumpNrEvaluatorCreator::add_evaluators( evaluation::MetaPoseEvaluator & eval ) const { using namespace core; using namespace basic::options; using namespace basic::options::OptionKeys; using protocols::evaluation::PoseEvaluatorOP; if ( option[ OptionKeys::evaluation::jump_nr ]() ) { eval.add_evaluation( utility::pointer::make_shared< JumpNrEvaluator >() ); } } std::string JumpNrEvaluatorCreator::type_name() const { return "JumpNrEvaluatorCreator"; } } //namespace } //namespace
[ "lzhangbk@connect.ust.hk" ]
lzhangbk@connect.ust.hk
05593287391492122f6e78984854ed0116692cef
9cb72ae1086657efd932cb7d6b55dfecd96a8393
/用户层/11/桌面截屏/ScreenCapture_Test/ScreenCapture_Test/ScreenCapture.cpp
f25d416ffea472d408b7153bdebe8e42a2df5e5e
[]
no_license
fanfansun/WindowsHack
dbed00e75a9953850825fa7f71450113a9195d38
241ca964c79443f8fe137c6dc46dcae671a8c5db
refs/heads/master
2022-01-10T00:09:26.662448
2019-03-01T23:21:03
2019-03-01T23:21:03
null
0
0
null
null
null
null
GB18030
C++
false
false
1,985
cpp
#include "stdafx.h" #include "ScreenCapture.h" BOOL PaintMouse(HDC hdc) { HDC bufdc = NULL; CURSORINFO cursorInfo = { 0 }; ICONINFO iconInfo = { 0 }; HBITMAP bmpOldMask = NULL; bufdc = ::CreateCompatibleDC(hdc); ::RtlZeroMemory(&iconInfo, sizeof(iconInfo)); cursorInfo.cbSize = sizeof(cursorInfo); // 获取光标信息 ::GetCursorInfo(&cursorInfo); // 获取光标图标信息 ::GetIconInfo(cursorInfo.hCursor, &iconInfo); // 绘制 白底黑鼠标(AND) bmpOldMask = (HBITMAP)::SelectObject(bufdc, iconInfo.hbmMask); ::BitBlt(hdc, cursorInfo.ptScreenPos.x, cursorInfo.ptScreenPos.y, 20, 20, bufdc, 0, 0, SRCAND); // 绘制 黑底彩色鼠标(OR) ::SelectObject(bufdc, iconInfo.hbmColor); ::BitBlt(hdc, cursorInfo.ptScreenPos.x, cursorInfo.ptScreenPos.y, 20, 20, bufdc, 0, 0, SRCPAINT); // 释放资源 ::SelectObject(bufdc, bmpOldMask); ::DeleteObject(iconInfo.hbmColor); ::DeleteObject(iconInfo.hbmMask); ::DeleteDC(bufdc); return TRUE; } HBITMAP GetScreenBmp() { // 获取屏幕截屏 // 获取桌面窗口句柄 HWND hDesktop = ::GetDesktopWindow(); // 获取桌面窗口DC HDC hdc = ::GetDC(hDesktop); // 创建兼容DC HDC mdc = ::CreateCompatibleDC(hdc); // 获取计算机屏幕的宽和高 DWORD dwWidth = ::GetSystemMetrics(SM_CXSCREEN); DWORD dwHeight = ::GetSystemMetrics(SM_CYSCREEN); // 创建兼容位图 HBITMAP bmp = ::CreateCompatibleBitmap(hdc, dwWidth, dwHeight); // 选中位图 HBITMAP holdbmp = (HBITMAP)::SelectObject(mdc, bmp); // 将窗口内容绘制到位图上 ::BitBlt(mdc, 0, 0, dwWidth, dwHeight, hdc, 0, 0, SRCCOPY); // 绘制鼠标 PaintMouse(mdc); ::SelectObject(mdc, holdbmp); // 释放内存 ::DeleteDC(mdc); ::ReleaseDC(hDesktop, hdc); return bmp; } BOOL ScreenCapture() { // 获取屏幕截屏位图句柄 HBITMAP hBmp = GetScreenBmp(); if (NULL == hBmp) { return FALSE; } // 保存为图片 SaveBmp(hBmp); // 释放位图句柄 ::DeleteObject(hBmp); return TRUE; }
[ "dearfuture2012@gmail.com" ]
dearfuture2012@gmail.com
1d4b7e8baeb0b5825e6eb741c24c8f2175caf827
f5d87ed79a91f17cdf2aee7bea7c15f5b5258c05
/cuts/config-common.h
b65941f0e32ad86e6bb13a27501810fcefca6200
[]
no_license
SEDS/CUTS
a4449214a894e2b47bdea42090fa6cfc56befac8
0ad462fadcd3adefd91735aef6d87952022db2b7
refs/heads/master
2020-04-06T06:57:35.710601
2016-08-16T19:37:34
2016-08-16T19:37:34
25,653,522
0
3
null
null
null
null
UTF-8
C++
false
false
892
h
// -*- C++ -*- //============================================================================= /** * @file config-common.h * * $Id$ * * @author James H. Hill <hillj@isis.vanderbilt.edu> */ //============================================================================= #ifndef _CUTS_CONFIG_COMMON_H_ #define _CUTS_CONFIG_COMMON_H_ #include "ace/config-all.h" #if defined (__CUTS_INLINE__) # define CUTS_INLINE inline #else # define CUTS_INLINE #endif #define CUTS_DEFAULT_PORT 3306 #define CUTS_DEFAULT_EVENT_COUNT 20 #define CUTS_EVENT_HANDLER_THREAD_COUNT 1 #define CUTS_UNKNOWN_IMPL 1 #define CUTS_DEFAULT_LOG_SIZE 50 #define CUTS_UNKNOWN_ID -1 #define CUTS_RESULT_DEFAULT_BUFFER_SIZE 1024 #if defined (CUTS_HAS_DOXYGEN) #include "config-doxygen.h" #endif #endif // !defined _CUTS_CONFIG_H_
[ "hillj@cs.iupui.edu" ]
hillj@cs.iupui.edu
fff2442041f5a85d7d69e4cea87e90cbd7b71e4f
297497957c531d81ba286bc91253fbbb78b4d8be
/third_party/libwebrtc/modules/audio_processing/high_pass_filter.h
6fa59fcc2b8cc5799e2f5586e63825e81472fcf9
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
marco-c/gecko-dev-comments-removed
7a9dd34045b07e6b22f0c636c0a836b9e639f9d3
61942784fb157763e65608e5a29b3729b0aa66fa
refs/heads/master
2023-08-09T18:55:25.895853
2023-08-01T00:40:39
2023-08-01T00:40:39
211,297,481
0
0
NOASSERTION
2019-09-29T01:27:49
2019-09-27T10:44:24
C++
UTF-8
C++
false
false
921
h
#ifndef MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_H_ #define MODULES_AUDIO_PROCESSING_HIGH_PASS_FILTER_H_ #include <memory> #include <vector> #include "api/array_view.h" #include "modules/audio_processing/utility/cascaded_biquad_filter.h" namespace webrtc { class AudioBuffer; class HighPassFilter { public: HighPassFilter(int sample_rate_hz, size_t num_channels); ~HighPassFilter(); HighPassFilter(const HighPassFilter&) = delete; HighPassFilter& operator=(const HighPassFilter&) = delete; void Process(AudioBuffer* audio, bool use_split_band_data); void Process(std::vector<std::vector<float>>* audio); void Reset(); void Reset(size_t num_channels); int sample_rate_hz() const { return sample_rate_hz_; } size_t num_channels() const { return filters_.size(); } private: const int sample_rate_hz_; std::vector<std::unique_ptr<CascadedBiQuadFilter>> filters_; }; } #endif
[ "mcastelluccio@mozilla.com" ]
mcastelluccio@mozilla.com
7f55c975a02ec17d0b5cc10b47d89aa7d4efeaa1
fa82a9d6db070341ef07fb62b966fc5e8202a293
/multicast.h
afd5367357cc6bc30bf84a52361375c8cb10ef4d
[]
no_license
ekkohao/TellMe
51ba73907e7d4dd2af0d19eb8cc199a57ee6ca4c
62ddb0fb064932a769c3e525bd1d36fa17839954
refs/heads/master
2021-06-17T18:22:53.787496
2017-06-14T16:49:21
2017-06-14T16:49:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
884
h
#ifndef MULTICAST_H #define MULTICAST_H #include <QUdpSocket> #include <QObject> #include <QDebug> #include <QDataStream> #include "netcommon.h" class MultiCast : public QObject { Q_OBJECT public: MultiCast(QString ip, int port); ~MultiCast(); void sendData(QString s); bool isConnected(); bool reJoinMultiAddr(QString ip); enum MessageType{Message, NewBuddy, NewGrpBuddy, BuddyLeft, BuddyGrpLeft}; private: QString mIP; int mPort; QUdpSocket *mQUdpSocket; bool mIsConnected; void initSocket(); private slots: void dataReceivedSlot(); signals: void newGrpHostSig(QString grpName,QString grpIP,QString hostName,QString hostIP); void newGrpMagReceivedSig(QString grpIP,QString hostName,QString hostIP,QString msg); void buddyGrpLeftSig(QString grpIP,QString hostName,QString hostIP); }; #endif // MULTICAST_H
[ "jerehao@gmail.com" ]
jerehao@gmail.com
5c4e98ed62d915f47dee08c78785344dfda401be
1277cb3a3733a8fc434ff210f3887c84b3b9c579
/Hyperion Engine/Tests/FileTests.hpp
7f4ddd95fb8a1278c5388fcdfb95a4e7100b0f0c
[]
no_license
zbomb/Hyperion-Engine
79d9f656617b79c66e8daefd94b7e4074777deef
8fca47a2b47c3add8a245c1d32cdcb9778063014
refs/heads/master
2023-03-23T12:07:24.204937
2021-02-22T15:39:49
2021-02-22T15:39:49
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
443
hpp
/*================================================================================================== Hyperion Engine Tests/FileTests.hpp © 2019, Zachary Berry ==================================================================================================*/ #pragma once #include "Hyperion/Core/File.h" #include "Hyperion/Core/Platform.h" #include <iostream> namespace Hyperion { namespace Tests { void RunFileTests() { } } }
[ "zackb123@hotmail.com" ]
zackb123@hotmail.com
36cd9a4122efe0b44c365ab47df2482cb75f17be
d1b9611505cf16f4de498fc2c1c1a176ab45ea16
/My exercises in Cpp/Robot_in_the_maze.cpp
66d07f577f657ec7bde01d726ea6a1338e391686
[]
no_license
artoro/Basics-of-programming
2d9ac9b1e83dfb5f7bc101544476ac05f1fd198d
c30cb5f5b86561296024cce78c1b36f75d69b131
refs/heads/master
2021-04-09T15:52:56.996438
2018-03-24T19:09:31
2018-03-24T19:09:31
125,715,755
0
0
null
null
null
null
UTF-8
C++
false
false
7,397
cpp
#include <iostream> #include <fstream> #include <cstdio> #include <cstdlib> // losowanie #include <ctime> // zmienne czasu #include <string> // zmienne tekstowe #include <math.h> #include <windows.h> // kolory using namespace std; int przejscie (int pozycja) { int kierunek = rand()%3; if (pozycja%10==0) kierunek = 1+rand()%4; // nie moze byc 0 if (pozycja%10==9) kierunek = rand()%4-3; // nie moze byc 1 switch (kierunek) { case 0: return -1; break; case 1: return 1; break; default: return 10; break; } } int dekoder (int b) { switch (b) { case 4: return -1; break; case 6: return 1; break; case 2: return -10; break; case 8: return 10; break; default: return 0; break; } } int nastepny (int b) { if (b==4) return 8; if (b==8) return 6; if (b==6) return 2; if (b==2) return 4; return 4; } int odleglosc (int pozycja, int cel) { int dane[5]; dane[0] = pozycja%10; //x pozycji dane[1] = pozycja/10; // y pozycji dane[2] = cel%10; // x celu dane[3] = cel/10; // y celu dane[4] = pow(dane[0]-dane[2], 2) + pow(dane[1]-dane[3], 2); return dane[4]; } int cstart=5, cnapoczatku=0, cszukaj=1, cnieszukaj=-10, j=200, lr; int main() { lr=100; ofstream dane; dane.open ("dane.txt", ios::app); if (!dane) cout << "Blad pliku."; HANDLE uchwyt = GetStdHandle(STD_OUTPUT_HANDLE); srand(clock()+time(NULL)); int pozycja = rand()%10, a = 0; cout << "Aby rozpoczac wcisnij enter."; cin.get(); // GENEROWANIE MAPY int mapa[100]; for (int i=0; i<=99; i++) mapa[i]=7; for (int i=10; i<=89; i++) mapa[i]=0; do { pozycja = pozycja+przejscie(pozycja); mapa [pozycja] = 7; }while (pozycja < 90); for (int i=0; i<=30; i++) mapa[rand()%80+10]=7; // GRA pozycja = rand()%10; if (mapa[pozycja+20]==7) pozycja = rand()%10; mapa[pozycja]--; int pamiec[7], pustepola [50]; for (int i=0; i<=49; i++) pustepola[i]=-1; int b = -1, c = 0, d = 1000, cel = 95; int czas = 0, liczbaruchow = 0; do { // WYSWIETLANIE MAPY system( "cls" ); for (int y=90; y>=0; cout << endl, y=y-10) for (int x=0; x<=9; x++) { if (mapa[y+x]==6) SetConsoleTextAttribute(uchwyt, FOREGROUND_RED | FOREGROUND_INTENSITY ); if (mapa[y+x]==7) SetConsoleTextAttribute(uchwyt, 8); cout << mapa[y+x]; SetConsoleTextAttribute(uchwyt, 7); } if (pozycja >= 90) c=10; // SZTUCZNA INTELIGENCJA // ROZPOZNANIE TERENU if (c<3) czas=cnapoczatku; if (c==0 && pozycja>0) { if (mapa[pozycja+10]==7 && mapa[pozycja+20]==7) a=8, c=2; else a=4; } if (c==0 && pozycja==0) c=1; if (c==1 && pozycja<=9) { if (mapa[pozycja+10]==7 && mapa[pozycja+20]==7) a=8, c=2; else a=6; } // ROZPOCZECIE PODROZY if (c==3) { if (mapa[pozycja+10]==7 && b!=2 && (mapa[pozycja+20]==7 || mapa[pozycja+9]==7 || mapa[pozycja+11]==7)) a=8; if (a==5) { for (int i=0; i<=6; i++) pamiec[i]=5; if ((mapa[pozycja+9]==7) && (mapa[pozycja-1]==7) && (pozycja%10!=0)) pamiec[0]=4; if ((mapa[pozycja-1]==7) && ((pozycja%10)!=0)) pamiec[1]=4; if (mapa[pozycja+11]==7 && mapa[pozycja+1]==7 && pozycja%10!=9) pamiec[2]=6; if (mapa[pozycja+1]==7 && pozycja%10!=9) pamiec[3]=6; if (mapa[pozycja+10]==7) pamiec[4]=8; if (mapa[pozycja-10]==7 && pozycja/10!=0) pamiec[5]=2; if (mapa[pozycja+dekoder(b)]==7 && (pozycja%10)!=0 && (pozycja%10)!=9 && b!=2) pamiec[6]=b; if (mapa[pozycja-10]==7 && b==2) pamiec[6]=b; do a=pamiec[rand()%7]; while(a==5 || a==0); for (int i=0; i<50 || pustepola[i]==-1; i++) if (pustepola[i]==100+mapa[pozycja+dekoder(a)]) { do a=pamiec[rand()%7]; while(a==5 || a==0); i=50; } } } // SZUKANIE PUSTYCH POL for (int i = 0; i<=4; i++) { if (mapa[pozycja+dekoder(b)]==7) { if ((pozycja%10!=0 && b!=4) || (pozycja%10!=9 && b!=6) || (pozycja/10!=0 && b!=2) || (pozycja/10!=9 && b!=8)) { int e = pozycja+dekoder(b); for (int i=0; e>=0 && i<=49; i++) if (pustepola[i]==e || pustepola[i]%100==e) e=-1; if (e!=-1) for (int i=0; e>=0 && i<=49; i++) if (pustepola[i]==-1) pustepola[i]=e, e=-1, czas--; } } b=nastepny(b); } czas++; for (int i=0; i<=49; i++) { if (pozycja==pustepola[i]) pustepola[i]=pustepola[i]+100, i=50; if (pustepola[i]==-1 || pustepola[i]%100==pozycja) i=50, czas=czas+2; } // SZUKANIE CELU POSREDNIEGO for (int i=49; i>=0 && czas>=cstart; i--) if(pustepola[i]>=0 && pustepola[i]/100==0) { cel = pustepola[i]; if (c!=5) c=5, czas = cszukaj; else c=3, czas = cnieszukaj; } // JAZDA DO CELU NAJKROTSZA DROGA if (c==5 && pozycja!=cel) { czas--; for (int i = 0; i<=4; i++) { if (mapa[pozycja+dekoder(b)]==7 && odleglosc(pozycja+dekoder(b), cel) < d ) { if (!((pozycja%10==0 && b==4) || (pozycja%10==9 && b==6) || (pozycja/10==0 && b==2) || (pozycja/10==9 && b==8))) d=odleglosc(pozycja+dekoder(b), cel), a=b; } b=nastepny(b); } } if (c==5 && pozycja == cel) c=3; // STEROWANIE ROBOTEM if (a==2) czas++; cout << "a " << a << " b " << b << " c " << c << " czas " << czas; b=a; d = clock()+CLOCKS_PER_SEC/5; while(d>clock()); mapa[pozycja]++; switch (a) { case 4: pozycja--; break; case 6: pozycja++; break; case 8: pozycja = pozycja+10; break; case 2: pozycja = pozycja-10; break; default: break; } mapa[pozycja]--, liczbaruchow++; a=5; if (c==2) c=3; // KONIEC PALIWA if (liczbaruchow>lr) { c=0; cout << "KONIEC PALIWA!"; if (dane) dane << "\tXXX\tXXX" << endl; system("PAUSE"); d=1; mapa[pozycja]++; pozycja = rand()%10; mapa[pozycja]--; liczbaruchow=0; for (int i=0; i<=49; i++) pustepola[i]=-1; } }while(c < 6); d=1; for (int i=0; i<=49 && pustepola[i]>=0; i++) if(pustepola[i]>99) d++; if (dane) dane << liczbaruchow << "\t" << d << endl; cout << "\nLiczba ruchow: " << liczbaruchow << "\t Ilosc zajetych pol: " << d << endl; dane.close(); cin >> c; if (c==0) main(); return 0; }
[ "noreply@github.com" ]
noreply@github.com
d5cd99234ef72f5cab1134a806b3a55eb792ebb3
b4403a3a22aa958c9686d153f8eaee28195436af
/MapReaderV2/Navmesh/InputGeom.h
e2178fb59c0a6f25aa8ebf2d1c262706fb2919ca
[ "MIT" ]
permissive
balannarcis96/skylake-tools
bdb0507828294840303ca9114d34d6268abcfb0e
e1ff6308d250f81397a85ab6012cc4dc10e06228
refs/heads/master
2022-12-30T00:35:06.818589
2020-10-12T16:06:21
2020-10-12T16:06:21
264,627,846
3
0
null
null
null
null
UTF-8
C++
false
false
5,393
h
// // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. // #ifndef INPUTGEOM_H #define INPUTGEOM_H static const int MAX_CONVEXVOL_PTS = 12; struct ConvexVolume { ConvexVolume() : areaMod(RC_AREA_FLAGS_MASK) {} float verts[MAX_CONVEXVOL_PTS * 3]; float hmin, hmax; int nverts; rcAreaModification areaMod; }; struct BuildSettings { // Cell size in world units float cellSize; // Cell height in world units float cellHeight; // Agent height in world units float agentHeight; // Agent radius in world units float agentRadius; // Agent max climb in world units float agentMaxClimb; // Agent max slope in degrees float agentMaxSlope; // Region minimum size in voxels. // regionMinSize = sqrt(regionMinArea) float regionMinSize; // Region merge size in voxels. // regionMergeSize = sqrt(regionMergeArea) float regionMergeSize; // Edge max length in world units float edgeMaxLen; // Edge max error in voxels float edgeMaxError; float vertsPerPoly; // Detail sample distance in voxels float detailSampleDist; // Detail sample max error in voxel heights. float detailSampleMaxError; // Partition type, see SamplePartitionType int partitionType; // Bounds of the area to mesh float navMeshBMin[3]; float navMeshBMax[3]; // Size of the tiles in voxels float tileSize; }; class InputGeom { rcChunkyTriMesh* m_chunkyMesh; rcMeshLoaderObj* m_mesh; float m_meshBMin[3], m_meshBMax[3]; BuildSettings m_buildSettings; bool m_hasBuildSettings; /// @name Off-Mesh connections. ///@{ static const int MAX_OFFMESH_CONNECTIONS = 256; float m_offMeshConVerts[MAX_OFFMESH_CONNECTIONS * 3 * 2]; float m_offMeshConRads[MAX_OFFMESH_CONNECTIONS]; unsigned char m_offMeshConDirs[MAX_OFFMESH_CONNECTIONS]; unsigned char m_offMeshConAreas[MAX_OFFMESH_CONNECTIONS]; unsigned short m_offMeshConFlags[MAX_OFFMESH_CONNECTIONS]; unsigned int m_offMeshConId[MAX_OFFMESH_CONNECTIONS]; int m_offMeshConCount; ///@} /// @name Convex Volumes. ///@{ static const int MAX_VOLUMES = 256; ConvexVolume m_volumes[MAX_VOLUMES]; int m_volumeCount; ///@} bool loadMesh(class rcContext* ctx, const std::string& filepath); bool loadGeomSet(class rcContext* ctx, const std::string& filepath); public: InputGeom(); ~InputGeom(); bool useMesh(rcMeshLoaderObj* mesh); bool load(class rcContext* ctx, const std::string& filepath); bool saveGeomSet(const BuildSettings* settings); /// Method to return static mesh data. const rcMeshLoaderObj* getMesh() const { return m_mesh; } const float* getMeshBoundsMin() const { return m_meshBMin; } const float* getMeshBoundsMax() const { return m_meshBMax; } const float* getNavMeshBoundsMin() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMin : m_meshBMin; } const float* getNavMeshBoundsMax() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMax : m_meshBMax; } const rcChunkyTriMesh* getChunkyMesh() const { return m_chunkyMesh; } const BuildSettings* getBuildSettings() const { return m_hasBuildSettings ? &m_buildSettings : 0; } bool raycastMesh(float* src, float* dst, float& tmin); /// @name Off-Mesh connections. ///@{ int getOffMeshConnectionCount() const { return m_offMeshConCount; } const float* getOffMeshConnectionVerts() const { return m_offMeshConVerts; } const float* getOffMeshConnectionRads() const { return m_offMeshConRads; } const unsigned char* getOffMeshConnectionDirs() const { return m_offMeshConDirs; } const unsigned char* getOffMeshConnectionAreas() const { return m_offMeshConAreas; } const unsigned short* getOffMeshConnectionFlags() const { return m_offMeshConFlags; } const unsigned int* getOffMeshConnectionId() const { return m_offMeshConId; } void addOffMeshConnection(const float* spos, const float* epos, const float rad, unsigned char bidir, unsigned char area, unsigned short flags); void deleteOffMeshConnection(int i); void drawOffMeshConnections(struct duDebugDraw* dd, bool hilight = false); ///@} /// @name Box Volumes. ///@{ int getConvexVolumeCount() const { return m_volumeCount; } const ConvexVolume* getConvexVolumes() const { return m_volumes; } void addConvexVolume(const float* verts, const int nverts, const float minh, const float maxh, rcAreaModification areaMod); void deleteConvexVolume(int i); void drawConvexVolumes(struct duDebugDraw* dd, bool hilight = false); ///@} private: // Explicitly disabled copy constructor and copy assignment operator. InputGeom(const InputGeom&); InputGeom& operator=(const InputGeom&); }; #endif // INPUTGEOM_H
[ "balannarcis96@gmail.com" ]
balannarcis96@gmail.com
1c5eeefd332ad24b0534c68b3a547f8ca67513af
c9d8f964ef46074e8298917076f7d0c61bccea38
/ServiceStartupType/ServiceStartupType/ServiceStartupType.cpp
42c2a4178e7ef6a303c455978121c542776a1d6d
[]
no_license
maheshmahajanplk/Windows-32-APIs-Demo-List
cc9e0878ea5232ea6eb96ac4a61603cb15d05be8
7bdb03caa8c8fda0cac6c0f7f4f173650951a800
refs/heads/master
2023-05-09T14:22:23.036220
2021-06-04T14:43:23
2021-06-04T14:43:23
49,653,085
1
0
null
null
null
null
UTF-8
C++
false
false
7,573
cpp
// ServiceStartupType.cpp : Defines the entry point for the application. /**********************************SERVICE_STATUS structure 2ND fIELD : dwCurrentState-> 0x00000005 ---->SERVICE_CONTINUE_PENDING 0x00000006 ---->SERVICE_PAUSE_PENDING 0x00000007 ---->SERVICE_PAUSED 0x00000004 ---->SERVICE_RUNNING 0x00000002 ---->SERVICE_START_PENDING 0x00000003 ---->SERVICE_STOP_PENDING 0x00000001 ---->SERVICE_STOPPED *********************************/ #include "stdafx.h" #include "ServiceStartupType.h" #include "stdio.h" void printServiceStartType(); VOID __stdcall DoQuerySvc(char *); struct stServiceInfo { char szAppId[51]; char szServiceName[256]; int iStatus; int iWinExitCode; int iServiceExitCode; int iEventErrorCode; }; int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { TCHAR srvName[300] = {0}; try{ printServiceStartType(); }catch(...){ } return 0; } // // Purpose: // Retrieves and displays the current service configuration. // // Parameters: // None // // Return value: // None // VOID __stdcall DoQuerySvc(char * szSvcName) { SC_HANDLE schSCManager; SC_HANDLE schService; LPQUERY_SERVICE_CONFIG lpsc; LPSERVICE_DESCRIPTION lpsd; DWORD dwBytesNeeded, cbBufSize, dwError; // Get a handle to the SCM database. schSCManager = OpenSCManager( NULL, // local computer NULL, // ServicesActive database SC_MANAGER_ALL_ACCESS); // full access rights if (NULL == schSCManager) { printf("OpenSCManager failed (%d)\n", GetLastError()); return; } // Get a handle to the service. schService = OpenService( schSCManager, // SCM database szSvcName, // name of service SERVICE_QUERY_CONFIG); // need query config access if (schService == NULL) { printf("OpenService failed (%d)\n", GetLastError()); CloseServiceHandle(schSCManager); return; } // Get the configuration information. if( !QueryServiceConfig( schService, NULL, 0, &dwBytesNeeded)) { dwError = GetLastError(); if( ERROR_INSUFFICIENT_BUFFER == dwError ) { cbBufSize = dwBytesNeeded; lpsc = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LMEM_FIXED, cbBufSize); } else { printf("QueryServiceConfig failed (%d)", dwError); goto cleanup; } } if( !QueryServiceConfig( schService, lpsc, cbBufSize, &dwBytesNeeded) ) { printf("QueryServiceConfig failed (%d)", GetLastError()); goto cleanup; } if( !QueryServiceConfig2( schService, SERVICE_CONFIG_DESCRIPTION, NULL, 0, &dwBytesNeeded)) { dwError = GetLastError(); if( ERROR_INSUFFICIENT_BUFFER == dwError ) { cbBufSize = dwBytesNeeded; lpsd = (LPSERVICE_DESCRIPTION) LocalAlloc(LMEM_FIXED, cbBufSize); } else { printf("QueryServiceConfig2 failed (%d)", dwError); goto cleanup; } } if (! QueryServiceConfig2( schService, SERVICE_CONFIG_DESCRIPTION, (LPBYTE) lpsd, cbBufSize, &dwBytesNeeded) ) { printf("QueryServiceConfig2 failed (%d)", GetLastError()); goto cleanup; } // Print the configuration information. _tprintf(TEXT("%s configuration: \n"), szSvcName); _tprintf(TEXT(" Type: 0x%x\n"), lpsc->dwServiceType); _tprintf(TEXT(" Start Type: 0x%x\n"), lpsc->dwStartType); _tprintf(TEXT(" Error Control: 0x%x\n"), lpsc->dwErrorControl); _tprintf(TEXT(" Binary path: %s\n"), lpsc->lpBinaryPathName); _tprintf(TEXT(" Account: %s\n"), lpsc->lpServiceStartName); if (lpsd->lpDescription != NULL && lstrcmp(lpsd->lpDescription, TEXT("")) != 0) _tprintf(TEXT(" Description: %s\n"), lpsd->lpDescription); if (lpsc->lpLoadOrderGroup != NULL && lstrcmp(lpsc->lpLoadOrderGroup, TEXT("")) != 0) _tprintf(TEXT(" Load order group: %s\n"), lpsc->lpLoadOrderGroup); if (lpsc->dwTagId != 0) _tprintf(TEXT(" Tag ID: %d\n"), lpsc->dwTagId); if (lpsc->lpDependencies != NULL && lstrcmp(lpsc->lpDependencies, TEXT("")) != 0) _tprintf(TEXT(" Dependencies: %s\n"), lpsc->lpDependencies); LocalFree(lpsc); LocalFree(lpsd); cleanup: CloseServiceHandle(schService); CloseServiceHandle(schSCManager); } void printServiceStartType() { SC_HANDLE scHandle = NULL; ENUM_SERVICE_STATUS enumServiceStatus = {0}; ENUM_SERVICE_STATUS* penumServiceStatus = NULL; DWORD dwBytesNeeded = 0; DWORD dwServicesReturned = 0; DWORD dwResumeHandle = 0; DWORD dwBytesAllocated = 0; DWORD dwCtr = 0; BOOL bRet = TRUE; int iCtr = 0; int iCheckNumServices = 0; int iEventId = 0; char szTimeINIFile[MAX_PATH + 100] = {0}; char szDef[10] = {0}; char szUpTime[101] = {0}; __try { __try { //Open the SCM manager scHandle = ::OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE); if(NULL == scHandle) { /*LogLastError(g_szErrorLogPath, 9999, NULL, ::GetLastError(), 0, NULL, "ERR: Open SC Manager failed", NULL, NULL);*/ return; } bRet = ::EnumServicesStatus(scHandle, SERVICE_WIN32, //<----Service Type SERVICE_STATE_ALL, //<----Service State &enumServiceStatus, //<----buf storing srvnm,srvst sizeof(enumServiceStatus),//size of structure &dwBytesNeeded, // &dwServicesReturned, &dwResumeHandle); if(dwBytesNeeded > 0) { dwBytesAllocated = dwBytesNeeded + sizeof(ENUM_SERVICE_STATUS); penumServiceStatus = new ENUM_SERVICE_STATUS[dwBytesAllocated]; memset(penumServiceStatus,NULL,dwBytesAllocated); } else { /*LogLastError(g_szErrorLogPath, 9999, NULL, ::GetLastError(), 0, NULL, "ERR: Enum Service Status failed", NULL, NULL);*/ return; } dwBytesNeeded = 0; dwServicesReturned = 0; dwResumeHandle = 0; bRet = ::EnumServicesStatus(scHandle, SERVICE_WIN32, SERVICE_STATE_ALL, penumServiceStatus, dwBytesAllocated, &dwBytesNeeded, &dwServicesReturned, &dwResumeHandle); if(0 == bRet) { /*LogLastError(g_szErrorLogPath, 9999, NULL, ::GetLastError(), 0, NULL, "ERR: Enum Service Status failed", NULL, NULL);*/ return; } ::CloseServiceHandle(scHandle); scHandle = NULL; for(dwCtr = 0; dwCtr < dwServicesReturned; ++dwCtr) { //Retrieve sERVICE nAME DoQuerySvc(penumServiceStatus[dwCtr].lpServiceName); _tprintf(TEXT(" Service Start Type: %s\n"), penumServiceStatus[dwCtr].ServiceStatus.dwCurrentState); } } __except(EXCEPTION_EXECUTE_HANDLER) { } } __finally { if(NULL != scHandle) { ::CloseServiceHandle(scHandle); scHandle = NULL; } } }
[ "mahesh.mahajan@noc.continuum.net" ]
mahesh.mahajan@noc.continuum.net
8204d318959ae6b60d3bc6c12809e3dd6bacd44e
6b6f3daa58e768e51f08cd6e365251a0f4895f72
/A - Domino piling.cpp
19d72143670385c7bef20f2c851b8765fd4ea92c
[]
no_license
maruf-rahad/codeforces
93027589ee6fd5effbf46daa335d58ae9680c47b
bde7758702b623e631f5d80feae0353e5b7abd44
refs/heads/master
2023-02-02T18:51:34.053455
2020-12-19T09:34:02
2020-12-19T09:34:02
292,863,425
1
0
null
null
null
null
UTF-8
C++
false
false
355
cpp
#include<bits/stdc++.h> using namespace std; int main() { int n,m,i,j,x,y,t,a,b; while(scanf("%d %d",&n,&m)==2) { a = (m/2)*n; if(m%2==1) { b = n/2; } else { b = 0; } printf("%d\n",a+b); } return 0; }
[ "noreply@github.com" ]
noreply@github.com
fbc95c4fa3e6d1e8c14e547f6062a17f9a25a559
f574f989d3b7436dbb7adc2871e551c31719a5e6
/bundlefusion_ros/src/FriedLiver/Source/FriedLiver.h
06209b39ebe378c7f8932692cab47fe5b6067af1
[]
no_license
meng-tsai/RGBD-IndoorSceneReconstruction-ROS
709365f26c929eefff2896e90fff4b995a77bb74
c9a8c06097574eda36462f5a4cde92bda8540d29
refs/heads/master
2023-02-05T05:07:17.215130
2020-12-26T15:47:28
2020-12-26T15:47:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,961
h
#include <string> #include <iostream> #include "GlobalAppState.h" #include "mLib.h" #include "GlobalBundlingState.h" #include "DualGPU.h" #include "ConditionManager.h" #include "RGBDSensor.h" //#include "BinaryDumpReader.h" #include "PrimeSenseSensor.h" //#include "KinectSensor.h" //#include "KinectOneSensor.h" //#include "StructureSensor.h" don't support linux for Uplink #include "SensorDataReader.h" #include "CUDAImageManager.h"//from here to change #include "OnlineBundler.h" #include "DepthSensing/DepthSensing.h" #include <ros/ros.h> //所有的ROS c++程序都要使用这个头文件 #include <topic_demo/pose.h> //gps.h使gps.msg文件编译生成的.h文件 // extern ros::Publisher pub; /* #ifdef KINECT #pragma comment(lib, "Kinect10.lib") #endif #ifdef KINECT_ONE #pragma comment(lib, "Kinect20.lib") #endif #ifdef OPEN_NI #pragma comment(lib, "OpenNI2.lib") #endif #ifdef INTEL_SENSOR #ifdef _DEBUG #pragma comment(lib, "DSAPI.dbg.lib") #else #pragma comment(lib, "DSAPI.lib") #endif #endif #ifdef REAL_SENSE #ifdef _DEBUG #pragma comment(lib, "libpxc_d.lib") #pragma comment(lib, "libpxcutils_d.lib") #else #pragma comment(lib, "libpxc.lib") #pragma comment(lib, "libpxcutils.lib") #endif #endif #ifdef STRUCTURE_SENSOR #pragma comment (lib, "Ws2_32.lib") #pragma comment(lib, "gdiplus.lib") #endif */ /* #include "RGBDSensor.h" #include "BinaryDumpReader.h" //TODO add other sensors here #include "PrimeSenseSensor.h" #include "KinectSensor.h" #include "KinectOneSensor.h" #include "StructureSensor.h" #include "SensorDataReader.h" #include "GlobalBundlingState.h" #include "TimingLog.h" #include "SiftGPU/MatrixConversion.h" #include "SiftGPU/CUDATimer.h" #include "SiftGPU/SIFTMatchFilter.h" #include "CUDAImageManager.h" #include "ConditionManager.h" #include "DualGPU.h" #include "OnlineBundler.h" #include "DepthSensing/DepthSensing.h" */
[ "zhuanqi@tongji.edu.cn" ]
zhuanqi@tongji.edu.cn
cb0a97c30275b0d945268724cb8754af14da4b4c
5425928d3a38ed14ff750098e5e2cb2928ade5c2
/Projects/Lab 2/Lab 2/Lab 2.cpp
3b0a35e3090ba45efe0c523d327c951e508dabd7
[]
no_license
davishyer/Introduction_to_Programming
12606bab1645aa34a643ee58fad0b83b166be94b
45627041336b8189a33ca7d354cc0abe7016f21c
refs/heads/master
2021-01-25T08:28:36.161202
2014-12-15T21:40:55
2014-12-15T21:40:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,828
cpp
#include <iostream> using namespace std; int main () { //Number of each size of pizza calculations cout << "Enter the number of guests" << endl; double guests = 0; cin >> guests; while(guests < 0) { cout << "Invalid Entry" << endl; cin >> guests; } cout << "Number of guests is: " << guests << endl; int large_pizzas = guests/7; cout << "Number of large pizzas is: " << large_pizzas << endl; int medium_pizzas = (guests - (7 * large_pizzas))/3; cout << "Number of medium pizzas is: " << medium_pizzas << endl; int small_pizzas = (guests - (7 * large_pizzas) - (3 * medium_pizzas)); cout << "Number of small pizzas is: " << small_pizzas << endl; system("pause"); //Surface area and serving size calculations double pi = 3.14159; double total_surface_area = ((large_pizzas * (100 * pi)) + (medium_pizzas * (64 * pi)) + (small_pizzas * (36 * pi))); cout << "Total surface area of pizzas is: " << total_surface_area << " square inches" << endl; double serving_size = total_surface_area / guests; cout << "Serving size per guest is: " << serving_size << " square inches" << endl; system("pause"); //Total cost calculations double total_before_tip = ((large_pizzas * 14.68) + (medium_pizzas * 11.48) + (small_pizzas * 7.28)); cout << "The total cost before the tip is: $" << total_before_tip << endl; cout << "Please enter the desired tip percentage as number between 0 and 100" << endl; double percent_tip = 0; cin >> percent_tip; while(percent_tip < 0) { cout << "Please enter number between 0 and 100" << endl; cin >> percent_tip; } double tip = (total_before_tip * (percent_tip/100)); int total_cost = (tip + total_before_tip) + .5; cout << "The total cost will approximately be: $" << total_cost << endl; system("pause"); return 0; }
[ "davishyer@gmail.com" ]
davishyer@gmail.com
069dcec187ec5c7e5f14746405906754b20799de
382ccad2998866e5390b36e65baf3b317b40163f
/Python-for-coding-test/5-DFS_BFS/Q22-블록 이동하기.cpp
7121dd2c48efab883bbd27384561b77f88541cca
[]
no_license
RoyKwonn/Problem-Solving
f799642897d7242847a0752f24a7b0fa194894a8
4947d902e491cdff3e3d4ec1ef92c0222333736a
refs/heads/master
2023-06-30T10:53:07.106946
2021-08-08T08:52:47
2021-08-08T08:52:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,275
cpp
#include <bits/stdc++.h> using namespace std; const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 }; const int ddx[] = { 0, 1 }; const int ddy[] = { 1, 0 }; int N; int conv(int a, int b, int c) { return a * 200 + b * 2 + c; } bool check(int x, int y, vector<vector<int>>& board) { return x >= 0 && x < N && y >= 0 && y < N && board[x][y] == 0; } int solution(vector<vector<int>> board) { N = board.size(); bool visit[100][100][2]{}; // 0-가로, 1-세로 visit[0][0][0] = 1; queue<int> Q; Q.push(conv(0, 0, 0)); int ans = 0; while (!Q.empty()) { int szQ = Q.size(); while (szQ--) { int x, y, d, K = Q.front(); Q.pop(); x = K / 200; y = K % 200 / 2; d = K % 2; int x2 = x + ddx[d]; int y2 = y + ddy[d]; if (x == N - 1 && y == N - 1 || x2 == N - 1 && y2 == N - 1) return ans; for (int i = 0; i < 4; ++i) { int nx = x + dx[i]; int ny = y + dy[i]; int nx2 = x2 + dx[i]; int ny2 = y2 + dy[i]; if (!check(nx, ny, board) || !check(nx2, ny2, board)) continue; // 단순 이동 if (!visit[nx][ny][d]) { visit[nx][ny][d] = 1; Q.push(conv(nx, ny, d)); } } // 회전 이동 if (d == 0) { if (check(x - 1, y, board) && check(x2 - 1, y2, board)) { if (!visit[x - 1][y][1]) { Q.push(conv(x - 1, y, 1)); visit[x - 1][y][1] = 1; } if (!visit[x - 1][y + 1][1]) { Q.push(conv(x - 1, y + 1, 1)); visit[x - 1][y + 1][1] = 1; } } if (check(x + 1, y, board) && check(x2 + 1, y2, board)) { if (!visit[x][y][1]) { Q.push(conv(x, y, 1)); visit[x][y][1] = 1; } if (!visit[x][y + 1][1]) { Q.push(conv(x, y + 1, 1)); visit[x][y + 1][1] = 1; } } } else { if (check(x, y + 1, board) && check(x2, y2 + 1, board)) { if (!visit[x][y][0]) { Q.push(conv(x, y, 0)); visit[x][y][0] = 1; } if (!visit[x + 1][y][0]) { Q.push(conv(x + 1, y, 0)); visit[x + 1][y][0] = 1; } } if (check(x, y - 1, board) && check(x2, y2 - 1, board)) { if (!visit[x][y - 1][0]) { Q.push(conv(x, y - 1, 0)); visit[x][y - 1][0] = 1; } if (!visit[x + 1][y - 1][0]) { Q.push(conv(x + 1, y - 1, 0)); visit[x + 1][y - 1][0] = 1; } } } } ++ans; } return -1; }
[ "sychar05@gmail.com" ]
sychar05@gmail.com
16ca30fe11ca37afb72eaa898070e0b805592e38
98b1e51f55fe389379b0db00365402359309186a
/homework_6/problem_2/10x10/0.255/phi
dab099f3090734dc6877ffd5b629dd2c37e862a1
[]
no_license
taddyb/597-009
f14c0e75a03ae2fd741905c4c0bc92440d10adda
5f67e7d3910e3ec115fb3f3dc89a21dcc9a1b927
refs/heads/main
2023-01-23T08:14:47.028429
2020-12-03T13:24:27
2020-12-03T13:24:27
311,713,551
1
0
null
null
null
null
UTF-8
C++
false
false
2,690
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 8 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class surfaceScalarField; location "0.255"; object phi; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 3 -1 0 0 0 0]; internalField nonuniform List<scalar> 180 ( 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 ) ; boundaryField { left { type calculated; value nonuniform List<scalar> 10(-0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002); } right { type calculated; value nonuniform List<scalar> 10(0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002); } up { type calculated; value nonuniform List<scalar> 10(0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.002); } down { type calculated; value nonuniform List<scalar> 10(-0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002 -0.002); } frontAndBack { type empty; value nonuniform List<scalar> 0(); } } // ************************************************************************* //
[ "tbindas@pop-os.localdomain" ]
tbindas@pop-os.localdomain
1942956b0eafc852fa5b7f6e2bbba94c30e12551
2800e6ff27e23b536c190907793ad3aeb0a9f7f0
/source/mystic/sound.cpp
12259f156f402373060e84ff28a190e88b21c6f9
[ "MIT" ]
permissive
SpaceManiac/HamSandwich
c091735dc64bdc1e5128c77d18d916c645c80c5d
b3910715eeea3691ee64af03bffb6991c7be8eda
refs/heads/master
2023-08-16T18:24:27.788739
2023-08-05T20:35:40
2023-08-05T20:35:40
186,207,665
33
13
MIT
2022-06-10T04:11:05
2019-05-12T03:40:47
C++
UTF-8
C++
false
false
1,590
cpp
#include "sound.h" #include "display.h" #include "player.h" #include "hammusic.h" static int curSong; void InitSound(void) { JamulSoundPurge(); curSong=0; } void ExitSound(void) { // don't need to do nothing, it's handled by jamulsoundexit } void MakeSound(int snd,int x,int y,int flags,int priority) { long pan,vol; int cx,cy; if(!SoundIsAvailable()) return; GetCamera(&cx,&cy); x>>=FIXSHIFT; y>>=FIXSHIFT; pan=(x-cx)*2; vol=-((x-cx)*(x-cx)+(y-cy)*(y-cy))/128; if(vol<-5000) return; // too quiet to play GoPlaySound(snd,pan,vol,(byte)flags,priority); } void MakeNormalSound(int snd) { if(!SoundIsAvailable()) return; GoPlaySound(snd,0,0,SND_MAXPRIORITY|SND_CUTOFF|SND_ONE,MAX_SNDPRIORITY); } void ReplaySong() { if (!PlayerGetMusicSettings()) return; char s[64]; sprintf(s, "sound/snd%03d.wav", curSong); PlaySongFile(s); } void PlaySong(int sng) { if(!SoundIsAvailable()) return; if(sng == curSong) return; // no need, it's already playing our song curSong = sng; ReplaySong(); } void VolumeSong(byte hi) { if(!SoundIsAvailable()) return; switch(hi) { case 0: StopSong(); break; case 1: SetMusicVolume(85); break; case 2: SetMusicVolume(170); break; case 3: SetMusicVolume(255); break; } } void VolumeSound(byte hi) { if(!SoundIsAvailable()) return; switch(hi) { case 0: JamulSoundVolume(0); break; case 1: JamulSoundVolume(85); break; case 2: JamulSoundVolume(170); break; case 3: JamulSoundVolume(255); break; } } int CurrentSong(void) { return curSong; }
[ "tad@platymuus.com" ]
tad@platymuus.com
27f4cdee7e623bf4fe2128d67faa37fc45d02600
0f88d1ff9eb49263794ff06e7861a29b8518b5de
/2046.cpp
c6b5b350b22f65b85386035826c86be8eb4d2dd4
[]
no_license
baiyucraft/HDUOJ_test
e48fcdff608f7e1dcd32e565e481c97eb330ee16
2aaced9ecdc7561036af890735f62b289b475dda
refs/heads/main
2023-03-13T00:40:42.323320
2021-03-07T03:42:54
2021-03-07T03:42:54
343,143,174
0
0
null
null
null
null
GB18030
C++
false
false
784
cpp
//Problem Description //在2×n的一个长方形方格中, 用一个1× 2的骨牌铺满方格, 输入n, 输出铺放方案的总数. //例如n = 3时, 为2× 3方格,骨牌的铺放方案有三种, 如下图: // //Input //输入数据由多行组成,每行包含一个整数n, 表示该测试实例的长方形方格的规格是2×n(0 < n <= 50)。 // //Output //对于每个测试实例,请输出铺放方案的总数,每个实例的输出占一行。 #include "problem.h" #include <iostream> using namespace std; long long *getN(int n) { long long* p = new long long[n + 1]; p[1] = 1; p[2] = 2; for (int i = 3; i <= n; i++) p[i] = p[i - 1] + p[i - 2]; return p; } void problem2046() { int n; long long* p = getN(50); while (cin >> n) cout << p[n] << endl; }
[ "1047852821@qq.com" ]
1047852821@qq.com
046f279341e0bcfa7f06456a36f1f625ebbbd5c5
d5bd083dbcacce8cf62ebbd73c77c14c8247e057
/external/fsl_imx_omx/OpenMAXIL/src/component/audio_fake_render/AudioFakeRender.h
280766328429442b8a9c2bb23edafa9b4cec8362
[]
no_license
RetronixTechInc/android-retronix
ab0e10840dab5dc7b0879737953ebf2e1916f2b0
cd7d794dea51c3b287da0d35ddb18c1bdef00372
refs/heads/RTX_NXP_Android601
2021-11-16T03:58:58.169998
2021-11-15T01:51:02
2021-11-15T01:51:02
198,991,737
4
5
null
2020-03-08T23:21:29
2019-07-26T09:49:01
Java
UTF-8
C++
false
false
960
h
/** * Copyright (c) 2009-2010, Freescale Semiconductor Inc., * All Rights Reserved. * * The following programs are the sole property of Freescale Semiconductor Inc., * and contain its proprietary and confidential information. * */ /** * @file AudioFakeRender.h * @brief Class definition of AudioFakeRender Component * @ingroup AudioFakeRender */ #ifndef AudioFakeRender_h #define AudioFakeRender_h #include "ComponentBase.h" #include "AudioRender.h" class AudioFakeRender : public AudioRender { public: AudioFakeRender(); private: /** Audio render device related */ OMX_ERRORTYPE OpenDevice(); OMX_ERRORTYPE CloseDevice(); OMX_ERRORTYPE SetDevice(); OMX_ERRORTYPE ResetDevice(); OMX_ERRORTYPE DrainDevice(); OMX_ERRORTYPE DeviceDelay(OMX_U32 *nDelayLen); OMX_ERRORTYPE WriteDevice(OMX_U8 *pBuffer, OMX_U32 nActuralLen, OMX_U32 *nConsumedLen); }; #endif /* File EOF */
[ "townwang@retronix.com.tw" ]
townwang@retronix.com.tw
348cbc375ecb047d7baf6c01802e3c80b2fc5b6b
3f0e48d32b034f26d0b4d2c22de706238fd6277c
/MainWindow/helpmedialog.h
60da1eae6830a94e5b6dcf529d4758e5e0c9f0d7
[]
no_license
jamesbee/QuickTalkV1.3
eeec17cca7ffb938cc549d5fe0d5f87ce861b2e6
e9433715cdd4d5df5c6331d6f4693fe429574a88
refs/heads/master
2016-08-03T21:50:34.509850
2012-09-11T05:22:27
2012-09-11T05:22:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
329
h
#ifndef HELPMEDIALOG_H #define HELPMEDIALOG_H #include <QDialog> namespace Ui { class HelpMeDialog; } class HelpMeDialog : public QDialog { Q_OBJECT public: explicit HelpMeDialog(QWidget *parent = 0); ~HelpMeDialog(); private: Ui::HelpMeDialog *ui; }; #endif // HELPMEDIALOG_H
[ "jambecome@gmail.com" ]
jambecome@gmail.com
4e761548fbd9b47103758f3f719a49bea2329da8
294621274eae9de26f5184167e9ff2a2df40e9da
/include/game/GroundUnit.hpp
3eb71843c3918d640c877ddfb853f6ad95fc4460
[]
no_license
narzull/MarinesSaveTheQueen
fc18ec22ee602e683814247dc104c353c469e2ea
f4e65ce55fb6f1c984e5eb1f9de2edc8c3224db8
refs/heads/master
2016-09-05T21:56:22.576861
2013-03-23T18:36:48
2013-03-23T18:36:48
7,947,687
0
1
null
null
null
null
UTF-8
C++
false
false
1,081
hpp
#ifndef __GROUNDUNIT_HPP__ #define __GROUNDUNIT_HPP__ #include "../api/Entity.hpp" #include <iostream> #define GRASS_TYPE 1 #define ROCK_TYPE 2 //GroundUnit class namespace game { class GroundUnit : public api::Entity{ public: //Static attribute const static float s_GROUNDUNIT_WIDTH = 0.5 + 0.01; const static float s_GROUNDUNIT_HEIGHT = 0.5 + 0.01; //Constructor GroundUnit(unsigned int X, unsigned int Y, unsigned int centralX, unsigned int centralY); virtual ~GroundUnit(){}; //Getters std::pair<unsigned int, unsigned int> getGroundUnitCoord()const{return m_Coord;}; unsigned int getType()const{return m_Type;}; int getWeight()const{return m_Weight;}; bool isOccupied()const{ return m_IsOccupied;}; //Setters void setWeight(int weight){ m_Weight = weight;}; void setOccupied(bool occupation){m_IsOccupied = occupation;}; private: std::pair<unsigned int, unsigned int> m_Coord; unsigned int m_Type; int m_Weight; bool m_IsOccupied; }; } // namespace game #endif // __GROUNDUNIT_HPP__
[ "jdananche@gmail.com" ]
jdananche@gmail.com
dc37c747d5ca71b216d786cf64cbe6fc901e1e19
6c77cf237697f252d48b287ae60ccf61b3220044
/aws-cpp-sdk-gamelift/include/aws/gamelift/model/StopFleetActionsRequest.h
37ffdaf0f878fe83f6b4d0d0191d74077da18ad3
[ "MIT", "Apache-2.0", "JSON" ]
permissive
Gohan/aws-sdk-cpp
9a9672de05a96b89d82180a217ccb280537b9e8e
51aa785289d9a76ac27f026d169ddf71ec2d0686
refs/heads/master
2020-03-26T18:48:43.043121
2018-11-09T08:44:41
2018-11-09T08:44:41
145,232,234
1
0
Apache-2.0
2018-08-30T13:42:27
2018-08-18T15:42:39
C++
UTF-8
C++
false
false
4,352
h
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/gamelift/GameLift_EXPORTS.h> #include <aws/gamelift/GameLiftRequest.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/gamelift/model/FleetAction.h> #include <utility> namespace Aws { namespace GameLift { namespace Model { /** */ class AWS_GAMELIFT_API StopFleetActionsRequest : public GameLiftRequest { public: StopFleetActionsRequest(); // Service request name is the Operation name which will send this request out, // each operation should has unique request name, so that we can get operation's name from this request. // Note: this is not true for response, multiple operations may have the same response name, // so we can not get operation's name from response. inline virtual const char* GetServiceRequestName() const override { return "StopFleetActions"; } Aws::String SerializePayload() const override; Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override; /** * <p>Unique identifier for a fleet</p> */ inline const Aws::String& GetFleetId() const{ return m_fleetId; } /** * <p>Unique identifier for a fleet</p> */ inline void SetFleetId(const Aws::String& value) { m_fleetIdHasBeenSet = true; m_fleetId = value; } /** * <p>Unique identifier for a fleet</p> */ inline void SetFleetId(Aws::String&& value) { m_fleetIdHasBeenSet = true; m_fleetId = std::move(value); } /** * <p>Unique identifier for a fleet</p> */ inline void SetFleetId(const char* value) { m_fleetIdHasBeenSet = true; m_fleetId.assign(value); } /** * <p>Unique identifier for a fleet</p> */ inline StopFleetActionsRequest& WithFleetId(const Aws::String& value) { SetFleetId(value); return *this;} /** * <p>Unique identifier for a fleet</p> */ inline StopFleetActionsRequest& WithFleetId(Aws::String&& value) { SetFleetId(std::move(value)); return *this;} /** * <p>Unique identifier for a fleet</p> */ inline StopFleetActionsRequest& WithFleetId(const char* value) { SetFleetId(value); return *this;} /** * <p>List of actions to suspend on the fleet. </p> */ inline const Aws::Vector<FleetAction>& GetActions() const{ return m_actions; } /** * <p>List of actions to suspend on the fleet. </p> */ inline void SetActions(const Aws::Vector<FleetAction>& value) { m_actionsHasBeenSet = true; m_actions = value; } /** * <p>List of actions to suspend on the fleet. </p> */ inline void SetActions(Aws::Vector<FleetAction>&& value) { m_actionsHasBeenSet = true; m_actions = std::move(value); } /** * <p>List of actions to suspend on the fleet. </p> */ inline StopFleetActionsRequest& WithActions(const Aws::Vector<FleetAction>& value) { SetActions(value); return *this;} /** * <p>List of actions to suspend on the fleet. </p> */ inline StopFleetActionsRequest& WithActions(Aws::Vector<FleetAction>&& value) { SetActions(std::move(value)); return *this;} /** * <p>List of actions to suspend on the fleet. </p> */ inline StopFleetActionsRequest& AddActions(const FleetAction& value) { m_actionsHasBeenSet = true; m_actions.push_back(value); return *this; } /** * <p>List of actions to suspend on the fleet. </p> */ inline StopFleetActionsRequest& AddActions(FleetAction&& value) { m_actionsHasBeenSet = true; m_actions.push_back(std::move(value)); return *this; } private: Aws::String m_fleetId; bool m_fleetIdHasBeenSet; Aws::Vector<FleetAction> m_actions; bool m_actionsHasBeenSet; }; } // namespace Model } // namespace GameLift } // namespace Aws
[ "henso@amazon.com" ]
henso@amazon.com
142d0f2a204c2300768aaf441828c12e391fa911
d5dc835e219a338253a71a837b24e38f3c36f439
/host/cli/sysmap_parse.cpp
fce76afca5f9baebfb64b2d23bb6284cc541a4d6
[]
no_license
MasterScott/flexsoc_cm3
01f3f40d5dc9628f217def62648f43bd9230fe86
98a6fa3630f7c011ff4c3cfb2ad43682fb7e1249
refs/heads/master
2023-02-23T19:21:52.823254
2020-10-09T19:14:31
2020-10-09T19:14:31
335,180,358
0
0
null
2021-02-02T05:36:02
2021-02-02T05:35:52
null
UTF-8
C++
false
false
7,995
cpp
/** * This function parses the system map and instantiates and connects the necessary plugins. * * All rights reserved. * Tiny Labs Inc * 2019 */ #include <iostream> #include <fstream> #include <algorithm> #include <stdlib.h> #include <bits/stdc++.h> #include "sysmap_parse.h" #include "plugini.h" #include "plugin.h" #include "Target.h" #include "PluginTarget.h" #include "log.h" /** * The system maps is specified in the following format: * - declaration per line * - # for comment * * Each declaration consists of either: * plugin@address:args:export (bus peripheral) * or: * plugin@export1,export2:args (secondary peripheral) * or: * rirq@A:B (Map remote IRQ B to local IRQ A) A/B=[0,240) * or: * rirq@A-B:C-D (Map remote IRQ range C-D to local range A-B) * * For instance a GPIO controller and SPI controller may be mapped as: * pl061@0x40001000::A (maps ARM primecell GPIO periph to addr, export as port A) * pl022@0x40002000::SPI.0 (maps ARM primecell SPI periph to addr, export as SPI.0) * * Note: Exports must match a valid interface. The following are valid interfaces: * UART * I2C * SPI * A-G - GPIO interface * * A simulated OLED can then be connected to the SPI bus: * ssd1306@SPI.0,A.9:rotate=1 * * The SSD1306 OLED controller is now connected to the SPI.0 bus. Pin A.9 (port A, pin 9) * terminates to the OLED controller as a CS pin. This allows other peripherals to * connect to the SPI.0 bus. ie: * sd@SPI.0,A.10:sz=4G * * The beauty of all of this is (if done right) the firmware running on the target * is 100% compatible between physical hardware and virtual peripherals. This makes * it easy to quickly prototype a new system using mostly virtual peripherals and then * migrate them over one-by-one until you have a fully physical system. * * In addition to the previous examples there are other "peripherals" with no * physical analog. These can be very useful for debugging/reverse engineering. * For instance you may have a binary image that runs on a piece of hardware that * you're trying to understand. By connecting the JTAG/SWD bridge to the physical * hardware and mapping that port (not covered here) you can perform a sort of * man-in-the-middle to log all peripheral accesses. * * Assuming the target is configured to map the local JTAG/SWD bridge * @0x6000.0000 -> remote 0x4000.0000 we can add the following line to the system * map: * remap@0x40000000:@0x60000000 sz=256M log=periph.txt * * This will map all peripheral accesses from the original firmware to the JTAG/SWD * bridge which will then complete on the original hardware. In addition accesses * will be logged a file for later analysis. Of course the downside is bus accesses * will get stretched when taking this path such that "clock time" and "system time" * will drift. */ using namespace std; static PluginTarget *ptarget; // trim from both ends (in place) static inline void trim(std::string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !std::isspace(ch); })); s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end()); } static uint32_t parse_uint (const char *str) { char *end; uint32_t val = strtoul (str, &end, 0); if (*end == 'k') val *= 1024; else if (*end == 'M') val *= (1024 * 1024); return val; } int sysmap_parse (const char *map, BusPeripheral ***bp, int *cnt) { int rv = 0; // Make sure bp and cnt are valid if (!bp || !cnt) return -1; // Get host target Target *target = Target::Ptr (); // Create plugin target ptarget = new PluginTarget (); // Clear count *cnt = 0; // Open map file ifstream file (map); string line; // Print out map header log (LOG_NORMAL, "Plugin Map:"); // Loop over each line while (getline (file, line)) { void *obj; plugin_type_t type; size_t pos; string plugin, addr; // Trim whitespace trim (line); // Check if line starts with # if ((line[0] == '#') || (line == "")) continue; // Tokenize into parts vector <string> tokens; stringstream decl (line); string token; // Loop over tokens while (getline (decl, token, ':')) tokens.push_back (token); // Split plugin and address if ((pos = tokens[0].find ("@")) != string::npos) { // Get plugin name plugin = tokens[0].substr (0, pos); // Get address addr = tokens[0].substr (pos + 1, tokens[0].length ()); } else { log (LOG_ERR, "Invalid line [%s]", line); rv = -1; goto cleanup; } // Analyze parts if ((tokens.size () < 1) || (tokens.size () > 4)) { log (LOG_ERR, "Invalid line [%s]", line); rv = -1; goto cleanup; } // Handle builtin functions if (plugin == "alias") { alias_t alias; uint8_t idx = 0; if (tokens.size () != 3) { log (LOG_ERR, "Invalid alias: alias@base:size:redirect"); rv = -1; goto cleanup; } // Configure memory alias if (parse_uint (addr.c_str ()) < 0x20000000) { if (target->CodeAliasGet (idx, &alias)) log (LOG_ERR, "Failed to get code alias[%d]", idx); // Check if alias used if (alias.base != 0) idx++; } // Setup alias alias.base = parse_uint (addr.c_str ()); alias.size = parse_uint (tokens[1].c_str ()); alias.remap = parse_uint (tokens[2].c_str ()); // Configure registers if (alias.base < 0x20000000) { if (target->CodeAliasSet (idx, &alias)) log (LOG_ERR, "Failed to set code alias %d", idx); } else { if (target->SysAliasSet (idx, &alias)) log (LOG_ERR, "Failed to set code alias %d", idx); } } else if (plugin == "remap32") { if ((tokens.size () != 2) || (stoi (addr) < 0) || (stoi (addr) > 7)) { log (LOG_ERR, "Invalid remap32: remap32@<0-7>:<remote addr>"); rv = -1; goto cleanup; } // Configure remote mapping target->RemoteRemap32M (parse_uint (addr.c_str()), parse_uint (tokens[1].c_str())); } else if (plugin == "remap256") { if (tokens.size () != 1) { log (LOG_ERR, "Invalid remap256: remap32@<remote addr>"); rv = -1; goto cleanup; } // Configure remote mapping target->RemoteRemap256M (parse_uint (addr.c_str ())); } else { // Look for plugin if (tokens.size () > 1) obj = plugin_load (plugin.c_str (), tokens[1].c_str(), &type); else obj = plugin_load (plugin.c_str (), "", &type); if (!obj) { log (LOG_ERR, "Plugin not found: %s", plugin); rv = -1; goto cleanup; } // Handle bus peripherals if (type == BUSPERIPH) { // Cast to busperipheral BusPeripheral *p = (BusPeripheral *)obj; // Set base address p->SetBase (strtoul (addr.c_str (), NULL, 0)); // Set target operations p->SetTarget (ptarget); // Initialize bus peripheral p->Init (); // Add to peripheral array *bp = (BusPeripheral **)realloc (*bp, sizeof (BusPeripheral *) * (*cnt + 1)); if (!*bp) { rv = -1; goto cleanup; } (*bp)[(*cnt)++] = p; // Print out log (LOG_NORMAL, " %08X: %s", p->Base(), plugin.c_str()); if (tokens.size() > 1) log (LOG_DEBUG, " %s", tokens[1].c_str()); } // Handle non busperipheral types else { } } } cleanup: // Close file file.close (); if (rv) delete ptarget; return rv; } void sysmap_cleanup (void) { delete ptarget; }
[ "elliot@tinylabs.io" ]
elliot@tinylabs.io
10c93bdfee93fc5da496fa95c420a68a1a1ccff0
4c0c57f9ddb87f46d58192e1ebfd2c40f6d2c315
/tdutils/td/utils/JsonBuilder.cpp
446a5d1a09c86b19d54cbb8485d3c998db39e354
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
luckydonald-backup/td
9693cf868b3afdc5b5257e95e37af79380472d0b
71d03f39c364367a8a7c51f783a41099297de826
refs/heads/master
2021-09-02T08:08:18.834827
2018-12-31T19:04:05
2017-12-31T20:08:40
115,928,341
2
0
null
2018-01-01T15:37:21
2018-01-01T15:37:20
null
UTF-8
C++
false
false
18,123
cpp
// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2017 // // 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) // #include "td/utils/JsonBuilder.h" #include "td/utils/misc.h" #include "td/utils/ScopeGuard.h" #include <cstring> namespace td { StringBuilder &operator<<(StringBuilder &sb, const JsonRawString &val) { sb << '"'; SCOPE_EXIT { sb << '"'; }; auto *s = val.value_.begin(); auto len = val.value_.size(); for (size_t pos = 0; pos < len; pos++) { auto ch = static_cast<unsigned char>(s[pos]); switch (ch) { case '"': sb << '\\' << '"'; break; case '\\': sb << '\\' << '\\'; break; case '\b': sb << '\\' << 'b'; break; case '\f': sb << '\\' << 'f'; break; case '\n': sb << '\\' << 'n'; break; case '\r': sb << '\\' << 'r'; break; case '\t': sb << '\\' << 't'; break; default: if (ch <= 31) { sb << JsonOneChar(s[pos]); break; } sb << s[pos]; break; } } return sb; } StringBuilder &operator<<(StringBuilder &sb, const JsonString &val) { sb << '"'; SCOPE_EXIT { sb << '"'; }; auto *s = val.str_.begin(); auto len = val.str_.size(); for (size_t pos = 0; pos < len; pos++) { auto ch = static_cast<unsigned char>(s[pos]); switch (ch) { case '"': sb << '\\' << '"'; break; case '\\': sb << '\\' << '\\'; break; case '\b': sb << '\\' << 'b'; break; case '\f': sb << '\\' << 'f'; break; case '\n': sb << '\\' << 'n'; break; case '\r': sb << '\\' << 'r'; break; case '\t': sb << '\\' << 't'; break; default: if (ch <= 31) { sb << JsonOneChar(s[pos]); break; } if (128 <= ch) { int a = s[pos]; CHECK((a & 0x40) != 0); CHECK(pos + 1 < len); int b = s[++pos]; CHECK((b & 0xc0) == 0x80); if ((a & 0x20) == 0) { CHECK((a & 0x1e) > 0); sb << JsonChar(((a & 0x1f) << 6) | (b & 0x3f)); break; } CHECK(pos + 1 < len); int c = s[++pos]; CHECK((c & 0xc0) == 0x80); if ((a & 0x10) == 0) { CHECK(((a & 0x0f) | (b & 0x20)) > 0); sb << JsonChar(((a & 0x0f) << 12) | ((b & 0x3f) << 6) | (c & 0x3f)); break; } CHECK(pos + 1 < len); int d = s[++pos]; CHECK((d & 0xc0) == 0x80); if ((a & 0x08) == 0) { CHECK(((a & 0x07) | (b & 0x30)) > 0); sb << JsonChar(((a & 0x07) << 18) | ((b & 0x3f) << 12) | ((c & 0x3f) << 6) | (d & 0x3f)); break; } UNREACHABLE(); break; } sb << s[pos]; break; } } return sb; } Result<MutableSlice> json_string_decode(Parser &parser) { if (!parser.try_skip('"')) { return Status::Error("Opening '\"' expected"); } auto *cur_src = parser.data().data(); auto *end_src = parser.data().end(); auto *end = cur_src; while (end < end_src && end[0] != '"') { if (end[0] == '\\') { end++; } end++; } if (end >= end_src) { return Status::Error("Closing '\"' not found"); } parser.advance(end + 1 - cur_src); end_src = end; auto *cur_dest = cur_src; auto *begin_dest = cur_src; while (cur_src != end_src) { auto *slash = static_cast<char *>(std::memchr(cur_src, '\\', end_src - cur_src)); if (slash == nullptr) { slash = end_src; } std::memmove(cur_dest, cur_src, slash - cur_src); cur_dest += slash - cur_src; cur_src = slash; if (cur_src != end_src) { cur_src++; if (cur_src == end_src) { // TODO UNREACHABLE(); return Status::Error("Unexpected end of string"); } switch (*cur_src) { case '"': case '\\': case '/': *cur_dest++ = *cur_src++; break; case 'b': *cur_dest++ = '\b'; cur_src++; break; case 'f': *cur_dest++ = '\f'; cur_src++; break; case 'n': *cur_dest++ = '\n'; cur_src++; break; case 'r': *cur_dest++ = '\r'; cur_src++; break; case 't': *cur_dest++ = '\t'; cur_src++; break; case 'u': { cur_src++; if (cur_src + 4 > end_src) { return Status::Error("\\u has less than 4 symbols"); } int num = 0; for (int i = 0; i < 4; i++, cur_src++) { int d = hex_to_int(*cur_src); if (d == 16) { return Status::Error("Invalid \\u -- not hex digit"); } num = num * 16 + d; } if (0xD7FF < num && num < 0xE000) { if (cur_src + 6 <= end_src && cur_src[0] == '\\' && cur_src[1] == 'u') { cur_src += 2; int new_num = 0; for (int i = 0; i < 4; i++, cur_src++) { int d = hex_to_int(*cur_src); if (d == 16) { return Status::Error("Invalid \\u -- not hex digit"); } new_num = new_num * 16 + d; } if (0xD7FF < new_num && new_num < 0xE000) { num = (((num & 0x3FF) << 10) | (new_num & 0x3FF)) + 0x10000; } else { cur_src -= 6; } } } if (num < 128) { *cur_dest++ = static_cast<char>(num); } else if (num < 0x800) { *cur_dest++ = static_cast<char>(0xc0 + (num >> 6)); *cur_dest++ = static_cast<char>(0x80 + (num & 63)); } else if (num < 0xffff) { *cur_dest++ = static_cast<char>(0xe0 + (num >> 12)); *cur_dest++ = static_cast<char>(0x80 + ((num >> 6) & 63)); *cur_dest++ = static_cast<char>(0x80 + (num & 63)); } else { *cur_dest++ = static_cast<char>(0xf0 + (num >> 18)); *cur_dest++ = static_cast<char>(0x80 + ((num >> 12) & 63)); *cur_dest++ = static_cast<char>(0x80 + ((num >> 6) & 63)); *cur_dest++ = static_cast<char>(0x80 + (num & 63)); } break; } } } } CHECK(cur_dest <= end_src); return MutableSlice(begin_dest, cur_dest); } Status json_string_skip(Parser &parser) { if (!parser.try_skip('"')) { return Status::Error("Opening '\"' expected"); } auto *begin_src = parser.data().data(); auto *cur_src = begin_src; auto *end_src = parser.data().end(); auto *end = cur_src; while (end < end_src && *end != '"') { if (*end == '\\') { end++; } end++; } if (end >= end_src) { return Status::Error("Closing '\"' not found"); } parser.advance(end + 1 - cur_src); end_src = end; while (cur_src != end_src) { auto *slash = static_cast<char *>(std::memchr(cur_src, '\\', end_src - cur_src)); if (slash == nullptr) { slash = end_src; } cur_src = slash; if (cur_src != end_src) { cur_src++; if (cur_src == end_src) { // TODO UNREACHABLE(); return Status::Error("Unexpected end of string"); } switch (*cur_src) { case '"': case '\\': case '/': case 'b': case 'f': case 'n': case 'r': case 't': cur_src++; break; case 'u': { cur_src++; if (cur_src + 4 > end_src) { return Status::Error("\\u has less than 4 symbols"); } int num = 0; for (int i = 0; i < 4; i++, cur_src++) { int d = hex_to_int(*cur_src); if (d == 16) { return Status::Error("Invalid \\u -- not hex digit"); } num = num * 16 + d; } if (0xD7FF < num && num < 0xE000) { if (cur_src + 6 <= end_src && cur_src[0] == '\\' && cur_src[1] == 'u') { cur_src += 2; int new_num = 0; for (int i = 0; i < 4; i++, cur_src++) { int d = hex_to_int(*cur_src); if (d == 16) { return Status::Error("Invalid \\u -- not hex digit"); } new_num = new_num * 16 + d; } if (0xD7FF < new_num && new_num < 0xE000) { // num = (((num & 0x3FF) << 10) | (new_num & 0x3FF)) + 0x10000; } else { cur_src -= 6; } } } break; } } } } return Status::OK(); } Result<JsonValue> do_json_decode(Parser &parser, int32 max_depth) { if (max_depth < 0) { return Status::Error("Too big object depth"); } parser.skip_whitespaces(); switch (parser.peek_char()) { case 'f': if (parser.skip_start_with("false")) { return JsonValue::create_boolean(false); } return Status::Error("Starts with 'f' -- false expected"); case 't': if (parser.skip_start_with("true")) { return JsonValue::create_boolean(true); } return Status::Error("Starts with 't' -- true expected"); case 'n': if (parser.skip_start_with("null")) { return JsonValue(); } return Status::Error("Starts with 'n' -- null expected"); case '"': { TRY_RESULT(slice, json_string_decode(parser)); return JsonValue::create_string(slice); } case '[': { parser.skip('['); parser.skip_whitespaces(); std::vector<JsonValue> res; if (parser.try_skip(']')) { return JsonValue::create_array(std::move(res)); } while (true) { if (parser.empty()) { return Status::Error("Unexpected end"); } TRY_RESULT(value, do_json_decode(parser, max_depth - 1)); res.emplace_back(std::move(value)); parser.skip_whitespaces(); if (parser.try_skip(']')) { break; } if (parser.try_skip(',')) { parser.skip_whitespaces(); continue; } return Status::Error("Unexpected symbol"); } return JsonValue::create_array(std::move(res)); } case '{': { parser.skip('{'); parser.skip_whitespaces(); std::vector<std::pair<MutableSlice, JsonValue> > res; if (parser.try_skip('}')) { return JsonValue::make_object(std::move(res)); } while (true) { if (parser.empty()) { return Status::Error("Unexpected end"); } TRY_RESULT(key, json_string_decode(parser)); parser.skip_whitespaces(); if (!parser.try_skip(':')) { return Status::Error("':' expected"); } TRY_RESULT(value, do_json_decode(parser, max_depth - 1)); res.emplace_back(std::move(key), std::move(value)); parser.skip_whitespaces(); if (parser.try_skip('}')) { break; } if (parser.try_skip(',')) { parser.skip_whitespaces(); continue; } return Status::Error("Unexpected symbol"); } return JsonValue::make_object(std::move(res)); } case '-': case '+': case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { auto num = parser.read_while( [](char c) { return c == '-' || ('0' <= c && c <= '9') || c == 'e' || c == 'E' || c == '+' || c == '.'; }); return JsonValue::create_number(num); } case 0: return Status::Error("Unexpected end"); default: { char next = parser.peek_char(); if (0 < next && next < 127) { return Status::Error(PSLICE() << "Unexpected symbol '" << parser.peek_char() << "'"); } else { return Status::Error("Unexpected symbol"); } } } UNREACHABLE(); } Status do_json_skip(Parser &parser, int32 max_depth) { if (max_depth < 0) { return Status::Error("Too big object depth"); } parser.skip_whitespaces(); switch (parser.peek_char()) { case 'f': if (parser.skip_start_with("false")) { return Status::OK(); } return Status::Error("Starts with 'f' -- false expected"); case 't': if (parser.skip_start_with("true")) { return Status::OK(); } return Status::Error("Starts with 't' -- true expected"); case 'n': if (parser.skip_start_with("null")) { return Status::OK(); } return Status::Error("Starts with 'n' -- null expected"); case '"': { return json_string_skip(parser); } case '[': { parser.skip('['); parser.skip_whitespaces(); if (parser.try_skip(']')) { return Status::OK(); } while (true) { if (parser.empty()) { return Status::Error("Unexpected end"); } TRY_STATUS(do_json_skip(parser, max_depth - 1)); parser.skip_whitespaces(); if (parser.try_skip(']')) { break; } if (parser.try_skip(',')) { parser.skip_whitespaces(); continue; } return Status::Error("Unexpected symbol"); } return Status::OK(); } case '{': { parser.skip('{'); parser.skip_whitespaces(); if (parser.try_skip('}')) { return Status::OK(); } while (true) { if (parser.empty()) { return Status::Error("Unexpected end"); } TRY_STATUS(json_string_skip(parser)); parser.skip_whitespaces(); if (!parser.try_skip(':')) { return Status::Error("':' expected"); } TRY_STATUS(do_json_skip(parser, max_depth - 1)); parser.skip_whitespaces(); if (parser.try_skip('}')) { break; } if (parser.try_skip(',')) { parser.skip_whitespaces(); continue; } return Status::Error("Unexpected symbol"); } return Status::OK(); } case '-': case '+': case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { parser.read_while( [](char c) { return c == '-' || ('0' <= c && c <= '9') || c == 'e' || c == 'E' || c == '+' || c == '.'; }); return Status::OK(); } case 0: return Status::Error("Unexpected end"); default: { char next = parser.peek_char(); if (0 < next && next < 127) { return Status::Error(PSLICE() << "Unexpected symbol '" << parser.peek_char() << "'"); } else { return Status::Error("Unexpected symbol"); } } } return Status::Error("Can't parse"); } Slice JsonValue::get_type_name(Type type) { switch (type) { case Type::Null: return Slice("Null"); case Type::Number: return Slice("Number"); case Type::Boolean: return Slice("Boolean"); case Type::String: return Slice("String"); case Type::Array: return Slice("Array"); case Type::Object: return Slice("Object"); default: UNREACHABLE(); return Slice("Unknown"); } } bool has_json_object_field(JsonObject &object, Slice name) { for (auto &field_value : object) { if (field_value.first == name) { return true; } } return false; } Result<JsonValue> get_json_object_field(JsonObject &object, Slice name, JsonValue::Type type, bool is_optional) { for (auto &field_value : object) { if (field_value.first == name) { if (type != JsonValue::Type::Null && field_value.second.type() != type) { return Status::Error(400, PSLICE() << "Field \"" << name << "\" must be of type " << JsonValue::get_type_name(type)); } return std::move(field_value.second); } } if (!is_optional) { return Status::Error(400, PSLICE() << "Can't find field \"" << name << "\""); } return JsonValue(); } Result<bool> get_json_object_bool_field(JsonObject &object, Slice name, bool is_optional, bool default_value) { TRY_RESULT(value, get_json_object_field(object, name, JsonValue::Type::Boolean, is_optional)); if (value.type() == JsonValue::Type::Null) { return default_value; } return value.get_boolean(); } Result<int32> get_json_object_int_field(JsonObject &object, Slice name, bool is_optional, int32 default_value) { TRY_RESULT(value, get_json_object_field(object, name, JsonValue::Type::Number, is_optional)); if (value.type() == JsonValue::Type::Null) { return default_value; } return to_integer_safe<int32>(value.get_number()); } Result<double> get_json_object_double_field(JsonObject &object, Slice name, bool is_optional, double default_value) { TRY_RESULT(value, get_json_object_field(object, name, JsonValue::Type::Number, is_optional)); if (value.type() == JsonValue::Type::Null) { return default_value; } return to_double(value.get_number().str()); } Result<string> get_json_object_string_field(JsonObject &object, Slice name, bool is_optional, string default_value) { for (auto &field_value : object) { if (field_value.first == name) { if (field_value.second.type() == JsonValue::Type::String) { return field_value.second.get_string().str(); } if (field_value.second.type() == JsonValue::Type::Number) { return field_value.second.get_number().str(); } return Status::Error(400, PSLICE() << "Field \"" << name << "\" must be of type String"); } } if (is_optional) { return default_value; } return Status::Error(400, PSLICE() << "Can't find field \"" << name << "\""); } } // namespace td
[ "arseny30@gmail.com" ]
arseny30@gmail.com
0aa4d7589d3e0b4bddb5708fdcb861f74d5357b6
f9a548e36fbd8ea303c8fb23d45b3eaa80de9201
/src/converts.cpp
5d08e93687c7bff5407f9089fd8306c1d5158bfd
[ "WTFPL" ]
permissive
patztablook22/BASUdoku
0d8d5149dd9feb9dcc2279f987c06d706a59cc57
5a582c92df05efc902ef61d2151a4545d6ca7fe3
refs/heads/master
2023-06-07T06:24:15.041861
2021-06-27T23:03:20
2021-06-27T23:03:20
380,799,626
0
0
null
null
null
null
UTF-8
C++
false
false
254
cpp
#include "game.hpp" uint8_t Game::convert(char c) { if (c >= 48 && c <= 57) return c - 48; else return 10 + c - 65; } char Game::convert(uint8_t i) { if (i < 10) return 48 + i; else return 65 + i - 10; }
[ "patz@tuta.io" ]
patz@tuta.io
4cad4caa6af649835533c4143ced8a70bba297be
83d1e8ede0d8999416580176063520417d2be936
/BFS/PerfectSquares_BFS.cpp
f030b6c0c106fddb6e8bc8d8c397326a708cc392
[]
no_license
Algoristme/ProgrammingQuestions
236e0665c766f3b5ea86ed6424ccb2c70954bf2f
ead6583151ff2a9dd036f34b706a502ccd67b7b0
refs/heads/master
2021-01-24T19:23:59.266245
2020-05-01T01:33:45
2020-05-01T01:33:45
82,957,858
0
0
null
null
null
null
UTF-8
C++
false
false
830
cpp
// BFS for perfect squares. class Solution { public: int numSquares(int n) { if(n < 0) return -1; queue<int> q; q.push(n); int depth = 0; while(!q.empty()){ ++depth; int sz = q.size(); for(int i = 0; i < sz; ++i ) { int curr = q.front(); int sr = sqrt(curr); q.pop(); for(int n = sr; n >0; --n){ int delta = curr -(n*n); if(delta == 0) { //cout << curr << " " << n << endl; return depth; } q.push(delta); //cout << "Delta " << delta << endl; } } } } };
[ "gsbhargav@gmail.com" ]
gsbhargav@gmail.com
14d7676549238dd8dd813c01f3bf9e7a16e6d399
f0347b369c3f9b5b353b35048016bff76f22a5b9
/9/sol1.cpp
ca82a4de9d0afd70e07822af211057d723b8bb29
[]
no_license
546Archie/Leetcode
a8224c6127a0afd270cb2397a667d148020c9492
366cfc6ffaff98fa4bf79209d9de7b60d5ed49b9
refs/heads/main
2023-06-08T21:50:48.440032
2021-06-26T03:48:44
2021-06-26T03:48:44
330,677,265
0
0
null
null
null
null
UTF-8
C++
false
false
570
cpp
#include "string.h" class Solution { public: bool isPalindrome(int x) { if(x<0) return false; //rhalf: reverse half int front = x, back = x, rhalf = 0; while(front/10){ //1464"1"->146"14" rhalf = rhalf*10+back%10; cout<<"rhalf: "<<rhalf<<endl; //1464->146 back /=10; cout<<"back"<<back<<endl; //146->1 front /=100; cout<<"front"<<front<<endl; } return front==0?rhalf==back:back/10==rhalf; } };
[ "archie.cs09g@nctu.edu.tw" ]
archie.cs09g@nctu.edu.tw
287f6195ed8b5d2e475fb169a9af3553f5adabc1
a9e205d6c0e824246dcf699b1ae1b8a3d96a6f38
/course2.h
cb3011e36fe7ba729cc44561bf8dba9413c27278
[ "MIT" ]
permissive
jtruon/Gator_Hatchling
69224dc0280537e65c32871c86c610c84c28958a
9f98cd6765b4a7f9a2b8c9099eb1704e2977c008
refs/heads/master
2021-04-26T23:16:06.497376
2018-04-30T21:05:11
2018-04-30T21:05:11
123,959,421
3
3
MIT
2018-04-25T03:36:57
2018-03-05T18:15:03
C++
UTF-8
C++
false
false
317
h
#ifndef COURSE2_H #define COURSE2_H #include <QDialog> namespace Ui { class Course2; } class Course2 : public QDialog { Q_OBJECT public: explicit Course2(QWidget *parent = 0); ~Course2(); private slots: void on_pushButton_course2_clicked(); private: Ui::Course2 *ui; }; #endif // COURSE2_H
[ "noreply@github.com" ]
noreply@github.com
956269722029bb5b229bd2fd9a9115d331390b92
1768e4f51a2a9ea391a3d3f7f95efbbfc310ad7b
/previous version/src/scrlog/scrlog_VC.cpp
8742d601f6f851133ced036ad20c753ab3282682
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
lazyuselessman/scrlog
cf202ad35d902bbf1565ca2400505e8b7785de7e
4197c5b1f9e9e885f82c72097e200282c00c3ada
refs/heads/master
2022-09-16T20:09:33.276765
2020-06-02T17:23:08
2020-06-02T17:23:08
268,770,375
2
0
null
null
null
null
UTF-8
C++
false
false
6,990
cpp
/* * scrlog_VC.cpp: * This file contains the hookers for GTA Vice City (all versions); * * Issues: * *No CollectGlobalVariableIndex or CollectVariablePointer (game fault) * *If using CLEO, this must be loaded after CLEO.asi (not really a issue, just a advice), * hopefully, this may happen always since scrlog.asi is after CLEO.asi in alphabetic order * *CLEO hooks all commands with label as parameter, so... yeah, we cant show label params if CLEO is installed * *Many of the Vice's script engine stuff is inlined, and when inlined we wont have access to the values since * no func is called. * * LICENSE: * (c) 2013 - LINK/2012 - <dma_2012@hotmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this plugin and source code, to copy, modify, merge, publish and/or distribute * as long as you leave the original credits (above copyright notice) * together with your derived work. Please not you are NOT permited to sell or get money from it * * THE SOFTWARE AND SOURCE CODE 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 "GameInfo.h" #include "Injector.h" #include "scrlog.h" // Some macros to help in saving important registers being used #define push_regs(a, b) _asm push a _asm push b #define pop_regs(a, b) _asm pop b _asm pop a static void PatchALL(bool bSteam); void VC_Patch(GameInfo& info) { PatchALL(info.IsSteam()); } static void* CRunningScript__ProcessOneCommand; static void HOOK_RegisterCommand(); static void HOOK_RegisterScript(); static void HOOK_CalledCollectParameters(); static void HOOK_RegisterCollectedDatatype(); static void HOOK_RegisterCollectedParam(); static void HOOK_CalledStoreParameters(); static void HOOK_CalledCollectVariablePointer(); static void HOOK_RegisterCollectVariablePointer(); // Structure to store addresses for each version, used in CommonPatch() function struct CommonPatchInfo { uint32_t phRegisterScript; uint32_t phRegisterCommand; uint32_t phCollectParameters; uint32_t phCollectedDatatype; uint32_t phCollectedValue; uint32_t phStoreParameters; uint32_t phUpdateCompareFlag; uint32_t CollectiveArray; uint32_t ScriptsUpdated; uint32_t ScriptSpace; uint32_t MissionSpace; size_t ScriptSpaceSize; size_t MissionSpaceSize; }; // Patches based on the sent CommonPatchInfo structure static void CommonPatch(CommonPatchInfo& c) { uint32_t ptr; c.ScriptSpaceSize = 225512; c.MissionSpaceSize = 35000; // Get pointers for scrlog { SCRLog::ScriptSpace = ReadMemory<char*>(c.ScriptSpace, true); SCRLog::MissionSpace = SCRLog::ScriptSpace + c.ScriptSpaceSize; SCRLog::CollectiveArray = ReadMemory<ScriptVar*>(c.CollectiveArray, true); SCRLog::ScriptsUpdated = ReadMemory<short*>(c.ScriptsUpdated, true); SCRLog::ScriptSpaceEnd = SCRLog::ScriptSpace + c.ScriptSpaceSize; SCRLog::MissionSpaceEnd = SCRLog::MissionSpace+ c.MissionSpaceSize; } // RegisterScript if(SCRLog::bHookRegisterScript) { ptr = c.phRegisterScript; MakeCALL(ptr, &HOOK_RegisterScript); MakeNOP(ptr+5, 1); } // RegisterCommand if(SCRLog::bHookRegisterCommand) { ptr = c.phRegisterCommand; CRunningScript__ProcessOneCommand = (void*) GetAbsoluteOffset(ReadMemory<int>(ptr+1, true), ptr+5); MakeCALL(ptr, &HOOK_RegisterCommand); } // Called CollectParameters if(SCRLog::bHookCollectParam) { ptr = c.phCollectParameters; MakeCALL(ptr, &HOOK_CalledCollectParameters); } // Register collected datatype if(SCRLog::bHookFindDatatype) { ptr = c.phCollectedDatatype; MakeCALL(ptr, &HOOK_RegisterCollectedDatatype); } // Register collected value if(SCRLog::bHookCollectParam) { ptr = c.phCollectedValue; MakeCALL(ptr, &HOOK_RegisterCollectedParam); MakeNOP(ptr+5, 2); } // Register call to store parameters if(SCRLog::bHookStoreParam) { ptr = c.phStoreParameters; MakeCALL(ptr, &HOOK_CalledStoreParameters); } // Replace UpdateCompareFlag if(SCRLog::bHookUpdateCompareFlag) { ptr = c.phUpdateCompareFlag; MakeJMP(ptr, SCRLog::New_CRunningScript__UpdateCompareFlag); MakeNOP(ptr+5, 2); } } // Patch all Vice City's versions // 1.0 and 1.1 have similar addresses (at least in .text segment) // Steam has a difference of -240 in the addresses compared to retail version static void PatchALL(bool bSteam) { CommonPatchInfo c; unsigned int off = bSteam? -240 : 0; c.phRegisterScript = 0x44FD71 + off; c.phRegisterCommand = 0x44FDB5 + off; c.phCollectParameters = 0x451025 + off; c.phCollectedDatatype = 0x451030 + off; c.phCollectedValue = 0x4510F0 + off; c.phStoreParameters = 0x450E57 + off; c.phUpdateCompareFlag = !bSteam? 0x463F00 : 0x463DE0; // this one differ c.ScriptsUpdated = 0x450239 + off; c.CollectiveArray = c.phCollectParameters + 1; c.ScriptSpace = c.phCollectedDatatype + 1; c.MissionSpace = 0; CommonPatch(c); } void __declspec(naked) HOOK_RegisterScript() { _asm { mov ebx, ecx // Replaced code push ecx call SCRLog::RegisterScript // Run replaced code and go back to normal flow mov ecx, ebx cmp byte ptr [ecx+0x7A], 0 retn } } void __declspec(naked) HOOK_RegisterCommand() { _asm { call SCRLog::RegisterCommand // Back mov ecx, ebx call CRunningScript__ProcessOneCommand retn } } void __declspec(naked) HOOK_CalledCollectParameters() { _asm { push edx push edi call SCRLog::RegisterCallToCollectParameters pop edx // Run replaced code and go back to normal flow mov ecx, SCRLog::CollectiveArray retn } } void __declspec(naked) HOOK_RegisterCollectedDatatype() { _asm { xor eax, eax mov ebx, dword ptr [edx] // CRunningScript.ip add ebx, dword ptr [SCRLog::ScriptSpace] mov al, byte ptr [ebx] mov SCRLog::Datatype, eax // Run replaced code and go back to normal flow mov eax, SCRLog::ScriptSpace retn } } void __declspec(naked) HOOK_RegisterCollectedParam() { _asm { push_regs(ecx, edx) mov eax, ecx // ecx is current value in iteration over CollectiveArray sub eax, SCRLog::CollectiveArray shr eax, 2 // (eax >>= 2) = (eax /= 4) inc eax // the index starts from 1 push eax call SCRLog::RegisterCollectionAtIndex pop_regs(ecx, edx) // Jump back add ecx, 4 sub di, 1 retn } } void __declspec(naked) HOOK_CalledStoreParameters() { _asm { push ecx push edi mov SCRLog::Datatype, 1 call SCRLog::RegisterCallToStoreParameters pop ecx // Run replaced code and go back to normal flow xor esi, esi test di, di retn } }
[ "GoldmasterUA@gmail.com" ]
GoldmasterUA@gmail.com
f20a02f9b117bd3b7b34a7ddf71845fc30927ee1
e23ce3b3d3f471e15b2af697463adcc7f80d5140
/concepts/hashTable_STL.cpp
6e23c366dc1afa0e8b1aa7b30f05505eac732d26
[]
no_license
sirraghavgupta/cpp-data-structures-and-algorithms
27a6620f5ab306186017b9ff5c14e378c18d5ce7
6a4c18b79eaa6c406414fd2b94a54403110993f8
refs/heads/master
2020-05-16T16:34:27.702583
2019-11-30T14:52:36
2019-11-30T14:52:36
183,165,972
3
0
null
null
null
null
UTF-8
C++
false
false
1,267
cpp
/*############################################################################## AUTHOR : RAGHAV GUPTA DATE : 20 september 2019 AIM : to implement hash table by STL STATUS : !!! success !!! ##############################################################################*/ #include <iostream> #include <unordered_map> using namespace std; int main(){ unordered_map<string, int> myMap; // 3 ways to insert myMap["banana"] = 500; // direct // insert function asls for a pair myMap.insert(make_pair("mango", 100)); // u can make pair by make_pair() function pair<string, int> p("apple", 600); // u can make pair by constructor myMap.insert(p); // iterate over the nodes. for(auto node:myMap){ // for each loop // auto keyword automatically determines the data type // its basically pair<string, int> here. cout<<node.first<<", "<<node.second<<endl; } myMap["guava"] = 90; myMap["papaya"] = 70; myMap["kiwi"] = 50; // how to iterate over the BUCKETS... int n = myMap.bucket_count(); for(int i=0; i<n; i++){ // for each bucket cout<<"bucket "<<i<<" : "; // it is a pointer to pair here - refer to cplusplus.com for(auto it = myMap.begin(i); it!=myMap.end(i); it++){ cout<<it->first<<" - "<<it->second<<", "; } cout<<endl; } return 0; }
[ "raghav.mhc@gmail.com" ]
raghav.mhc@gmail.com
1982acd010784e2095ce75747f86255b73650eee
acf6c6b9550b660f59d81be0c78bcac2a4331f94
/src/apps/ntvplus/subscriber.h
60ae25525a8b16b0a1b2f7baf83cdce5b9fa7d33
[]
no_license
wangscript007/Miniwin
95ad9fff4f234cf0235a017e51a7cfb47c0b0353
001d8804d9ae7a1b265fc7a62029469b15505b92
refs/heads/master
2022-12-15T11:12:01.746551
2020-09-04T07:44:39
2020-09-04T07:44:39
293,456,945
2
0
null
2020-09-07T07:41:31
2020-09-07T07:41:30
null
UTF-8
C++
false
false
1,344
h
#ifndef __SUBSCRIBER_H__ #define __SUBSCRIBER_H__ #include <scheduler.h> #include <dvbepg.h> namespace nglui{ struct SubscribeItem{ SERVICELOCATOR svc; system_clock::time_point time; UINT eventid; UINT duration;/*unint in seconds*/ std::string name; int type;/*0-->once,1-->daily,2-->weekly...*/ int weekday;/*only for weekly:one bits per weekday:bit 0-->sunday,...,bit1 -->Monday...*/ void onPrompt(); void onTriggered(); }; class Subscriber:public Scheduler{ private: Subscriber():Scheduler(){} static Subscriber*mInst; protected: std::map<system_clock::time_point,SubscribeItem>items; public: static Subscriber*getInstance(); static SubscribeItem FromEvent(const DVBEvent&,const SERVICELOCATOR*svc=nullptr); int add(SubscribeItem&); int addOnce(SubscribeItem&); int addDaily(SubscribeItem&); int addWeekly(SubscribeItem&); int addWeekly(SubscribeItem&,int weekday); const SubscribeItem*find(int64_t tm);/*find subscribe by tm(time_t)*/ void remove(int64_t tm);/*remove subscribe by tm(time_t)*/ void remove(system_clock::time_point&point); size_t size(){return items.size();} void clear(){items.clear();} int load(const std::string&filename); int save(const std::string&filename); int getItems(std::vector<SubscribeItem>&itms); }; } #endif
[ "1225012331@qq.com" ]
1225012331@qq.com
ea3bdd526d6731bbfd5b793a1ea1a26039ec8030
e951386450438ae7b6cf9f9aa1edaeff8db2f345
/dyninst-demo/tracetool/main.cpp
3ba7ed362e9441def3d41a7ef28325434e5558dc
[]
no_license
MarkZ3/multicore
d21cf645e775625b02b4d378716765e17b69c57e
cac88eb54597e4ce4e9c95d80527e5acf149e751
refs/heads/master
2020-04-02T23:33:09.995578
2016-08-08T15:43:38
2016-08-08T15:43:38
65,210,256
0
0
null
null
null
null
UTF-8
C++
false
false
2,014
cpp
#include <BPatch.h> #include <BPatch_object.h> #include <BPatch_point.h> #include <BPatch_function.h> #include <vector> #include <cstdlib> #include <QCommandLineOption> #include <QCommandLineParser> #include <QCoreApplication> #include <QDebug> #include <cstring> #include <vector> int main (int argc, char** argv) { QCoreApplication app(argc, argv); QCommandLineParser parser; parser.addHelpOption(); parser.setApplicationDescription("dynamic instrumentation"); parser.addPositionalArgument("binary", "path to binary to execute"); QCommandLineOption inOption("function", "function to instrument", "function"); parser.addOption(inOption); parser.process(app); QStringList lst = parser.positionalArguments(); if (!parser.isSet(inOption) || lst.size() == 0) { parser.showHelp(1); } setenv("DYNINSTAPI_RT_LIB", "/usr/local/lib/libdyninstAPI_RT.so", 0); // convert QStringList to array of char const char *args[lst.size() + 1]; for (int i = 0; i < lst.size(); i++) { args[i] = lst.at(i).toStdString().c_str(); } args[lst.size()] = NULL; BPatch bpatch; BPatch_process *proc = bpatch.processCreate(args[0], args + 1); BPatch_image *image = proc->getImage(); std::vector<BPatch_function*> funcs; std::vector<BPatch_function*> probes; image->findFunction("_ZN3Foo3fooEv", funcs); image->findFunction("probe", probes); if (!funcs.empty() && !probes.empty()) { for (BPatch_function *func: funcs) { qDebug() << "func" << func->getBaseAddr(); } for (BPatch_function *func: probes) { qDebug() << "probe" << func->getBaseAddr(); } std::vector<BPatch_snippet*> probe_args; BPatch_funcCallExpr call_probe(*probes[0], probe_args); proc->insertSnippet(call_probe, (funcs[0]->findPoint(BPatch_entry))[0]); } proc->continueExecution(); while (!proc->isTerminated()) { bpatch.waitForStatusChange(); } }
[ "francis.giraldeau@gmail.com" ]
francis.giraldeau@gmail.com
3187106d61be50130d980290ab09043856e30ae4
535663fe24598c762066242e64f3849389531de0
/bin/Release/Grent/CPP/Config/BuffTypeCfg.h
3e0c4aa05cb9d7bc3e64b33ee9d45854c2c999a3
[]
no_license
wanggan768q/RpcCoder_SY
9fd8c153233b03cadc61a87b3f740d7561fa4907
91ce81e852478300ef23344c77966ab22c019ea3
refs/heads/master
2022-03-27T16:48:46.629157
2022-02-17T11:49:44
2022-02-17T11:49:44
108,358,956
1
3
null
2020-10-15T02:56:45
2017-10-26T03:51:46
C++
UTF-8
C++
false
false
4,549
h
#ifndef __BUFFTYPE_CONFIG_H #define __BUFFTYPE_CONFIG_H #include "Logger.h" #include "CommonDefine.h" #include "DK_Assertx.h" #include <vector> #include <string> #include <unordered_map> #include "jsoncpp/json.h" #include <functional> #include <vector> #include <string> #include <unordered_map> using namespace std; //Buff冒字显示配置数据结构 struct BuffTypeElement { friend class BuffTypeTable; int id; //对应的BuffID 对应的BuffID string desc; //参数说明 仅说明 int desc_id; //StringBuff_buff_id StringBuff_buff_id string res; //资源名称 资源名称 private: public: BuffTypeElement() { id = -1; } }; //Buff冒字显示配置封装类 class BuffTypeTable { public: typedef unordered_map<int, BuffTypeElement*> MapElementMap; typedef vector<BuffTypeElement> vec_type; typedef std::function<void()> ReloadCallback; typedef vector<ReloadCallback> reload_vec_type; private: BuffTypeTable(){} ~BuffTypeTable(){} MapElementMap m_mapElements; vector<BuffTypeElement> m_vecAllElements; reload_vec_type m_vReLoadCb; public: friend class TableData; static BuffTypeTable& Instance() { static BuffTypeTable sInstance; return sInstance; } void RegisterReLoadCb(const ReloadCallback &cb) { m_vReLoadCb.push_back(cb); } const BuffTypeElement* GetElement(int key) { MapElementMap::iterator it = m_mapElements.find(key); if (it == m_mapElements.end()) { return NULL; } return it->second; } bool HasElement(int key) { return m_mapElements.find(key) != m_mapElements.end(); } vec_type& GetAllElement() { return m_vecAllElements; } bool Load() { return LoadJson("BuffType.json"); } void NotifyCb() { for (auto it : m_vReLoadCb) { it(); } } bool LoadJson(const std::string& jsonFile) { Json::Reader filereader; Json::Value root; std::ifstream is(std::string(CONFIG_PATH) + jsonFile); if (is) { // get length of file: is.seekg(0, is.end); int length = (int)is.tellg(); length = length + 1; is.seekg(0, is.beg); char * buffer = new char[length]; memset(buffer, 0, length); // read data as a block: is.read(buffer, length); is.close(); filereader.parse(buffer, buffer + length, root); delete[] buffer; } m_vecAllElements.resize(root.size()); int32_t m_nIndex = 0; for (Json::ValueIterator it = root.begin(); it != root.end(); ++it, ++m_nIndex) { try { auto p = (*it); BuffTypeElement & member = m_vecAllElements[m_nIndex]; member.id=p["id"].asInt(); member.desc=p["desc"].asString(); member.desc_id=p["desc_id"].asInt(); member.res=p["res"].asString(); m_mapElements.emplace(member.id, &member); } catch (std::exception const & e) { ELOG("%s error config id : %d", e.what(), (*it)["id"].asInt()); Assert(false); } } NotifyCb(); return true; } bool ReLoad() { Json::Reader filereader; Json::Value root; std::ifstream is(std::string(CONFIG_PATH) + "BuffType.json"); if (is) { // get length of file: is.seekg(0, is.end); int length = (int)is.tellg(); length = length + 1; is.seekg(0, is.beg); char * buffer = new char[length]; memset(buffer, 0, length); // read data as a block: is.read(buffer, length); is.close(); filereader.parse(buffer, buffer + length, root); delete[] buffer; } for (Json::ValueIterator it = root.begin(); it != root.end(); ++it ) { try { auto p = (*it); BuffTypeElement member; member.id=p["id"].asInt(); member.desc=p["desc"].asString(); member.desc_id=p["desc_id"].asInt(); member.res=p["res"].asString(); *m_mapElements[member.id] = member; } catch (std::exception const & e) { ELOG("%s error config id : %d", e.what(), (*it)["id"].asInt()); Assert(false); } } NotifyCb(); return true; } }; #endif
[ "ambitiongxb@foxmail.com" ]
ambitiongxb@foxmail.com
044bab85ac98907e5c3ee865822f2e9a0b949ece
5c5ba0cbdc972b56a3ac7664f68a74fe382c645a
/uri/7 - Graphs/1907/Main.cpp
47d88444b336b5ebca4a3bea02e6d7d898384a5a
[]
no_license
humbertodias/challenges
91e090b70ed65269ff94f0b8d4096526d3545ba3
b832d55491b4d5c840b0bb25b931aef8f04f5784
refs/heads/master
2020-04-05T14:03:38.384606
2019-01-29T12:28:13
2019-01-29T12:28:13
94,749,550
0
0
null
null
null
null
UTF-8
C++
false
false
792
cpp
#include <cstdio> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; #define MAX 1030 char mapa[MAX][MAX]; int n,m; int dx[] = {1,-1,0,0}; int dy[] = {0,0,-1,1}; bool inGrid(int i, int j){ if(i<0 || i >= n || j < 0 || j>= m) return false; return mapa[i][j] == '.'; } void dfs(int i, int j){ mapa[i][j] = 'o'; for(int x = 0; x < 4; x++) if(inGrid(i + dx[x], j + dy[x])) dfs(i+dx[x], j + dy[x]); } int main(){ scanf("%d %d", &n, &m); for(int i=0; i < n; i++) scanf("%s", mapa[i]); int ans = 0; for(int i=0; i < n; i++) for(int j=0; j < m; j++) if(mapa[i][j] == '.') { ans++; dfs(i,j); } printf("%d\n", ans); return 0; }
[ "humberto.dias@techne.com.br" ]
humberto.dias@techne.com.br
b3957075049674e9cd63de23a33a0f827f315ad6
f10e3e0cd04c795f5c533c2dd9ecc7243f664ad5
/lib/PCD8544/src/PCD8544.cpp
21f2a316ac71a8812226c39fe6f5d9fea99f83fb
[]
no_license
pavlenko/hexapod-mk2-leg
8ef04c83a9279449095762ac6803ec7571fad4a1
b57472a1363fd73c748930a0ed17030c91e0b130
refs/heads/master
2020-04-03T02:08:23.190854
2018-11-30T10:02:01
2018-11-30T10:02:01
154,947,870
0
0
null
null
null
null
UTF-8
C++
false
false
2,040
cpp
#include "PCD8544.h" #include <SPI.h> #define CONSTRAIN(_val_, _min_, _max_) (_min_ > _val_ ? _min_ : (_max_ < _val_ ? _max_ : _val_)) void PCD8544Class::initialize(PCD8544Pin_t reset, PCD8544Pin_t dc, SPISlaveSelect_t ss) { _reset = reset; _dc = dc; _ss = ss; // Configure non-SPI bus pins *(_reset.DDR) |= _BV(_reset.PIN); *(_dc.DDR) |= _BV(_dc.PIN); // Configure SPI bus SPI.setDataMode(SPI_MODE_SAMPLE_RISING_NORMAL); SPI.setDataOrder(SPI_DATA_ORDER_MSB_FIRST); SPI.setBusMode(SPI_BUS_MASTER); // Connect to LCD SPI.start(_ss); // Reset the LCD to a known state *(_reset.PORT) &= ~_BV(_reset.PIN); *(_reset.PORT) |= _BV(_reset.PIN); this->write(PCD8544_DC_COMMAND, PCD8544_FUNCTION_SET(0, 0, 1)); // <-- Tell LCD extended commands follow this->write(PCD8544_DC_COMMAND, PCD8544_VOP(0x30)); // <-- Set LCD Vop (Contrast) this->write(PCD8544_DC_COMMAND, PCD8544_TEMP_COEFFICIENT(0x03)); // <-- Set Temp coefficient this->write(PCD8544_DC_COMMAND, PCD8544_BIAS(0x04)); // <-- Set LCD bias mode 1:48 (can try 0x03) this->write(PCD8544_DC_COMMAND, PCD8544_FUNCTION_SET(0, 0, 0)); // <-- Tell LCD normal commands follow this->write(PCD8544_DC_COMMAND, PCD8544_DISPLAY_CONTROL(1, 0)); // <-- Set display normal mode, not inverse } void PCD8544Class::write(PCD8544_DC dc, uint8_t data) { // Tell the LCD that we are writing either to data or a command if (PCD8544_DC_DATA == dc) { *(_dc.PORT) |= _BV(_dc.PIN); } else { *(_dc.PORT) &= ~_BV(_dc.PIN); } //*(_ss.PORT) &= ~_BV(_ss.SS);//TODO are this need ??? SPI.transfer(data); //*(_ss.PORT) |= _BV(_ss.SS);//TODO are this need ??? } void PCD8544Class::setX(uint8_t value) { this->write(PCD8544_DC_COMMAND, (uint8_t) PCD8544_SET_X(CONSTRAIN(value, 0, 83))); } void PCD8544Class::setY(uint8_t value) { this->write(PCD8544_DC_COMMAND, (uint8_t) PCD8544_SET_Y(CONSTRAIN(value, 0, 5))); } PCD8544Class PCD8544;
[ "pavlenko.obs@gmail.com" ]
pavlenko.obs@gmail.com
0d47417267fce93f2344e34fc4735e299d04efa5
a4efb3c4fab758fd1d50b36ff4fb2d10e35385fd
/4.23/ExampleProject/Plugins/PlayFab/Source/PlayFab/Private/PlayFabEventsAPI.cpp
defd6efb94939a4e30bf9cd3cc07b04d4cf237ec
[ "Apache-2.0" ]
permissive
MaxPlay/UnrealMarketplacePlugin
7a2fe68d1ffc0132918273072f01ddf1751c801b
04218cb94c4562f19b8d5859f97ab428eb7ca566
refs/heads/master
2022-12-17T07:43:07.287881
2020-09-16T12:46:06
2020-09-16T12:46:06
296,027,494
0
0
Apache-2.0
2020-09-16T12:35:26
2020-09-16T12:35:25
null
UTF-8
C++
false
false
11,952
cpp
////////////////////////////////////////////////////// // Copyright (C) Microsoft. 2018. All rights reserved. ////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// // Automatically generated cpp file for the UE4 PlayFab plugin. // // API: Events ////////////////////////////////////////////////////////////////////////////////////////////// #include "PlayFabEventsAPI.h" #include "PlayFabEventsModels.h" #include "PlayFabEventsModelDecoder.h" #include "PlayFabPrivate.h" #include "PlayFabEnums.h" #include "PlayFabCommon/Public/PlayFabAuthenticationContext.h" #include "PlayFabCommon/Public/PlayFabCommonUtils.h" UPlayFabEventsAPI::UPlayFabEventsAPI(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) , CallAuthenticationContext(nullptr) { } void UPlayFabEventsAPI::SetCallAuthenticationContext(UPlayFabAuthenticationContext* InAuthenticationContext) { CallAuthenticationContext = InAuthenticationContext; } void UPlayFabEventsAPI::SetRequestObject(UPlayFabJsonObject* JsonObject) { RequestJsonObj = JsonObject; } UPlayFabJsonObject* UPlayFabEventsAPI::GetResponseObject() { return ResponseJsonObj; } FString UPlayFabEventsAPI::PercentEncode(const FString& Text) { FString OutText = Text; OutText = OutText.Replace(TEXT("!"), TEXT("%21")); OutText = OutText.Replace(TEXT("\""), TEXT("%22")); OutText = OutText.Replace(TEXT("#"), TEXT("%23")); OutText = OutText.Replace(TEXT("$"), TEXT("%24")); //OutText = OutText.Replace(TEXT("&"), TEXT("%26")); OutText = OutText.Replace(TEXT("'"), TEXT("%27")); OutText = OutText.Replace(TEXT("("), TEXT("%28")); OutText = OutText.Replace(TEXT(")"), TEXT("%29")); OutText = OutText.Replace(TEXT("*"), TEXT("%2A")); OutText = OutText.Replace(TEXT("+"), TEXT("%2B")); OutText = OutText.Replace(TEXT(","), TEXT("%2C")); //OutText = OutText.Replace(TEXT("/"), TEXT("%2F")); OutText = OutText.Replace(TEXT(":"), TEXT("%3A")); OutText = OutText.Replace(TEXT(";"), TEXT("%3B")); OutText = OutText.Replace(TEXT("="), TEXT("%3D")); //OutText = OutText.Replace(TEXT("?"), TEXT("%3F")); OutText = OutText.Replace(TEXT("@"), TEXT("%40")); OutText = OutText.Replace(TEXT("["), TEXT("%5B")); OutText = OutText.Replace(TEXT("]"), TEXT("%5D")); OutText = OutText.Replace(TEXT("{"), TEXT("%7B")); OutText = OutText.Replace(TEXT("}"), TEXT("%7D")); return OutText; } ////////////////////////////////////////////////////////////////////////// // Generated PlayFab Events API Functions ////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////// // PlayStream Events ////////////////////////////////////////////////////// /** Write batches of entity based events to PlayStream. The namespace of the Event must be 'custom' or start with 'custom.'. */ UPlayFabEventsAPI* UPlayFabEventsAPI::WriteEvents(FEventsWriteEventsRequest request, FDelegateOnSuccessWriteEvents onSuccess, FDelegateOnFailurePlayFabError onFailure, UObject* customData) { // Objects containing request data UPlayFabEventsAPI* manager = NewObject<UPlayFabEventsAPI>(); if (manager->IsSafeForRootSet()) manager->AddToRoot(); UPlayFabJsonObject* OutRestJsonObj = NewObject<UPlayFabJsonObject>(); manager->mCustomData = customData; // Assign delegates manager->OnSuccessWriteEvents = onSuccess; manager->OnFailure = onFailure; manager->OnPlayFabResponse.AddDynamic(manager, &UPlayFabEventsAPI::HelperWriteEvents); // Setup the request manager->SetCallAuthenticationContext(request.AuthenticationContext); manager->PlayFabRequestURL = "/Event/WriteEvents"; manager->useEntityToken = true; // Serialize all the request properties to json if (request.CustomTags != nullptr) OutRestJsonObj->SetObjectField(TEXT("CustomTags"), request.CustomTags); if (request.Events.Num() == 0) { OutRestJsonObj->SetFieldNull(TEXT("Events")); } else { OutRestJsonObj->SetObjectArrayField(TEXT("Events"), request.Events); } // Add Request to manager manager->SetRequestObject(OutRestJsonObj); return manager; } // Implements FOnPlayFabEventsRequestCompleted void UPlayFabEventsAPI::HelperWriteEvents(FPlayFabBaseModel response, UObject* customData, bool successful) { FPlayFabError error = response.responseError; if (error.hasError && OnFailure.IsBound()) { OnFailure.Execute(error, customData); } else if (!error.hasError && OnSuccessWriteEvents.IsBound()) { FEventsWriteEventsResponse ResultStruct = UPlayFabEventsModelDecoder::decodeWriteEventsResponseResponse(response.responseData); OnSuccessWriteEvents.Execute(ResultStruct, mCustomData); } this->RemoveFromRoot(); } /** Write batches of entity based events to as Telemetry events (bypass PlayStream). The namespace must be 'custom' or start with 'custom.' */ UPlayFabEventsAPI* UPlayFabEventsAPI::WriteTelemetryEvents(FEventsWriteEventsRequest request, FDelegateOnSuccessWriteTelemetryEvents onSuccess, FDelegateOnFailurePlayFabError onFailure, UObject* customData) { // Objects containing request data UPlayFabEventsAPI* manager = NewObject<UPlayFabEventsAPI>(); if (manager->IsSafeForRootSet()) manager->AddToRoot(); UPlayFabJsonObject* OutRestJsonObj = NewObject<UPlayFabJsonObject>(); manager->mCustomData = customData; // Assign delegates manager->OnSuccessWriteTelemetryEvents = onSuccess; manager->OnFailure = onFailure; manager->OnPlayFabResponse.AddDynamic(manager, &UPlayFabEventsAPI::HelperWriteTelemetryEvents); // Setup the request manager->SetCallAuthenticationContext(request.AuthenticationContext); manager->PlayFabRequestURL = "/Event/WriteTelemetryEvents"; manager->useEntityToken = true; // Serialize all the request properties to json if (request.CustomTags != nullptr) OutRestJsonObj->SetObjectField(TEXT("CustomTags"), request.CustomTags); if (request.Events.Num() == 0) { OutRestJsonObj->SetFieldNull(TEXT("Events")); } else { OutRestJsonObj->SetObjectArrayField(TEXT("Events"), request.Events); } // Add Request to manager manager->SetRequestObject(OutRestJsonObj); return manager; } // Implements FOnPlayFabEventsRequestCompleted void UPlayFabEventsAPI::HelperWriteTelemetryEvents(FPlayFabBaseModel response, UObject* customData, bool successful) { FPlayFabError error = response.responseError; if (error.hasError && OnFailure.IsBound()) { OnFailure.Execute(error, customData); } else if (!error.hasError && OnSuccessWriteTelemetryEvents.IsBound()) { FEventsWriteEventsResponse ResultStruct = UPlayFabEventsModelDecoder::decodeWriteEventsResponseResponse(response.responseData); ResultStruct.Request = RequestJsonObj; OnSuccessWriteTelemetryEvents.Execute(ResultStruct, mCustomData); } this->RemoveFromRoot(); } void UPlayFabEventsAPI::OnProcessRequestComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) { // Be sure that we have no data from previous response ResetResponseData(); if (!IsValidLowLevel()) { UE_LOG(LogPlayFab, Error, TEXT("The request object is invalid during OnProcessRequestComplete.")); return; } if (!OnPlayFabResponse.IsBound()) { UE_LOG(LogPlayFab, Error, TEXT("OnPlayFabResponse has come un-bound during OnProcessRequestComplete.")); return; } FPlayFabBaseModel myResponse; // Check we have result to process further if (!bWasSuccessful) { UE_LOG(LogPlayFab, Error, TEXT("Request failed: %s"), *Request->GetURL()); // Broadcast the result event myResponse.responseError.hasError = true; myResponse.responseError.ErrorCode = 503; myResponse.responseError.ErrorName = "Unable to contact server"; myResponse.responseError.ErrorMessage = "Unable to contact server"; OnPlayFabResponse.Broadcast(myResponse, mCustomData, false); return; } // Save response data as a string ResponseContent = Response->GetContentAsString(); // Save response code as int32 ResponseCode = Response->GetResponseCode(); // Try to deserialize data to JSON TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(ResponseContent); FJsonSerializer::Deserialize(JsonReader, ResponseJsonObj->GetRootObject()); // Decide whether the request was successful bIsValidJsonResponse = bWasSuccessful && ResponseJsonObj->GetRootObject().IsValid(); // Log errors if (!bIsValidJsonResponse) UE_LOG(LogPlayFab, Warning, TEXT("JSON could not be decoded!")); // Log response state UE_LOG(LogPlayFab, Log, TEXT("Response : %s"), *ResponseContent); myResponse.responseError.decodeError(ResponseJsonObj); myResponse.responseData = ResponseJsonObj; IPlayFab* pfSettings = &(IPlayFab::Get()); if (returnsEntityToken) { CallAuthenticationContext = NewObject<UPlayFabAuthenticationContext>(); FString NewEntityToken = myResponse.responseData->GetObjectField("data")->GetStringField("EntityToken"); pfSettings->setEntityToken(NewEntityToken); CallAuthenticationContext->SetEntityToken(MoveTemp(NewEntityToken)); } // Broadcast the result event OnPlayFabResponse.Broadcast(myResponse, mCustomData, !myResponse.responseError.hasError); pfSettings->ModifyPendingCallCount(-1); } void UPlayFabEventsAPI::Activate() { IPlayFab* pfSettings = &(IPlayFab::Get()); FString RequestUrl; RequestUrl = pfSettings->getUrl(PlayFabRequestURL); TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest(); HttpRequest->SetURL(RequestUrl); HttpRequest->SetVerb(TEXT("POST")); // Headers if (useEntityToken) HttpRequest->SetHeader(TEXT("X-EntityToken"), CallAuthenticationContext != nullptr ? CallAuthenticationContext->GetEntityToken() : pfSettings->getEntityToken()); else if (useSessionTicket) HttpRequest->SetHeader(TEXT("X-Authorization"), CallAuthenticationContext != nullptr ? CallAuthenticationContext->GetClientSessionTicket() : pfSettings->getSessionTicket()); else if (useSecretKey) HttpRequest->SetHeader(TEXT("X-SecretKey"), CallAuthenticationContext != nullptr ? CallAuthenticationContext->GetDeveloperSecretKey() : pfSettings->getDeveloperSecretKey()); HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json")); HttpRequest->SetHeader(TEXT("X-PlayFabSDK"), pfSettings->getVersionString()); HttpRequest->SetHeader(TEXT("X-ReportErrorAsSuccess"), TEXT("true")); // FHttpResponsePtr doesn't provide sufficient information when an error code is returned for (TMap<FString, FString>::TConstIterator It(RequestHeaders); It; ++It) HttpRequest->SetHeader(It.Key(), It.Value()); // Serialize data to json string FString OutputString; TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&OutputString); FJsonSerializer::Serialize(RequestJsonObj->GetRootObject().ToSharedRef(), Writer); // Set Json content HttpRequest->SetContentAsString(OutputString); UE_LOG(LogPlayFab, Log, TEXT("Request: %s"), *OutputString); // Bind event HttpRequest->OnProcessRequestComplete().BindUObject(this, &UPlayFabEventsAPI::OnProcessRequestComplete); // Execute the request pfSettings->ModifyPendingCallCount(1); HttpRequest->ProcessRequest(); } void UPlayFabEventsAPI::ResetResponseData() { if (ResponseJsonObj != nullptr) ResponseJsonObj->Reset(); else ResponseJsonObj = NewObject<UPlayFabJsonObject>(); bIsValidJsonResponse = false; }
[ "jenkins-bot@playfab.com" ]
jenkins-bot@playfab.com
794ce9efab15077b453418e97e36bd9f20ba41bf
e010ae8714dbc4094a86d837f4d96fd00f973bd8
/gourav11.cpp
6ce9bce44007c75378e84bd274cd1e4a639da795
[]
no_license
ks20soni/hacktoberfest_2k21
fa2f4d1c339f528d180a2234d781cdc479c236d7
07aadee5d086abf65a81ea2f3514939a871fe5a7
refs/heads/main
2023-08-31T23:11:42.205464
2021-10-30T10:21:45
2021-10-30T10:21:45
422,855,755
0
0
null
2021-10-30T10:57:51
2021-10-30T10:57:50
null
UTF-8
C++
false
false
377
cpp
#include<bits/stdc++.h> using namespace std; int main() { int a[30],i,n,j,temp; cout<<"enter array size"<<endl; cin>>n; cout<<"enter an element"<<endl; for(i=0;i<n;i++) { cin>>a[i]; } for(i=0;i<n-1;i++) { for(j=0;j<n-i-1;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } for(i=0;i<n;i++) { cout<<a[i]<<" "; } }
[ "noreply@github.com" ]
noreply@github.com
4b1255b3dd8f234819b808d3cea8ee5c5f61b2b6
75ea6893359ed6232422d0d7c5231d668f1056d8
/hardTests/Menu/Config.hpp
ba21abb0c5767dc1439e410eb4acc6fbe170b4ba
[]
no_license
AcumenDev/humidity_controller
f5f79b049b703746207250ac9c725c835ef7f14c
184aca9876433449475938abf22d629cefd59629
refs/heads/master
2021-01-25T13:57:36.020197
2018-10-28T12:40:13
2018-10-28T12:40:13
123,626,587
1
1
null
null
null
null
UTF-8
C++
false
false
1,257
hpp
#ifndef Config_HPP_ #define Config_HPP_ #define CLIMATE_DEBUG ///Номер порта, адреса датчиков температуры #define TEMP_SENSOR_PIN A1 const uint8_t WET_SENSOR_ADR[8] = { 0x28, 0xFF, 0x7A, 0xC4, 0xB1, 0x17, 0x4, 0x5B }; const uint8_t DRY_SENSOR_ADR[8] = { 0x28, 0xFF, 0x0, 0xC2, 0xB1, 0x17, 0x4, 0x82 }; /// ///Номера портов куда подключен дисплей #define DISPLAY_RS_PIN 8 #define DISPLAY_ENABLE_PIN 9 #define DISPLAY_D0_PIN 4 #define DISPLAY_D1_PIN 5 #define DISPLAY_D2_PIN 6 #define DISPLAY_D3_PIN 7 /// ///Номера порта куда подлюченны кнопки #define BUTTONS_PIN A0 /// ///Номера портов куда подключенны реле #define HUMIDIFICATION_RELAY_PIN A2 #define HEATING_RELAY_PIN A3 /// ///Настройка управление влажностью #define MIN_TARGET_HUMIDITY 20 #define MAX_TARGET_HUMIDITY 99 #define HUMIDITY_GISTERIS 2 //// #define MIN_TARGET_TEMPERATURE 10 #define MAX_TARGET_TEMPERATURE 90 #define TEMPERATURE_GISTERIS 1 ///Адреса EEPROM для сохранения настроек, чтобы не терять при выключении #define TARGET_HUMIDITY_EEPROM_ADR 1 #endif
[ "akummail@gmail.com" ]
akummail@gmail.com
2e06e9f140d704657a309c5c34f237b481234c5c
b98f9f4ff359e26543b5303de3c36f1135fc9e04
/9 DOF Humanoid/BT_Check/BT_Check.ino
f8f802b27ee62759eee6b6d7f76ccae03502f575
[]
no_license
Nex2-code/Arduino
e18f073bb4563b9b86b97d5f8e18c5a1ed7455c3
5055a31eca72abf438c0baed520c3121a881e9bf
refs/heads/main
2023-06-16T22:10:50.091832
2021-07-06T04:12:13
2021-07-06T04:12:13
383,333,358
0
0
null
null
null
null
UTF-8
C++
false
false
372
ino
#include <SoftwareSerial.h> SoftwareSerial bt(12,13); void setup() { Serial.begin(115200); bt.begin(9600); } void loop() { if(bt.available()){ String data = bt.readStringUntil('\n'); Serial.print("Received : "); Serial.println(data); } if(Serial.available()){ String data = Serial.readStringUntil('\n'); bt.print(data); } delay(10); }
[ "adarshnegi23@gmail.com" ]
adarshnegi23@gmail.com
1538e1a7232e52eac9e1eed7a6f07172d677a6c9
ff3b513ffe0925bba25cf0af4c62ea846388339b
/VereEngine/GameDirectionalLight.h
ca707f267d55554927e1f3204c2365a37d2a7e52
[ "Zlib", "MIT" ]
permissive
VereWolf/VereEngine
9b311796fbd2c4919040c8ce93a1272a42713e80
6b5453554cef1ef5d5dbf58206806198a3beec35
refs/heads/master
2021-07-18T13:32:31.815101
2017-12-24T21:15:08
2017-12-24T21:15:08
94,897,016
4
1
null
2017-11-22T13:09:45
2017-06-20T13:55:34
C++
UTF-8
C++
false
false
482
h
#pragma once #include "pch.h" class GameDirectionalLight : public GameBaseObject { public: GameDirectionalLight() {} ~GameDirectionalLight() { ReleaseDirectionalLight(); } void SetDirectionalLight(DirectionalLight *L) { m_gameDirectionalLight = L; } DirectionalLight* GetDirectionalLight() { return m_gameDirectionalLight; } inline void ReleaseDirectionalLight() { SafeDelete(m_gameDirectionalLight); } private: DirectionalLight *m_gameDirectionalLight; };
[ "noreply@github.com" ]
noreply@github.com
d267056a83361086f7b9c4c48e292bcf8fcb72b3
25cb9f1bee72c930e0f828899474fc1287137fe4
/algoritmos/Longest_Increasing_Subsequence.cpp
d157286fc210c60b0355bd4c825a72243f0e4739
[]
no_license
torres07/competitive-programming
815b9ca85633b30d3f74c70925ae85a0d9a664a6
e79185c45180b0e8f8583cc924bc440ae2f871eb
refs/heads/master
2020-03-23T08:01:43.814012
2018-10-04T20:02:59
2018-10-04T20:02:59
141,304,254
0
2
null
null
null
null
UTF-8
C++
false
false
1,776
cpp
#include <algorithm> // lower_bound #include <vector> // vector using namespace std; // para uso do C++ #define PB push_back // por simplicidade #define MAXN 100100 // defino o valor de MAXN vector<int> lis(vector<int> &v){ // declaro s variáveis que vou usar vector<int> pilha, resp; int pos[MAXN], pai[MAXN]; // para cada elemento for(int i=0; i<v.size(); i++){ // declaro um iterador que guardará o elemento mais à esquerda de pilha // que não é menor que v[i] vector<int>::iterator it = lower_bound(pilha.begin(), pilha.end(), v[i]); // guardo a posição da pilha em que adicionarei o elemento int p = it-pilha.begin(); // se it for o fim do vector, então não há elemento que não seja menor que v[i] // ou seja, todos os topos de pilha são menores ou iguais a v[i] // logo, criamos uma nova pilha e colocamos x no seu topo if(it==pilha.end()) pilha.PB(v[i]); // porém, se it apontar para alguma posição válida do vector // colocamos v[i] no topo desta pilha, substintuindo o valor que it aponta por v[i] else *it = x; // a posição original na sequência do número no topo da pilha p agora é i pos[p]=i; // se o elemento foi inserido na primeira pilha if(p==0) pai[i]=-1; // seu pai será -1 // caso contrário, seu pai será a posição do elemento no topo da pilha anterior a ele else pai[i]=pos[p-1]; } // p será a posição do elemento no topo da última pilha int p = pos[pilha.size()-1]; // enquanto p não for -1 while(p>=0){ // adiciono o elemento na posição p à resposta resp.PB(v[p]); // e vou para o pai de p p=pai[p]; } // inverto a ordem da resposta reverse(resp.begin(), resp.end()); // por fim, retorno o vetor resp return resp; }
[ "enoque_itb@outlook.com" ]
enoque_itb@outlook.com
f3f7bfa07bd932c12a935d6ec038b2b6b0250cd6
af5a2e5a63709e83ac09ef544b45d01043f9a504
/tugas 3_no 3 (2).cpp
802c3a77853fe62491cdac02c9d8a31d5671591f
[]
no_license
isnakhoirunnisa/tugas-alpro-bab7
0a3b296f0937dbddacdbb0e0e9b5a9415e46a7f9
575227f3a3a2a2ac5c76692df74c7ceb39750926
refs/heads/master
2020-04-05T12:55:19.449299
2018-11-10T17:49:31
2018-11-10T17:49:31
156,886,492
0
0
null
null
null
null
UTF-8
C++
false
false
363
cpp
#include <stdio.h> #include <conio.h> #include <iostream> using namespace std; int main (){ float bil, max, total, rerata; cout<<"Masukkan Nilai Max : ";cin>>max; bil=0; total=0; do { total+=bil; rerata=total/max; bil++; } while (bil<=max); cout<<"Total : "<<total<<endl; cout<<"Rerata : "<<rerata<<endl; getch (); return 0; }
[ "isna99nisa@gmail.com" ]
isna99nisa@gmail.com
64c7a3652d7705ffdf853903308e0b41fd22a967
3b9b4049a8e7d38b49e07bb752780b2f1d792851
/src/cc/trees/layer_tree_host_unittest_record_gpu_histogram.cc
f56109b077fa5a48813845f78feeefd84556a104
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
webosce/chromium53
f8e745e91363586aee9620c609aacf15b3261540
9171447efcf0bb393d41d1dc877c7c13c46d8e38
refs/heads/webosce
2020-03-26T23:08:14.416858
2018-08-23T08:35:17
2018-09-20T14:25:18
145,513,343
0
2
Apache-2.0
2019-08-21T22:44:55
2018-08-21T05:52:31
null
UTF-8
C++
false
false
1,369
cc
// Copyright 2015 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 "cc/test/fake_layer_tree_host.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/test_task_graph_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace cc { namespace { TEST(LayerTreeHostRecordGpuHistogramTest, SingleThreaded) { FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); TestTaskGraphRunner task_graph_runner; LayerTreeSettings settings; std::unique_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client, &task_graph_runner, settings, CompositorMode::SINGLE_THREADED); host->RecordGpuRasterizationHistogram(); EXPECT_FALSE(host->gpu_rasterization_histogram_recorded()); } TEST(LayerTreeHostRecordGpuHistogramTest, Threaded) { FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); TestTaskGraphRunner task_graph_runner; LayerTreeSettings settings; std::unique_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create( &host_client, &task_graph_runner, settings, CompositorMode::THREADED); host->RecordGpuRasterizationHistogram(); EXPECT_TRUE(host->gpu_rasterization_histogram_recorded()); } } // namespace } // namespace cc
[ "changhyeok.bae@lge.com" ]
changhyeok.bae@lge.com
7cf0083a498db8bb3217ef43e739a4210645cd6b
d30537985a7060a669f0ac0f480e571c26daf70d
/Codeforces/C++/0061/61_A.cpp
6a9a4ee88d2497767dbf9bc16ee8641888b55b01
[]
no_license
Navidulhaque/competitive-programming-solutions
ab8e58d15bed071fdb6da1f5eccab1b5500383c9
b6d204ac2b87c091709fdd52c7ff695e4b973156
refs/heads/main
2023-08-21T03:25:08.766083
2021-10-29T15:41:00
2021-10-29T15:41:00
419,967,083
0
0
null
2021-10-22T04:37:10
2021-10-22T04:37:10
null
UTF-8
C++
false
false
249
cpp
// https://codeforces.com/problemset/problem/61/A #include <iostream> using namespace std; string a,b; int main() { cin>>a>>b; for(int i=0;i<a.size();i++) { if(a[i]==b[i]){cout<<0;} else{cout<<1;} } return 0; }
[ "darkrayl3igh@gmail.com" ]
darkrayl3igh@gmail.com
e196cf6e86584c68d7cc8b64589172f5134a4490
3083387dab447dded915a5df17a9c1db2af37986
/il2cpp-v21/libil2cpp/debugger/protocol/commands/type.cpp
6533b71b7ac0259eb037d3b78ce65e87207b06e2
[]
no_license
WuFengXue/il2cpp-Mirror
5defc24ac6fe537ddaa518d062d9291f2aaf2dad
48790bd85e868fc01f55decef1717488ebb10f1e
refs/heads/master
2022-09-30T11:41:05.218173
2020-06-03T03:17:07
2020-06-03T03:17:07
263,846,048
4
1
null
null
null
null
UTF-8
C++
false
false
285
cpp
#if IL2CPP_DEBUGGER_ENABLED #include "type.h" using namespace il2cpp::debugger; void TypeGetValuesCommand::Reply::WriteContentTo(Buffer &out) const { for(std::vector<Variant>::const_iterator it = _values.begin(); it != _values.end(); ++it) { out.WriteVariant(*it); } } #endif
[ "jianbo.li01@ucarinc.com" ]
jianbo.li01@ucarinc.com
c5c761cd505b91a27e8e922da306b65b75cd165f
552beffb39d296e35161c153be30c41fa5a989f0
/VisionProcessingFramework/src/Plugins/ResizeImage/resize_image_wnd.h
630daa9f1df2c57c6c764e99f51c6a3480039262
[]
no_license
toriumi/toritest
c6cfaecabef28a30775deec1377e126580b65227
4259049746a694ee9a5939d45b6916015317fb34
refs/heads/master
2021-01-17T15:56:46.434527
2017-03-26T16:00:30
2017-03-26T16:00:30
82,935,382
0
1
null
null
null
null
UTF-8
C++
false
false
2,907
h
/** * @file resize_image_wnd.h * @brief Window of ResizeImage plugin. * @author Vision Processing Community * @copyright 2016 Vision Processing Community. All rights reserved. */ #ifndef _RESIZE_IMAGE_WND_H_ #define _RESIZE_IMAGE_WND_H_ #include <vector> #include "./include.h" #include "./resize_image_define.h" class ResizeImage; /** * @class ResizeImageWnd * @brief Setting window of ResizeImage plugin. */ class ResizeImageWnd : public wxFrame { private: /*! Pointer to the ResizeImage class */ ResizeImage* parent_; /*! It manages the resize type of specific. (enable after Apply button clicked) */ ResizeImageType resize_type_; /*! It manages the resize type of specific.(temporally) */ ResizeImageType temp_resize_type_; /*! It manages the selected value of percent. */ int slider_resize_value_; /*! It manages the selected value of how to resize. */ int how_to_resize_; protected: wxRadioBox* wx_radio_select_how_to_resize_; wxRadioBox* wx_radio_select_resize_; wxButton* wx_button_setting_apply_; wxStaticBox* wx_static_box_slider_resize_; wxSlider* wx_slider_resize_; wxStaticText* wx_static_text_slider_resize_; public: /** * @brief * Constructor for this window. */ explicit ResizeImageWnd(ResizeImage* parent); /** * @brief * Destructor for this window. */ virtual ~ResizeImageWnd(void); /** * @brief * The handler function for button(id = kButtonApplyId). */ virtual void OnApply(wxCommandEvent& event); /* NOLINT */ /** * @brief * The handler function for radio box(id = kRboxResizeId). */ virtual void OnSelectResizeValue(wxCommandEvent& event); /* NOLINT */ /** * @brief * The handler function for EVT_CLOSE. */ virtual void OnClose(wxCloseEvent& event); /* NOLINT */ /** * @brief * The handler function for radio box(id = kRboxHowToResizeId). */ void OnSelectResizeMode(wxCommandEvent &event); /* NOLINT */ /** * @brief * The handler function for slider(id = kSliderResizeId). */ void OnSliderResize(wxScrollEvent& event); /* NOLINT */ /** * @brief * Apply resize slider value. */ void UpdateSliderResizeValue(void); /** * @brief * Set the list of parameter setting string for the Resize plugin. * @param params [in] settings string. */ void SetPluginSettings(std::vector<wxString> params); private: /*! Event table of wxWidgets.*/ DECLARE_EVENT_TABLE(); /** * @brief * Load the parameters from the file. * @param file_path [in] file path. * @return If true, reading the file success */ bool LoadSettingsFromFile(wxString file_path); /** * @brief * Write the parameters to the file. * @param file_path [in] file path. * @return If true, writing the file success */ bool WriteSettingsToFile(wxString file_path); }; #endif /* _RESIZE_IMAGE_WND_H_*/
[ "initial.st@gmail.com" ]
initial.st@gmail.com
0f1e21758c8bb54a12c5a36672e5338e0efb86d6
e217eaf05d0dab8dd339032b6c58636841aa8815
/IfcTunnel/src/OpenInfraPlatform/IfcTunnel/entity/include/IfcSpecularRoughness.h
e85feab77fa77fa1b978b55e668e3781a1791521
[]
no_license
bigdoods/OpenInfraPlatform
f7785ebe4cb46e24d7f636e1b4110679d78a4303
0266e86a9f25f2ea9ec837d8d340d31a58a83c8e
refs/heads/master
2021-01-21T03:41:20.124443
2016-01-26T23:20:21
2016-01-26T23:20:21
57,377,206
0
1
null
2016-04-29T10:38:19
2016-04-29T10:38:19
null
UTF-8
C++
false
false
1,105
h
/*! \verbatim * \copyright Copyright (c) 2014 Julian Amann. All rights reserved. * \date 2014-03-05 19:30 * \author Julian Amann <julian.amann@tum.de> (https://www.cms.bgu.tum.de/en/team/amann) * \brief This file is part of the BlueFramework. * \endverbatim */ #pragma once #include <vector> #include <map> #include <sstream> #include <string> #include "../../model/shared_ptr.h" #include "../../model/IfcTunnelObject.h" #include "IfcSpecularHighlightSelect.h" namespace OpenInfraPlatform { namespace IfcTunnel { // TYPE IfcSpecularRoughness = REAL; class IfcSpecularRoughness : public IfcSpecularHighlightSelect, public IfcTunnelType { public: IfcSpecularRoughness(); IfcSpecularRoughness( double value ); ~IfcSpecularRoughness(); virtual const char* classname() const { return "IfcSpecularRoughness"; } virtual void getStepParameter( std::stringstream& stream, bool is_select_type = false ) const; static shared_ptr<IfcSpecularRoughness> readStepData( std::string& arg ); double m_value; }; } // end namespace IfcTunnel } // end namespace OpenInfraPlatform
[ "planung.cms.bv@tum.de" ]
planung.cms.bv@tum.de
0faa17d2a1aec2a34fdeba31285ae6ef416523a1
d09945668f19bb4bc17087c0cb8ccbab2b2dd688
/srm/771-810/796/ChristmasBatteries.cpp
3d985379eaac9b5af6751f0ba3442587ec6d0691
[]
no_license
kmjp/procon
27270f605f3ae5d80fbdb28708318a6557273a57
8083028ece4be1460150aa3f0e69bdb57e510b53
refs/heads/master
2023-09-04T11:01:09.452170
2023-09-03T15:25:21
2023-09-03T15:25:21
30,825,508
23
2
null
2023-08-18T14:02:07
2015-02-15T11:25:23
C++
UTF-8
C++
false
false
3,515
cpp
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<to;x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- vector<ll> V[5]; class ChristmasBatteries { public: int mostFun(int B, int N, int X, int Y, int Z, int M) { int i; FOR(i,5) V[i].clear(); int sum=0; FOR(i,N) { int a=(1LL*X*i*i+1LL*Y*i+Z)%M; if(i%5==0) sum+=a; V[i%5].push_back(a); } FOR(i,5) sort(ALL(V[i])); FOR(i,5) reverse(ALL(V[i])); int ma=0; int a1,a2,a3,a4; for(a1=0;a1<=min(B,(int)V[1].size());a1++) { for(a2=0;a2<=V[2].size()&&a1+a2*2<=B;a2++) { for(a3=0;a3<=V[3].size()&&a3*3+a2*2+a1<=B;a3++) { for(a4=0;a4<=V[4].size()&&a4*4+a3*3+a2*2+a1<=B;a4++) { int tot=0; FOR(i,a1) tot+=V[1][i]; FOR(i,a2) tot+=V[2][i]; FOR(i,a3) tot+=V[3][i]; FOR(i,a4) tot+=V[4][i]; ma=max(ma,tot); } } } } return sum+ma; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { int Arg0 = 0; int Arg1 = 5; int Arg2 = 1; int Arg3 = 1; int Arg4 = 1; int Arg5 = 1000; int Arg6 = 1; verify_case(0, Arg6, mostFun(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)); } void test_case_1() { int Arg0 = 3; int Arg1 = 5; int Arg2 = 1; int Arg3 = 1; int Arg4 = 1; int Arg5 = 1000; int Arg6 = 14; verify_case(1, Arg6, mostFun(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)); } void test_case_2() { int Arg0 = 3; int Arg1 = 5; int Arg2 = 1; int Arg3 = 1; int Arg4 = 1; int Arg5 = 13; int Arg6 = 11; verify_case(2, Arg6, mostFun(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)); } void test_case_3() { int Arg0 = 4; int Arg1 = 10000; int Arg2 = 123; int Arg3 = 456; int Arg4 = 789; int Arg5 = 1; int Arg6 = 0; verify_case(3, Arg6, mostFun(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)); } void test_case_4() { int Arg0 = 7; int Arg1 = 4; int Arg2 = 3; int Arg3 = 5; int Arg4 = 7; int Arg5 = 997; int Arg6 = 100; verify_case(4, Arg6, mostFun(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)); } void test_case_5() { int Arg0 = 2; int Arg1 = 12345; int Arg2 = 234; int Arg3 = 34; int Arg4 = 5; int Arg5 = 117; int Arg6 = 143371; verify_case(5, Arg6, mostFun(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)); } // END CUT HERE }; // BEGIN CUT HERE int main(int argc,char** argv) { ChristmasBatteries ___test; ___test.run_test((argc==1)?-1:atoi(argv[1])); }
[ "kmjp@users.noreply.github.com" ]
kmjp@users.noreply.github.com
8401f3b3402e8db732157ba8cf8dd5cb4f759372
156c0861ce5650248099d917bc22dfe1b012c7cb
/第6章/第六章/6.36.cpp
718a5b73a5470d2610eb908a69ac34a87e961736
[]
no_license
bietaixian/cppPrimer5th
ba1309bdf2c0e2be80b8da26e1ee442ead611606
82a4866512f770f8e8d7010172db414cdf3911e0
refs/heads/master
2020-04-02T05:49:24.490678
2016-06-22T02:39:20
2016-06-22T02:39:20
61,682,696
0
0
null
null
null
null
UTF-8
C++
false
false
34
cpp
//int (&v(string (&str)[10]))[10];
[ "649968264@qq.com" ]
649968264@qq.com
2d3aa4e468cbdceea02c0931c22279966fbf04f3
ef4f97a53805e08bb5ebf0f138e0f2b8feb2d62f
/MDBFix/registry.cpp
ed76c719a9684e3b8064c74cd621300ce2d5a1a4
[]
no_license
rayargy/old_software
703da5b1c28b0ba47a4cbf2944c8323585996a87
26d3198cede2d39e217ce0aa30fa3b2675cd952c
refs/heads/master
2020-04-03T04:40:19.325156
2018-10-28T00:27:30
2018-10-28T00:27:30
155,020,073
0
0
null
null
null
null
UTF-8
C++
false
false
9,767
cpp
// Registry.cpp: implementation of the CRegistry class. // ////////////////////////////////////////////////////////////////////// #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #include <afxmt.h> // MFC multi thread support #include "Registry.h" //MCCONFIG{{ Do not modify these lines - use MCCONFIG! // // This custom block declares one instance of the // current source filename to pass to MemCheck. // Only one copy of the filename is created per module (efficient). // // MCCONFIG for Windows used the MFC block style (see main screen) // to insert this #include block after the last header or occurrence // of an IMPLEMENT_SERIAL or IMPLEMENT_DYNAMIC statement. // #ifndef _MCSF_ #define _MCSF_ szMCFile #endif // The MEMCHECK constant is defined by default in the MemCheck // header file. If you want to compile MemCheck out of your // code, simply define the symbol NOMC or NOMEMCHECK. // It's not necessary to remove the header file to compile // MemCheck out of your code. // #if defined(MEMCHECK) // defined in memcheck.h if !defined(NOMC) static char szMCFile[] = __FILE__; #endif //}}MCCONFIG ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CRegistry::CRegistry() { } CRegistry::~CRegistry() { } //////////////////////////////////////////////////////////////// // Close an open key in the Registry long CRegistry::CloseRegKey(HKEY hKeyToClose) { return ( RegCloseKey( hKeyToClose ) ); // Close the key } //////////////////////////////////////////////////////////////// // Connects to the registry of another computer // hKey needs to contain one of the predefined registry keys. // Currently, only HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER are // supported. long CRegistry::ConnectToRegistry(LPTSTR lpMachineName, HKEY *phkResult, HKEY hKey) { return( RegConnectRegistry( lpMachineName, // address of name of remote computer hKey, // predefined registry handle - defaults to HKEY_LOCAL_MACHINE phkResult ) ); // address of buffer for remote registry handle } //////////////////////////////////////////////////////////////// // Create a key in the Registry long CRegistry::CreateRegKey(char *szKeyToCreate, HKEY hBaseKey) { long RetVal; HKEY hKeyHandle; RetVal = RegCreateKeyEx( hBaseKey, // Defaults to HKEY_LOCAL_MACHINE szKeyToCreate, // This is the key we want to create 0, // RESERVED - must be 0 NULL, // No class info. REG_OPTION_NON_VOLATILE, // We want this permanent KEY_ALL_ACCESS, // No restrictions NULL, // No security descriptor &hKeyHandle, // Resultant handle &m_dwDisposition); // Disposition of call // If successful, we have an open key if ( RetVal == ERROR_SUCCESS || RetVal == REG_CREATED_NEW_KEY || RetVal == REG_OPENED_EXISTING_KEY ) CloseRegKey( hKeyHandle ); // Return results return ( RetVal ); } //////////////////////////////////////////////////////////////// // Deletes a key in the Registry long CRegistry::DeleteRegKey(char *szKeyToDelete, HKEY hBaseKey) { return ( RegDeleteKey ( hBaseKey, // Defaults to HKEY_LOCAL_MACHINE (const char *) szKeyToDelete) ); // Key to delete } //////////////////////////////////////////////////////////////// // Deletes a value name in the Registry long CRegistry::DeleteRegValue(HKEY hKey, LPTSTR lpValueName) { return ( RegDeleteValue( hKey, // handle of key (const char *) lpValueName ) ); // address of value name } //////////////////////////////////////////////////////////////// // Enumerates a key's subkeys in the Registry // Increment dwIndex to proceed through subkeys - Starts at 0 long CRegistry::EnumRegKey(HKEY hKey, LPTSTR lpName, LPDWORD lpcbName, PFILETIME lpftLastWrite, DWORD dwIndex) { return ( RegEnumKeyEx( hKey, // handle of key to enumerate dwIndex, // index of subkey to enumerate lpName, // address of buffer for subkey name lpcbName, // address for size of subkey buffer NULL, // reserved NULL, // address of buffer for class string NULL, // address for size of class buffer lpftLastWrite ) ); // address for time key last written to } //////////////////////////////////////////////////////////////// // Enumerates a key's values in the Registry // Increment dwIndex to proceed through values - Starts at 0 long CRegistry::EnumRegValue(HKEY hKey, LPTSTR lpName, LPDWORD lpcbName, LPDWORD lpType, LPBYTE lpValue, LPDWORD lpcbValue, DWORD dwIndex) { return ( RegEnumValue( hKey, // handle of key to query dwIndex, // index of value to query lpName, // address of buffer for value string lpcbName, // address for size of value buffer NULL, // reserved lpType, // address of buffer for type code lpValue, // address of buffer for value data lpcbValue ) ); // address for size of data buffer } //////////////////////////////////////////////////////////////// // Open a key in the Registry HKEY CRegistry::OpenRegKey(long *Results, char *KeyToOpen, HKEY hOpenKey) { long RetVal; HKEY hKeyHandle; // We use RegCreateKeyEx instead of RegOpenKeyEx because you // have to open only one layer at a time with RegOpenKeyEx and // you can open a fully qualified key via RegCreateKeyEx. RetVal = RegCreateKeyEx( hOpenKey, // Defaults to HKEY_LOCAL_MACHINE KeyToOpen, // This is the key we want to create 0, // RESERVED - must be 0 NULL, // No class info. REG_OPTION_NON_VOLATILE, // We want this permanent KEY_ALL_ACCESS, // No restrictions NULL, // No security descriptor &hKeyHandle, // Resultant handle &m_dwDisposition); // Disposition of call *Results = RetVal; return ( hKeyHandle ); } //////////////////////////////////////////////////////////////// // Queries a key in the Registry to find out info about sub-keys // and values associated with that key. long CRegistry::QueryRegKey(HKEY hKey, LPDWORD lpcSubKeys, LPDWORD lpcbMaxSubKeyLen, LPDWORD lpcValues, LPDWORD lpcbMaxValueNameLen, LPDWORD lpcbMaxValueLen) { return ( RegQueryInfoKey ( hKey, // handle of key to query NULL, // address of buffer for class string NULL, // address of size of class string buffer NULL, // reserved lpcSubKeys, // address of buffer for number of subkeys lpcbMaxSubKeyLen, // address of buffer for longest subkey name length NULL, // address of buffer for longest class string length lpcValues, // address of buffer for number of value entries lpcbMaxValueNameLen, // address of buffer for longest value name length lpcbMaxValueLen, // address of buffer for longest value data length NULL, // address of buffer for security descriptor length NULL ) ); // address of buffer for last write time } //////////////////////////////////////////////////////////////// // Retrieves a specific value from a key in the Registry long CRegistry::QueryRegValue(HKEY hKey, LPTSTR lpName, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData) { return ( RegQueryValueEx( hKey, // handle of key to query lpName, // address of name of value to query NULL, // reserved lpType, // address of buffer for value type lpData, // address of data buffer lpcbData ) ); // address of data buffer size } //////////////////////////////////////////////////////////////// // Sets a specific value form an item under a key in the Registry long CRegistry::SetRegValue(HKEY hKey, LPCTSTR lpValueName, DWORD dwType, CONST BYTE * lpData, DWORD cbData) { return ( RegSetValueEx( hKey, // handle of key to set value for lpValueName, // address of value to set NULL, // reserved dwType, // flag for value type lpData, // address of value data cbData ) ); // size of value data } DWORD CRegistry::FetchDWValue(long * RetValue, HKEY OpenKey, char * ItemToRead) { DWORD lpType, lpcbData, lRetVal = 0; unsigned char lpData[128]; lpcbData = 128; *RetValue = QueryRegValue( OpenKey, ItemToRead, &lpType, lpData, &lpcbData ); if ( *RetValue == ERROR_SUCCESS ) memcpy( &lRetVal, &lpData, sizeof ( lRetVal ) ); return lRetVal; } CString CRegistry::FetchStrValue(long * RetValue, HKEY OpenKey, char * ItemToRead) { CString sRetVal = ""; DWORD lpType, lpcbData; unsigned char lpData[512]; lpcbData = 512; *RetValue = QueryRegValue( OpenKey, ItemToRead, &lpType, lpData, &lpcbData ); if ( *RetValue == ERROR_SUCCESS ) { lpData[lpcbData] = 0; sRetVal = (char *) lpData; } return sRetVal; } BOOL CRegistry::FetchBoolValue(long * RetValue, HKEY OpenKey, char * ItemToRead) { DWORD lpType, lpcbData; unsigned char lpData[128]; lpcbData = 128; *RetValue = QueryRegValue( OpenKey, ItemToRead, &lpType, lpData, &lpcbData ); if ( *RetValue == ERROR_SUCCESS ) for (unsigned int iCount = 0; iCount < lpcbData; iCount++) if ( lpData[iCount] != 0 ) return TRUE; return FALSE; }
[ "ray.argy@gmail.com" ]
ray.argy@gmail.com
728536279d1750e3b10fc6fecd51ea8029a4f7e1
55412ef700cc8e0535d350d69aca536e95252362
/Source/General/NetworkData.h
67bf3911c2de325718398b3300478d05523a6142
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
dixxxy/rsatoolbox
eb596878c6848b8883ced8bd27411155e6e5b91a
a1a6b069f2434980fb679919652a33eb3eab2a2c
refs/heads/master
2020-12-11T01:42:18.089454
2016-05-09T22:02:10
2016-05-09T22:02:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,556
h
#ifndef NETWORK_DATA_H #define NETWORK_DATA_H // RsaToolbox #include "Definitions.h" // Qt #include <QString> #include <QStringList> #include <QDateTime> #include <QMetaType> #include <QDateTime> #include <QFile> #include <QDataStream> // Std lib // namespace RsaToolbox { class NetworkData { public: NetworkData(); NetworkData(const NetworkData &other); bool isSParameter() const; bool isYParameter() const; bool isZParameter() const; bool isHParameter() const; bool isGParameter() const; NetworkParameter parameter() const; void setParameter(NetworkParameter parameter); QString comment() const; void setComment(const QString &comment); QString timestamp() const; void setTimestamp(const QDateTime &dateTime = QDateTime::currentDateTime()); uint ports() const; void setPorts(uint ports); QString portComment(uint port) const; void setPortComment(uint port, const QString &comment); double referenceImpedance_Ohms() const; void setReferenceImpedance(double Ohms); Units xUnits() const; SiPrefix xPrefix() const; void setXUnits(Units units, SiPrefix prefix = SiPrefix::None); uint points() const; QRowVector &x(); ComplexMatrix3D &y(); ComplexRowVector y(uint outputPort, uint inputPort) const; QRowVector y_dB(uint outputPort, uint inputPort) const; QRowVector y_magnitude(uint outputPort, uint inputPort) const; QRowVector y_phase_deg(uint outputPort, uint inputPort) const; QRowVector y_phase_rad(uint outputPort, uint inputPort) const; QRowVector y_vswr(uint port) const; QRowVector y_real(uint outputPort, uint inputPort) const; QRowVector y_imaginary(uint outputPort, uint inputPort) const; void clear(); void resize(uint ports, uint points); void setPoints(uint points); void setData(QRowVector const &x, ComplexMatrix3D const &y); // Operators void operator=(const NetworkData &other); void write(QDataStream &stream) const; void read(QDataStream &stream); private: QDateTime _timestamp; QString _comment; QStringList _portComments; NetworkParameter _parameter; double _impedance_Ohms; uint _ports; uint _points; QRowVector _x; Units _xUnits; SiPrefix _xPrefix; ComplexMatrix3D _y; }; } QDataStream& operator<<(QDataStream &stream, const RsaToolbox::NetworkData &data); QDataStream& operator>>(QDataStream &stream, RsaToolbox::NetworkData &data); Q_DECLARE_METATYPE(RsaToolbox::NetworkData) #endif // NETWORK_DATA_H
[ "nick.lalic@gmail.com" ]
nick.lalic@gmail.com
3c24c732d04157b136b3dea519ed7e53f3c04cf1
bf681fbd7edbf4f8f1e0b20cbd09b362f777c9c3
/cpp/rvo_check.cc
01db6d634b1405fa99f7e53c445becce1585c470
[ "BSD-3-Clause" ]
permissive
EricCousineau-TRI/repro
308d4a86f3c7da8be5811db2f3f68d39db60d7ed
9800f45e07f511c9a355ee90333955451b55559a
refs/heads/master
2023-08-31T13:49:23.540640
2023-08-25T19:18:33
2023-08-25T19:18:33
87,116,976
24
13
NOASSERTION
2023-03-25T01:40:55
2017-04-03T20:19:28
Jupyter Notebook
UTF-8
C++
false
false
1,710
cc
#include <iostream> #include <type_traits> #include "name_trait.h" #include "type_pack.h" template <typename T> struct Count { static int num_constructed; int value{100}; Count() { num_constructed++; } Count(const Count&) { num_constructed++; } Count(Count&&) { num_constructed++; } }; template <typename T> int Count<T>::num_constructed = 0; struct A : public Count<A> {}; struct B : public Count<B> {}; struct C : public Count<C> { using Base = Count<C>; // Allow implicit conversion. using Base::Base; C(const B&) : Base() {} }; template <typename T> auto GetTypeTag() { if constexpr (std::is_same_v<T, B>) { return type_tag<C>{}; } else { return type_tag<const T&>{}; } } template <typename T> using get_type = typename decltype(GetTypeTag<T>())::type; template <typename T> get_type<T> MaybeConvert(const T& value) { return value; } template <typename T> void Check(const T& x) { const auto& y = MaybeConvert(x); if (y.value != 100) { throw std::runtime_error("Bad: " + std::to_string(y.value)); } } void print_constructed_and_reset() { std::cout << "num_constructed: " << "A: " << A::num_constructed << ", " << "B: " << B::num_constructed << ", " << "C: " << C::num_constructed << "\n\n\n"; A::num_constructed = 0; B::num_constructed = 0; C::num_constructed = 0; } int main() { EVAL(Check(A{})); print_constructed_and_reset(); EVAL(Check(B{})); print_constructed_and_reset(); EVAL(Check(C{})); print_constructed_and_reset(); return 0; } /** >>> Check(A{}); num_constructed: A: 1, B: 0, C: 0 >>> Check(B{}); num_constructed: A: 0, B: 1, C: 1 >>> Check(C{}); num_constructed: A: 0, B: 0, C: 1 */
[ "eric.cousineau@tri.global" ]
eric.cousineau@tri.global
2f315f7194a6f61a715867c402d8b75e310ae2b0
9030ce2789a58888904d0c50c21591632eddffd7
/SDK/ARKSurvivalEvolved_PrimalItemCostume_GhostOwl_parameters.hpp
24bfb0cad169778d8b5d82e534e60d74a91a25ec
[ "MIT" ]
permissive
2bite/ARK-SDK
8ce93f504b2e3bd4f8e7ced184980b13f127b7bf
ce1f4906ccf82ed38518558c0163c4f92f5f7b14
refs/heads/master
2022-09-19T06:28:20.076298
2022-09-03T17:21:00
2022-09-03T17:21:00
232,411,353
14
5
null
null
null
null
UTF-8
C++
false
false
758
hpp
#pragma once // ARKSurvivalEvolved (332.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_PrimalItemCostume_GhostOwl_classes.hpp" namespace sdk { //--------------------------------------------------------------------------- //Parameters //--------------------------------------------------------------------------- // Function PrimalItemCostume_GhostOwl.PrimalItemCostume_GhostOwl_C.ExecuteUbergraph_PrimalItemCostume_GhostOwl struct UPrimalItemCostume_GhostOwl_C_ExecuteUbergraph_PrimalItemCostume_GhostOwl_Params { int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "sergey.2bite@gmail.com" ]
sergey.2bite@gmail.com
e481c3fdf9a13ef3d5c3cf1d870368651fdd7b16
33526de9b19486100705efe849e78f6bfea25e3f
/BOJ/1195.cpp
ba3fddb32bd2795f571ed3bbaa77797237280430
[]
no_license
whrlgus/PS
32f6771f03afdfdec61f12b790e527f4b2a5e8bc
596f91e7e40485b96a1199a4acc1ba9fb05d9ab2
refs/heads/master
2023-07-31T14:34:59.279677
2021-09-12T11:20:24
2021-09-12T11:20:24
277,535,565
0
0
null
null
null
null
UTF-8
C++
false
false
533
cpp
#include<bits/stdc++.h> #define f(i,l,r) for(int i=l;i<r;++i) using namespace std; int mxCnt; bool isValid(int cnt, char *a, char *b){ while(cnt--){ if(*a=='2'&&*a==*b)return false; --a; --b; } return true; } void sol(char *a, char *b, int lenA, int lenB){ f(i,0,lenA){ int cnt=min(i+1,lenB); if(isValid(cnt, a+i, b))mxCnt=max(mxCnt,cnt); } } int main(){ char a[101],b[101];cin>>a>>b; int lenA=strlen(a),lenB=strlen(b); sol(a,b+lenB-1,lenA,lenB); sol(b,a+lenA-1,lenB,lenA); cout<<lenA+lenB-mxCnt; return 0; }
[ "whrlgus33@gmail.com" ]
whrlgus33@gmail.com
73dbd91523b4be5a000c93f470524aeadfe1d015
6ced41da926682548df646099662e79d7a6022c5
/aws-cpp-sdk-pinpoint-sms-voice-v2/source/model/PoolOriginationIdentitiesFilter.cpp
38b38122bf6c8130cf6ad85e7969149f72ba5b64
[ "Apache-2.0", "MIT", "JSON" ]
permissive
irods/aws-sdk-cpp
139104843de529f615defa4f6b8e20bc95a6be05
2c7fb1a048c96713a28b730e1f48096bd231e932
refs/heads/main
2023-07-25T12:12:04.363757
2022-08-26T15:33:31
2022-08-26T15:33:31
141,315,346
0
1
Apache-2.0
2022-08-26T17:45:09
2018-07-17T16:24:06
C++
UTF-8
C++
false
false
2,111
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/pinpoint-sms-voice-v2/model/PoolOriginationIdentitiesFilter.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace PinpointSMSVoiceV2 { namespace Model { PoolOriginationIdentitiesFilter::PoolOriginationIdentitiesFilter() : m_name(PoolOriginationIdentitiesFilterName::NOT_SET), m_nameHasBeenSet(false), m_valuesHasBeenSet(false) { } PoolOriginationIdentitiesFilter::PoolOriginationIdentitiesFilter(JsonView jsonValue) : m_name(PoolOriginationIdentitiesFilterName::NOT_SET), m_nameHasBeenSet(false), m_valuesHasBeenSet(false) { *this = jsonValue; } PoolOriginationIdentitiesFilter& PoolOriginationIdentitiesFilter::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("Name")) { m_name = PoolOriginationIdentitiesFilterNameMapper::GetPoolOriginationIdentitiesFilterNameForName(jsonValue.GetString("Name")); m_nameHasBeenSet = true; } if(jsonValue.ValueExists("Values")) { Array<JsonView> valuesJsonList = jsonValue.GetArray("Values"); for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex) { m_values.push_back(valuesJsonList[valuesIndex].AsString()); } m_valuesHasBeenSet = true; } return *this; } JsonValue PoolOriginationIdentitiesFilter::Jsonize() const { JsonValue payload; if(m_nameHasBeenSet) { payload.WithString("Name", PoolOriginationIdentitiesFilterNameMapper::GetNameForPoolOriginationIdentitiesFilterName(m_name)); } if(m_valuesHasBeenSet) { Array<JsonValue> valuesJsonList(m_values.size()); for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex) { valuesJsonList[valuesIndex].AsString(m_values[valuesIndex]); } payload.WithArray("Values", std::move(valuesJsonList)); } return payload; } } // namespace Model } // namespace PinpointSMSVoiceV2 } // namespace Aws
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
e97f76c1f3454c622e337a9977d5fdbb0294e6a4
c6ed85dd8d7716fe7732f4f43389196dcadcb73b
/include/PSDFCore/Event/EventStation.h
f41509d20de2acafda095dda009d3731cbd0b725
[]
no_license
ymy88/InfraredTarget
0d9c0d934e889927ba7f5c7bfeced6652d0112c0
73b2db0b6fa538d273452e8c4e39cf01e52e2f1d
refs/heads/master
2020-04-24T12:56:11.061136
2013-10-14T08:13:06
2013-10-14T08:13:06
12,411,590
0
0
null
null
null
null
UTF-8
C++
false
false
3,070
h
#pragma once #include "../Common/Common.h" #include "../Thread/PosixThreads.h" #include "EventType.h" #include "EventHandler.h" class EventCenter; class OsgViewerBase; const short EVENT_STATION_QUEUE_LENGTH = 10000; class PSDF_CORE_DLL_DECL EventStation { friend class EventCenter; friend class OsgViewerBase; private: struct EventStationStruct { unsigned int eventType; int param1; int param2; EventStationStruct() : eventType(0), param1(0), param2(0) {} }; class EventStationDispatcher : public PosixThread { public: void run(); /* this method is called by the main thread of the window, before every frame */ void manuallyRun(); bool peekEvent( unsigned int &eventType, int &param1, int &param2, bool shouldWait ); void dispatchEvent( unsigned int eventType, int param1, int param2 ); public: EventStation * _station; }; class EventHandlerQueue { public: const vector< EventHandler * > &beginUpdate(); void endUpdate(); void addHandler( EventHandler * handler ); void removeHandler( EventHandler * handler ); private: void solvePending(); private: vector< EventHandler * > _handlers; vector< EventHandler * > _pendingHandlers; PosixMutex _pendingMutex; PosixReadWriteLock _handlersLock; }; private: EventStation(int stationId = -1); ~EventStation(); void triggerEvent( unsigned int eventType, int param1, int param2, bool shouldWait ); /* * Parameter "eventGroupMask" can be any conbination of the event * cluster type. If eventGroupMask is EVENT_GROUP_TYPE_MASK_ALL, * it means the handler wants to handle all events (when registering), * or does not want to handle any event any longer (when unregistering). */ void registerHandler( EventHandler * handler, unsigned int eventGroupMask = EVENT_GROUP_ALL ); void unregisterHandler( EventHandler * handler, unsigned int eventGroupMask = EVENT_GROUP_ALL ); public: unsigned int getStationId() { return _stationId; } void manuallyDispatchEvent(); void outputLog(ofstream& fout); private: //event handler queues for every event cluster. EventHandlerQueue _eventHandlerQueues[ EVENT_GROUP_COUNT ]; /* 消息处理者队列 */ EventStationDispatcher _dispatcher; /* 消息站消息投递分发器 */ EventStationStruct _stationEventQueue[ EVENT_STATION_QUEUE_LENGTH ]; /* 消息站消息队列 */ PosixMutex _eventQueueMutex; /* 消息队列互斥量 */ PosixSemaphore _freeSem; /* 消息站空闲信号量 */ PosixSemaphore _usedSem; /* 消息站使用信号量 */ int _putPos; /* 消息队列消息存储位置索引 */ int _getPos; /* 消息队列消息读取位置索引 */ unsigned int _stationId; /* 消息站编号,视窗与消息站通过编号对应 */ size_t _triggerCount; size_t _handleSystemCount; size_t _handleCustomCount; static unsigned int _nextStationId; };
[ "yuanmengyu_88@me.com" ]
yuanmengyu_88@me.com
a1d54ed48f0a14b177caf8622196c290d9ffc2df
1f9ff37c2383ea01758a486eeb9d46185c28520f
/Solved Problems/Count_Divisors.cpp
d64d56f39ab2111bc8db1bdaa07704de4dd0d85e
[]
no_license
Manii-M/InterviewBit
992a9fbca290052d2386536443e57f62818bdc12
b5d735d9c22edebfbcbd2ee06532cba28f18f64d
refs/heads/master
2022-12-15T10:31:55.391785
2020-09-07T13:56:44
2020-09-07T13:56:44
263,404,249
0
0
null
null
null
null
UTF-8
C++
false
false
1,590
cpp
/* Approach - calculate SPF of each number in the array then count all prime factors and based on that calculate all divisors of the number TIme Complexity - O(sqrt(n)log log (n)) */ void CalculateSPFandPrimeNumbers(vector<int> &v, vector<bool> &prime) { int m = 1000001; for (int i = 2; i <= sqrt(m); i++) { if (prime[i]) { v[i] = i; for (int j = i; (long long int)j * i <= m; j++) { prime[i * j] = false; v[i * j] = i; } } } } vector<int> Solution::solve(vector<int> &A) { int answer = 1; vector<int> SPFArray(1000001, 0); vector<bool> prime(1000001, true); CalculateSPFandPrimeNumbers(SPFArray, prime); int total = 1; for (int i = 0; i < A.size(); i++) { if (A[i] <= 1) continue; if (!prime[A[i]]) { int number = A[i]; int count = 0; while (number != 1) { int SPF = SPFArray[number];//smallest prime factor for each array element int count = 0; if (prime[number]) SPF = number; while (SPF != 0 && number % SPF == 0) { number /= SPF; count++; } total *= (count + 1); //total number of divisors product of all prime divisors + 1. } A[i] = total;//total divisors } else A[i] = 2; total = 1; } return A; }
[ "manii.nitc@gmail.com" ]
manii.nitc@gmail.com
36eda37862239e4831ff34928823c34364f1888a
183e242af385f62a44057b9e53f48da56ce0ab52
/SFML/SFML05-ActionRpg/src/core/system_manager.h
a6f73abd3fddaadba9d4ca30b0ee01be77a565df
[ "MIT" ]
permissive
Gaetz/cpp-training
ade384e99b6b690ff69a4c552f128f3ede7f196b
5191da36be37c5bef18637ba82f1edac1c2474fa
refs/heads/master
2021-01-19T16:41:56.910412
2020-04-07T20:38:49
2020-04-07T20:38:49
101,016,941
0
0
null
null
null
null
UTF-8
C++
false
false
1,548
h
#ifndef SYSTEM_MANAGER_H #define SYSTEM_MANAGER_H #include <SFML/Graphics.hpp> #include "window.h" #include "../ecs/s_renderer.h" #include "../ecs/s_movement.h" #include "../ecs/s_control.h" #include "../ecs/s_state.h" #include "../ecs/s_sheet_animation.h" //#include "../ecs/s_collision.h" #include "event_queue.h" #include "messaging/message_handler.h" #include <unordered_map> #include "../utils/debug_overlay.h" #include "../utils/more_hash.h" using SystemContainer = std::unordered_map<System, S_Base*, EnumClassHash>; using EntityEventContainer = std::unordered_map<EntityId, EventQueue>; class EntityManager; class SystemManager { public: SystemManager(); ~SystemManager(); EntityManager* getEntityManager(); void setEntityManager(EntityManager* entityManager); MessageHandler* getMessageHandler(); template<class T> T* getSystem(const System& system) { auto itr = mSystems.find(system); return (itr != mSystems.end() ? dynamic_cast<T*>(itr->second) : nullptr); } void addEvent(const EntityId& entityId, const EventId& event); void update(float dt); void handleEvents(); void draw(Window* window, unsigned int elevation); void entityModified(const EntityId& entityId, const Bitmask& bits); void removeEntity(const EntityId& entity); void purgeEntities(); void purgeSystems(); private: SystemContainer mSystems; EntityManager* mEntityManager; EntityEventContainer mEvents; MessageHandler mMessages; }; #endif // SYSTEM_MANAGER_H
[ "gaetz@rufflerim.com" ]
gaetz@rufflerim.com
422a74fe16804c85d9633d738ba8abea1b28230c
2043f98861b83d3aff7527c7493f0f36b4906edf
/outputwidget.cpp
665d0b2f45dafe493fe1ca0dd41f668e921a511f
[]
no_license
VladislavLechner/FileWidget
432f6ca1ab466df0fa76be4738b411818a80cc35
45a2a61409cd285c104e636bf7385b1da17758fc
refs/heads/master
2023-05-04T09:38:15.892910
2021-05-26T09:14:11
2021-05-26T09:14:11
369,635,609
0
0
null
null
null
null
UTF-8
C++
false
false
1,129
cpp
#include "outputwidget.h" OutputFileWidget::OutputFileWidget(QWidget *parent) : QWidget(parent) { setUpLayout(); } void OutputFileWidget::setUpLayout() { m_automaticCollection = new QLabel("Автоматически собранная информация\n",this); m_filterCollectrion = new QLabel("Информация, полученная от пользователя\n",this); m_gridLayout = new QGridLayout(this); m_gridLayout->addWidget(m_automaticCollection,0,0); m_gridLayout->addWidget( m_filterCollectrion,0,1); } void OutputFileWidget::outputTheResults(std::pair<std::map<char, std::size_t>, int> result, QString filter) { for (auto& x:result.first) { m_automaticCollection->setText(m_automaticCollection->text() + "Символ '" + x.first + "' встречается ровно " + QString::number(x.second) + " раз\n"); } m_filterCollectrion->setText(m_filterCollectrion->text() + "Введенный пользователем фильтр '" + filter + "' повторяется ровно " + QString::number(result.second) + " раз\n"); }
[ "semen.isaev@ro.ru" ]
semen.isaev@ro.ru
e04e039e2280b8c5ffb49035cd07230d67dc397f
075bdc1c2b67e514a0e256d9f766711615c6d739
/frozen/bits/basic_types.h
cd4f9092b348c129fecc43b12611856938af5e92
[ "Apache-2.0" ]
permissive
qicosmos/ormpp
8595f7fef01db9c98cf53e7950d11ca72eb15399
eb9e4362138909fd3666b65a903663069701cd85
refs/heads/master
2023-08-31T08:31:26.436712
2023-08-25T09:52:00
2023-08-25T09:52:00
109,477,358
1,035
268
Apache-2.0
2023-09-08T02:43:41
2017-11-04T07:57:11
C++
UTF-8
C++
false
false
7,364
h
/* * Frozen * Copyright 2016 QuarksLab * * 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. */ #ifndef FROZEN_LETITGO_BASIC_TYPES_H #define FROZEN_LETITGO_BASIC_TYPES_H #include <array> #include <iterator> #include <string> #include <utility> #include "frozen/bits/exceptions.h" namespace frozen { namespace bits { // used as a fake argument for frozen::make_set and frozen::make_map in the case // of N=0 struct ignored_arg {}; template <class T, std::size_t N> class cvector { T data[N] = {}; // zero-initialization for scalar type T, default-initialized // otherwise std::size_t dsize = 0; public: // Container typdefs using value_type = T; using reference = value_type &; using const_reference = const value_type &; using pointer = value_type *; using const_pointer = const value_type *; using iterator = pointer; using const_iterator = const_pointer; using size_type = std::size_t; using difference_type = std::ptrdiff_t; // Constructors constexpr cvector(void) = default; constexpr cvector(size_type count, const T &value) : dsize(count) { for (std::size_t i = 0; i < N; ++i) data[i] = value; } // Iterators constexpr iterator begin() noexcept { return data; } constexpr iterator end() noexcept { return data + dsize; } // Capacity constexpr size_type size() const { return dsize; } // Element access constexpr reference operator[](std::size_t index) { return data[index]; } constexpr const_reference operator[](std::size_t index) const { return data[index]; } constexpr reference back() { return data[dsize - 1]; } constexpr const_reference back() const { return data[dsize - 1]; } // Modifiers constexpr void push_back(const T &a) { data[dsize++] = a; } constexpr void push_back(T &&a) { data[dsize++] = std::move(a); } constexpr void pop_back() { --dsize; } constexpr void clear() { dsize = 0; } }; template <class T, std::size_t N> class carray { T data_[N] = {}; // zero-initialization for scalar type T, // default-initialized otherwise template <std::size_t M, std::size_t... I> constexpr carray(T const (&init)[M], std::index_sequence<I...>) : data_{init[I]...} {} template <class Iter, std::size_t... I> constexpr carray(Iter iter, std::index_sequence<I...>) : data_{((void)I, *iter++)...} {} public: // Container typdefs using value_type = T; using reference = value_type &; using const_reference = const value_type &; using pointer = value_type *; using const_pointer = const value_type *; using iterator = pointer; using const_iterator = const_pointer; using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; using size_type = std::size_t; using difference_type = std::ptrdiff_t; // Constructors constexpr carray(void) = default; template <std::size_t M> constexpr carray(T const (&init)[M]) : carray(init, std::make_index_sequence<N>()) { static_assert(M >= N, "Cannot initialize a carray with an smaller array"); } template <std::size_t M> constexpr carray(std::array<T, M> const &init) : carray(&init[0], std::make_index_sequence<N>()) { static_assert(M >= N, "Cannot initialize a carray with an smaller array"); } constexpr carray(std::initializer_list<T> init) : carray(init.begin(), std::make_index_sequence<N>()) { // clang & gcc doesn't recognize init.size() as a constexpr // static_assert(init.size() >= N, "Cannot initialize a carray with an // smaller initializer list"); } // Iterators constexpr iterator begin() noexcept { return data_; } constexpr const_iterator begin() const noexcept { return data_; } constexpr const_iterator cbegin() const noexcept { return data_; } constexpr iterator end() noexcept { return data_ + N; } constexpr const_iterator end() const noexcept { return data_ + N; } constexpr const_iterator cend() const noexcept { return data_ + N; } constexpr reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } constexpr reverse_iterator rend() noexcept { return reverse_iterator(begin()); } constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } // Capacity constexpr size_type size() const { return N; } constexpr size_type max_size() const { return N; } // Element access constexpr reference operator[](std::size_t index) { return data_[index]; } constexpr const_reference operator[](std::size_t index) const { return data_[index]; } constexpr reference at(std::size_t index) { if (index > N) FROZEN_THROW_OR_ABORT( std::out_of_range("Index (" + std::to_string(index) + ") out of bound (" + std::to_string(N) + ')')); return data_[index]; } constexpr const_reference at(std::size_t index) const { if (index > N) FROZEN_THROW_OR_ABORT( std::out_of_range("Index (" + std::to_string(index) + ") out of bound (" + std::to_string(N) + ')')); return data_[index]; } constexpr reference front() { return data_[0]; } constexpr const_reference front() const { return data_[0]; } constexpr reference back() { return data_[N - 1]; } constexpr const_reference back() const { return data_[N - 1]; } constexpr value_type *data() noexcept { return data_; } constexpr const value_type *data() const noexcept { return data_; } // Modifiers constexpr void fill(const value_type &val) { for (std::size_t i = 0; i < N; ++i) data_[i] = val; } }; template <class T> class carray<T, 0> { public: // Container typdefs using value_type = T; using reference = value_type &; using const_reference = const value_type &; using pointer = value_type *; using const_pointer = const value_type *; using iterator = pointer; using const_iterator = const_pointer; using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; using size_type = std::size_t; using difference_type = std::ptrdiff_t; // Constructors constexpr carray(void) = default; }; } // namespace bits } // namespace frozen #endif
[ "qicosmos@163.com" ]
qicosmos@163.com
61aae709910b30a71006c7ec4723fd7be856cb4a
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/third_party/blink/renderer/modules/mediastream/transferred_media_stream_track_test.cc
5de414d505ad542c243c21098af0d5583c398d60
[ "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "MIT", "Apache-2.0" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
13,551
cc
// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/renderer/modules/mediastream/transferred_media_stream_track.h" #include "third_party/blink/public/web/web_heap.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_capabilities.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_constraints.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_settings.h" #include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/native_event_listener.h" #include "third_party/blink/renderer/modules/mediastream/mock_media_stream_track.h" namespace blink { namespace { using testing::_; using testing::Return; class TestObserver : public GarbageCollected<TestObserver>, public MediaStreamTrack::Observer { public: void TrackChangedState() override { observation_count_++; } int ObservationCount() const { return observation_count_; } private: int observation_count_ = 0; }; } // namespace class TransferredMediaStreamTrackTest : public testing::Test { public: void CustomSetUp(V8TestingScope& scope) { mock_impl_ = MakeGarbageCollected<MockMediaStreamTrack>(); transferred_track_ = MakeGarbageCollected<TransferredMediaStreamTrack>( scope.GetExecutionContext(), MediaStreamTrack::TransferredValues{ .kind = "video", .id = "", .label = "dummy", .enabled = true, .muted = false, .content_hint = WebMediaStreamTrack::ContentHintType::kNone, .ready_state = MediaStreamSource::kReadyStateLive}); } void TearDown() override { WebHeap::CollectAllGarbageForTesting(); } WeakPersistent<MockMediaStreamTrack> mock_impl_; Persistent<TransferredMediaStreamTrack> transferred_track_; }; class MockEventListener final : public NativeEventListener { public: MOCK_METHOD2(Invoke, void(ExecutionContext* executionContext, Event*)); }; TEST_F(TransferredMediaStreamTrackTest, InitialProperties) { V8TestingScope scope; CustomSetUp(scope); EXPECT_EQ(transferred_track_->kind(), "video"); EXPECT_EQ(transferred_track_->id(), ""); EXPECT_EQ(transferred_track_->label(), "dummy"); EXPECT_EQ(transferred_track_->enabled(), true); EXPECT_EQ(transferred_track_->muted(), false); EXPECT_EQ(transferred_track_->ContentHint(), ""); EXPECT_EQ(transferred_track_->readyState(), "live"); EXPECT_EQ(transferred_track_->GetReadyState(), MediaStreamSource::kReadyStateLive); EXPECT_EQ(transferred_track_->Ended(), false); EXPECT_EQ(transferred_track_->device(), absl::nullopt); } TEST_F(TransferredMediaStreamTrackTest, PropertiesInheritFromImplementation) { V8TestingScope scope; CustomSetUp(scope); const String kKind = "audio"; const String kId = "id"; const String kLabel = "label"; const bool kEnabled = false; const bool kMuted = true; const String kContentHint = "motion"; const String kReadyState = "ended"; const MediaStreamSource::ReadyState kReadyStateEnum = MediaStreamSource::kReadyStateEnded; const bool kEnded = true; base::UnguessableToken kSerializableSessionId = base::UnguessableToken::Create(); MediaStreamDevice kDevice = MediaStreamDevice(); kDevice.set_session_id(kSerializableSessionId); Persistent<MediaTrackCapabilities> capabilities = MediaTrackCapabilities::Create(); Persistent<MediaTrackConstraints> constraints = MediaTrackConstraints::Create(); Persistent<MediaTrackSettings> settings = MediaTrackSettings::Create(); Persistent<CaptureHandle> capture_handle = CaptureHandle::Create(); mock_impl_->SetKind(kKind); mock_impl_->SetId(kId); mock_impl_->SetLabel(kLabel); mock_impl_->setEnabled(kEnabled); mock_impl_->SetMuted(kMuted); mock_impl_->SetContentHint(kContentHint); mock_impl_->SetReadyState(kReadyState); mock_impl_->SetCapabilities(capabilities); mock_impl_->SetConstraints(constraints); mock_impl_->SetSettings(settings); mock_impl_->SetCaptureHandle(capture_handle); mock_impl_->SetReadyState(kReadyStateEnum); mock_impl_->SetComponent(nullptr); mock_impl_->SetEnded(kEnded); mock_impl_->SetDevice(kDevice); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); EXPECT_CALL(*mock_impl_, AddedEventListener(_, _)).Times(4); transferred_track_->SetImplementation(mock_impl_); EXPECT_EQ(transferred_track_->kind(), kKind); EXPECT_EQ(transferred_track_->id(), kId); EXPECT_EQ(transferred_track_->label(), kLabel); EXPECT_EQ(transferred_track_->enabled(), kEnabled); EXPECT_EQ(transferred_track_->muted(), kMuted); EXPECT_EQ(transferred_track_->ContentHint(), kContentHint); EXPECT_EQ(transferred_track_->readyState(), kReadyState); EXPECT_EQ(transferred_track_->GetReadyState(), kReadyStateEnum); EXPECT_EQ(transferred_track_->Ended(), kEnded); EXPECT_TRUE(transferred_track_->device().has_value()); EXPECT_EQ(transferred_track_->device()->serializable_session_id(), kSerializableSessionId); } TEST_F(TransferredMediaStreamTrackTest, EventsArePropagated) { V8TestingScope scope; CustomSetUp(scope); auto* mock_event_handler = MakeGarbageCollected<MockEventListener>(); transferred_track_->addEventListener(event_type_names::kEnded, mock_event_handler); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); EXPECT_CALL(*mock_impl_, AddedEventListener(_, _)).Times(4); transferred_track_->SetImplementation(mock_impl_); // Dispatching an event on the actual track underneath the // TransferredMediaStreamTrack should get propagated to be an event fired on // the TMST itself. EXPECT_CALL(*mock_event_handler, Invoke(_, _)); ASSERT_EQ(mock_impl_->DispatchEvent(*Event::Create(event_type_names::kEnded)), DispatchEventResult::kNotCanceled); } TEST_F(TransferredMediaStreamTrackTest, ConstraintsAppliedBeforeImplementation) { V8TestingScope scope; CustomSetUp(scope); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); transferred_track_->applyConstraints(scope.GetScriptState(), MediaTrackConstraints::Create()); EXPECT_CALL(*mock_impl_, AddedEventListener(_, _)).Times(4); EXPECT_CALL(*mock_impl_, applyConstraintsScriptState(_, _)).Times(0); EXPECT_CALL(*mock_impl_, applyConstraintsResolver(_, _)).Times(1); transferred_track_->SetImplementation(mock_impl_); } TEST_F(TransferredMediaStreamTrackTest, ConstraintsAppliedAfterImplementation) { V8TestingScope scope; CustomSetUp(scope); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); EXPECT_CALL(*mock_impl_, AddedEventListener(_, _)).Times(4); EXPECT_CALL(*mock_impl_, applyConstraintsScriptState(_, _)).Times(1); EXPECT_CALL(*mock_impl_, applyConstraintsResolver(_, _)).Times(0); transferred_track_->SetImplementation(mock_impl_); transferred_track_->applyConstraints(scope.GetScriptState(), MediaTrackConstraints::Create()); } TEST_F(TransferredMediaStreamTrackTest, ContentHintSetBeforeImplementation) { V8TestingScope scope; CustomSetUp(scope); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); const String kContentHint = "music"; transferred_track_->SetContentHint(kContentHint); ASSERT_EQ(transferred_track_->ContentHint(), ""); transferred_track_->SetImplementation(mock_impl_); EXPECT_EQ(transferred_track_->ContentHint(), kContentHint); } TEST_F(TransferredMediaStreamTrackTest, ContentHintSetAfterImplementation) { V8TestingScope scope; CustomSetUp(scope); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); const String kContentHint = "speech"; transferred_track_->SetImplementation(mock_impl_); ASSERT_TRUE(transferred_track_->ContentHint().IsNull()); transferred_track_->SetContentHint(kContentHint); EXPECT_EQ(transferred_track_->ContentHint(), kContentHint); } TEST_F(TransferredMediaStreamTrackTest, SetEnabledBeforeImplementation) { V8TestingScope scope; CustomSetUp(scope); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); transferred_track_->setEnabled(/*enabled=*/true); ASSERT_TRUE(transferred_track_->enabled()); ASSERT_FALSE(mock_impl_->enabled()); transferred_track_->SetImplementation(mock_impl_); EXPECT_TRUE(transferred_track_->enabled()); } TEST_F(TransferredMediaStreamTrackTest, SetEnabledAfterImplementation) { V8TestingScope scope; CustomSetUp(scope); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); ASSERT_TRUE(transferred_track_->enabled()); transferred_track_->SetImplementation(mock_impl_); EXPECT_FALSE(transferred_track_->enabled()); transferred_track_->setEnabled(/*enabled=*/true); EXPECT_TRUE(transferred_track_->enabled()); } TEST_F(TransferredMediaStreamTrackTest, MultipleSetterFunctions) { V8TestingScope scope; CustomSetUp(scope); EXPECT_CALL(*mock_impl_, applyConstraintsResolver(_, _)).Times(1); mock_impl_->SetExecutionContext(scope.GetExecutionContext()); transferred_track_->SetContentHint("speech"); transferred_track_->applyConstraints(scope.GetScriptState(), MediaTrackConstraints::Create()); transferred_track_->setEnabled(/*enabled=*/true); transferred_track_->SetContentHint("music"); transferred_track_->setEnabled(/*enabled=*/false); ASSERT_TRUE(transferred_track_->enabled()); ASSERT_EQ(transferred_track_->ContentHint(), ""); transferred_track_->SetImplementation(mock_impl_); EXPECT_EQ(transferred_track_->ContentHint(), "music"); EXPECT_FALSE(transferred_track_->enabled()); } TEST_F(TransferredMediaStreamTrackTest, SetImplementationTriggersObservers) { V8TestingScope scope; CustomSetUp(scope); TestObserver* testObserver = MakeGarbageCollected<TestObserver>(); transferred_track_->AddObserver(testObserver); transferred_track_->SetImplementation( MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>()); EXPECT_EQ(testObserver->ObservationCount(), 1); } TEST_F(TransferredMediaStreamTrackTest, ObserversAddedToImpl) { V8TestingScope scope; CustomSetUp(scope); transferred_track_->AddObserver(MakeGarbageCollected<TestObserver>()); MockMediaStreamTrack* mock_impl_ = MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>(); EXPECT_CALL(*mock_impl_, AddObserver(_)); transferred_track_->SetImplementation(mock_impl_); } TEST_F(TransferredMediaStreamTrackTest, CloneInitialProperties) { V8TestingScope scope; CustomSetUp(scope); MediaStreamTrack* clone = transferred_track_->clone(scope.GetExecutionContext()); EXPECT_EQ(clone->kind(), "video"); EXPECT_EQ(clone->id(), ""); EXPECT_EQ(clone->label(), "dummy"); EXPECT_EQ(clone->enabled(), true); EXPECT_EQ(clone->muted(), false); EXPECT_EQ(clone->ContentHint(), ""); EXPECT_EQ(clone->readyState(), "live"); EXPECT_EQ(clone->GetReadyState(), MediaStreamSource::kReadyStateLive); EXPECT_EQ(clone->Ended(), false); EXPECT_EQ(clone->device(), absl::nullopt); } TEST_F(TransferredMediaStreamTrackTest, CloneSetImplementation) { V8TestingScope scope; CustomSetUp(scope); TransferredMediaStreamTrack* clone = static_cast<TransferredMediaStreamTrack*>( transferred_track_->clone(scope.GetExecutionContext())); MockMediaStreamTrack* mock_impl_ = MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>(); EXPECT_CALL(*mock_impl_, clone(_)) .WillOnce(Return( MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>())); transferred_track_->SetImplementation(mock_impl_); EXPECT_TRUE(clone->HasImplementation()); } TEST_F(TransferredMediaStreamTrackTest, CloneMutationsReplayed) { V8TestingScope scope; CustomSetUp(scope); transferred_track_->setEnabled(false); TransferredMediaStreamTrack* clone = static_cast<TransferredMediaStreamTrack*>( transferred_track_->clone(scope.GetExecutionContext())); MockMediaStreamTrack* mock_impl_ = MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>(); EXPECT_CALL(*mock_impl_, clone(_)) .WillOnce(Return( MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>())); transferred_track_->SetImplementation(mock_impl_); EXPECT_EQ(transferred_track_->enabled(), false); EXPECT_EQ(clone->enabled(), false); } TEST_F(TransferredMediaStreamTrackTest, CloneDoesntIncludeLaterMutations) { V8TestingScope scope; CustomSetUp(scope); // Clone, the track, then disable the original. The clone should still be // enabled. transferred_track_->setEnabled(true); MediaStreamTrack* clone = transferred_track_->clone(scope.GetExecutionContext()); transferred_track_->setEnabled(false); MockMediaStreamTrack* mock_impl_ = MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>(); EXPECT_CALL(*mock_impl_, clone(_)).WillOnce([&](ExecutionContext*) { MockMediaStreamTrack* mock_clone_impl_ = MakeGarbageCollected<testing::NiceMock<MockMediaStreamTrack>>(); mock_clone_impl_->setEnabled(mock_impl_->enabled()); return mock_clone_impl_; }); transferred_track_->SetImplementation(mock_impl_); EXPECT_EQ(transferred_track_->enabled(), false); EXPECT_EQ(clone->enabled(), true); } } // namespace blink
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
6ceaf3f7e1e94eb931dc8182fdde4d95961580fa
bc13c9f60fe8e46d85d72892256cd3a26f8e2ad2
/tests/visNET.Test/connectionidentifierTest.cpp
de94cec11a79435d06ed010ced109b492b1c615b
[ "MIT" ]
permissive
UnknownException/visNET
8e00786d063b7e1444891e8388a18fa8aa68fa96
5682b4e03a3c6dfb74cf76e68054481df0a44c4b
refs/heads/master
2021-01-11T18:37:16.987830
2019-11-13T19:10:58
2019-11-13T19:10:58
79,582,995
5
1
MIT
2019-11-13T19:10:59
2017-01-20T17:56:01
C++
UTF-8
C++
false
false
1,229
cpp
#include "pch.h" TEST(Structure_ConnectionIdentifier, CreateConnectionIdentifier) { // Assign // Act visNET::ConnectionIdentifier id(123); // Assert EXPECT_EQ(123, id.getValue()); EXPECT_TRUE(id.isValid()); } TEST(Structure_ConnectionIdentifier, CreateInvalidConnectionIdentifier) { // Assign // Act visNET::ConnectionIdentifier id(0); // Assert EXPECT_FALSE(id.isValid()); } TEST(Structure_ConnectionIdentifier, IncreaseConnectionIdentifier) { // Assign visNET::ConnectionIdentifier id(100); // Act auto increasedId = id.increase(); // Assert EXPECT_EQ(100, id.getValue()); EXPECT_EQ(101, increasedId.getValue()); } TEST(Structure_ConnectionIdentifier, CompareEqualIdentifiers) { // Assign visNET::ConnectionIdentifier id1(234); visNET::ConnectionIdentifier id2(234); // Act bool areEqual = id1 == id2; bool areNotEqual = id1 != id2; // Assert EXPECT_TRUE(areEqual); EXPECT_FALSE(areNotEqual); } TEST(Structure_ConnectionIdentifier, CompareNotEqualIdentifiers) { // Assign visNET::ConnectionIdentifier id1(234); visNET::ConnectionIdentifier id2(9000); // Act bool areEqual = id1 == id2; bool areNotEqual = id1 != id2; // Assert EXPECT_FALSE(areEqual); EXPECT_TRUE(areNotEqual); }
[ "UnknownException@users.noreply.github.com" ]
UnknownException@users.noreply.github.com
0cd64f9a6a8935f36839bb26eb32307951563718
23941ea52cf485db9c5d4c45373e4aa2c535a568
/tests/unit/parallel/datapar_algorithms/count_datapar.cpp
d9a5b654b5adc86f1b5369401d22e9514392f7f1
[ "LicenseRef-scancode-free-unknown", "BSL-1.0" ]
permissive
bremerm31/hpx
29b42ed14110d3adbf1733f714bbdb6f78f21739
a9d22b8eb2e443d2e95991da9b1a621f94d4ebaa
refs/heads/master
2020-03-21T14:36:00.873062
2019-04-06T18:44:00
2019-04-06T18:44:00
138,664,981
0
0
BSL-1.0
2018-06-26T00:43:06
2018-06-26T00:43:06
null
UTF-8
C++
false
false
3,605
cpp
// Copyright (c) 2014 Grant Mercer // // 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) #include <hpx/hpx_init.hpp> #include <hpx/hpx.hpp> #include <hpx/include/datapar.hpp> #include <iostream> #include <string> #include <vector> #include "../algorithms/count_tests.hpp" //////////////////////////////////////////////////////////////////////////// template <typename IteratorTag> void test_count() { using namespace hpx::parallel; test_count(execution::dataseq, IteratorTag()); test_count(execution::datapar, IteratorTag()); test_count_async(execution::dataseq(execution::task), IteratorTag()); test_count_async(execution::datapar(execution::task), IteratorTag()); } void count_test() { test_count<std::random_access_iterator_tag>(); test_count<std::forward_iterator_tag>(); #if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT) test_count<std::input_iterator_tag>(); #endif } ////////////////////////////////////////////////////////////////////////////// template <typename IteratorTag> void test_count_exception() { using namespace hpx::parallel; test_count_exception(execution::dataseq, IteratorTag()); test_count_exception(execution::datapar, IteratorTag()); test_count_exception_async(execution::dataseq(execution::task), IteratorTag()); test_count_exception_async(execution::datapar(execution::task), IteratorTag()); } void count_exception_test() { test_count_exception<std::random_access_iterator_tag>(); test_count_exception<std::forward_iterator_tag>(); #if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT) test_count_exception<std::input_iterator_tag>(); #endif } ////////////////////////////////////////////////////////////////////////////// template <typename IteratorTag> void test_count_bad_alloc() { using namespace hpx::parallel; test_count_bad_alloc(execution::dataseq, IteratorTag()); test_count_bad_alloc(execution::datapar, IteratorTag()); test_count_bad_alloc_async(execution::dataseq(execution::task), IteratorTag()); test_count_bad_alloc_async(execution::datapar(execution::task), IteratorTag()); } void count_bad_alloc_test() { test_count_bad_alloc<std::random_access_iterator_tag>(); test_count_bad_alloc<std::forward_iterator_tag>(); #if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT) test_count_bad_alloc<std::input_iterator_tag>(); #endif } int hpx_main(boost::program_options::variables_map& vm) { unsigned int seed = (unsigned int)std::time(nullptr); if (vm.count("seed")) seed = vm["seed"].as<unsigned int>(); std::cout << "using seed: " << seed << std::endl; std::srand(seed); count_test(); count_exception_test(); count_bad_alloc_test(); return hpx::finalize(); } int main(int argc, char* argv[]) { // add command line option which controls the random number generator seed using namespace boost::program_options; options_description desc_commandline( "Usage: " HPX_APPLICATION_STRING " [options]"); desc_commandline.add_options() ("seed,s", value<unsigned int>(), "the random number generator seed to use for this run") ; // By default this test should run on all available cores std::vector<std::string> const cfg = { "hpx.os_threads=all" }; // Initialize and run HPX HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0, "HPX main exited with non-zero status"); return hpx::util::report_errors(); }
[ "hartmut.kaiser@gmail.com" ]
hartmut.kaiser@gmail.com
6a97f29f92e3d65bdeaf81e1f364233432bf3920
201c337ade624418a077514ca4db608b3d800886
/content/browser/back_forward_cache_browsertest.cc
a6ddde7c5b55be0cb7f43a79a31cdf4450f945ec
[ "BSD-3-Clause" ]
permissive
huningxin/chromium-src
78282bff41a04ab0e76298e82a5d097f0d9f9dd2
e7b9a67db6608d4358141193994194705dc95b0d
refs/heads/webml
2023-05-26T21:09:02.471210
2019-09-04T06:56:33
2019-09-26T01:48:14
217,235,865
0
1
BSD-3-Clause
2019-11-11T05:11:12
2019-10-24T07:16:04
null
UTF-8
C++
false
false
83,059
cc
// Copyright 2018 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/command_line.h" #include "base/task/post_task.h" #include "base/test/bind_test_util.h" #include "base/test/scoped_feature_list.h" #include "base/time/time.h" #include "components/network_session_configurator/common/network_switches.h" #include "content/browser/frame_host/back_forward_cache.h" #include "content/browser/frame_host/frame_tree_node.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/site_isolation_policy.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.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/navigation_handle_observer.h" #include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_throttle.h" #include "content/public/test/test_navigation_throttle_inserter.h" #include "content/public/test/test_utils.h" #include "content/public/test/url_loader_interceptor.h" #include "content/shell/browser/shell.h" #include "content/test/content_browser_test_utils_internal.h" #include "net/base/filename_util.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/controllable_http_response.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "services/device/public/cpp/test/scoped_geolocation_overrider.h" #include "testing/gmock/include/gmock/gmock.h" #include "third_party/blink/public/common/scheduler/web_scheduler_tracked_feature.h" using testing::Each; using testing::Not; namespace content { namespace { // Test about the BackForwardCache. class BackForwardCacheBrowserTest : public ContentBrowserTest { public: ~BackForwardCacheBrowserTest() override = default; protected: void SetUpCommandLine(base::CommandLine* command_line) override { base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kUseFakeUIForMediaStream); base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kIgnoreCertificateErrors); feature_list_.InitAndEnableFeatureWithParameters( features::kBackForwardCache, GetFeatureParams()); ContentBrowserTest::SetUpCommandLine(command_line); } virtual base::FieldTrialParams GetFeatureParams() { return {}; } void SetUpOnMainThread() override { host_resolver()->AddRule("*", "127.0.0.1"); ContentBrowserTest::SetUpOnMainThread(); } WebContentsImpl* web_contents() const { return static_cast<WebContentsImpl*>(shell()->web_contents()); } RenderFrameHostImpl* current_frame_host() { return web_contents()->GetFrameTree()->root()->current_frame_host(); } private: base::test::ScopedFeatureList feature_list_; }; // Match RenderFrameHostImpl* that are in the BackForwardCache. MATCHER(InBackForwardCache, "") { return arg->is_in_back_forward_cache(); } // Match RenderFrameDeleteObserver* which observed deletion of the RenderFrame. MATCHER(Deleted, "") { return arg->deleted(); } // Helper function to pass an initializer list to the EXPECT_THAT macro. This is // indeed the identity function. std::initializer_list<RenderFrameHostImpl*> Elements( std::initializer_list<RenderFrameHostImpl*> t) { return t; } // Execute a custom callback when two RenderFrameHosts are swapped. This is // useful for simulating race conditions happening when a page enters the // BackForwardCache and receive inflight messages sent when it wasn't frozen // yet. class RenderFrameHostChangedCallback : public WebContentsObserver { public: RenderFrameHostChangedCallback( WebContents* content, base::OnceCallback<void(RenderFrameHost*, RenderFrameHost*)> callback) : WebContentsObserver(content), callback_(std::move(callback)) {} private: // WebContentsObserver: void RenderFrameHostChanged(RenderFrameHost* old_host, RenderFrameHost* new_host) override { if (callback_) std::move(callback_).Run(old_host, new_host); } base::OnceCallback<void(RenderFrameHost*, RenderFrameHost*)> callback_; DISALLOW_COPY_AND_ASSIGN(RenderFrameHostChangedCallback); }; } // namespace // Navigate from A to B and go back. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, Basic) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); const url::Origin origin_a = url::Origin::Create(url_a); const url::Origin origin_b = url::Origin::Create(url_b); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_EQ(rfh_a->GetVisibilityState(), PageVisibilityState::kHidden); EXPECT_EQ(origin_a, rfh_a->GetLastCommittedOrigin()); EXPECT_EQ(origin_b, rfh_b->GetLastCommittedOrigin()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); EXPECT_EQ(rfh_b->GetVisibilityState(), PageVisibilityState::kVisible); // 3) Go back to A. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_EQ(origin_a, rfh_a->GetLastCommittedOrigin()); EXPECT_EQ(origin_b, rfh_b->GetLastCommittedOrigin()); EXPECT_EQ(rfh_a, current_frame_host()); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); EXPECT_EQ(rfh_a->GetVisibilityState(), PageVisibilityState::kVisible); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); EXPECT_EQ(rfh_b->GetVisibilityState(), PageVisibilityState::kHidden); } // Navigate from A to B and go back. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, BasicDocumentInitiated) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(ExecJs(shell(), JsReplace("location = $1;", url_b.spec()))); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // The two pages are using different BrowsingInstances. EXPECT_FALSE(rfh_a->GetSiteInstance()->IsRelatedSiteInstance( rfh_b->GetSiteInstance())); // 3) Go back to A. EXPECT_TRUE(ExecJs(shell(), "history.back();")); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_EQ(rfh_a, current_frame_host()); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); } // Navigate from back and forward repeatedly. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NavigateBackForwardRepeatedly) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // 3) Go back to A. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(rfh_a, current_frame_host()); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); // 4) Go forward to B. web_contents()->GetController().GoForward(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(rfh_b, current_frame_host()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // 5) Go back to A. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(rfh_a, current_frame_host()); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); // 6) Go forward to B. web_contents()->GetController().GoForward(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(rfh_b, current_frame_host()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); } // The current page can't enter the BackForwardCache if another page can script // it. This can happen when one document opens a popup using window.open() for // instance. It prevents the BackForwardCache from being used. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, WindowOpen) { // This test assumes cross-site navigation staying in the same // BrowsingInstance to use a different SiteInstance. Otherwise, it will // timeout at step 2). if (!SiteIsolationPolicy::UseDedicatedProcessesForAllSites()) return; ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A and open a popup. EXPECT_TRUE(NavigateToURL(shell(), url_a)); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); EXPECT_EQ(1u, rfh_a->GetSiteInstance()->GetRelatedActiveContentsCount()); Shell* popup = OpenPopup(rfh_a, url_a, ""); EXPECT_EQ(2u, rfh_a->GetSiteInstance()->GetRelatedActiveContentsCount()); // 2) Navigate to B. The previous document can't enter the BackForwardCache, // because of the popup. EXPECT_TRUE(ExecJs(rfh_a, JsReplace("location = $1;", url_b.spec()))); delete_observer_rfh_a.WaitUntilDeleted(); RenderFrameHostImpl* rfh_b = current_frame_host(); EXPECT_EQ(2u, rfh_b->GetSiteInstance()->GetRelatedActiveContentsCount()); // 3) Go back to A. The previous document can't enter the BackForwardCache, // because of the popup. RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_TRUE(ExecJs(rfh_b, "history.back();")); delete_observer_rfh_b.WaitUntilDeleted(); // 4) Make the popup drop the window.opener connection. It happens when the // user does an omnibox-initiated navigation, which happens in a new // BrowsingInstance. RenderFrameHostImpl* rfh_a_new = current_frame_host(); EXPECT_EQ(2u, rfh_a_new->GetSiteInstance()->GetRelatedActiveContentsCount()); EXPECT_TRUE(NavigateToURL(popup, url_b)); EXPECT_EQ(1u, rfh_a_new->GetSiteInstance()->GetRelatedActiveContentsCount()); // 5) Navigate to B again. In theory, the current document should be able to // enter the BackForwardCache. It can't, because the RenderFrameHost still // "remembers" it had access to the popup. See // RenderFrameHostImpl::scheduler_tracked_features(). RenderFrameDeletedObserver delete_observer_rfh_a_new(rfh_a_new); EXPECT_TRUE(ExecJs(rfh_a_new, JsReplace("location = $1;", url_b.spec()))); EXPECT_TRUE(WaitForLoadStop(web_contents())); delete_observer_rfh_a_new.WaitUntilDeleted(); // 6) Go back to A. The current document can finally enter the // BackForwardCache, because it is alone in its BrowsingInstance and has never // been related to any other document. RenderFrameHostImpl* rfh_b_new = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b_new(rfh_b_new); EXPECT_TRUE(ExecJs(rfh_b_new, "history.back();")); EXPECT_TRUE(WaitForLoadStop(web_contents())); EXPECT_FALSE(delete_observer_rfh_b_new.deleted()); EXPECT_TRUE(rfh_b_new->is_in_back_forward_cache()); } // Navigate from A(B) to C and go back. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, BasicIframe) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(b)")); const GURL url_c(embedded_test_server()->GetURL("c.com", "/title1.html")); // 1) Navigate to A(B). EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameHostImpl* rfh_b = rfh_a->child_at(0)->current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); // 2) Navigate to C. EXPECT_TRUE(NavigateToURL(shell(), url_c)); RenderFrameHostImpl* rfh_c = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_c(rfh_c); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); EXPECT_FALSE(rfh_c->is_in_back_forward_cache()); // 3) Go back to A(B). web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_FALSE(delete_observer_rfh_c.deleted()); EXPECT_EQ(rfh_a, current_frame_host()); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); EXPECT_TRUE(rfh_c->is_in_back_forward_cache()); } // Ensure flushing the BackForwardCache works properly. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, BackForwardCacheFlush) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); // 3) Flush A. web_contents()->GetController().back_forward_cache().Flush(); EXPECT_TRUE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); // 4) Go back to a new A. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_TRUE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); // 5) Flush B. web_contents()->GetController().back_forward_cache().Flush(); EXPECT_TRUE(delete_observer_rfh_b.deleted()); } // Check the visible URL in the omnibox is properly updated when restoring a // document from the BackForwardCache. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, VisibleURL) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Go to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); // 2) Go to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); // 3) Go back to A. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(url_a, web_contents()->GetVisibleURL()); // 4) Go forward to B. web_contents()->GetController().GoForward(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(url_b, web_contents()->GetVisibleURL()); } // Test only 1 document is kept in the at a time BackForwardCache. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, CacheSizeLimitedToOneDocumentPerTab) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); const GURL url_c(embedded_test_server()->GetURL("c.com", "/title1.html")); EXPECT_TRUE(NavigateToURL(shell(), url_a)); // BackForwardCache is empty. RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); EXPECT_TRUE(NavigateToURL(shell(), url_b)); // BackForwardCache contains only rfh_a. RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_TRUE(NavigateToURL(shell(), url_c)); // BackForwardCache contains only rfh_b. delete_observer_rfh_a.WaitUntilDeleted(); EXPECT_FALSE(delete_observer_rfh_b.deleted()); // If/when the cache size is increased, this can be tested iteratively, see // deleted code in: https://crrev.com/c/1782902. } // Test documents are evicted from the BackForwardCache at some point. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, CacheEvictionWithIncreasedCacheSize) { ASSERT_TRUE(embedded_test_server()->Start()); // The number of document the BackForwardCache can hold per tab. static constexpr size_t kBackForwardCacheLimit = 5; web_contents() ->GetController() .back_forward_cache() .set_cache_size_limit_for_testing(kBackForwardCacheLimit); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); EXPECT_TRUE(NavigateToURL(shell(), url_a)); // BackForwardCache size is 0. RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); EXPECT_TRUE(NavigateToURL(shell(), url_b)); // BackForwardCache size is 1. RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); for (size_t i = 2; i < kBackForwardCacheLimit; ++i) { EXPECT_TRUE(NavigateToURL(shell(), i % 2 ? url_b : url_a)); // After |i+1| navigations, |i| documents went into the BackForwardCache. // When |i| is greater than the BackForwardCache size limit, they are // evicted: EXPECT_EQ(i >= kBackForwardCacheLimit + 1, delete_observer_rfh_a.deleted()); EXPECT_EQ(i >= kBackForwardCacheLimit + 2, delete_observer_rfh_b.deleted()); } } // Similar to BackForwardCacheBrowserTest.SubframeSurviveCache* // Test case: a1(b2) -> c3 -> a1(b2) IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SubframeSurviveCache1) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(b)")); const GURL url_c(embedded_test_server()->GetURL("c.com", "/title1.html")); std::vector<RenderFrameDeletedObserver*> rfh_observer; // 1) Navigate to a1(b2). EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* a1 = current_frame_host(); RenderFrameHostImpl* b2 = a1->child_at(0)->current_frame_host(); RenderFrameDeletedObserver a1_observer(a1), b2_observer(b2); rfh_observer.insert(rfh_observer.end(), {&a1_observer, &b2_observer}); EXPECT_TRUE(ExecJs(b2, "window.alive = 'I am alive';")); // 2) Navigate to c3. EXPECT_TRUE(NavigateToURL(shell(), url_c)); RenderFrameHostImpl* c3 = current_frame_host(); RenderFrameDeletedObserver c3_observer(c3); rfh_observer.push_back(&c3_observer); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_THAT(Elements({a1, b2}), Each(InBackForwardCache())); EXPECT_THAT(c3, Not(InBackForwardCache())); // 3) Go back to a1(b2). web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_THAT(Elements({a1, b2}), Each(Not(InBackForwardCache()))); EXPECT_THAT(c3, InBackForwardCache()); // Even after a new IPC round trip with the renderer, b2 must still be alive. EXPECT_EQ("I am alive", EvalJs(b2, "window.alive")); EXPECT_FALSE(b2_observer.deleted()); } // Similar to BackForwardCacheBrowserTest.SubframeSurviveCache* // Test case: a1(b2) -> b3 -> a1(b2). IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SubframeSurviveCache2) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(b)")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); std::vector<RenderFrameDeletedObserver*> rfh_observer; // 1) Navigate to a1(b2). EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* a1 = current_frame_host(); RenderFrameHostImpl* b2 = a1->child_at(0)->current_frame_host(); RenderFrameDeletedObserver a1_observer(a1), b2_observer(b2); rfh_observer.insert(rfh_observer.end(), {&a1_observer, &b2_observer}); EXPECT_TRUE(ExecJs(b2, "window.alive = 'I am alive';")); // 2) Navigate to b3. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* b3 = current_frame_host(); RenderFrameDeletedObserver b3_observer(b3); rfh_observer.push_back(&b3_observer); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_THAT(Elements({a1, b2}), Each(InBackForwardCache())); EXPECT_THAT(b3, Not(InBackForwardCache())); // 3) Go back to a1(b2). web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_EQ(a1, current_frame_host()); EXPECT_THAT(Elements({a1, b2}), Each(Not(InBackForwardCache()))); EXPECT_THAT(b3, InBackForwardCache()); // Even after a new IPC round trip with the renderer, b2 must still be alive. EXPECT_EQ("I am alive", EvalJs(b2, "window.alive")); EXPECT_FALSE(b2_observer.deleted()); } // Similar to BackForwardCacheBrowserTest.tSubframeSurviveCache* // Test case: a1(b2) -> b3(a4) -> a1(b2) -> b3(a4) IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SubframeSurviveCache3) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(b)")); const GURL url_b(embedded_test_server()->GetURL( "b.com", "/cross_site_iframe_factory.html?b(a)")); std::vector<RenderFrameDeletedObserver*> rfh_observer; // 1) Navigate to a1(b2). EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* a1 = current_frame_host(); RenderFrameHostImpl* b2 = a1->child_at(0)->current_frame_host(); RenderFrameDeletedObserver a1_observer(a1), b2_observer(b2); rfh_observer.insert(rfh_observer.end(), {&a1_observer, &b2_observer}); EXPECT_TRUE(ExecJs(b2, "window.alive = 'I am alive';")); // 2) Navigate to b3(a4) EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* b3 = current_frame_host(); RenderFrameHostImpl* a4 = b3->child_at(0)->current_frame_host(); RenderFrameDeletedObserver b3_observer(b3), a4_observer(a4); rfh_observer.insert(rfh_observer.end(), {&b3_observer, &a4_observer}); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_THAT(Elements({a1, b2}), Each(InBackForwardCache())); EXPECT_THAT(Elements({b3, a4}), Each(Not(InBackForwardCache()))); EXPECT_TRUE(ExecJs(a4, "window.alive = 'I am alive';")); // 3) Go back to a1(b2). web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_EQ(a1, current_frame_host()); EXPECT_THAT(Elements({a1, b2}), Each(Not(InBackForwardCache()))); EXPECT_THAT(Elements({b3, a4}), Each(InBackForwardCache())); // Even after a new IPC round trip with the renderer, b2 must still be alive. EXPECT_EQ("I am alive", EvalJs(b2, "window.alive")); EXPECT_FALSE(b2_observer.deleted()); // 4) Go forward to b3(a4). web_contents()->GetController().GoForward(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_EQ(b3, current_frame_host()); EXPECT_THAT(Elements({a1, b2}), Each(InBackForwardCache())); EXPECT_THAT(Elements({b3, a4}), Each(Not(InBackForwardCache()))); // Even after a new IPC round trip with the renderer, a4 must still be alive. EXPECT_EQ("I am alive", EvalJs(a4, "window.alive")); EXPECT_FALSE(a4_observer.deleted()); } // Similar to BackForwardCacheBrowserTest.SubframeSurviveCache* // Test case: a1(b2) -> b3 -> a4 -> b5 -> a1(b2). IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SubframeSurviveCache4) { // Increase the cache size so that a1(b2) is still in the cache when we // reach b5. web_contents() ->GetController() .back_forward_cache() .set_cache_size_limit_for_testing(3); ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_ab(embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(b)")); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); std::vector<RenderFrameDeletedObserver*> rfh_observer; // 1) Navigate to a1(b2). EXPECT_TRUE(NavigateToURL(shell(), url_ab)); RenderFrameHostImpl* a1 = current_frame_host(); RenderFrameHostImpl* b2 = a1->child_at(0)->current_frame_host(); RenderFrameDeletedObserver a1_observer(a1), b2_observer(b2); rfh_observer.insert(rfh_observer.end(), {&a1_observer, &b2_observer}); EXPECT_TRUE(ExecJs(b2, "window.alive = 'I am alive';")); // 2) Navigate to b3. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* b3 = current_frame_host(); RenderFrameDeletedObserver b3_observer(b3); rfh_observer.push_back(&b3_observer); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_THAT(Elements({a1, b2}), Each(InBackForwardCache())); EXPECT_THAT(b3, Not(InBackForwardCache())); // 3) Navigate to a4. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* a4 = current_frame_host(); RenderFrameDeletedObserver a4_observer(a4); rfh_observer.push_back(&a4_observer); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); // 4) Navigate to b5 EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* b5 = current_frame_host(); RenderFrameDeletedObserver b5_observer(b5); rfh_observer.push_back(&b5_observer); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_THAT(Elements({a1, b2, b3, a4}), Each(InBackForwardCache())); EXPECT_THAT(b5, Not(InBackForwardCache())); // 3) Go back to a1(b2). web_contents()->GetController().GoToOffset(-3); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(a1, current_frame_host()); ASSERT_THAT(rfh_observer, Each(Not(Deleted()))); EXPECT_THAT(Elements({b3, a4, b5}), Each(InBackForwardCache())); EXPECT_THAT(Elements({a1, b2}), Each(Not(InBackForwardCache()))); // Even after a new IPC round trip with the renderer, b2 must still be alive. EXPECT_EQ("I am alive", EvalJs(b2, "window.alive")); EXPECT_FALSE(b2_observer.deleted()); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NavigationsAreFullyCommitted) { ASSERT_TRUE(embedded_test_server()->Start()); // During a navigation, the document being navigated *away from* can either be // deleted or stored into the BackForwardCache. The document being navigated // *to* can either be new or restored from the BackForwardCache. // // This test covers every combination: // // 1. Navigate to a cacheable page (()->A) // 2. Navigate to an uncacheable page (A->B) // 3. Go Back to a cached page (B->A) // 4. Navigate to a cacheable page (A->C) // 5. Go Back to a cached page (C->A) // // +-+-------+----------------+---------------+ // |#|nav | curr_document | dest_document | // +-+-------+----------------+---------------| // |1|(()->A)| N/A | new | // |2|(A->B) | cached | new | // |3|(B->A) | deleted | restored | // |4|(A->C) | cached | new | // |5|(C->A) | cached | restored | // +-+-------+----------------+---------------+ // // As part of these navigations we check that LastCommittedURL was updated, // to verify that the frame wasn't simply swapped in without actually // committing. const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL( "b.com", "/back_forward_cache/page_with_dedicated_worker.html")); const GURL url_c(embedded_test_server()->GetURL("c.com", "/title1.html")); // 1. Navigate to a cacheable page (A). EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2. Navigate from a cacheable page to an uncacheable page (A->B). EXPECT_TRUE(NavigateToURL(shell(), url_b)); EXPECT_EQ(web_contents()->GetLastCommittedURL(), url_b); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); // Page A should be in the cache. EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); // 3. Navigate from an uncacheable to a cached page page (B->A). web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(web_contents()->GetLastCommittedURL(), url_a); // Page B should be deleted (not cached). delete_observer_rfh_b.WaitUntilDeleted(); // 4. Navigate from a cacheable page to a cacheable page (A->C). EXPECT_TRUE(NavigateToURL(shell(), url_c)); EXPECT_EQ(web_contents()->GetLastCommittedURL(), url_c); RenderFrameHostImpl* rfh_c = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_c(rfh_c); // Page A should be in the cache. EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); // 5. Navigate from a cacheable page to a cached page (C->A). web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(web_contents()->GetLastCommittedURL(), url_a); // Page C should be in the cache. EXPECT_FALSE(delete_observer_rfh_c.deleted()); EXPECT_TRUE(rfh_c->is_in_back_forward_cache()); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, PageWithDedicatedWorkerNotCached) { ASSERT_TRUE(embedded_test_server()->Start()); EXPECT_TRUE(NavigateToURL( shell(), embedded_test_server()->GetURL( "a.com", "/back_forward_cache/page_with_dedicated_worker.html"))); RenderFrameDeletedObserver delete_observer_rfh_a(current_frame_host()); // Navigate away. EXPECT_TRUE(NavigateToURL( shell(), embedded_test_server()->GetURL("b.com", "/title1.html"))); // The page with the unsupported feature should be deleted (not cached). delete_observer_rfh_a.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SubframeWithDisallowedFeatureNotCached) { ASSERT_TRUE(embedded_test_server()->Start()); // Navigate to a page with an iframe that contains a dedicated worker. EXPECT_TRUE(NavigateToURL( shell(), embedded_test_server()->GetURL( "a.com", "/back_forward_cache/dedicated_worker_in_subframe.html"))); RenderFrameDeletedObserver delete_rfh_a(current_frame_host()); // Navigate away. EXPECT_TRUE(NavigateToURL( shell(), embedded_test_server()->GetURL("b.com", "/title1.html"))); // The page with the unsupported feature should be deleted (not cached). delete_rfh_a.WaitUntilDeleted(); } // Check that unload event handlers are not dispatched when the page goes // into BackForwardCache. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, ConfirmUnloadEventNotFired) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Set unload handler and check the title. EXPECT_TRUE(ExecJs(rfh_a, "document.title = 'loaded!';" "window.addEventListener('unload', () => {" " document.title = 'unloaded!';" "});")); { base::string16 title_when_loaded = base::UTF8ToUTF16("loaded!"); TitleWatcher title_watcher(web_contents(), title_when_loaded); EXPECT_EQ(title_watcher.WaitAndGetTitle(), title_when_loaded); } // 3) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // 4) Go back to A and check the title again. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(web_contents())); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_EQ(rfh_a, current_frame_host()); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); { base::string16 title_when_loaded = base::UTF8ToUTF16("loaded!"); TitleWatcher title_watcher(web_contents(), title_when_loaded); EXPECT_EQ(title_watcher.WaitAndGetTitle(), title_when_loaded); } } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfRecordingAudio) { ASSERT_TRUE(embedded_test_server()->Start()); // Navigate to an empty page. GURL url(embedded_test_server()->GetURL("/title1.html")); EXPECT_TRUE(NavigateToURL(shell(), url)); // Request for audio recording. EXPECT_EQ("success", EvalJs(current_frame_host(), R"( new Promise(resolve => { navigator.mediaDevices.getUserMedia({audio: true}) .then(m => { resolve("success"); }) .catch(() => { resolve("error"); }); }); )")); RenderFrameDeletedObserver deleted(current_frame_host()); // 2) Navigate away. shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); // The page was still recording audio when we navigated away, so it shouldn't // have been cached. deleted.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfSubframeRecordingAudio) { ASSERT_TRUE(embedded_test_server()->Start()); // Navigate to a page with an iframe. GURL url(embedded_test_server()->GetURL("/page_with_iframe.html")); EXPECT_TRUE(NavigateToURL(shell(), url)); RenderFrameHostImpl* rfh = current_frame_host(); // Request for audio recording from the subframe. EXPECT_EQ("success", EvalJs(rfh->child_at(0)->current_frame_host(), R"( new Promise(resolve => { navigator.mediaDevices.getUserMedia({audio: true}) .then(m => { resolve("success"); }) .catch(() => { resolve("error"); }); }); )")); RenderFrameDeletedObserver deleted(current_frame_host()); // 2) Navigate away. shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); // The page was still recording audio when we navigated away, so it shouldn't // have been cached. deleted.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfMainFrameStillLoading) { net::test_server::ControllableHttpResponse response(embedded_test_server(), "/main_document"); ASSERT_TRUE(embedded_test_server()->Start()); // 1) Navigate to a page that doesn't finish loading. GURL url(embedded_test_server()->GetURL("a.com", "/main_document")); TestNavigationManager navigation_manager(shell()->web_contents(), url); shell()->LoadURL(url); // The navigation starts. EXPECT_TRUE(navigation_manager.WaitForRequestStart()); navigation_manager.ResumeNavigation(); // The server sends the first part of the response and waits. response.WaitForRequest(); response.Send( "HTTP/1.1 200 OK\r\n" "Content-Type: text/html; charset=utf-8\r\n" "\r\n" "<html><body> ... "); // The navigation finishes while the body is still loading. navigation_manager.WaitForNavigationFinished(); RenderFrameDeletedObserver delete_observer_rfh_a(current_frame_host()); // 2) Navigate away. shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); // The page was still loading when we navigated away, so it shouldn't have // been cached. delete_observer_rfh_a.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfImageStillLoading) { ASSERT_TRUE(embedded_test_server()->Start()); // 1) Navigate to a page with an image that loads forever. GURL url(embedded_test_server()->GetURL("a.com", "/infinitely_loading_image.html")); TestNavigationManager navigation_manager(shell()->web_contents(), url); shell()->LoadURL(url); // The navigation finishes while the image is still loading. navigation_manager.WaitForNavigationFinished(); RenderFrameDeletedObserver delete_observer_rfh_a(current_frame_host()); // 2) Navigate away. shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); // The page was still loading when we navigated away, so it shouldn't have // been cached. delete_observer_rfh_a.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheLoadingSubframe) { net::test_server::ControllableHttpResponse response(embedded_test_server(), "/controlled"); ASSERT_TRUE(embedded_test_server()->Start()); // 1) Navigate to a page with an iframe that loads forever. GURL url(embedded_test_server()->GetURL( "a.com", "/back_forward_cache/controllable_subframe.html")); TestNavigationManager navigation_manager(shell()->web_contents(), url); shell()->LoadURL(url); // The navigation finishes while the iframe is still loading. navigation_manager.WaitForNavigationFinished(); // Wait for the iframe request to arrive, and leave it hanging with no // response. response.WaitForRequest(); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate away. shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); // The page should not have been added to cache, since it had a subframe that // was still loading at the time it was navigated away from. delete_observer_rfh_a.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheLoadingSubframeOfSubframe) { net::test_server::ControllableHttpResponse response(embedded_test_server(), "/controlled"); ASSERT_TRUE(embedded_test_server()->Start()); // 1) Navigate to a page with an iframe that contains yet another iframe, that // hangs while loading. GURL url(embedded_test_server()->GetURL( "a.com", "/back_forward_cache/controllable_subframe_of_subframe.html")); TestNavigationManager navigation_manager(shell()->web_contents(), url); shell()->LoadURL(url); // The navigation finishes while the iframe within an iframe is still loading. navigation_manager.WaitForNavigationFinished(); // Wait for the innermost iframe request to arrive, and leave it hanging with // no response. response.WaitForRequest(); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_rfh_a(rfh_a); // 2) Navigate away. shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); // The page should not have been added to the cache, since it had an iframe // that was still loading at the time it was navigated away from. delete_rfh_a.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfWebGL) { ASSERT_TRUE(embedded_test_server()->Start()); // 1) Navigate to a page with WebGL usage GURL url(embedded_test_server()->GetURL( "example.com", "/back_forward_cache/page_with_webgl.html")); EXPECT_TRUE(NavigateToURL(shell(), url)); RenderFrameDeletedObserver delete_observer_rfh_a(current_frame_host()); // 2) Navigate away. shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); // The page had an active WebGL context when we navigated away, // so it shouldn't have been cached. } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfHttpError) { ASSERT_TRUE(embedded_test_server()->Start()); GURL error_url(embedded_test_server()->GetURL("a.com", "/page404.html")); GURL url(embedded_test_server()->GetURL("b.com", "/title1.html")); // Navigate to an error page. EXPECT_TRUE(NavigateToURL(shell(), error_url)); EXPECT_EQ(net::HTTP_NOT_FOUND, current_frame_host()->last_http_status_code()); RenderFrameDeletedObserver delete_rfh_a(current_frame_host()); // Navigate away. EXPECT_TRUE(NavigateToURL(shell(), url)); // The page did not return 200 (OK), so it shouldn't have been cached. delete_rfh_a.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfPageUnreachable) { ASSERT_TRUE(embedded_test_server()->Start()); GURL error_url(embedded_test_server()->GetURL("a.com", "/empty.html")); GURL url(embedded_test_server()->GetURL("b.com", "/title1.html")); std::unique_ptr<URLLoaderInterceptor> url_interceptor = URLLoaderInterceptor::SetupRequestFailForURL(error_url, net::ERR_DNS_TIMED_OUT); // Start with a successful navigation to a document. EXPECT_TRUE(NavigateToURL(shell(), url)); EXPECT_EQ(net::HTTP_OK, current_frame_host()->last_http_status_code()); // Navigate to an error page. NavigationHandleObserver observer(shell()->web_contents(), error_url); EXPECT_FALSE(NavigateToURL(shell(), error_url)); EXPECT_TRUE(observer.is_error()); EXPECT_EQ(net::ERR_DNS_TIMED_OUT, observer.net_error_code()); EXPECT_EQ( GURL(kUnreachableWebDataURL), shell()->web_contents()->GetMainFrame()->GetSiteInstance()->GetSiteURL()); EXPECT_EQ(net::OK, current_frame_host()->last_http_status_code()); RenderFrameDeletedObserver delete_rfh_a(current_frame_host()); // Navigate away. EXPECT_TRUE(NavigateToURL(shell(), url)); // The page had a networking error, so it shouldn't have been cached. delete_rfh_a.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DisableBackforwardCacheForTesting) { ASSERT_TRUE(embedded_test_server()->Start()); // Disable the BackForwardCache. web_contents()->GetController().back_forward_cache().DisableForTesting( BackForwardCache::TEST_ASSUMES_NO_CACHING); // Navigate to a page that would normally be cacheable. NavigateToURL(shell(), embedded_test_server()->GetURL("a.com", "/title1.html")); RenderFrameDeletedObserver delete_observer_rfh_a(current_frame_host()); // Navigate away. NavigateToURL(shell(), embedded_test_server()->GetURL("b.com", "/title1.html")); // The page should be deleted (not cached). delete_observer_rfh_a.WaitUntilDeleted(); } // Navigate from A to B, then cause JavaScript execution on A, then go back. // Test the RenderFrameHost in the cache is evicted by JavaScript. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, EvictionOnJavaScriptExecution) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // 3) Execute JavaScript on A. // // Run JavaScript on a page in the back-forward cache. The page should be // evicted. As the frame is deleted, ExecJs returns false without executing. EXPECT_FALSE(ExecJs(rfh_a, "console.log('hi');")); // RenderFrameHost A is evicted from the BackForwardCache: delete_observer_rfh_a.WaitUntilDeleted(); } // Similar to BackForwardCacheBrowserTest.EvictionOnJavaScriptExecution. // Test case: A(B) -> C -> JS on B -> A(B) IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, EvictionOnJavaScriptExecutionIframe) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(b)")); GURL url_c(embedded_test_server()->GetURL("c.com", "/title1.html")); // 1) Navigate to A(B). EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameHostImpl* rfh_b = rfh_a->child_at(0)->current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); // 2) Navigate to C. EXPECT_TRUE(NavigateToURL(shell(), url_c)); RenderFrameHostImpl* rfh_c = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_c(rfh_c); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_FALSE(delete_observer_rfh_c.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); EXPECT_FALSE(rfh_c->is_in_back_forward_cache()); // 3) Execute JavaScript on B. // // As the frame is deleted, ExecJs returns false without executing. EXPECT_FALSE(ExecJs(rfh_b, "console.log('hi');")); // The A(B) page is evicted. So A and B are removed: delete_observer_rfh_a.WaitUntilDeleted(); delete_observer_rfh_b.WaitUntilDeleted(); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, EvictionOnJavaScriptExecutionInAnotherWorld) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Execute JavaScript on A in a new world. This ensures a new world. const int32_t kNewWorldId = content::ISOLATED_WORLD_ID_CONTENT_END + 1; EXPECT_TRUE(ExecJs(rfh_a, "console.log('hi');", EXECUTE_SCRIPT_DEFAULT_OPTIONS, kNewWorldId)); // 3) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // 4) Execute JavaScript on A in the new world. EXPECT_FALSE(ExecJs(rfh_a, "console.log('hi');", EXECUTE_SCRIPT_DEFAULT_OPTIONS, kNewWorldId)); // RenderFrameHost A is evicted from the BackForwardCache: delete_observer_rfh_a.WaitUntilDeleted(); } // Similar to BackForwardCacheBrowserTest.EvictionOnJavaScriptExecution, but // cause the race condition of eviction and restoring. // // ┌───────┐ ┌────────┐ // │Browser│ │Renderer│ // └───┬───┘ └───┬────┘ // (Store to the bfcache) │ // │ Freeze │ // │────────────────────────>│ // │ │ // (Restore from the bfcache) │ // │──┐ │ // │ │ │ // │EvictFromBackForwardCache│ // │<────────────────────────│ // │ │ │ // │ │ Resume │ // │ └─────────────────────>│ // ┌───┴───┐ ┌───┴────┐ // │Browser│ │Renderer│ // └───────┘ └────────┘ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, EvictionOnJavaScriptExecutionRace) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); EXPECT_TRUE(ExecJs(rfh_a, "window.foo = 'initial document'")); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // 3) Execute JavaScript on A when restoring A. // Execute JavaScript after committing but before swapping happens on the // renderer. RenderFrameHostChangedCallback host_changed_callback( web_contents(), base::BindOnce( [](RenderFrameHostImpl* rfh_a, RenderFrameDeletedObserver* delete_observer_rfh_a, RenderFrameHost* old_host, RenderFrameHost* new_host) { EXPECT_FALSE(delete_observer_rfh_a->deleted()); EXPECT_EQ(rfh_a, new_host); ExecuteScriptAsync(new_host, "console.log('hi');"); }, rfh_a, &delete_observer_rfh_a)); // Wait for two navigations to finish. The first one is the BackForwardCache // navigation, the other is the reload caused by the eviction. // // 1. BFcache navigation start. // 2. BFcache navigation commit & finish. // 3. Evict & reload start. // 4. Reload commit. // 5. Reload finish. // // Each item is a single task. TestNavigationObserver observer(web_contents(), 2 /* number of navigations */); observer.set_wait_event( TestNavigationObserver::WaitEvent::kNavigationFinished); web_contents()->GetController().GoBack(); observer.WaitForNavigationFinished(); // A is not destroyed. A is reloaded instead. EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); EXPECT_TRUE(rfh_b->is_in_back_forward_cache()); EXPECT_NE("initial document", EvalJs(rfh_a, "window.foo")); } // Tests the events are fired when going back from the cache. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, Events) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); EXPECT_TRUE(ExecJs(shell(), R"( window.testObservedEvents = []; let event_list = [ 'visibilitychange', 'pagehide', 'pageshow', 'freeze', 'resume', ]; for (event_name of event_list) { let result = event_name; window.addEventListener(event_name, event => { if (event.persisted) result +='.persisted'; window.testObservedEvents.push(result); }); document.addEventListener(event_name, () => window.testObservedEvents.push(result)); } )")); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // TODO(yuzus): Post message to the frozen page, and make sure that the // messages arrive after the page visibility events, not before them. // 3) Go back to A. Confirm that expected events are fired. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_EQ(rfh_a, current_frame_host()); // visibilitychange events are added twice per each because it is fired for // both window and document. EXPECT_EQ( ListValueOf("visibilitychange", "visibilitychange", "pagehide.persisted", "freeze", "resume", "pageshow.persisted", "visibilitychange", "visibilitychange"), EvalJs(shell(), "window.testObservedEvents")); } // Tests the events are fired when going back from the cache. // Same as: BackForwardCacheBrowserTest.Events, but with a document-initiated // navigation. This is a regression test for https://crbug.com/1000324 IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, EventsAfterDocumentInitiatedNavigation) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); EXPECT_TRUE(ExecJs(shell(), R"( window.testObservedEvents = []; let event_list = [ 'visibilitychange', 'pagehide', 'pageshow', 'freeze', 'resume', ]; for (event_name of event_list) { let result = event_name; window.addEventListener(event_name, event => { if (event.persisted) result +='.persisted'; window.testObservedEvents.push(result); }); document.addEventListener(event_name, () => window.testObservedEvents.push(result)); } )")); // 2) Navigate to B. EXPECT_TRUE(ExecJs(shell(), JsReplace("location = $1;", url_b.spec()))); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); // TODO(https://crbug.com/1000324): This shouldn't be deleted. Fix this bug // and re-enable the rest of this test. delete_observer_rfh_a.WaitUntilDeleted(); return; EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(rfh_b->is_in_back_forward_cache()); // TODO(yuzus): Post message to the frozen page, and make sure that the // messages arrive after the page visibility events, not before them. // 3) Go back to A. Confirm that expected events are fired. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_FALSE(delete_observer_rfh_b.deleted()); EXPECT_EQ(rfh_a, current_frame_host()); // visibilitychange events are added twice per each because it is fired for // both window and document. EXPECT_EQ( ListValueOf("visibilitychange", "visibilitychange", "pagehide.persisted", "freeze", "resume", "pageshow.persisted", "visibilitychange", "visibilitychange"), EvalJs(shell(), "window.testObservedEvents")); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NavigationCancelledAtWillStartRequest) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); // Cancel all navigation attempts. content::TestNavigationThrottleInserter throttle_inserter( shell()->web_contents(), base::BindLambdaForTesting( [&](NavigationHandle* handle) -> std::unique_ptr<NavigationThrottle> { auto throttle = std::make_unique<TestNavigationThrottle>(handle); throttle->SetResponse(TestNavigationThrottle::WILL_START_REQUEST, TestNavigationThrottle::SYNCHRONOUS, NavigationThrottle::CANCEL_AND_IGNORE); return throttle; })); // 3) Go back to A, which will be cancelled by the NavigationThrottle. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); // We should still be showing page B. EXPECT_EQ(rfh_b, current_frame_host()); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NavigationCancelledAtWillProcessResponse) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); // Cancel all navigation attempts. content::TestNavigationThrottleInserter throttle_inserter( shell()->web_contents(), base::BindLambdaForTesting( [&](NavigationHandle* handle) -> std::unique_ptr<NavigationThrottle> { auto throttle = std::make_unique<TestNavigationThrottle>(handle); throttle->SetResponse(TestNavigationThrottle::WILL_PROCESS_RESPONSE, TestNavigationThrottle::SYNCHRONOUS, NavigationThrottle::CANCEL_AND_IGNORE); return throttle; })); // 3) Go back to A, which will be cancelled by the NavigationThrottle. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); // We should still be showing page B. EXPECT_EQ(rfh_b, current_frame_host()); } // Test the race condition where a document is evicted from the BackForwardCache // while it is in the middle of being restored. // // ┌───────┐ ┌────────┐ // │Browser│ │Renderer│ // └───┬───┘ └───┬────┘ // (Freeze & store the cache) │ // │────────────────────────>│ // │ │ // (Navigate to cached document) │ // │──┐ │ // │ │ │ // │EvictFromBackForwardCache│ // │<────────────────────────│ // │ │ │ // │ x Navigation cancelled │ // │ and reissued │ // ┌───┴───┐ ┌───┴────┐ // │Browser│ │Renderer│ // └───────┘ └────────┘ // // When the eviction occurs, the in flight NavigationRequest to the cached // document should be reissued (cancelled and replaced by a normal navigation). IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, ReissuesNavigationIfEvictedDuringNavigation) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title2.html")); // 1) Navigate to page A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to page B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_NE(rfh_a, rfh_b); // 3) Start navigation to page A, and cause the document to be evicted during // the navigation. TestNavigationManager navigation_manager(shell()->web_contents(), url_a); web_contents()->GetController().GoBack(); EXPECT_TRUE(navigation_manager.WaitForRequestStart()); // Try to execute javascript, this will cause the document we are restoring to // get evicted from the cache. EXPECT_FALSE(ExecJs(rfh_a, "console.log('hi');")); // The navigation should get reissued, and ultimately finish. navigation_manager.WaitForNavigationFinished(); // rfh_a should have been deleted, and page A navigated to normally. EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_TRUE(delete_observer_rfh_a.deleted()); RenderFrameHostImpl* rfh_a2 = current_frame_host(); EXPECT_NE(rfh_a2, rfh_b); EXPECT_EQ(rfh_a2->GetLastCommittedURL(), url_a); } // Test that if the renderer process crashes while a document is in the // BackForwardCache, it gets evicted. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, EvictsFromCacheIfRendererProcessCrashes) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); RenderFrameHostImpl* rfh_b = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); EXPECT_FALSE(delete_observer_rfh_a.deleted()); // 3) Crash A's renderer process while it is in the cache. RenderProcessHost* process = rfh_a->GetProcess(); RenderProcessHostWatcher crash_observer( process, RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); rfh_a->GetProcess()->Shutdown(0); // The cached RenderFrameHost should be destroyed (not kept in the cache). crash_observer.Wait(); EXPECT_TRUE(delete_observer_rfh_a.deleted()); // rfh_b should still be the current frame. EXPECT_EQ(current_frame_host(), rfh_b); EXPECT_FALSE(delete_observer_rfh_b.deleted()); } // The test is simulating a race condition. The scheduler tracked features are // updated during the "freeze" event in a way that would have prevented the // document from entering the BackForwardCache in the first place. // // TODO(https://crbug.com/996267): The document should be evicted. // // ┌───────┐ ┌────────┐ // │browser│ │renderer│ // └───┬───┘ └────┬───┘ // (enter cache) │ // │ Freeze() │ // │─────────────────────────────>│ // │ (onfreeze) // │OnSchedulerTrackedFeaturesUsed│ // │<─────────────────────────────│ // │ (frozen) // │ │ // ┌───┴───┐ ┌────┴───┐ // │browser│ │renderer│ // └───────┘ └────────┘ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SchedulerTrackedFeaturesUpdatedWhileStoring) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // When the page will enter the BackForwardCache, just before being frozen, // use a feature that would have been prevented the document from being // cached. EXPECT_TRUE(ExecJs(rfh_a, R"( document.addEventListener('freeze', event => { let canvas = document.createElement('canvas'); document.body.appendChild(canvas); gl = canvas.getContext('webgl'); }); )")); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); // rfh_a should be evicted from the cache and destroyed. delete_observer_rfh_a.WaitUntilDeleted(); } // A fetch request starts during the "freeze" event. The current behavior is to // send the request anyway. However evicting the page from the BackForwardCache // might be a better behavior. // // ┌───────┐┌────────┐ ┌───────────────┐ // │browser││renderer│ │network service│ // └───┬───┘└───┬────┘ └───────┬───────┘ // │Freeze()│ │ // │───────>│ │ // │ (onfreeze) │ // │ │CreateLoaderAndStart│ // │ │───────────────────>│ // │ (frozen) │ // ┌───┴───┐┌───┴────┐ ┌───────┴───────┐ // │browser││renderer│ │network service│ // └───────┘└────────┘ └───────────────┘ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, FetchWhileStoring) { net::test_server::ControllableHttpResponse fetch_response( embedded_test_server(), "/fetch"); ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); // Use "fetch" immediately before being frozen. EXPECT_TRUE(ExecJs(rfh_a, R"( document.addEventListener('freeze', event => { my_fetch = fetch('/fetch', { keepalive: true}); }); )")); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); fetch_response.WaitForRequest(); fetch_response.Send(net::HTTP_OK, "text/html", "TheResponse"); fetch_response.Done(); // 3) Go back to A. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_EQ(current_frame_host(), rfh_a); // TODO(https://crbug.com/996267). Consider evicting the page or closing the // connection. EXPECT_EQ("TheResponse", EvalJs(rfh_a, R"( new Promise(async resolve => { if (my_fetch == undefined) { resolve("undefined"); return; } try { response = await my_fetch; text = await response.text(); resolve(text); } catch (exception) { resolve("error"); } }); )")); } // Only HTTP/HTTPS main document can enter the BackForwardCache. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, CacheHTTPDocumentOnly) { ASSERT_TRUE(embedded_test_server()->Start()); net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); https_server.AddDefaultHandlers(GetTestDataFilePath()); https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK); ASSERT_TRUE(https_server.Start()); GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL https_url(https_server.GetURL("a.com", "/title1.html")); GURL file_url = net::FilePathToFileURL(GetTestFilePath("", "title1.html")); GURL data_url = GURL("data:text/html,"); GURL blank_url = GURL(url::kAboutBlankURL); GURL webui_url = GetWebUIURL("gpu"); enum { STORED, DELETED }; struct { int expectation; GURL url; } test_cases[] = { // Only document with HTTP/HTTPS URLs are allowed to enter the // BackForwardCache. {STORED, http_url}, {STORED, https_url}, // Others aren't allowed. {DELETED, file_url}, {DELETED, data_url}, {DELETED, webui_url}, {DELETED, blank_url}, }; char hostname[] = "a.unique"; for (auto& test_case : test_cases) { SCOPED_TRACE(testing::Message() << std::endl << "expectation = " << test_case.expectation << std::endl << "url = " << test_case.url << std::endl); // 1) Navigate to. EXPECT_TRUE(NavigateToURL(shell(), test_case.url)); RenderFrameHostImpl* rfh = current_frame_host(); RenderFrameDeletedObserver delete_observer(rfh); // 2) Navigate away. hostname[0]++; GURL reset_url(embedded_test_server()->GetURL(hostname, "/title1.html")); EXPECT_TRUE(NavigateToURL(shell(), reset_url)); if (test_case.expectation == STORED) { EXPECT_FALSE(delete_observer.deleted()); EXPECT_TRUE(rfh->is_in_back_forward_cache()); continue; } // On Android, navigations to about:blank keeps the same RenderFrameHost. // Obviously, it can't enter the BackForwardCache, because it is still used // to display the current document. if (test_case.url == blank_url && !SiteIsolationPolicy::UseDedicatedProcessesForAllSites()) { EXPECT_FALSE(delete_observer.deleted()); EXPECT_FALSE(rfh->is_in_back_forward_cache()); EXPECT_EQ(rfh, current_frame_host()); continue; } delete_observer.WaitUntilDeleted(); } } namespace { void RegisterServiceWorker(RenderFrameHostImpl* rfh) { EXPECT_EQ("success", EvalJs(rfh, R"( let controller_changed_promise = new Promise(resolve_controller_change => { navigator.serviceWorker.oncontrollerchange = resolve_controller_change; }); new Promise(async resolve => { try { await navigator.serviceWorker.register( "./service-worker.js", {scope: "./"}) } catch (e) { resolve("error: registration has failed"); } await controller_changed_promise; if (navigator.serviceWorker.controller) { resolve("success"); } else { resolve("error: not controlled by service worker"); } }); )")); } } // namespace IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCachePagesWithServiceWorkers) { net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); https_server.AddDefaultHandlers(GetTestDataFilePath()); https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK); ASSERT_TRUE(https_server.Start()); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL( shell(), https_server.GetURL("a.com", "/back_forward_cache/empty.html"))); // Register a service worker. RegisterServiceWorker(current_frame_host()); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver deleted(rfh_a); // 2) Navigate away. shell()->LoadURL(https_server.GetURL("b.com", "/title1.html")); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); // The page is controlled by a service worker, so it shouldn't have been // cached. deleted.WaitUntilDeleted(); } class BackForwardCacheBrowserTestWithServiceWorkerEnabled : public BackForwardCacheBrowserTest { public: BackForwardCacheBrowserTestWithServiceWorkerEnabled() {} ~BackForwardCacheBrowserTestWithServiceWorkerEnabled() override {} protected: base::FieldTrialParams GetFeatureParams() override { return {{"service_worker_supported", "true"}}; } }; IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithServiceWorkerEnabled, CachedPagesWithServiceWorkers) { net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); https_server.AddDefaultHandlers(GetTestDataFilePath()); https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK); SetupCrossSiteRedirector(&https_server); ASSERT_TRUE(https_server.Start()); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL( shell(), https_server.GetURL("a.com", "/back_forward_cache/empty.html"))); // Register a service worker. RegisterServiceWorker(current_frame_host()); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver deleted(rfh_a); // 2) Navigate away. EXPECT_TRUE( NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html"))); EXPECT_FALSE(deleted.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); // 3) Go back to A. The navigation should be served from the cache. web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_FALSE(deleted.deleted()); EXPECT_EQ(rfh_a, current_frame_host()); } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, CachePagesWithBeacon) { constexpr char kKeepalivePath[] = "/keepalive"; net::test_server::ControllableHttpResponse keepalive(embedded_test_server(), kKeepalivePath); ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_ping(embedded_test_server()->GetURL("a.com", kKeepalivePath)); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); EXPECT_TRUE( ExecJs(shell(), JsReplace(R"(navigator.sendBeacon($1, "");)", url_ping))); // 2) Navigate to B. GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); EXPECT_TRUE(NavigateToURL(shell(), url_b)); // Ensure that the keepalive request is sent. keepalive.WaitForRequest(); // Don't actually send the response. // Page A should be in the cache. EXPECT_FALSE(delete_observer_rfh_a.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); } // Regression test for https://crbug.com/993337. IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NavigateToTwoPagesOnSameSite) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a1(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL url_a2(embedded_test_server()->GetURL("a.com", "/title2.html")); GURL url_b1(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A1. EXPECT_TRUE(NavigateToURL(shell(), url_a1)); // 2) Navigate to A2. EXPECT_TRUE(NavigateToURL(shell(), url_a2)); RenderFrameHostImpl* rfh_a2 = current_frame_host(); RenderFrameDeletedObserver delete_rfh_a2(current_frame_host()); // 3) Navigate to B1. EXPECT_TRUE(NavigateToURL(shell(), url_b1)); EXPECT_TRUE(rfh_a2->is_in_back_forward_cache()); RenderFrameHostImpl* rfh_b1 = current_frame_host(); // 4) Do a history navigation back to A1. web_contents()->GetController().GoToIndex(0); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_TRUE(rfh_b1->is_in_back_forward_cache()); // As a result, rfh_a2 is deleted. The history navigation tried to restore an // entry using the same BrowsingInstance. They both can't live together. delete_rfh_a2.WaitUntilDeleted(); } class GeolocationBackForwardCacheBrowserTest : public BackForwardCacheBrowserTest { protected: GeolocationBackForwardCacheBrowserTest() : geo_override_(0.0, 0.0) {} device::ScopedGeolocationOverrider geo_override_; }; // Test that a page which has queried geolocation in the past, but have no // active geolocation query, can be bfcached. IN_PROC_BROWSER_TEST_F(GeolocationBackForwardCacheBrowserTest, CacheAfterGeolocationRequest) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); // Query current position, and wait for the query to complete. EXPECT_EQ("received", EvalJs(rfh_a, R"( new Promise(resolve => { navigator.geolocation.getCurrentPosition(() => resolve('received')); }); )")); RenderFrameDeletedObserver deleted(rfh_a); // 2) Navigate away. EXPECT_TRUE(NavigateToURL(shell(), url_b)); // The page has no inflight geolocation request when we navigated away, // so it should have been cached. EXPECT_FALSE(deleted.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); } // Test that a page which has an inflight geolocation query can be bfcached, // and verify that the page does not observe any geolocation while the page // was inside bfcache. IN_PROC_BROWSER_TEST_F(GeolocationBackForwardCacheBrowserTest, CancelGeolocationRequestInFlight) { ASSERT_TRUE(embedded_test_server()->Start()); const GURL url_a(embedded_test_server()->GetURL("/title1.html")); const GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); RenderFrameHostImpl* rfh_a = current_frame_host(); // Continuously query current geolocation. EXPECT_TRUE(ExecJs(rfh_a, R"( window.longitude_log = []; window.err_log = []; window.wait_for_first_position = new Promise(resolve => { navigator.geolocation.watchPosition( pos => { window.longitude_log.push(pos.coords.longitude); resolve("resolved"); }, err => window.err_log.push(err) ); }) )")); geo_override_.UpdateLocation(0.0, 0.0); EXPECT_EQ("resolved", EvalJs(rfh_a, "window.wait_for_first_position")); // Pause resolving Geoposition queries to keep the request inflight. geo_override_.Pause(); geo_override_.UpdateLocation(1.0, 1.0); EXPECT_EQ(1u, geo_override_.GetGeolocationInstanceCount()); // 2) Navigate away. base::RunLoop loop_until_close; geo_override_.SetGeolocationCloseCallback(loop_until_close.QuitClosure()); RenderFrameDeletedObserver deleted(rfh_a); EXPECT_TRUE(NavigateToURL(shell(), url_b)); loop_until_close.Run(); // The page has no inflight geolocation request when we navigated away, // so it should have been cached. EXPECT_FALSE(deleted.deleted()); EXPECT_TRUE(rfh_a->is_in_back_forward_cache()); // Resume resolving Geoposition queries. geo_override_.Resume(); // We update the location while the page is BFCached, but this location should // not be observed. geo_override_.UpdateLocation(2.0, 2.0); // 3) Navigate back to A. // The location when navigated back can be observed geo_override_.UpdateLocation(3.0, 3.0); web_contents()->GetController().GoBack(); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_EQ(rfh_a, current_frame_host()); EXPECT_FALSE(rfh_a->is_in_back_forward_cache()); // Wait for an update after the user navigates back to A. EXPECT_EQ("resolved", EvalJs(rfh_a, R"( window.wait_for_position_after_resume = new Promise(resolve => { navigator.geolocation.watchPosition( pos => { window.longitude_log.push(pos.coords.longitude); resolve("resolved"); }, err => window.err_log.push(err) ); }) )")); EXPECT_LE(0, EvalJs(rfh_a, "longitude_log.indexOf(0.0)").ExtractInt()) << "Geoposition before the page is put into BFCache should be visible"; EXPECT_EQ(-1, EvalJs(rfh_a, "longitude_log.indexOf(1.0)").ExtractInt()) << "Geoposition while the page is put into BFCache should be invisible"; EXPECT_EQ(-1, EvalJs(rfh_a, "longitude_log.indexOf(2.0)").ExtractInt()) << "Geoposition while the page is put into BFCache should be invisible"; EXPECT_LT(0, EvalJs(rfh_a, "longitude_log.indexOf(3.0)").ExtractInt()) << "Geoposition when the page is restored from BFCache should be visible"; EXPECT_EQ(0, EvalJs(rfh_a, "err_log.length")) << "watchPosition API should have reported no errors"; } } // namespace content
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
a959fc4d03e5915293fd7ce8b7367c69239bdf1b
715023da006513f0dd09e5c4267d371b8ba4e4f6
/xray-svn-trunk/xr_3da/xrGame/CustomTimer_script.cpp
dcc5e1cba63d648b5eb0bf47257273126ca467a1
[]
no_license
tsnest/lost-alpha-dc-sources-master
5727d58878b1d4036e8f68df9780f3d078e89f21
fbb61af25da7e722d21492cbaebd6670d84e211c
refs/heads/main
2023-02-11T16:37:16.570856
2021-01-09T17:09:49
2021-01-09T17:09:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,186
cpp
#include "stdafx.h" #include "CustomTimer.h" #include "pch_script.h" #include "actor.h" using namespace luabind; CTimerCustomWrapper::CTimerCustomWrapper(CTimersManager *parent) : CTimerCustom(parent) { } CTimerCustomWrapper::~CTimerCustomWrapper() { } void CTimerCustomWrapper::load (IReader& stream) { luabind::call_member<void> (this, "load", stream); } void CTimerCustomWrapper::save (NET_Packet& stream) { luabind::call_member<void> (this, "save", stream); } void CTimerCustomWrapper::load_static (CTimerCustom* self, IReader& stream) { self->CTimerCustom::load (stream); } void CTimerCustomWrapper::save_static (CTimerCustom* self, NET_Packet& stream) { self->CTimerCustom::save (stream); } void CTimerCustomWrapper::execute (LPCSTR action) { luabind::call_member<void> (this, "execute", action); } void CTimerCustomWrapper::execute_static (CTimerCustom* self, LPCSTR action) { self->CTimerCustom::execute (action); } #pragma optimize("s",on) void CTimerCustom::script_register(lua_State *L) { module(L) [ class_<CTimerCustom, CTimerCustomWrapper>("Timer") .def(constructor<>()) .def("SetName", &CTimerCustom::SetName) .def("Name", &CTimerCustom::Name) .def("SetTimerType", &CTimerCustom::SetTimerType) .def("Time", &CTimerCustom::Time) .def("isGameTimer", &CTimerCustom::isGameTimer) .def("TimeElapsed", &CTimerCustom::TimeElapsed) .def("SetAction", &CTimerCustom::SetAction) .def_readwrite("day", &CTimerCustom::m_day) .def_readwrite("hour", &CTimerCustom::m_hour) .def_readwrite("min", &CTimerCustom::m_min) .def_readwrite("sec", &CTimerCustom::m_sec) .def_readwrite("ms", &CTimerCustom::m_ms) .def_readwrite("game_time", &CTimerCustom::m_game_time) .def("SetHUD", &CTimerCustom::SetHUD) .def("isHUD", &CTimerCustom::isHUD) .def("Valide", &CTimerCustom::valide) .def("save", &CTimerCustom::save, &CTimerCustomWrapper::save_static) .def("load", &CTimerCustom::load, &CTimerCustomWrapper::load_static) .def("execute", &CTimerCustom::execute, &CTimerCustomWrapper::execute_static) ]; }
[ "58656613+NikitaNikson@users.noreply.github.com" ]
58656613+NikitaNikson@users.noreply.github.com
b2b02a6b1242b0889a11b4c8ae1ae5ddb9f4d2de
a477611bff0c9d180688a08f28df422797b11021
/Mlib/Images/Optical_Flow.hpp
8fac3adfeda6e1b2facc3bb2052eaf07c46caafa
[]
no_license
orcilano/Mlib
64e67c44b6f2aabaefe4b2c0850cf4af7a88f825
8c17ca580c3e5e084a2f7114ff0ad5e36ce2a6f9
refs/heads/master
2023-06-23T22:05:53.374415
2021-07-11T14:08:03
2021-07-11T14:08:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
302
hpp
#pragma once #include <Mlib/Array/Array_Forward.hpp> namespace Mlib { void optical_flow( const Array<float>& image0, const Array<float>& image1, const Array<float>* image2, const ArrayShape& window_shape, float max_displacement, Array<float>& flow, Array<bool>& mask); }
[ "you@example.com" ]
you@example.com
0d4303396ab863e18451ac7bbdecde0108904297
cd416734b3ed2ce14e28bb342b8ddf3cad992f74
/tests/memory/host/host.cpp
320ad6fc334051dbb5c4f4ff361549f6155b2460
[ "MIT", "LicenseRef-scancode-generic-cla" ]
permissive
kernullist/openenclave
261b030ce36dde3cc065e45a58ad49e3a472f81f
c7c3edf41e7fcbfd6528a36eb0e06b4257979679
refs/heads/master
2020-03-31T20:19:28.489012
2018-10-11T00:39:41
2018-10-11T00:39:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,092
cpp
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include <cstdio> #include <thread> #include <vector> #include <openenclave/host.h> #include <openenclave/internal/error.h> #include <openenclave/internal/globals.h> #include <openenclave/internal/tests.h> #include "memory_u.h" #define ITERS 1024 #define BUFSIZE 1024 static void _malloc_basic_test(oe_enclave_t* enclave) { OE_TEST(test_malloc(enclave) == OE_OK); OE_TEST(test_calloc(enclave) == OE_OK); OE_TEST(test_realloc(enclave) == OE_OK); OE_TEST(test_memalign(enclave) == OE_OK); OE_TEST(test_posix_memalign(enclave) == OE_OK); } static void _malloc_stress_test_single_thread( oe_enclave_t* enclave, int thread_num) { OE_TEST(malloc_stress_test(enclave, thread_num) == OE_OK); } static void _malloc_stress_test_multithread(oe_enclave_t* enclave) { std::vector<std::thread> vec; for (int i = 0; i < 4; i++) vec.push_back( std::thread(_malloc_stress_test_single_thread, enclave, 4)); for (auto& t : vec) t.join(); } static void _malloc_stress_test(oe_enclave_t* enclave) { OE_TEST(init_malloc_stress_test(enclave) == OE_OK); _malloc_stress_test_single_thread(enclave, 1); _malloc_stress_test_multithread(enclave); } static void _malloc_boundary_test(oe_enclave_t* enclave, uint32_t flags) { /* Test host malloc boundary. */ buffer array[ITERS]; for (int i = 0; i < ITERS; i++) { array[i].buf = (unsigned char*)malloc(BUFSIZE); OE_TEST(array[i].buf != NULL); array[i].size = BUFSIZE; OE_TEST(test_host_boundaries(enclave, array[i]) == OE_OK); } for (int i = 0; i < ITERS; i++) free(array[i].buf); /* Test enclave boundaries. */ OE_TEST(test_enclave_boundaries(enclave) == OE_OK); /* Test enclave memory across boundaries. */ unsigned char stackbuf[BUFSIZE]; for (int i = 0; i < BUFSIZE; i++) stackbuf[i] = 1; unsigned char* heapbuf = (unsigned char*)malloc(BUFSIZE); OE_TEST(heapbuf != NULL); for (int i = 0; i < BUFSIZE; i++) heapbuf[i] = 2; buffer host_stack = {.buf = stackbuf, .size = sizeof(stackbuf)}; buffer host_heap = {.buf = heapbuf, .size = BUFSIZE}; buffer enclave_memory; buffer enclave_host_memory; OE_TEST( test_between_enclave_boundaries( enclave, host_stack, host_heap, &enclave_memory, &enclave_host_memory) == OE_OK); /* Abort page returns all 0xFFs when accessing. In simulation mode, it's * just regular memory. */ for (size_t i = 0; i < enclave_memory.size; i++) { if ((flags & OE_ENCLAVE_FLAG_SIMULATE)) OE_TEST(enclave_memory.buf[i] == 3); else OE_TEST(enclave_memory.buf[i] == 255); } for (size_t i = 0; i < enclave_host_memory.size; i++) OE_TEST(enclave_host_memory.buf[i] == 4); /* Ensure that enclave_memory still works when passed from the host. */ OE_TEST(try_input_enclave_pointer(enclave, enclave_memory) == OE_OK); /* Cleanup all memory. */ OE_TEST( free_boundary_memory(enclave, enclave_memory, enclave_host_memory) == OE_OK); free(heapbuf); } int main(int argc, const char* argv[]) { oe_result_t result; oe_enclave_t* enclave = NULL; if (argc != 2) { fprintf(stderr, "Usage: %s ENCLAVE_PATH\n", argv[0]); return 1; } const uint32_t flags = oe_get_create_flags(); result = oe_create_enclave( argv[1], OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave); if (result != OE_OK) oe_put_err("oe_create_enclave(): result=%u", result); printf("===Starting basic malloc test.\n"); _malloc_basic_test(enclave); printf("===Starting malloc stress test.\n"); _malloc_stress_test(enclave); printf("===Starting malloc boundary test.\n"); _malloc_boundary_test(enclave, flags); printf("===All tests pass.\n"); oe_terminate_enclave(enclave); return 0; }
[ "akagup@microsoft.com" ]
akagup@microsoft.com
f7304adc57d688a6a56ab1d719c45f2ab6a1dbf2
959efaa20ae3919d04f7db99fb4dd4327039dce5
/include/UDP/Visitor/detail/cincVisitor.inl
f4a570c8a5b07dc33d46d363a748d28978286b1d
[]
no_license
nilop-psn/UDP
3a02117e7b36e87c6256f08244a8c929278c46b0
b8f6eaa88e1b2ba7d2a4cd8072f278685240a770
refs/heads/master
2022-06-09T16:06:08.972879
2020-05-05T14:57:30
2020-05-05T14:57:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,389
inl
#pragma once namespace Ubpa { template<typename Impl, typename Ret, typename... Args> Ret Visitor<Ret(Impl::*)(void*, Args...)const>::Visit(size_t ID, void* ptr, Args... args) const { assert("ERROR::Visitor::Visit: unregistered" && IsRegistered(ID)); auto target = impl_callbacks.find(ID); if (target != impl_callbacks.end()) return target->second(detail::Visitor_::Accessor<Impl>::template cast(this), ptr, std::forward<Args>(args)...); else return this->callbacks.find(ID)->second(ptr, std::forward<Args>(args)...); } template<typename Impl, typename Ret, typename... Args> Ret Visitor<Ret(Impl::*)(void*, Args...)const>::Visit(void* ptr, Args... args) const { return Visit(reinterpret_cast<size_t>(vtable(ptr)), ptr, std::forward<Args>(args)...); } template<typename Impl, typename Ret, typename... Args> template<typename T> inline Ret Visitor<Ret(Impl::*)(void*, Args...)const>::Visit(T* ptr, Args... args) const { if constexpr (std::is_polymorphic_v<T>) return Visit(static_cast<void*>(ptr), std::forward<Args>(args)...); else return Visit(TypeID<T>, ptr, std::forward<Args>(args)...); } template<typename Impl, typename Ret, typename... Args> template<typename... Deriveds> void Visitor<Ret(Impl::*)(void*, Args...)const>::Register() { (RegisterOne<Deriveds>(), ...); } template<typename Impl, typename Ret, typename... Args> template<typename Derived> void Visitor<Ret(Impl::*)(void*, Args...)const>::RegisterOne() { impl_callbacks[detail::Visitor_::GetID<Derived>()] = [](const Impl* impl, void* ptr, Args... args) { return detail::Visitor_::Accessor<Impl>:: template run<Derived*, Ret>(impl, ptr, std::forward<Args>(args)...); }; } template<typename Impl, typename Ret, typename... Args> bool Visitor<Ret(Impl::*)(void*, Args...)const>::IsRegistered(size_t ID) const { return impl_callbacks.find(ID) != impl_callbacks.end() || this->callbacks.find(ID) != this->callbacks.end(); } template<typename Impl, typename Ret, typename... Args> template<typename T> bool Visitor<Ret(Impl::*)(void*, Args...)const>::IsRegistered() const { return IsRegistered(detail::Visitor_::GetID<T>()); } template<typename Impl, typename Ret, typename... Args> bool Visitor<Ret(Impl::*)(void*, Args...)const>::IsRegistered(const void* ptr) const { return IsRegistered(reinterpret_cast<size_t>(vtable(ptr))); } }
[ "641614112@qq.com" ]
641614112@qq.com
4cf35d24263a4847c3d73ad8487e49bb1f985a52
927dc022f088aa1ce76aa931c343ad44506a52af
/Mario/Mario/CoinTile.cpp
9aeed41605f9b9b5cb646b508a18f4bd6e9e882e
[]
no_license
ChoiDeborah/Super_Mario
b2021ef2f36b67289901c58eefed2ad25142f615
4516e3b6b4b151e0a83e17400ce77557114282be
refs/heads/master
2020-05-16T09:17:57.831031
2019-04-23T17:48:17
2019-04-23T17:48:17
182,942,042
0
0
null
null
null
null
UTF-8
C++
false
false
547
cpp
#include "stdafx.h" #include "CoinTile.h" CCoinTile::CCoinTile() { } CCoinTile::~CCoinTile() { } void CCoinTile::Initialize() { m_tInfo.fCX = 50.f; m_tInfo.fCY = 50.f; m_tInfo.fX = 200.f; m_tInfo.fY = 500.f; } int CCoinTile::Update() { if (m_bIsDead) return OBJ_DEAD; return OBJ_NOEVENT; } void CCoinTile::LateUpdate() { } void CCoinTile::Render(HDC hDC) { CObj::UpdateRect(); Rectangle(hDC, m_tRect.left, m_tRect.top, m_tRect.right, m_tRect.bottom); } void CCoinTile::Release() { }
[ "Administrator@JUSIN-20180206T" ]
Administrator@JUSIN-20180206T
95a1ebda1ac3b73221ac8fca5d2a71841b30f2ee
8782472a476a545b52f6fe1b8b9bb333eacc3359
/myregex.cpp
1419f5aad59c4ffcc0f8804ff1306f98d77e62ed
[]
no_license
lukenomo/Database-Coursework
f5090a1e42045f4e7a0f032f38e46d0d91154049
0907b56f8a2bf10d28ffc16d8836390cc94f3675
refs/heads/main
2023-05-22T10:15:17.006309
2021-06-16T08:08:25
2021-06-16T08:08:25
374,918,528
0
0
null
null
null
null
UTF-8
C++
false
false
646
cpp
#include "myregex.h" QRegExp creg::getRegularExpression(creg::RegularExpressions type) { QRegExp expression; switch (type) { case REGEXP_PASSWORD: expression.setPattern("(?=.*[0-9])(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z!@#$%^&*]{6,}"); break; case REGEXP_LOGIN: expression.setPattern("^[A-z0-9_-]{1,20}$"); break; case REGEXP_NAME: expression.setPattern("([A-z]{1}[a-z]{1,20})$"); break; case REGEXP_EMAIL: expression.setPattern("\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\\b"); break; case REGEXP_CITIZENSHIP: expression.setPattern("([A-z]{1}[a-z]{1,20})$"); break; } return expression; }
[ "lukenomo@gmail.com" ]
lukenomo@gmail.com
7d34a7a4834b544ad4f41386ff5b005311ae2c67
ddbb3a892d38a75902030b56fb6333752460bedc
/headers/AFood.hpp
7ae1f49892195e2cf79f56ebaac2c37d7990a1e1
[]
no_license
kiuKisas/Plazza
b7af893d0dc32761e51b3ad11930fbdcd02971a3
e18ca764ec1259d709ef66831e9def8c30522bde
refs/heads/master
2021-01-10T08:26:03.997078
2015-06-06T00:53:48
2015-06-06T00:53:48
36,955,582
0
3
null
null
null
null
UTF-8
C++
false
false
1,261
hpp
/* ** AFood.hpp for plazza in /home/nlequain/projets/tek2/cpp/cpp_plazza ** ** Made by nlequain ** Login <nlequain@epitech.net> ** ** Started on Fri Apr 17 19:09:50 2015 nlequain ** Last update Sun Apr 26 15:32:04 2015 nlequain */ #ifndef __AFOOD_HH__ # define __AFOOD_HH__ # include <unistd.h> # include <string> # include <iostream> # include "ADecorable.hpp" template <typename T> class AFood : public ADecorable<T> { private: std::string _name; int _cookingTime; public: virtual ~AFood() {} const std::string & getName() const { return this->_name; } int getCookingTime() const { int cookingTime = this->getThisCookingTime(); if (this->_decorator) cookingTime += this->_decorator->getCookingTime(); return cookingTime; } void cook(double timeMultiplier) const { usleep(this->getCookingTime() * timeMultiplier); } protected: AFood(const std::string & name, double cookingTime) : _name(name), _cookingTime(cookingTime * 1000000) {} virtual int getThisCookingTime() const { return this->_cookingTime; } }; template <typename T> std::ostream & operator<<(std::ostream & os, const AFood<T> & food) { os << food.getName(); if (food.getDecorator()) os << *(food.getDecorator()); return os; } #endif /* !__AFOOD_HH__ */
[ "kinoo_m@epitech.eu" ]
kinoo_m@epitech.eu
3b083016d3c508fd645da2c1b04094d99404ee0e
c6a98b8e273e69533009e5073a505508e3a0c2c5
/Problems/Codeforces/FretsOnFire.cpp
8cf791ad0d87ab9509c146265d44fb68da829625
[]
no_license
BenjaminRubio/CompetitiveProgramming
5c72a9b803e66e194fd7fe8a26d0d81d14a7fc5c
33ba1125a2eb5ba4d6f9cbc8522c92432bc92b0d
refs/heads/master
2023-06-08T19:43:44.069793
2023-05-27T18:53:32
2023-05-27T18:53:32
176,643,093
16
5
null
null
null
null
UTF-8
C++
false
false
678
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)n; i++) int N, Q; ll l, r; vector<ll> S, D, acc; int main() { cin >> N; S.resize(N); rep(i, N) cin >> S[i]; sort(S.begin(), S.end()); D.resize(N - 1); rep(i, N - 1) D[i] = S[i + 1] - S[i]; sort(D.begin(), D.end()); acc = D; rep(i, N - 2) acc[i + 1] = acc[i + 1] + acc[i]; cin >> Q; while (Q--) { cin >> l >> r; r = r - l + 1; int p = lower_bound(D.begin(), D.end(), r) - D.begin(); ll ans = r * (N - p) + (p ? acc[p - 1] : 0); cout << ans << ' '; } cout << '\n'; }
[ "berubio@uc.cl" ]
berubio@uc.cl
d493b95e8493d4c3dc03d7d4b8ee29771400cf93
b137f5bb9d3b77266f46073bc2da72bf445854d6
/sol1B_C.cpp
69914b276a541602cd84bdf1b682e106a423423c
[]
no_license
killzdesu/cpp-archive
307fa05be71618f2a64b3c852078eef88696da86
70f62a7bbc2f3398ac28818849841f18b1145f91
refs/heads/master
2023-04-08T20:16:57.460572
2021-04-20T06:23:31
2021-04-20T06:23:31
359,705,314
0
0
null
null
null
null
UTF-8
C++
false
false
2,011
cpp
#include <cstdio> #include <numeric> #include <iostream> #include <vector> #include <set> #include <cstring> #include <string> #include <map> #include <cmath> #include <ctime> #include <algorithm> #include <bitset> #include <queue> #include <sstream> #include <deque> using namespace std; #define mp make_pair #define pb push_back #define rep(i,n) for(int i = 0; i < (n); i++) #define re return #define fi first #define se second #define sz(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end() #define sqr(x) ((x) * (x)) #define sqrt(x) sqrt(abs(x)) #define y0 y3487465 #define y1 y8687969 #define fill(x,y) memset(x,y,sizeof(x)) #define prev PREV typedef vector<int> vi; typedef long long ll; typedef long double ld; typedef double D; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef vector<vi> vvi; template<class T> T abs(T x) { re x > 0 ? x : -x; } int n; int m; int d[500000]; int t[500000]; int was[500000]; set<pair<ll, int> > all; int main () { //freopen("C:\\Users\\Jui\\Downloads\\C-small-1-attempt0.in", "r", stdin); int tt; cin >> tt; for (int it = 1; it <= tt; it++) { scanf ("%d", &n); int o = 0; for (int i = 0; i < n; i++) { int d, h, m; scanf ("%d%d%d", &d, &h, &m); for (int j = 0; j < h; j++) { ::d[o] = d; ::t[o] = m + j; was[o] = 0; o++; } } all.clear (); int cur = o, ans = o; for (int i = 0; i < o; i++) all.insert (mp ((ll)(360 - d[i]) * t[i], i)); ll last = 0; while (cur <= 2 * o) { ll x = all.begin ()->fi; int y = all.begin ()->se; all.erase (all.begin ()); if (x > last) ans = min (ans, cur); last = x; if (was[y]) cur++; else cur--; // printf ("%I64d %d : %d %d\n", x, y, cur, was[y]); was[y] = 1; all.insert (mp (x + (ll)360 * t[y], y)); } cout << "Case #" << it << ": " << ans; cout << endl; fprintf (stderr, "%d / %d = %.2f | %.2f\n", it, tt, (double)clock () / CLOCKS_PER_SEC, ((double)clock () / it * tt) / CLOCKS_PER_SEC); } return 0; }
[ "killzdesu@gmail.com" ]
killzdesu@gmail.com