hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
57dc91b93565abdfc2ee7dc1e690cd091ca2cbaf | 2,302 | cpp | C++ | InfoBar.cpp | NamaChikara/Minesweeper_Cpp | 1edfc0c886d21dc172c5c387978d5212cf81fa1f | [
"MIT"
] | null | null | null | InfoBar.cpp | NamaChikara/Minesweeper_Cpp | 1edfc0c886d21dc172c5c387978d5212cf81fa1f | [
"MIT"
] | null | null | null | InfoBar.cpp | NamaChikara/Minesweeper_Cpp | 1edfc0c886d21dc172c5c387978d5212cf81fa1f | [
"MIT"
] | null | null | null | #include "InfoBar.h"
InfoBar::InfoBar(float swidth, float yloc, float height,
std::string font_file)
: screen_width{ swidth }, y_offset{ yloc }, info_height{ height }
{
if (!font.loadFromFile(font_file))
{
std::cerr << "Could not load " << font_file << " font file." << std::endl;
}
// note: the string values of these text boxes is set in main.cpp
// the locations are also set in main.cpp via InfoBar::update_location();
clock_text.setFont(font);
clock_text.setCharacterSize(30);
clock_text.setFillColor(sf::Color(255,255,255));
bomb_text.setFont(font);
bomb_text.setCharacterSize(30);
bomb_text.setFillColor(sf::Color(255,255,255));
mistake_text.setFont(font);
mistake_text.setCharacterSize(30);
mistake_text.setFillColor(sf::Color(255,255,255));
}
void InfoBar::update_text(sf::Clock clock, const Board& m_board)
{
int mistakes_made = m_board.num_mistakes();
std::string m_text = "Mistakes: " + std::to_string(mistakes_made);
mistake_text.setString(m_text);
int bombs_unmarked = m_board.num_bombs() - m_board.num_marked() - mistakes_made;
std::string b_text = "Unmarked: " + std::to_string(bombs_unmarked);
bomb_text.setString(b_text);
sf::Time elapsed = clock.getElapsedTime();
int time = (int)elapsed.asSeconds();
clock_text.setString(std::to_string(time));
}
void InfoBar::update_location()
{
// x spacing first
float clock_width = clock_text.getGlobalBounds().width;
float bomb_width = bomb_text.getGlobalBounds().width;
float mistake_width = mistake_text.getGlobalBounds().width;
float spacing = (screen_width - clock_width - bomb_width - mistake_width) / 4;
// y spacing
float y_set = y_offset + (info_height - bomb_text.getGlobalBounds().height) / 2;
float clock_x = spacing;
clock_text.setPosition(sf::Vector2f(clock_x, y_set));
float bomb_x = 2 * spacing + clock_width;
bomb_text.setPosition(sf::Vector2f(bomb_x, y_set));
float mistake_x = 3 * spacing + clock_width + bomb_width;
mistake_text.setPosition(sf::Vector2f(mistake_x, y_set));
}
void InfoBar::update(sf::Clock clock, const Board& m_board,
sf::RenderTarget& target)
{
update_text(clock, m_board);
update_location();
}
void InfoBar::draw(sf::RenderTarget& target, sf::RenderStates) const
{
target.draw(clock_text);
target.draw(bomb_text);
target.draw(mistake_text);
} | 30.289474 | 81 | 0.739357 | NamaChikara |
57e0bc11489f3ab79808b051e9cb3a628f3e4dae | 9,818 | cpp | C++ | src/sqp.cpp | nuft/sqp_solver | 7d059a717bb649d63ab27e4d3ec967b42a8b071c | [
"MIT"
] | 40 | 2019-10-16T08:05:43.000Z | 2022-03-08T04:51:20.000Z | src/sqp.cpp | likping/sqp_solver | 7d059a717bb649d63ab27e4d3ec967b42a8b071c | [
"MIT"
] | 1 | 2019-12-19T19:12:42.000Z | 2020-03-16T09:18:04.000Z | src/sqp.cpp | likping/sqp_solver | 7d059a717bb649d63ab27e4d3ec967b42a8b071c | [
"MIT"
] | 10 | 2019-10-18T17:47:05.000Z | 2022-03-28T07:07:22.000Z | #include <Eigen/Eigenvalues>
#include <cmath>
#include <iostream>
#include <solvers/bfgs.hpp>
#include <solvers/sqp.hpp>
#ifndef SOLVER_ASSERT
#define SOLVER_ASSERT(x) eigen_assert(x)
#endif
namespace sqp {
template <typename T>
SQP<T>::SQP() {
// TODO(mi): Performance strongly depends on QP solver settings, which is bad.
qp_solver_.settings().warm_start = true;
qp_solver_.settings().check_termination = 10;
qp_solver_.settings().eps_abs = 1e-4;
qp_solver_.settings().eps_rel = 1e-4;
qp_solver_.settings().max_iter = 100;
qp_solver_.settings().adaptive_rho = true;
qp_solver_.settings().adaptive_rho_interval = 50;
qp_solver_.settings().alpha = 1.6;
}
template <typename T>
void SQP<T>::solve(Problem& prob, const Vector& x0, const Vector& lambda0) {
x_ = x0;
lambda_ = lambda0;
run_solve(prob);
}
template <typename T>
void SQP<T>::solve(Problem& prob) {
const int nx = prob.num_var;
const int nc = prob.num_constr;
x_.setZero(nx);
lambda_.setZero(nc);
run_solve(prob);
}
template <typename T>
void SQP<T>::run_solve(Problem& prob) {
Vector p; // search direction
Vector p_lambda; // dual search direction
Scalar alpha; // step size
const int nx = prob.num_var;
const int nc = prob.num_constr;
p.resize(nx);
p_lambda.resize(nc);
step_prev_.resize(nx);
grad_L_.resize(nx);
delta_grad_L_.resize(nx);
Hess_.resize(nx, nx);
grad_obj_.resize(nx);
Jac_constr_.resize(nc, nx);
constr_.resize(nc);
l_.resize(nc);
u_.resize(nc);
info_.qp_solver_iter = 0;
if (settings_.iteration_callback) {
settings_.iteration_callback(*this);
}
int& iter = info_.iter;
for (iter = 1; iter <= settings_.max_iter; iter++) {
// Solve QP
solve_qp(prob, p, p_lambda);
p_lambda -= lambda_;
alpha = line_search(prob, p);
// take step
x_ = x_ + alpha * p;
lambda_ = lambda_ + alpha * p_lambda;
// update step info
step_prev_ = alpha * p;
primal_step_norm_ = alpha * p.template lpNorm<Eigen::Infinity>();
dual_step_norm_ = alpha * p_lambda.template lpNorm<Eigen::Infinity>();
if (settings_.iteration_callback) {
settings_.iteration_callback(*this);
}
if (termination_criteria(x_, prob)) {
info_.status = SOLVED;
break;
}
}
if (iter > settings_.max_iter) {
info_.status = MAX_ITER_EXCEEDED;
}
}
template <typename Matrix>
bool is_posdef_eigen(Matrix H) {
Eigen::EigenSolver<Matrix> eigensolver(H);
for (int i = 0; i < eigensolver.eigenvalues().rows(); i++) {
double v = eigensolver.eigenvalues()(i).real();
if (v <= 0) {
return false;
}
}
return true;
}
template <typename Matrix>
bool is_posdef(Matrix H) {
Eigen::LLT<Matrix> llt(H);
if (llt.info() == Eigen::NumericalIssue) {
return false;
}
return true;
}
template <typename T>
bool SQP<T>::termination_criteria(const Vector& x, Problem& prob) {
if (primal_step_norm_ <= settings_.eps_prim && dual_step_norm_ <= settings_.eps_dual &&
max_constraint_violation(x, prob) <= settings_.eps_prim) {
return true;
}
return false;
}
template <typename Derived>
inline bool is_nan(const Eigen::MatrixBase<Derived>& x) {
// return ((x.array() == x.array())).all();
return x.array().isNaN().any();
}
template <typename T>
void SQP<T>::solve_qp(Problem& prob, Vector& step, Vector& lambda) {
/* QP from linearized NLP:
* minimize 0.5 x'.P.x + q'.x
* subject to l <= A.x + b <= u
*
* with:
* P Hessian of Lagrangian
* q objective gradient
* A,b linearized constraint at current iterate
* l,u constraint bounds
*
* transform to:
* minimize 0.5 x'.P.x + q'.x
* subject to l <= A.x <= u
*
* Where the constraint bounds l,u set to l=u for equality constraints or
* set to +/-INFINITY if unbounded.
*/
prob.objective_linearized(x_, grad_obj_, obj_);
prob.constraint_linearized(x_, Jac_constr_, constr_, l_, u_);
delta_grad_L_ = -grad_L_;
grad_L_ = grad_obj_ + Jac_constr_.transpose() * lambda_;
// BFGS update
if (info_.iter == 1) {
Hess_.setIdentity();
} else {
delta_grad_L_ += grad_L_; // delta_grad_L_ = grad_L_prev - grad_L
BFGS_update(Hess_, step_prev_, delta_grad_L_);
}
if (!is_posdef(Hess_)) {
std::cout << "Hessian not positive definite\n";
Scalar tau = 1e-3;
Vector v = Vector(prob.num_var);
while (!is_posdef(Hess_)) {
v.setConstant(tau);
Hess_ += v.asDiagonal();
tau *= 10;
}
}
if (is_nan(Hess_)) {
std::cout << "Hessian is NaN\n";
}
SOLVER_ASSERT(is_posdef(Hess_));
SOLVER_ASSERT(!is_nan(Hess_));
// Constraints
// from l <= A.x + b <= u
// to l-b <= A.x <= u-b
Vector l = l_ - constr_;
Vector u = u_ - constr_;
Matrix& A = Jac_constr_;
Matrix& P = Hess_;
Vector& q = grad_obj_;
// solve the QP
run_solve_qp(P, q, A, l, u, step, lambda);
if (settings_.second_order_correction) {
second_order_correction(prob, step, lambda);
}
// TODO:
// B is not convex then use grad_L as step direction
// i.e. fallback to steepest descent of Lagrangian
}
template <typename T>
bool SQP<T>::run_solve_qp(const Matrix& P, const Vector& q, const Matrix& A, const Vector& l,
const Vector& u, Vector& prim, Vector& dual) {
qp_solver::QuadraticProblem<Scalar> qp_;
qp_.P = &P;
qp_.q = &q;
qp_.A = &A;
qp_.l = &l;
qp_.u = &u;
qp_solver_.setup(qp_);
qp_solver_.solve(qp_);
info_.qp_solver_iter += qp_solver_.info().iter;
if (qp_solver_.info().status == qp_solver::NUMERICAL_ISSUES) {
std::cout << "QPSolver NUMERICAL_ISSUES\n";
return false;
}
// if (qp_solver_.info().status == qp_solver::MAX_ITER_EXCEEDED) {
// std::cout << "QPSolver MAX_ITER_EXCEEDED\n";
// return false;
// }
prim = qp_solver_.primal_solution();
dual = qp_solver_.dual_solution();
SOLVER_ASSERT(!is_nan(prim));
SOLVER_ASSERT(!is_nan(dual));
return true;
}
template <typename T>
void SQP<T>::second_order_correction(Problem& prob, Vector& p, Vector& lambda) {
// Scalar mu, constr_l1, phi_l1;
// constr_l1 = constraint_norm(constr_, l_, u_);
// mu = (grad_obj_.dot(p) + 0.5 * p.dot(Hess_ * p)) / ((1 - settings_.rho) * constr_l1);
// phi_l1 = obj_ + mu * constr_l1;
// Scalar obj_step, constr_l1_step, phi_l1_step;
// Vector x_step = x_ + p;
// prob.objective(x_step, obj_step);
// constr_l1_step = constraint_norm(x_step, prob);
// phi_l1_step = obj_step + mu * constr_l1_step;
// printf("phi_l1_step %f phi_l1 %f constr_l1_step %f constr_l1 %f\n", phi_l1_step, phi_l1,
// constr_l1_step, constr_l1);
// if (phi_l1_step >= phi_l1 && constr_l1_step >= constr_l1) {
{
Vector x_step = x_ + p;
Vector constr_step(constr_.rows());
prob.constraint(x_step, constr_step, l_, u_);
Matrix& A = Jac_constr_;
Matrix& P = Hess_;
Vector& q = grad_obj_;
Vector d = constr_step - A * p;
Vector l = l_ - d;
Vector u = u_ - d;
// TODO: only l and u change, possible to update QP solver more efficiently
run_solve_qp(P, q, A, l, u, p, lambda);
}
}
template <typename T>
typename SQP<T>::Scalar SQP<T>::line_search(Problem& prob, const Vector& p) {
// Note: using members obj_ and grad_obj_, which are updated in solve_qp().
Scalar mu, phi_l1, Dp_phi_l1;
const Scalar tau = settings_.tau; // line search step decrease, 0 < tau < settings.tau
Scalar constr_l1 = constraint_norm(constr_, l_, u_);
// get mu from merit function model using hessian of Lagrangian instead
mu = (grad_obj_.dot(p) + 0.5 * p.dot(Hess_ * p)) / ((1 - settings_.rho) * constr_l1);
phi_l1 = obj_ + mu * constr_l1;
Dp_phi_l1 = grad_obj_.dot(p) - mu * constr_l1;
Scalar alpha = 1.0;
int i;
for (i = 1; i < settings_.line_search_max_iter; i++) {
Scalar obj_step;
Vector x_step = x_ + alpha * p;
prob.objective(x_step, obj_step);
Scalar phi_l1_step = obj_step + mu * constraint_norm(x_step, prob);
if (phi_l1_step <= phi_l1 + alpha * settings_.eta * Dp_phi_l1) {
// accept step
break;
} else {
alpha = tau * alpha;
}
}
return alpha;
}
template <typename T>
typename SQP<T>::Scalar SQP<T>::constraint_norm(const Vector &constr, const Vector &l, const Vector &u) const {
Scalar c_l1 = DIV_BY_ZERO_REGUL;
// l <= c(x) <= u
c_l1 += (l - constr).cwiseMax(0.0).sum();
c_l1 += (constr - u).cwiseMax(0.0).sum();
return c_l1;
}
template <typename T>
typename SQP<T>::Scalar SQP<T>::constraint_norm(const Vector& x, Problem& prob) {
// Note: uses members constr_, l_ and u_ as temporary
prob.constraint(x, constr_, l_, u_);
return constraint_norm(constr_, l_, u_);
}
template <typename T>
typename SQP<T>::Scalar SQP<T>::max_constraint_violation(const Vector& x, Problem& prob) {
// Note: uses members constr_, l_ and u_ as temporary
Scalar c_max = 0;
prob.constraint(x, constr_, l_, u_);
// l <= c(x) <= u
if (prob.num_constr > 0) {
c_max = fmax(c_max, (l_ - constr_).maxCoeff());
c_max = fmax(c_max, (constr_ - u_).maxCoeff());
}
return c_max;
}
template class SQP<double>;
template class SQP<float>;
} // namespace sqp
| 28.131805 | 111 | 0.606743 | nuft |
57e0c53b9df2aed101c81120bc0523b33ce3ccec | 911 | cpp | C++ | devdc133.cpp | vidit1999/coding_problems | b6c9fa7fda37d9424cd11bcd54b385fd8cf1ee0a | [
"BSD-2-Clause"
] | 1 | 2020-02-24T18:28:48.000Z | 2020-02-24T18:28:48.000Z | devdc133.cpp | vidit1999/coding_problems | b6c9fa7fda37d9424cd11bcd54b385fd8cf1ee0a | [
"BSD-2-Clause"
] | null | null | null | devdc133.cpp | vidit1999/coding_problems | b6c9fa7fda37d9424cd11bcd54b385fd8cf1ee0a | [
"BSD-2-Clause"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
/*
Mr. Square is going on holiday. He wants to bring 2 of his favorite squares with him,
so he put them in his rectangle suitcase.
Write a function that, given the size of the squares and the suitcase,
return whether the squares can fit inside the suitcase.
fit_in(a,b,m,n)
a,b are the sizes of the squares
m,n are the sizes of the suitcase
Example
fit_in(1,2,3,2) should return True
fit_in(1,2,2,1) should return False
fit_in(3,2,3,2) should return False
fit_in(1,2,1,2) should return False
*/
bool fit_in(int a, int b, int m, int n){
return ((a + b) <= max(m, n)) && (max(a, b) <= min(m, n));
}
void testFunc(vector<vector<int>> v){
for(auto it : v){
if(fit_in(it[0], it[1], it[2], it[3]))
cout << "Yes\n";
else
cout << "No\n";
}
}
// main function
int main(){
testFunc({
{1,2,3,2},
{1,2,2,1},
{3,2,3,2},
{1,2,1,2},
});
return 0;
} | 20.704545 | 85 | 0.642151 | vidit1999 |
57e38e13bdd8e64842c2f7f12155964f57472d38 | 667 | cpp | C++ | Cpp/Codes/Practice/LeetCodeCN/15 3sum.cpp | QuincyWork/AllCodes | 59fe045608dda924cb993dde957da4daff769438 | [
"MIT"
] | null | null | null | Cpp/Codes/Practice/LeetCodeCN/15 3sum.cpp | QuincyWork/AllCodes | 59fe045608dda924cb993dde957da4daff769438 | [
"MIT"
] | null | null | null | Cpp/Codes/Practice/LeetCodeCN/15 3sum.cpp | QuincyWork/AllCodes | 59fe045608dda924cb993dde957da4daff769438 | [
"MIT"
] | 1 | 2019-04-01T10:30:03.000Z | 2019-04-01T10:30:03.000Z | #include <gtest\gtest.h>
#include <vector>
using namespace std;
namespace LC15
{
class Solution {
public:
vector<vector<int>> threeSum(vector<int>& nums) {
vector<vector<int>> result;
sort(nums.begin(), nums.end());
for (int i = 0; i < nums.size(); ++i)
{
for (int j = i+1; j < nums.size(); ++j)
{
for (int k = j + 1; k < nums.size(); ++k)
{
if (nums[i] + nums[j] + nums[k] == 0)
{
result.push_back(vector<int>({ nums[i],nums[j],nums[k] }));
}
}
}
}
return result;
}
};
TEST(LeetCodeCN, tThreeSum)
{
Solution s;
auto result = s.threeSum(vector<int>({ -1,0,1,2,-1,-4 }));
}
}
| 17.552632 | 66 | 0.521739 | QuincyWork |
57e3b19dad6d500cbd34c4778663bf4ed6443daf | 130,234 | cpp | C++ | Unity-Project/App-HL2/Il2CppOutputProject/Source/il2cppOutput/Il2CppCCWs117.cpp | JBrentJ/mslearn-mixed-reality-and-azure-digital-twins-in-unity | 6e13b31a0b053443b9c93267d8f174f1554e79dd | [
"CC-BY-4.0",
"MIT"
] | 1 | 2021-06-01T19:33:53.000Z | 2021-06-01T19:33:53.000Z | Unity-Project/App-HL2/Il2CppOutputProject/Source/il2cppOutput/Il2CppCCWs117.cpp | JBrentJ/mslearn-mixed-reality-and-azure-digital-twins-in-unity | 6e13b31a0b053443b9c93267d8f174f1554e79dd | [
"CC-BY-4.0",
"MIT"
] | null | null | null | Unity-Project/App-HL2/Il2CppOutputProject/Source/il2cppOutput/Il2CppCCWs117.cpp | JBrentJ/mslearn-mixed-reality-and-azure-digital-twins-in-unity | 6e13b31a0b053443b9c93267d8f174f1554e79dd | [
"CC-BY-4.0",
"MIT"
] | null | null | null | #include "pch-cpp.hpp"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include <limits>
#include "vm/CachedCCWBase.h"
#include "utils/New.h"
// UnityEngine.EventSystems.RaycastResult[]
struct RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D;
// System.Text.Json.ReadStackFrame[]
struct ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E;
// UnityEngine.Rect[]
struct RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE;
// UnityEngine.UI.RectMask2D[]
struct RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7;
// UnityEngine.RectTransform[]
struct RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5;
// Newtonsoft.Json.Utilities.ReflectionObject[]
struct ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F;
// System.Text.RegularExpressions.RegexNode[]
struct RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056;
// System.Text.RegularExpressions.RegexOptions[]
struct RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67;
// UnityEngine.Renderer[]
struct RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7;
// UnityEngine.AddressableAssets.ResourceLocators.ResourceLocationData[]
struct ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F;
struct IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8;
struct IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB;
struct IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA;
struct IIterator_1_t6A46A7244E5AAD0AE4F2A07AF43DA5052D55F4A4;
struct IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C;
IL2CPP_EXTERN_C_BEGIN
IL2CPP_EXTERN_C_END
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Windows.Foundation.Collections.IIterable`1<System.Collections.IEnumerable>
struct NOVTABLE IIterable_1_t6359E278A71A51A15FA83695BA7C54F9B3E04824 : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m512126C71D7E9D1C31B56F64455F33E9FEEC89F8(IIterator_1_t6A46A7244E5AAD0AE4F2A07AF43DA5052D55F4A4** comReturnValue) = 0;
};
// Windows.Foundation.Collections.IIterable`1<System.Object>
struct NOVTABLE IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4 : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619(IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue) = 0;
};
// Windows.Foundation.Collections.IVectorView`1<System.Collections.IEnumerable>
struct NOVTABLE IVectorView_1_t7215C7C44306F73B6AC4A835AEABA3B0222EA80A : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m72849F526862E096635BA971A074D9B06ABFEE1E(uint32_t ___index0, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8** comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_mB93C08E36F2225BE1862007FAF30C9F2DEE8DAD9(uint32_t* comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_m3D87181F28EC65303ECB5017476C3B38D0944E17(IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8* ___value0, uint32_t* ___index1, bool* comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_mE432D0460C5D84FEC9104DF80F5809975EAE32F8(uint32_t ___startIndex0, uint32_t ___items1ArraySize, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8** ___items1, uint32_t* comReturnValue) = 0;
};
// Windows.Foundation.Collections.IVectorView`1<System.Object>
struct NOVTABLE IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260(uint32_t ___index0, Il2CppIInspectable** comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B(uint32_t* comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1(uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue) = 0;
};
// Windows.UI.Xaml.Interop.IBindableIterable
struct NOVTABLE IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8 : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) = 0;
};
// Windows.UI.Xaml.Interop.IBindableVector
struct NOVTABLE IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() = 0;
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() = 0;
};
// System.Object
// System.Collections.Generic.List`1<UnityEngine.EventSystems.RaycastResult>
struct List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447 : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447, ____items_1)); }
inline RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D* get__items_1() const { return ____items_1; }
inline RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_StaticFields, ____emptyArray_5)); }
inline RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D* get__emptyArray_5() const { return ____emptyArray_5; }
inline RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(RaycastResultU5BU5D_t55B9DF597EFA3BE063604C0950E370D850283B9D* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<System.Text.Json.ReadStackFrame>
struct List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD, ____items_1)); }
inline ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E* get__items_1() const { return ____items_1; }
inline ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_StaticFields, ____emptyArray_5)); }
inline ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E* get__emptyArray_5() const { return ____emptyArray_5; }
inline ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(ReadStackFrameU5BU5D_tB1A9284204A44718E083DDC3A099B723E2F6763E* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<UnityEngine.Rect>
struct List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE, ____items_1)); }
inline RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE* get__items_1() const { return ____items_1; }
inline RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_StaticFields, ____emptyArray_5)); }
inline RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE* get__emptyArray_5() const { return ____emptyArray_5; }
inline RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(RectU5BU5D_tD4F5052A6F89820365269FF4CA7C3EB1ACD4B1EE* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<UnityEngine.UI.RectMask2D>
struct List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0 : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0, ____items_1)); }
inline RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7* get__items_1() const { return ____items_1; }
inline RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_StaticFields, ____emptyArray_5)); }
inline RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7* get__emptyArray_5() const { return ____emptyArray_5; }
inline RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(RectMask2DU5BU5D_tB3154B58708CFB10CC9FCB6C15301C2EFEAAB2D7* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<UnityEngine.RectTransform>
struct List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3 : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3, ____items_1)); }
inline RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5* get__items_1() const { return ____items_1; }
inline RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_StaticFields, ____emptyArray_5)); }
inline RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5* get__emptyArray_5() const { return ____emptyArray_5; }
inline RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(RectTransformU5BU5D_tA38C18F6D88709B30F107C43E0669847172879D5* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<Newtonsoft.Json.Utilities.ReflectionObject>
struct List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190 : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190, ____items_1)); }
inline ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F* get__items_1() const { return ____items_1; }
inline ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_StaticFields, ____emptyArray_5)); }
inline ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F* get__emptyArray_5() const { return ____emptyArray_5; }
inline ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(ReflectionObjectU5BU5D_t5BFC5E4615B234D61E7A5108FC35331A2FCA751F* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<System.Text.RegularExpressions.RegexNode>
struct List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9 : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9, ____items_1)); }
inline RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056* get__items_1() const { return ____items_1; }
inline RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_StaticFields, ____emptyArray_5)); }
inline RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056* get__emptyArray_5() const { return ____emptyArray_5; }
inline RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(RegexNodeU5BU5D_tDCE5A1DFD56515BBA16233216439F0948F453056* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<System.Text.RegularExpressions.RegexOptions>
struct List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A, ____items_1)); }
inline RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67* get__items_1() const { return ____items_1; }
inline RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_StaticFields, ____emptyArray_5)); }
inline RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67* get__emptyArray_5() const { return ____emptyArray_5; }
inline RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(RegexOptionsU5BU5D_t7331675FC2B3783AD45B7A664FB7365174D43C67* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<UnityEngine.Renderer>
struct List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE, ____items_1)); }
inline RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7* get__items_1() const { return ____items_1; }
inline RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_StaticFields, ____emptyArray_5)); }
inline RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7* get__emptyArray_5() const { return ____emptyArray_5; }
inline RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(RendererU5BU5D_tE2D3C4350893C593CA40DE876B9F2F0EBBEC49B7* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
// System.Collections.Generic.List`1<UnityEngine.AddressableAssets.ResourceLocators.ResourceLocationData>
struct List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55 : public RuntimeObject
{
public:
// T[] System.Collections.Generic.List`1::_items
ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F* ____items_1;
// System.Int32 System.Collections.Generic.List`1::_size
int32_t ____size_2;
// System.Int32 System.Collections.Generic.List`1::_version
int32_t ____version_3;
// System.Object System.Collections.Generic.List`1::_syncRoot
RuntimeObject * ____syncRoot_4;
public:
inline static int32_t get_offset_of__items_1() { return static_cast<int32_t>(offsetof(List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55, ____items_1)); }
inline ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F* get__items_1() const { return ____items_1; }
inline ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F** get_address_of__items_1() { return &____items_1; }
inline void set__items_1(ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F* value)
{
____items_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&____items_1), (void*)value);
}
inline static int32_t get_offset_of__size_2() { return static_cast<int32_t>(offsetof(List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55, ____size_2)); }
inline int32_t get__size_2() const { return ____size_2; }
inline int32_t* get_address_of__size_2() { return &____size_2; }
inline void set__size_2(int32_t value)
{
____size_2 = value;
}
inline static int32_t get_offset_of__version_3() { return static_cast<int32_t>(offsetof(List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55, ____version_3)); }
inline int32_t get__version_3() const { return ____version_3; }
inline int32_t* get_address_of__version_3() { return &____version_3; }
inline void set__version_3(int32_t value)
{
____version_3 = value;
}
inline static int32_t get_offset_of__syncRoot_4() { return static_cast<int32_t>(offsetof(List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55, ____syncRoot_4)); }
inline RuntimeObject * get__syncRoot_4() const { return ____syncRoot_4; }
inline RuntimeObject ** get_address_of__syncRoot_4() { return &____syncRoot_4; }
inline void set__syncRoot_4(RuntimeObject * value)
{
____syncRoot_4 = value;
Il2CppCodeGenWriteBarrier((void**)(&____syncRoot_4), (void*)value);
}
};
struct List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_StaticFields
{
public:
// T[] System.Collections.Generic.List`1::_emptyArray
ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F* ____emptyArray_5;
public:
inline static int32_t get_offset_of__emptyArray_5() { return static_cast<int32_t>(offsetof(List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_StaticFields, ____emptyArray_5)); }
inline ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F* get__emptyArray_5() const { return ____emptyArray_5; }
inline ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F** get_address_of__emptyArray_5() { return &____emptyArray_5; }
inline void set__emptyArray_5(ResourceLocationDataU5BU5D_t1AA66640C35B4DB8F9C452CA4CE7EF141D72E87F* value)
{
____emptyArray_5 = value;
Il2CppCodeGenWriteBarrier((void**)(&____emptyArray_5), (void*)value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
il2cpp_hresult_t IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(RuntimeObject* __this, IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue);
il2cpp_hresult_t IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___index0, Il2CppIInspectable** comReturnValue);
il2cpp_hresult_t IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t* comReturnValue);
il2cpp_hresult_t IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(RuntimeObject* __this, IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue);
il2cpp_hresult_t IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(RuntimeObject* __this, Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue);
il2cpp_hresult_t IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___index0, Il2CppIInspectable* ___value1);
il2cpp_hresult_t IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___index0, Il2CppIInspectable* ___value1);
il2cpp_hresult_t IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___index0);
il2cpp_hresult_t IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(RuntimeObject* __this, Il2CppIInspectable* ___value0);
il2cpp_hresult_t IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(RuntimeObject* __this);
il2cpp_hresult_t IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(RuntimeObject* __this);
il2cpp_hresult_t IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619_ComCallableWrapperProjectedMethod(RuntimeObject* __this, IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue);
il2cpp_hresult_t IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___index0, Il2CppIInspectable** comReturnValue);
il2cpp_hresult_t IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t* comReturnValue);
il2cpp_hresult_t IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67_ComCallableWrapperProjectedMethod(RuntimeObject* __this, Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue);
il2cpp_hresult_t IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue);
il2cpp_hresult_t IIterable_1_First_m512126C71D7E9D1C31B56F64455F33E9FEEC89F8_ComCallableWrapperProjectedMethod(RuntimeObject* __this, IIterator_1_t6A46A7244E5AAD0AE4F2A07AF43DA5052D55F4A4** comReturnValue);
il2cpp_hresult_t IVectorView_1_GetAt_m72849F526862E096635BA971A074D9B06ABFEE1E_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___index0, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8** comReturnValue);
il2cpp_hresult_t IVectorView_1_get_Size_mB93C08E36F2225BE1862007FAF30C9F2DEE8DAD9_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t* comReturnValue);
il2cpp_hresult_t IVectorView_1_IndexOf_m3D87181F28EC65303ECB5017476C3B38D0944E17_ComCallableWrapperProjectedMethod(RuntimeObject* __this, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8* ___value0, uint32_t* ___index1, bool* comReturnValue);
il2cpp_hresult_t IVectorView_1_GetMany_mE432D0460C5D84FEC9104DF80F5809975EAE32F8_ComCallableWrapperProjectedMethod(RuntimeObject* __this, uint32_t ___startIndex0, uint32_t ___items1ArraySize, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8** ___items1, uint32_t* comReturnValue);
// COM Callable Wrapper for System.Collections.Generic.List`1<UnityEngine.EventSystems.RaycastResult>
struct List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC
{
inline List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[1] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_t367B604D3EA3D6A9EC95A32A521EF83F5DA9B447_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<System.Text.Json.ReadStackFrame>
struct List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC
{
inline List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[1] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_t814EF893AA45ADB5DD8897F915DAADC58EBB5CDD_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<UnityEngine.Rect>
struct List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC
{
inline List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[1] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_t7AFC5094F7C1D24DAAA8893B11B1743A7A0D2CFE_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<UnityEngine.UI.RectMask2D>
struct List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_ComCallableWrapper>, IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC, IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A
{
inline List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(4);
interfaceIds[0] = IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[2] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
interfaceIds[3] = IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID;
*iidCount = 4;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619(IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1(uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___startIndex0, ___items1ArraySize, ___items1, comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_t5709CD2CBFF795FF126CD146B019D4F8EC972EA0_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<UnityEngine.RectTransform>
struct List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_ComCallableWrapper>, IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4, IIterable_1_t6359E278A71A51A15FA83695BA7C54F9B3E04824, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC, IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A, IVectorView_1_t7215C7C44306F73B6AC4A835AEABA3B0222EA80A
{
inline List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t6359E278A71A51A15FA83695BA7C54F9B3E04824::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t6359E278A71A51A15FA83695BA7C54F9B3E04824*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IVectorView_1_t7215C7C44306F73B6AC4A835AEABA3B0222EA80A::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IVectorView_1_t7215C7C44306F73B6AC4A835AEABA3B0222EA80A*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(6);
interfaceIds[0] = IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID;
interfaceIds[1] = IIterable_1_t6359E278A71A51A15FA83695BA7C54F9B3E04824::IID;
interfaceIds[2] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[3] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
interfaceIds[4] = IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID;
interfaceIds[5] = IVectorView_1_t7215C7C44306F73B6AC4A835AEABA3B0222EA80A::IID;
*iidCount = 6;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619(IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m512126C71D7E9D1C31B56F64455F33E9FEEC89F8(IIterator_1_t6A46A7244E5AAD0AE4F2A07AF43DA5052D55F4A4** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_m512126C71D7E9D1C31B56F64455F33E9FEEC89F8_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1(uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___startIndex0, ___items1ArraySize, ___items1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m72849F526862E096635BA971A074D9B06ABFEE1E(uint32_t ___index0, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8** comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetAt_m72849F526862E096635BA971A074D9B06ABFEE1E_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_mB93C08E36F2225BE1862007FAF30C9F2DEE8DAD9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_get_Size_mB93C08E36F2225BE1862007FAF30C9F2DEE8DAD9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_m3D87181F28EC65303ECB5017476C3B38D0944E17(IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_IndexOf_m3D87181F28EC65303ECB5017476C3B38D0944E17_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_mE432D0460C5D84FEC9104DF80F5809975EAE32F8(uint32_t ___startIndex0, uint32_t ___items1ArraySize, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8** ___items1, uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetMany_mE432D0460C5D84FEC9104DF80F5809975EAE32F8_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___startIndex0, ___items1ArraySize, ___items1, comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_t432BA4439FC00E108A9A351BD7FBCD9242270BB3_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<Newtonsoft.Json.Utilities.ReflectionObject>
struct List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_ComCallableWrapper>, IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC, IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A
{
inline List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(4);
interfaceIds[0] = IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[2] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
interfaceIds[3] = IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID;
*iidCount = 4;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619(IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1(uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___startIndex0, ___items1ArraySize, ___items1, comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_t04A11A365D1B0F4481DE8D0B98866FF3448D2190_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<System.Text.RegularExpressions.RegexNode>
struct List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_ComCallableWrapper>, IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC, IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A
{
inline List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(4);
interfaceIds[0] = IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[2] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
interfaceIds[3] = IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID;
*iidCount = 4;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619(IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1(uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___startIndex0, ___items1ArraySize, ___items1, comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_t692D260BEBA1E69864C98DEEDB3E9256C38CD9B9_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<System.Text.RegularExpressions.RegexOptions>
struct List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC
{
inline List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[1] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_tE931333A40AB4E57F72E00F9F23D19057C78120A_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<UnityEngine.Renderer>
struct List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_ComCallableWrapper>, IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC, IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A
{
inline List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(4);
interfaceIds[0] = IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[2] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
interfaceIds[3] = IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID;
*iidCount = 4;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619(IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1(uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___startIndex0, ___items1ArraySize, ___items1, comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_tB73BF10E0869BDB4D391E61BA46B75BECA4DCDBE_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.List`1<UnityEngine.AddressableAssets.ResourceLocators.ResourceLocationData>
struct List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_ComCallableWrapper>, IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8, IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC, IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A
{
inline List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(4);
interfaceIds[0] = IIterable_1_t64693143CE4E5082C6101BC54B0427C21F3C01C4::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
interfaceIds[2] = IBindableVector_tC070A96258CD93818901E9B7808E1A8EFB64B7EC::IID;
interfaceIds[3] = IVectorView_1_t9D427951F2D09C2E6F846759B5273E993F185D4A::IID;
*iidCount = 4;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619(IIterator_1_tB1AB5AB497E87D6A397AA084D3D3D6B8D211022C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_m54AC7E778E98ED35C6B7AD98C35C325B8A3DF619_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38(IBindableVectorView_tD80A01049DD2609FEA5FACD5E77BF95A875534FA** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5(uint32_t ___index0, Il2CppIInspectable* ___value1) IL2CPP_OVERRIDE
{
return IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, ___value1);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0(uint32_t ___index0) IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F(Il2CppIInspectable* ___value0) IL2CPP_OVERRIDE
{
return IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0);
}
virtual il2cpp_hresult_t STDCALL IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3() IL2CPP_OVERRIDE
{
return IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF() IL2CPP_OVERRIDE
{
return IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF_ComCallableWrapperProjectedMethod(GetManagedObjectInline());
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260(uint32_t ___index0, Il2CppIInspectable** comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetAt_m38CCDDE1E25317AEF5170D9818FC01816AF34260_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___index0, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B(uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_get_Size_m33BC340C458F20A80A8B07FF4764CEF1F5513F8B_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67(Il2CppIInspectable* ___value0, uint32_t* ___index1, bool* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_IndexOf_mFAE432DA0C1902EEF54AB68CFFD3E2182C443F67_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___value0, ___index1, comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1(uint32_t ___startIndex0, uint32_t ___items1ArraySize, Il2CppIInspectable** ___items1, uint32_t* comReturnValue) IL2CPP_OVERRIDE
{
return IVectorView_1_GetMany_m6AA46969FB50015EB7107EBCC29E48B7AD4BB6B1_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), ___startIndex0, ___items1ArraySize, ___items1, comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) List_1_tBDF311CB6BA8AF1C9046A9DAC3502AC9DF88EF55_ComCallableWrapper(obj));
}
| 49.688668 | 528 | 0.849571 | JBrentJ |
57e4487c4befc46e5a1b9538a1355ee1c7cfe0a8 | 2,090 | cc | C++ | tests/test_minibus_web.cc | clambassador/minibus | 7a9699a53461911b503840b55ac630c894a0bb78 | [
"Apache-2.0"
] | 1 | 2019-01-17T15:17:32.000Z | 2019-01-17T15:17:32.000Z | tests/test_minibus_web.cc | clambassador/minibus | 7a9699a53461911b503840b55ac630c894a0bb78 | [
"Apache-2.0"
] | null | null | null | tests/test_minibus_web.cc | clambassador/minibus | 7a9699a53461911b503840b55ac630c894a0bb78 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <functional>
#include <ncurses.h>
#include <sstream>
#include <string>
#include <vector>
#include "minibus/driver/minibus_driver.h"
#include "minibus/io/key.h"
#include "minibus/web/minibus_web.h"
#include "minibus/widgets/close_on_key.h"
#include "minibus/widgets/list_select.h"
#include "minibus/widgets/text.h"
using namespace std;
using namespace std::placeholders;
using namespace minibus;
vector<string> vs;
bool decide(ListSelect* ls) {
if (!ls) return true;
return ls->get_selected();
}
class MinibusDriverTest : public MinibusDriver {
public:
MinibusDriverTest(IDisplay* display,
IInput* input)
: MinibusDriver(display, input) {
vs.push_back("new const");
_ls = new ListSelect("ls", vs);
_tx1 = new Text("tx1", "Hello THERE!!");
_tx1->bold();
_tx2 = new Text("tx2", "loading.");
_f_pos = _ls->get_selected_pos();
_cur = build_program("main", new CloseOnKey(_tx1))
->then(new CloseOnKey(_ls))
->when(new CloseOnKey(_tx1), new CloseOnKey(_tx2),
bind(&decide, _ls))
->loop(nullptr, bind(&decide, nullptr))
->loop(nullptr, bind(&decide, nullptr))->finish();
}
virtual ~MinibusDriverTest() {
Logger::error("EXIT");
}
protected:
virtual void after_keypress(const Key& key, Widget* widget) {
if (state(widget, _tx2)) {
_tx2->set_text(
Logger::stringify("You chose: % (item %)",
vs[_ls->get_selected()],
_ls->get_selected()));
}
}
virtual bool pos_ready() {
if (!_f_pos.valid()) return false;
return _f_pos.wait_for(chrono::seconds(0)) ==
future_status::ready;
}
ListSelect* _ls;
Text* _tx1;
Text* _tx2;
future<int> _f_pos;
};
int main() {
vs.push_back("hello");
vs.push_back("there");
vs.push_back("good");
vs.push_back("sir");
Config::_()->load("tests/test.cfg");
MinibusWeb<MinibusDriverTest> mw;
WebServer webserver(&mw);
webserver.start_server(Config::_()->get("http_port"));
cout << Config::_()->get("http_port") << endl;
cout << "Running.\nHit enter to stop.";
getchar();
webserver.stop_server();
}
| 24.022989 | 62 | 0.664115 | clambassador |
57e534fb967978afcc9738fe78957e05f949a79e | 3,406 | cpp | C++ | CSES/PrefixSumQueries.cpp | julianferres/Codeforces | ac80292a4d53b8078fc1a85e91db353c489555d9 | [
"MIT"
] | 4 | 2020-01-31T15:49:25.000Z | 2020-07-07T11:44:03.000Z | CSES/prefix_sum_queries.cpp | julianferres/CodeForces | 14e8369e82a2403094183d6f7824201f681c9f65 | [
"MIT"
] | null | null | null | CSES/prefix_sum_queries.cpp | julianferres/CodeForces | 14e8369e82a2403094183d6f7824201f681c9f65 | [
"MIT"
] | null | null | null | /* AUTHOR: julianferres */
#include <bits/stdc++.h>
using namespace std;
// neal Debugger
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
typedef long long ll;
typedef vector<ll> vi; typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define DBG(x) cerr << #x << " = " << (x) << endl
#define RAYA cerr << "===============================" << endl
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define esta(x,c) ((c).find(x) != (c).end())
const int INF = 1e9+15; // const ll INF = 2e18;
const int MOD = 1e9+7; // 998244353
const int MAXN = 2e5+5;
typedef long long tipo;
struct segtree {
struct node {
tipo ans, l, r; // Poner el neutro del update
tipo suma_total;
tipo nomatch = 0; // No match en el intervalo de query
node base(node aux) {aux.ans = nomatch; aux.suma_total = 0; return aux;} //Poner el neutro de la query
void set_node(tipo x, tipo pos) {suma_total = x, ans = max(0LL, x), l = r = pos;}; // Assigment
void combine(node a, node b) {
suma_total = a.suma_total + b.suma_total; //Operacion de query
ans = max(a.ans, a.suma_total + b.ans);
l = min(a.l,b.l); r = max(a.r,b.r);
}
};
vector <node> t;
node ask(int p, tipo l, tipo r) {
if(l > t[p].r || r < t[p].l) return t[p].base(t[p]);
if(l <= t[p].l && t[p].r <= r) return t[p];
node ans; ans.combine(ask(2*p+1,l,r),ask(2*p+2,l,r));
return ans;
}
void update(int p, tipo pos, tipo val) {
if(t[p].r < pos || t[p].l > pos) return;
if(t[p].l == t[p].r) { t[p].set_node(val,pos); return; }
update(2*p+1, pos, val); update(2*p+2, pos, val);
t[p].combine(t[2*p+1], t[2*p+2]);
}
void build(tipo a, tipo b, int p, vector <tipo> &v) {
if(a==b) {t[p].set_node(v[a],a); return;}
tipo med=(a+b)/2;
build(a, med, 2*p+1, v); build(med+1, b, 2*p+2, v);
t[p].combine(t[2*p+1], t[2*p+2]);
}
node query(tipo l, tipo r) {return ask(0,l,r);}
void modificar(tipo pos, tipo val) {update(0,pos,val);}
void construir(vector <tipo> &v, int n) { t.resize(4*n); build(0,n-1,0,v); }
};
//~ Range Minimum Query with cont
int main(){
FIN;
int n, q; cin >> n >> q;
vi a(n); forn(i, n) cin >> a[i];
segtree st; st.construir(a, n);
forn(i, q){
int tipo; cin >> tipo;
if(tipo == 1){
int k, u; cin >> k >> u;
k--;
st.modificar(k, u);
} else{
int a, b; cin >> a >> b;
a--, b--;
cout << st.query(a, b).ans << "\n";
}
}
return 0;
}
| 33.067961 | 290 | 0.548444 | julianferres |
57e60b13c663fdb02c754af29c1957114ae8f8aa | 233 | cpp | C++ | source/dynamic_value/value_not_found.cpp | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | 12 | 2019-04-16T17:35:53.000Z | 2020-04-12T14:37:27.000Z | source/dynamic_value/value_not_found.cpp | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | 47 | 2019-05-27T15:24:43.000Z | 2020-04-27T17:54:54.000Z | source/dynamic_value/value_not_found.cpp | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | null | null | null | #include "value_not_found.h"
namespace pagoda
{
ValueNotFoundException::ValueNotFoundException(const std::string &valueName)
: Exception("Value with name '" + valueName + "' not found in value table")
{
}
} // namespace pagoda
| 23.3 | 79 | 0.733906 | diegoarjz |
57eaf683eb325761156a4703f3d6a4a297ea6961 | 43 | hh | C++ | RAVL2/MSVC/include/Ravl/3D/HEMeshFace.hh | isuhao/ravl2 | 317e0ae1cb51e320b877c3bad6a362447b5e52ec | [
"BSD-Source-Code"
] | null | null | null | RAVL2/MSVC/include/Ravl/3D/HEMeshFace.hh | isuhao/ravl2 | 317e0ae1cb51e320b877c3bad6a362447b5e52ec | [
"BSD-Source-Code"
] | null | null | null | RAVL2/MSVC/include/Ravl/3D/HEMeshFace.hh | isuhao/ravl2 | 317e0ae1cb51e320b877c3bad6a362447b5e52ec | [
"BSD-Source-Code"
] | null | null | null |
#include "../.././3D/Mesh/HEMeshFace.hh"
| 10.75 | 40 | 0.581395 | isuhao |
57eb44abdeb263cef210716a830cab9a64e07624 | 2,451 | cpp | C++ | framework/scene_graph/components/orthographic_camera.cpp | NoreChair/Vulkan-Samples | 30e0ef953f9492726945d2042400a3808c8408f5 | [
"Apache-2.0"
] | 2,842 | 2016-02-16T14:01:31.000Z | 2022-03-30T19:10:32.000Z | framework/scene_graph/components/orthographic_camera.cpp | ZandroFargnoli/Vulkan-Samples | 04278ed5f0f9847ae6897509eb56d7b21b4e8cde | [
"Apache-2.0"
] | 316 | 2016-02-16T20:41:29.000Z | 2022-03-29T02:20:32.000Z | framework/scene_graph/components/orthographic_camera.cpp | ZandroFargnoli/Vulkan-Samples | 04278ed5f0f9847ae6897509eb56d7b21b4e8cde | [
"Apache-2.0"
] | 504 | 2016-02-16T16:43:37.000Z | 2022-03-31T20:24:35.000Z | /* Copyright (c) 2020, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "orthographic_camera.h"
VKBP_DISABLE_WARNINGS()
#include <glm/gtc/matrix_transform.hpp>
VKBP_ENABLE_WARNINGS()
namespace vkb
{
namespace sg
{
OrthographicCamera::OrthographicCamera(const std::string &name) :
Camera{name}
{}
OrthographicCamera::OrthographicCamera(const std::string &name, float left, float right, float bottom, float top, float near_plane, float far_plane) :
Camera{name},
left{left},
right{right},
top{top},
bottom{bottom},
near_plane{near_plane},
far_plane{far_plane}
{
}
void OrthographicCamera::set_left(float new_left)
{
left = new_left;
}
float OrthographicCamera::get_left() const
{
return left;
}
void OrthographicCamera::set_right(float new_right)
{
right = new_right;
}
float OrthographicCamera::get_right() const
{
return right;
}
void OrthographicCamera::set_bottom(float new_bottom)
{
bottom = new_bottom;
}
float OrthographicCamera::get_bottom() const
{
return bottom;
}
void OrthographicCamera::set_top(float new_top)
{
top = new_top;
}
float OrthographicCamera::get_top() const
{
return top;
}
void OrthographicCamera::set_near_plane(float new_near_plane)
{
near_plane = new_near_plane;
}
float OrthographicCamera::get_near_plane() const
{
return near_plane;
}
void OrthographicCamera::set_far_plane(float new_far_plane)
{
far_plane = new_far_plane;
}
float OrthographicCamera::get_far_plane() const
{
return far_plane;
}
glm::mat4 OrthographicCamera::get_projection()
{
// Note: Using Revsered depth-buffer for increased precision, so Znear and Zfar are flipped
return glm::ortho(left, right, bottom, top, far_plane, near_plane);
}
} // namespace sg
} // namespace vkb
| 22.281818 | 151 | 0.712362 | NoreChair |
57eb7f4b019dcbe6bcb29f2f86ddb9ebd1d408d9 | 7,893 | cpp | C++ | auxiliary/generate-blas3-solve-align1.cpp | bollig/viennacl | 6dac70e558ed42abe63d8c5bfd08465aafeda859 | [
"MIT"
] | 1 | 2020-09-21T08:33:10.000Z | 2020-09-21T08:33:10.000Z | auxiliary/generate-blas3-solve-align1.cpp | bollig/viennacl | 6dac70e558ed42abe63d8c5bfd08465aafeda859 | [
"MIT"
] | null | null | null | auxiliary/generate-blas3-solve-align1.cpp | bollig/viennacl | 6dac70e558ed42abe63d8c5bfd08465aafeda859 | [
"MIT"
] | null | null | null | /*
* Generates BLAS level 3 routines for direct solve
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <iostream>
#include <stdlib.h>
//generate code for inplace_solve(op1(A), op2(B), tag) where A and B can have different storage layouts and opX(D) = D or trans(D)
void printMatrixMatrixSolve(bool row_major_A, bool row_major_B,
bool transpose_A, bool transpose_B,
bool upper_solve, bool unit_diagonal)
{
//write header:
std::cout << "// file automatically generated - do not edit!" << std::endl;
std::cout << "// inplace solve ";
if (transpose_A)
std::cout << "A^T \\\\ ";
else
std::cout << "A \\\\ ";
if (transpose_B)
std::cout << "B^T" << std::endl;
else
std::cout << "B" << std::endl;
std::cout << "// matrix layouts: ";
if (row_major_A)
std::cout << "A...row_major, ";
else
std::cout << "A...col_major, ";
if (row_major_B)
std::cout << "B...row_major" << std::endl;
else
std::cout << "B...col_major" << std::endl;
//start OpenCL code:
std::cout << "__kernel void ";
if (transpose_A)
std::cout << "trans_";
if (unit_diagonal)
std::cout << "unit_";
if (upper_solve)
std::cout << "upper_";
else
std::cout << "lower_";
if (transpose_B)
std::cout << "trans_";
std::cout << "solve";
std::cout << "(" << std::endl;
std::cout << " __global const float * A," << std::endl;
std::cout << " unsigned int A_start1, unsigned int A_start2," << std::endl;
std::cout << " unsigned int A_inc1, unsigned int A_inc2," << std::endl;
std::cout << " unsigned int A_size1, unsigned int A_size2," << std::endl;
std::cout << " unsigned int A_internal_size1, unsigned int A_internal_size2," << std::endl;
std::cout << " __global float * B," << std::endl;
std::cout << " unsigned int B_start1, unsigned int B_start2," << std::endl;
std::cout << " unsigned int B_inc1, unsigned int B_inc2," << std::endl;
std::cout << " unsigned int B_size1, unsigned int B_size2," << std::endl;
std::cout << " unsigned int B_internal_size1, unsigned int B_internal_size2)" << std::endl;
std::cout << "{ " << std::endl;
std::cout << " float temp; " << std::endl;
if (upper_solve)
{
//Note: A is square, thus A_rows == A_cols and no dispatch for transposedness needed
std::cout << " for (unsigned int row_cnt = 0; row_cnt < A_size1; ++row_cnt) " << std::endl;
std::cout << " { " << std::endl;
std::cout << " unsigned int row = A_size1 - 1 - row_cnt;" << std::endl;
}
else //lower triangular solve
{
std::cout << " for (unsigned int row = 0; row < A_size1; ++row) " << std::endl;
std::cout << " { " << std::endl;
}
if (!unit_diagonal)
{
std::cout << " barrier(CLK_GLOBAL_MEM_FENCE); " << std::endl;
std::cout << " if (get_local_id(0) == 0) " << std::endl;
//Note: A is square, thus A_internal_rows == A_internal_cols and no dispatch for transposedness needed
if (row_major_B && transpose_B)
std::cout << " B[(get_group_id(0) * B_inc1 + B_start1) * B_internal_size2 + (row * B_inc2 + B_start2)] /= ";
else if (row_major_B && !transpose_B)
std::cout << " B[(row * B_inc1 + B_start1) * B_internal_size2 + (get_group_id(0) * B_inc2 + B_start2)] /= ";
else if (!row_major_B && transpose_B)
std::cout << " B[(get_group_id(0) * B_inc1 + B_start1) + (row * B_inc2 + B_start2) * B_internal_size1] /= ";
else if (!row_major_B && !transpose_B)
std::cout << " B[(row * B_inc1 + B_start1) + (get_group_id(0) * B_inc2 + B_start2) * B_internal_size1] /= ";
if (row_major_A)
std::cout << "A[(row * A_inc1 + A_start1) * A_internal_size2 + (row * A_inc2 + A_start2)];" << std::endl;
else
std::cout << "A[(row * A_inc1 + A_start1) + (row * A_inc2 + A_start2)*A_internal_size1];" << std::endl;
}
std::cout << " barrier(CLK_GLOBAL_MEM_FENCE); " << std::endl;
if (row_major_B && transpose_B)
std::cout << " temp = B[(get_group_id(0) * B_inc1 + B_start1) * B_internal_size2 + (row * B_inc2 + B_start2)]; " << std::endl;
else if (row_major_B && !transpose_B)
std::cout << " temp = B[(row * B_inc1 + B_start1) * B_internal_size2 + (get_group_id(0) * B_inc2 + B_start2)]; " << std::endl;
else if (!row_major_B && transpose_B)
std::cout << " temp = B[(get_group_id(0) * B_inc1 + B_start1) + (row * B_inc2 + B_start2) * B_internal_size1]; " << std::endl;
else if (!row_major_B && !transpose_B)
std::cout << " temp = B[(row * B_inc1 + B_start1) + (get_group_id(0) * B_inc2 + B_start2) * B_internal_size1]; " << std::endl;
std::cout << " //eliminate column of op(A) with index 'row' in parallel: " << std::endl;
if (upper_solve)
std::cout << " for (unsigned int elim = get_local_id(0); elim < row; elim += get_local_size(0)) " << std::endl;
else
std::cout << " for (unsigned int elim = row + get_local_id(0) + 1; elim < A_size1; elim += get_local_size(0)) " << std::endl;
if (row_major_B && transpose_B)
std::cout << " B[(get_group_id(0) * B_inc1 + B_start1) * B_internal_size2 + (elim * B_inc2 + B_start2)] -= temp * ";
else if (row_major_B && !transpose_B)
std::cout << " B[(elim * B_inc1 + B_start1) * B_internal_size2 + (get_group_id(0) * B_inc2 + B_start2)] -= temp * ";
else if (!row_major_B && transpose_B)
std::cout << " B[(get_group_id(0) * B_inc1 + B_start1) + (elim * B_inc2 + B_start2) * B_internal_size1] -= temp * ";
else if (!row_major_B && !transpose_B)
std::cout << " B[(elim * B_inc1 + B_start1) + (get_group_id(0) * B_inc2 + B_start2) * B_internal_size1] -= temp * ";
if (row_major_A && transpose_A)
std::cout << "A[(row * A_inc1 + A_start1) * A_internal_size2 + (elim * A_inc2 + A_start2)];" << std::endl;
else if (row_major_A && !transpose_A)
std::cout << "A[(elim * A_inc1 + A_start1) * A_internal_size2 + (row * A_inc2 + A_start2)];" << std::endl;
else if (!row_major_A && transpose_A)
std::cout << "A[(row * A_inc1 + A_start1) + (elim * A_inc2 + A_start2) * A_internal_size1];" << std::endl;
else if (!row_major_A && !transpose_A)
std::cout << "A[(elim * A_inc1 + A_start1) + (row * A_inc2 + A_start2) * A_internal_size1];" << std::endl;
std::cout << " }" << std::endl;
std::cout << "}" << std::endl;
}
void printUsage()
{
std::cout << "Must have six parameters for A \\ B:" << std::endl;
std::cout << " 0/1 : storage layout for A (column_major/row_major)" << std::endl;
std::cout << " 0/1 : storage layout for B (column_major/row_major)" << std::endl;
std::cout << " 0/1 : transpose for A (no/yes)" << std::endl;
std::cout << " 0/1 : transpose for B (no/yes)" << std::endl;
std::cout << " 0/1 : upper triangular system (no/yes)" << std::endl;
std::cout << " 0/1 : has unit diagonal (no/yes)" << std::endl;
}
void readParameter(bool & param, char input)
{
if (input == '0')
param = false;
else if (input == '1')
param = true;
else
{
printUsage();
exit(EXIT_FAILURE);
}
}
int main(int args, char * argsv[])
{
if (args != 7)
{
printUsage();
exit(EXIT_FAILURE);
}
//the following flags are 'true' for row_major layout
bool layout_A;
bool layout_B;
readParameter(layout_A, argsv[1][0]);
readParameter(layout_B, argsv[2][0]);
bool transpose_A;
bool transpose_B;
readParameter(transpose_A, argsv[3][0]);
readParameter(transpose_B, argsv[4][0]);
bool upper_solve;
bool unit_diagonal;
readParameter(upper_solve, argsv[5][0]);
readParameter(unit_diagonal, argsv[6][0]);
printMatrixMatrixSolve(layout_A, layout_B,
transpose_A, transpose_B,
upper_solve, unit_diagonal);
}
| 41.109375 | 133 | 0.592044 | bollig |
57ecb6efbd0f4dc142a301c4fb47a828d7f09729 | 569 | cpp | C++ | dayOfYear.cpp | jlokhande46/LeetcodeProblems | 2023902e392e651f67cf226be1760f43111a3b55 | [
"MIT"
] | null | null | null | dayOfYear.cpp | jlokhande46/LeetcodeProblems | 2023902e392e651f67cf226be1760f43111a3b55 | [
"MIT"
] | null | null | null | dayOfYear.cpp | jlokhande46/LeetcodeProblems | 2023902e392e651f67cf226be1760f43111a3b55 | [
"MIT"
] | null | null | null | iclass Solution:
def dayOfYear(self, date: str) -> int:
year=int(date[0:4])
month=int(date[5:7])
day=int(date[8:10])
dayOfYear=day
# print(year,day,month)
for i in range(month-1):
if(i==1):
if((year%4==0 and year%100!=0) or (year%400==0)):
dayOfYear+=29
else:
dayOfYear+=28
elif(i in [0,2,4,6,7,9,11]):
dayOfYear+=31
else:
dayOfYear+=30
# if()
return dayOfYear
| 28.45 | 65 | 0.427065 | jlokhande46 |
57ef78d0b33d18aaed00ce70a808c29fc55643c5 | 4,428 | cxx | C++ | private/windows/shell/lmui/shareui/menuutil.cxx | King0987654/windows2000 | 01f9c2e62c4289194e33244aade34b7d19e7c9b8 | [
"MIT"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | shell/osshell/lmui/shareui/menuutil.cxx | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | shell/osshell/lmui/shareui/menuutil.cxx | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | //+---------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1995 - 1995.
//
// File: menuutil.cxx
//
// Contents: Context menu utilities, stolen from the shell. This is
// basically CDefFolderMenu_MergeMenu and its support.
//
// History: 20-Dec-95 BruceFo Created
//
//----------------------------------------------------------------------------
#include "headers.hxx"
#pragma hdrstop
#include "menuutil.hxx"
// Cannonical command names stolen from the shell
TCHAR const c_szDelete[] = TEXT("delete");
TCHAR const c_szCut[] = TEXT("cut");
TCHAR const c_szCopy[] = TEXT("copy");
TCHAR const c_szLink[] = TEXT("link");
TCHAR const c_szProperties[] = TEXT("properties");
TCHAR const c_szPaste[] = TEXT("paste");
TCHAR const c_szPasteLink[] = TEXT("pastelink");
TCHAR const c_szRename[] = TEXT("rename");
HMENU
LoadPopupMenu(
HINSTANCE hinst,
UINT id
)
{
HMENU hmParent = LoadMenu(hinst, MAKEINTRESOURCE(id));
if (NULL == hmParent)
{
return NULL;
}
HMENU hmPopup = GetSubMenu(hmParent, 0);
RemoveMenu(hmParent, 0, MF_BYPOSITION);
DestroyMenu(hmParent);
return hmPopup;
}
HMENU
MyGetMenuFromID(
HMENU hmMain,
UINT uID
)
{
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_SUBMENU;
mii.cch = 0; // just in case
if (!GetMenuItemInfo(hmMain, uID, FALSE, &mii))
{
return NULL;
}
return mii.hSubMenu;
}
int
MyMergePopupMenus(
HMENU hmMain,
HMENU hmMerge,
int idCmdFirst,
int idCmdLast)
{
int i;
int idTemp;
int idMax = idCmdFirst;
for (i = GetMenuItemCount(hmMerge) - 1; i >= 0; --i)
{
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_ID | MIIM_SUBMENU;
mii.cch = 0; // just in case
if (!GetMenuItemInfo(hmMerge, i, TRUE, &mii))
{
continue;
}
idTemp = Shell_MergeMenus(
MyGetMenuFromID(hmMain, mii.wID),
mii.hSubMenu,
0,
idCmdFirst,
idCmdLast,
MM_ADDSEPARATOR | MM_SUBMENUSHAVEIDS);
if (idMax < idTemp)
{
idMax = idTemp;
}
}
return idMax;
}
VOID
MyMergeMenu(
HINSTANCE hinst,
UINT idMainMerge,
UINT idPopupMerge,
LPQCMINFO pqcm)
{
HMENU hmMerge;
UINT idMax = pqcm->idCmdFirst;
UINT idTemp;
if (idMainMerge
&& (hmMerge = LoadPopupMenu(hinst, idMainMerge)) != NULL)
{
idMax = Shell_MergeMenus(
pqcm->hmenu,
hmMerge,
pqcm->indexMenu,
pqcm->idCmdFirst,
pqcm->idCmdLast,
MM_ADDSEPARATOR | MM_SUBMENUSHAVEIDS);
DestroyMenu(hmMerge);
}
if (idPopupMerge
&& (hmMerge = LoadMenu(hinst, MAKEINTRESOURCE(idPopupMerge))) != NULL)
{
idTemp = MyMergePopupMenus(
pqcm->hmenu,
hmMerge,
pqcm->idCmdFirst,
pqcm->idCmdLast);
if (idMax < idTemp)
{
idMax = idTemp;
}
DestroyMenu(hmMerge);
}
pqcm->idCmdFirst = idMax;
}
VOID
MyInsertMenu(
HINSTANCE hinst,
UINT idInsert,
LPQCMINFO pqcm)
{
HMENU hmInsert;
UINT idMax = pqcm->idCmdFirst;
if (idInsert
&& (hmInsert = LoadPopupMenu(hinst, idInsert)) != NULL)
{
for (int i = GetMenuItemCount(hmInsert) - 1; i >= 0; --i)
{
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_ID | MIIM_SUBMENU;
mii.cch = 0; // just in case
if (!GetMenuItemInfo(hmInsert, i, TRUE, &mii))
{
continue;
}
if (!InsertMenuItem(pqcm->hmenu, idMax, TRUE, &mii))
{
++idMax;
}
}
DestroyMenu(hmInsert);
}
pqcm->idCmdFirst = idMax;
}
| 23.553191 | 79 | 0.485095 | King0987654 |
57f016fca6e086220759202675cf1ef3bef9d88e | 427 | cpp | C++ | src/master/cpp/0037.cpp | matiaslindgren/hackerrank-solutions | e4f436fa7e8cfcf04541601d0dcedfaf9bcc338f | [
"MIT"
] | null | null | null | src/master/cpp/0037.cpp | matiaslindgren/hackerrank-solutions | e4f436fa7e8cfcf04541601d0dcedfaf9bcc338f | [
"MIT"
] | null | null | null | src/master/cpp/0037.cpp | matiaslindgren/hackerrank-solutions | e4f436fa7e8cfcf04541601d0dcedfaf9bcc338f | [
"MIT"
] | null | null | null |
//Overload operators + and << for the class complex
//+ should add two complex numbers as (a+ib) + (c+id) = (a+c) + i(b+d)
//<< should print a complex number in the format "a+ib"
Complex operator+(Complex const& lhs, Complex const& rhs) {
Complex sum;
sum.a = lhs.a + rhs.a;
sum.b = lhs.b + rhs.b;
return sum;
}
ostream& operator<<(ostream& os, Complex const& c) {
return os << c.a << "+i" << c.b;
}
| 23.722222 | 70 | 0.594848 | matiaslindgren |
57f14eceab53df2bda30aaf4aab681f826a5042d | 754 | hpp | C++ | src/almost/primesieve-5.6.0/include/primesieve/primesieve_error.hpp | bgwines/project-euler | 06c0dd8e4b2de2909bb8f48e9b02d181de7a19b0 | [
"BSD-3-Clause"
] | null | null | null | src/almost/primesieve-5.6.0/include/primesieve/primesieve_error.hpp | bgwines/project-euler | 06c0dd8e4b2de2909bb8f48e9b02d181de7a19b0 | [
"BSD-3-Clause"
] | null | null | null | src/almost/primesieve-5.6.0/include/primesieve/primesieve_error.hpp | bgwines/project-euler | 06c0dd8e4b2de2909bb8f48e9b02d181de7a19b0 | [
"BSD-3-Clause"
] | null | null | null | ///
/// @file primesieve_error.hpp
/// @brief The primesieve_error class is used for all exceptions
/// within primesieve.
///
/// Copyright (C) 2013 Kim Walisch, <kim.walisch@gmail.com>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///
#ifndef PRIMESIEVE_ERROR_HPP
#define PRIMESIEVE_ERROR_HPP
#include <stdexcept>
#include <string>
namespace primesieve {
/// primesieve throws a primesieve_error exception
/// if an error occurs that cannot be handled
/// e.g. stop > primesieve::max_stop().
///
class primesieve_error : public std::runtime_error
{
public:
primesieve_error(const std::string& msg)
: std::runtime_error(msg)
{ }
};
} // namespace primesieve
#endif
| 21.542857 | 67 | 0.709549 | bgwines |
57f1b76dc005b240d929f240073585fe1410f9e5 | 822 | cpp | C++ | Problem 4/main4.cpp | NickKaparinos/Project-Euler-Solutions | 6dbb884a79b01e8b8712ffbb623bcc4d809d3f53 | [
"MIT"
] | null | null | null | Problem 4/main4.cpp | NickKaparinos/Project-Euler-Solutions | 6dbb884a79b01e8b8712ffbb623bcc4d809d3f53 | [
"MIT"
] | null | null | null | Problem 4/main4.cpp | NickKaparinos/Project-Euler-Solutions | 6dbb884a79b01e8b8712ffbb623bcc4d809d3f53 | [
"MIT"
] | null | null | null | /*
Project Euler Problem 4
Nick Kaparinos
2021
*/
#include <iostream>
#include <string>
using namespace std;
bool is_palindrome(int number) {
string str = to_string(number);
int num_iterations = str.size() / 2;
for (int i = 0; i <= num_iterations; i++) {
if (str[i] != str[str.size() - 1 - i]) {
return false;
}
}
return true;
}
int main(int argc, char *argv[]) {
int result = -1;
for (int i = 999; i > 1; i--) {
for (int j = 999; j > 1; j--) {
int product = i * j;
if (is_palindrome(product)) {
if (product > result) {
result = product;
}
}
if (product <= result) {
break;
}
}
}
cout << result << endl;
} | 18.681818 | 48 | 0.454988 | NickKaparinos |
57f3abd46a69814ddfdfd384134f2e86e414f8d1 | 1,373 | cpp | C++ | ui-qt/LearningDialog/Learning.cpp | qianyongjun123/FPGA-Industrial-Smart-Camera | 54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32 | [
"MIT"
] | 1 | 2017-12-28T08:08:02.000Z | 2017-12-28T08:08:02.000Z | ui-qt/LearningDialog/Learning.cpp | qianyongjun123/FPGA-Industrial-Smart-Camera | 54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32 | [
"MIT"
] | null | null | null | ui-qt/LearningDialog/Learning.cpp | qianyongjun123/FPGA-Industrial-Smart-Camera | 54b3e2c2661cf7f6774a7fb4d6ae637fa73cba32 | [
"MIT"
] | 3 | 2017-12-28T08:08:05.000Z | 2021-11-12T07:59:13.000Z | #include "Learning.h"
#include "ui_Learning.h"
#include <QSettings>
#include <QDebug>
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
Learning::Learning(QWidget *parent) :
QDialog(parent),
ui(new Ui::Learning)
{
ui->setupUi(this);
this->move(272,520);
this->setWindowFlags(Qt::WindowTitleHint);
m_Timer = new QTimer;
connect(m_Timer,&QTimer::timeout,this,&Learning::TimerSlot);
ui->pushButton->setVisible(false);
m_Timer->start(200);
}
Learning::~Learning()
{
delete ui;
}
/**
* @brief Learning::on_pushButton_clicked
* @author dgq
* @note OK按钮响应函数
*/
void Learning::on_pushButton_clicked()
{
QDialog::reject();
}
/**
* @brief Learning::SetResultString
* @param code_str
* @author dgq
* @note 设置取样结果信息
*/
void Learning::SetResultString(QString code_str)
{
ui->pushButton->setVisible(true);
m_Timer->stop();
m_rst_Str = code_str;
ui->textBrowser->setText(code_str);
ui->progressBar->setValue(100);
}
/**
* @brief Learning::TimerSlot
* @author dgq
* @note 刷新进度条的定时器响应函数
*/
void Learning::TimerSlot()
{
// qDebug()<<"ui->progressBar->value() =="<<ui->progressBar->value();
if(ui->progressBar->value() < 99)
ui->progressBar->setValue(ui->progressBar->value()+1);
else
{
m_Timer->stop();
ui->textBrowser->setText(tr("取样超时!"));
}
}
| 19.898551 | 72 | 0.648216 | qianyongjun123 |
57f706b45ea85e8e8f4efc09bb3698c64fb97bc9 | 4,638 | cpp | C++ | Qor/ViewModel.cpp | flipcoder/qor | 7a2ebf667be4c913fbc7daf5e0b07a4c1723389d | [
"MIT"
] | 84 | 2015-03-30T14:29:29.000Z | 2022-01-28T12:29:25.000Z | Qor/ViewModel.cpp | flipcoder/qor | 7a2ebf667be4c913fbc7daf5e0b07a4c1723389d | [
"MIT"
] | 5 | 2016-01-22T18:54:35.000Z | 2021-07-24T10:21:12.000Z | Qor/ViewModel.cpp | flipcoder/qor | 7a2ebf667be4c913fbc7daf5e0b07a4c1723389d | [
"MIT"
] | 22 | 2015-08-06T05:32:29.000Z | 2022-03-05T13:20:46.000Z | #include "ViewModel.h"
#include <memory>
using namespace std;
ViewModel :: ViewModel(shared_ptr<Camera> camera, shared_ptr<Node> node):
Tracker(static_pointer_cast<Node>(camera), Tracker::ORIENT, Freq::Time::ms(25)),
m_pCamera(camera.get()),
m_pNode(node)
{
assert(node);
assert(camera);
assert(not node->parent());
///if(node->parent() != this)
add(node);
fov(m_pCamera->fov());
m_SprintLowerAnim.stop(0.0f);
m_SprintRotateAnim.stop(0.0f);
m_RecoilAnim.stop(0.0f);
m_EquipAnim.stop(0.0f);
reset_zoom();
}
void ViewModel :: logic_self(Freq::Time t)
{
Tracker::logic_self(t);
auto targ = target();
if(not targ)
return;
position(targ->position(Space::WORLD));
m_ZoomAnim.logic(t);
m_SprintLowerAnim.logic(t);
m_SprintRotateAnim.logic(t);
m_ZoomFOVAnim.logic(t);
m_RecoilAnim.logic(t);
m_EquipAnim.logic(t);
m_pNode->position(
m_ZoomAnim.get() +
glm::vec3(0.0f, m_SprintLowerAnim.get() + m_EquipAnim.get(), 0.0f));
m_pCamera->fov(m_ZoomFOVAnim.get());
m_pNode->reset_orientation();
m_pNode->rotate(m_SprintRotateAnim.get(), Axis::Y);
m_SwayOffset = glm::vec3(0.0f);
if(m_bSway && not m_bZoomed)
{
m_SwayTime += t.s();
const float SwaySpeed = 1.0f;
m_SwayTime -= trunc(m_SwayTime);
m_SwayOffset = glm::vec3(
-0.01f * sin(m_SwayTime * SwaySpeed * K_TAU),
0.005f * cos(m_SwayTime * SwaySpeed * 2.0f * K_TAU),
0.01f * -sin(m_SwayTime * SwaySpeed * 2.0f * K_TAU)
);
}
m_SwayOffset += glm::vec3(
0.0f, 0.0f, m_RecoilAnim.get()
);
m_pNode->move(m_SwayOffset);
}
void ViewModel :: sprint(bool b)
{
if(m_bEquipping)
return;
if(m_bSprint == b)
return;
m_bSprint = b;
if(b)
zoom(false);
m_SprintLowerAnim.stop(
m_bSprint ? -0.15 : 0.0f,
Freq::Time::ms(250),
m_bSprint ? INTERPOLATE(out_sine<float>) : INTERPOLATE(in_sine<float>)
);
m_SprintRotateAnim.stop(
m_bSprint ? (1.0f / 4.0f) : 0.0f,
Freq::Time::ms(250),
m_bSprint ? INTERPOLATE(out_sine<float>) : INTERPOLATE(in_sine<float>)
);
}
void ViewModel :: zoom(bool b, std::function<void()> cb)
{
if(m_bZoomed == b)
return;
if(m_bSprint && b)
return;
m_bZoomed = b;
m_ZoomAnim.finish();
m_ZoomAnim.stop(
m_bZoomed ? m_ZoomedModelPos : m_ModelPos,
m_ZoomTime,
(m_bZoomed ? INTERPOLATE(in_sine<glm::vec3>) : INTERPOLATE(out_sine<glm::vec3>)),
cb
);
m_ZoomFOVAnim.finish();
m_ZoomFOVAnim.stop(
(m_bZoomed ? m_ZoomedFOV : m_DefaultFOV),
m_ZoomTime,
(m_bZoomed ? INTERPOLATE(in_sine<float>) : INTERPOLATE(out_sine<float>))
);
}
void ViewModel :: fast_zoom(bool b)
{
zoom(b);
reset_zoom();
}
void ViewModel :: reset()
{
m_bZoomed = false;
m_pCamera->fov(m_DefaultFOV);
}
void ViewModel :: reset_zoom()
{
m_ZoomAnim.finish();
m_ZoomAnim.stop(m_bZoomed ? m_ZoomedModelPos : m_ModelPos);
//m_bZoomed ? 0.0f : 0.05f,
//m_bZoomed ? -0.04f : -0.06f,
//m_bZoomed ? -0.05f : -0.15f
m_ZoomFOVAnim.finish();
m_ZoomFOVAnim.stop(m_DefaultFOV);
}
void ViewModel :: recoil(Freq::Time out, Freq::Time in, float dist)
{
m_RecoilAnim.stop(0.0f);
m_RecoilAnim.frame(Frame<float>(
dist,
out,
INTERPOLATE(in_sine<float>)
));
m_RecoilAnim.frame(Frame<float>(
0.0f,
in,
INTERPOLATE(in_sine<float>)
));
}
void ViewModel :: equip(bool r, std::function<void()> cb)
{
//if(m_bEquipping)
// return;
if(r == m_bEquip) // redundant
return;
m_bEquipping = true;
m_bEquip = false;
m_onEquip = cb;
m_EquipAnim.abort();
m_EquipAnim.frame(Frame<float>(
r ? 0.0f : -0.5f,
m_EquipTime,
r ? INTERPOLATE(in_sine<float>) : INTERPOLATE(out_sine<float>),
[&,r]{
m_bEquipping = false;
m_bEquip = r;
auto cbc = std::move(m_onEquip);
if(cbc)
cbc();
}
));
}
void ViewModel :: fast_equip(bool r)
{
m_bEquip = r;
m_bEquipping = false;
m_EquipAnim.stop(r ? 0.0f : -0.5f);
}
bool ViewModel :: idle() const
{
return m_SprintRotateAnim.elapsed() &&
not m_bSprint &&
not recoil() &&
not m_bEquipping;
}
ViewModel :: ~ViewModel()
{
}
void ViewModel :: fov(float f)
{
m_DefaultFOV = f;
m_ZoomedFOV = f * (2.0f/3.0f);
}
| 22.735294 | 89 | 0.580423 | flipcoder |
57f7bf9d235a0439aad7bd726c4a233872ded4c8 | 827 | cpp | C++ | src/main.cpp | UniHD-CEG/sonar | 22fae5634f561b8b3a3205d4ca8ef3d38f3e7179 | [
"Unlicense"
] | 1 | 2017-03-15T15:55:09.000Z | 2017-03-15T15:55:09.000Z | src/main.cpp | UniHD-CEG/sonar | 22fae5634f561b8b3a3205d4ca8ef3d38f3e7179 | [
"Unlicense"
] | null | null | null | src/main.cpp | UniHD-CEG/sonar | 22fae5634f561b8b3a3205d4ca8ef3d38f3e7179 | [
"Unlicense"
] | null | null | null | #include <iostream>
#include <globals.h>
#include <config.h>
#include <otf_manager.h>
int main(const int argc, const char* argv[])
{
int error {0};
try
{
std::shared_ptr<Config> cfg = std::make_shared<Config>(argc, argv);
OTF_Manager manager(cfg);
manager.read_otf();
}
catch (const std::invalid_argument &e)
{
std::cout << "invalid_argument: " << e.what() << std::endl;
error = 1;
}
catch (const std::bad_alloc &e)
{
std::cout << "bad_alloc: " << e.what() << std::endl;
error = 2;
}
catch (const std::runtime_error &e)
{
std::cout << "runtime_error: " << e.what() << std::endl;
error = 3;
}
catch (const std::exception &e)
{
std::cout << "exception: " << e.what() << std::endl;
error = 4;
}
catch (...)
{
std::cout << "Unknown error!" << "\n";
error = 255;
}
return error;
}
| 17.978261 | 69 | 0.588875 | UniHD-CEG |
57f82d0db49acb6f2a1bf3edbf0bbfad94ccae0c | 5,067 | cpp | C++ | Quasar/src/Quasar/Scene/Scene.cpp | rvillegasm/Quasar | 69a3e518030b52502bd1bf700cd6a44dc104d697 | [
"Apache-2.0"
] | null | null | null | Quasar/src/Quasar/Scene/Scene.cpp | rvillegasm/Quasar | 69a3e518030b52502bd1bf700cd6a44dc104d697 | [
"Apache-2.0"
] | null | null | null | Quasar/src/Quasar/Scene/Scene.cpp | rvillegasm/Quasar | 69a3e518030b52502bd1bf700cd6a44dc104d697 | [
"Apache-2.0"
] | null | null | null | #include "Scene.hpp"
#include "Quasar/Renderer/Renderer2D.hpp"
#include "Quasar/Renderer/Camera.hpp"
#include "Quasar/Scene/Components.hpp"
#include "Quasar/Scene/Entity.hpp"
namespace Quasar
{
Scene::Scene()
{
}
Entity Scene::createEntity(const std::string &name)
{
Entity entity = { m_Registry.create(), this };
entity.addComponent<TransformComponent>();
auto &tagComponent = entity.addComponent<TagComponent>();
tagComponent.tag = name.empty() ? "Entity" : name;
return entity;
}
void Scene::destroyEntity(Entity entity)
{
m_Registry.destroy(entity);
}
void Scene::onUpdateRuntime(Timestep ts)
{
// Update Native Scripts
m_Registry.view<NativeScriptComponent>().each([this, ts](auto entity, NativeScriptComponent &nsc)
{
// TODO: Move to Scene::onScenePlay
if (!nsc.instance)
{
nsc.instance = nsc.instantiateScript();
nsc.instance->m_Entity = Entity{ entity, this };
nsc.instance->onCreate();
}
nsc.instance->onUpdate(ts);
});
// Render 2D
Camera *mainCamera = nullptr;
glm::mat4 cameraTransform;
auto tcView = m_Registry.view<TransformComponent, CameraComponent>();
for (auto entity : tcView)
{
auto [transformComponent, cameraComponent] = tcView.get<TransformComponent, CameraComponent>(entity);
if (cameraComponent.primary)
{
mainCamera = &cameraComponent.camera;
cameraTransform = transformComponent.getTransform();
break;
}
}
if (mainCamera)
{
Renderer2D::beginScene(*mainCamera, cameraTransform);
auto tsGroup = m_Registry.group<TransformComponent>(entt::get<SpriteRendererComponent>);
for (auto entity : tsGroup)
{
auto [transformComponent, spriteComponent] = tsGroup.get<TransformComponent, SpriteRendererComponent>(entity);
Renderer2D::drawSprite(transformComponent.getTransform(), spriteComponent, (int)entity);
}
Renderer2D::endScene();
}
}
void Scene::onUpdateEditor(Timestep ts, EditorCamera &camera)
{
Renderer2D::beginScene(camera);
auto tsGroup = m_Registry.group<TransformComponent>(entt::get<SpriteRendererComponent>);
for (auto entity : tsGroup)
{
auto [transformComponent, spriteComponent] = tsGroup.get<TransformComponent, SpriteRendererComponent>(entity);
Renderer2D::drawSprite(transformComponent.getTransform(), spriteComponent, (int)entity);
}
Renderer2D::endScene();
}
void Scene::onViewportResize(uint32_t width, uint32_t height)
{
m_ViewportWidth = width;
m_ViewportHeight = height;
// Resize our non-fixed aspect ratio cameras
auto cView = m_Registry.view<CameraComponent>();
for (auto entity : cView)
{
auto &cameraComponent = cView.get<CameraComponent>(entity);
if (!cameraComponent.fixedAspectRatio)
{
cameraComponent.camera.setViewportSize(width, height);
}
}
}
Entity Scene::getPrimaryCameraEntity()
{
auto cView = m_Registry.view<CameraComponent>();
for (auto entity : cView)
{
const auto &cameraComponent = cView.get<CameraComponent>(entity);
if (cameraComponent.primary)
{
return Entity{ entity, this };
}
}
return {};
}
template<typename T>
void Scene::onComponentAdded(Entity entity, T &component)
{ // There should always be a template specialization
}
template<>
void Scene::onComponentAdded<TagComponent>(Entity entity, TagComponent &component)
{ // Nothing for now; Maybe do something in the future
}
template<>
void Scene::onComponentAdded<TransformComponent>(Entity entity, TransformComponent &component)
{ // Nothing for now; Maybe do something in the future
}
template<>
void Scene::onComponentAdded<SpriteRendererComponent>(Entity entity, SpriteRendererComponent &component)
{ // Nothing for now; Maybe do something in the future
}
template<>
void Scene::onComponentAdded<CameraComponent>(Entity entity, CameraComponent &component)
{
if (m_ViewportWidth > 0 && m_ViewportHeight > 0)
{
component.camera.setViewportSize(m_ViewportWidth, m_ViewportHeight);
}
}
template<>
void Scene::onComponentAdded<NativeScriptComponent>(Entity entity, NativeScriptComponent &component)
{ // Nothing for now; Maybe do something in the future
}
// TODO: add onComponentRemoved as well (for example for destraying script instances)
} // namespace Quasar
| 31.47205 | 126 | 0.613973 | rvillegasm |
57f8633bcaca80045b5acb151abadb9aef5abc3c | 3,113 | hpp | C++ | packages/kokkos/core/src/impl/Kokkos_Rendezvous.hpp | mathstuf/seacas | 49b3466e3bba12ec6597e364ce0f0f149f9ca909 | [
"BSD-3-Clause",
"NetCDF",
"Zlib",
"MIT"
] | null | null | null | packages/kokkos/core/src/impl/Kokkos_Rendezvous.hpp | mathstuf/seacas | 49b3466e3bba12ec6597e364ce0f0f149f9ca909 | [
"BSD-3-Clause",
"NetCDF",
"Zlib",
"MIT"
] | null | null | null | packages/kokkos/core/src/impl/Kokkos_Rendezvous.hpp | mathstuf/seacas | 49b3466e3bba12ec6597e364ce0f0f149f9ca909 | [
"BSD-3-Clause",
"NetCDF",
"Zlib",
"MIT"
] | null | null | null | /*
//@HEADER
// ************************************************************************
//
// Kokkos v. 2.0
// Copyright (2014) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_IMPL_RENDEZVOUS_HPP
#define KOKKOS_IMPL_RENDEZVOUS_HPP
#include <cstdint>
namespace Kokkos { namespace Impl {
inline
constexpr int rendezvous_buffer_size( int max_members ) noexcept
{
return (((max_members + 7) / 8) * 4) + 4 + 4;
}
/** \brief Thread pool rendezvous
*
* Rendezvous pattern:
* if ( rendezvous(root) ) {
* ... only root thread here while all others wait ...
* rendezvous_release();
* }
* else {
* ... all other threads release here ...
* }
*
* Requires: buffer[ rendezvous_buffer_size( max_threads ) ];
*
* When slow != 0 the expectation is thread arrival will be
* slow so the threads that arrive early should quickly yield
* their core to the runtime thus possibly allowing the late
* arriving threads to have more resources
* (e.g., power and clock frequency).
*/
int rendezvous( volatile int64_t * const buffer
, int const size
, int const rank
, int const slow = 0 ) noexcept ;
void rendezvous_release( volatile int64_t * const buffer ) noexcept ;
}} // namespace Kokkos::Impl
#endif // KOKKOS_IMPL_RENDEZVOUS_HPP
| 35.375 | 75 | 0.6823 | mathstuf |
57f876e6f245324c90ff20460666832b75390b2e | 427 | cpp | C++ | timus/1880.cpp | y-wan/OJ | 5dea140dbaaec98e440ad4b1c10fa5072f1ceea7 | [
"MIT"
] | null | null | null | timus/1880.cpp | y-wan/OJ | 5dea140dbaaec98e440ad4b1c10fa5072f1ceea7 | [
"MIT"
] | null | null | null | timus/1880.cpp | y-wan/OJ | 5dea140dbaaec98e440ad4b1c10fa5072f1ceea7 | [
"MIT"
] | null | null | null | #include <iostream>
#include <string>
#include <map>
using namespace std;
map<int, int> dict;
int main() {
int a, tmp, kase = 0, res = 0;
while (cin >> a) {
kase++;
for (int i = 0; i < a; i++) {
cin >> tmp;
if (!dict.count(tmp)) dict[tmp] = 1;
else dict[tmp]++;
}
}
for (map<int, int>::iterator it = dict.begin(); it != dict.end(); it++)
if (it->second == kase) res++;
cout << res << endl;
return 0;
}
| 18.565217 | 72 | 0.540984 | y-wan |
520605250313984057f9925718623df850d46c51 | 311 | cpp | C++ | ch0105/ch0105_07.cpp | sun1218/openjudge | 07e44235fc6ac68bf8e8125577dcd008b08d59ec | [
"MIT"
] | null | null | null | ch0105/ch0105_07.cpp | sun1218/openjudge | 07e44235fc6ac68bf8e8125577dcd008b08d59ec | [
"MIT"
] | null | null | null | ch0105/ch0105_07.cpp | sun1218/openjudge | 07e44235fc6ac68bf8e8125577dcd008b08d59ec | [
"MIT"
] | 1 | 2021-05-16T13:36:06.000Z | 2021-05-16T13:36:06.000Z | #include <iostream>
#include <cstdio>
using namespace std;
int main(void){
int n,x=0,y=0,z=0,c=0;
scanf("%d",&n);
for(int i = 0;i<n;i++){
int temp1,temp2,temp3;
scanf("%d%d%d",&temp1,&temp2,&temp3);
x += temp1;
y += temp2;
z += temp3;
}
c += (x+y+z);
printf("%d %d %d %d",x,y,z,c);
return 0;
}
| 17.277778 | 39 | 0.546624 | sun1218 |
5206522abfa144bbf6f920469aa768667566b9bc | 4,006 | hpp | C++ | modules/dnn/src/cuda/functors.hpp | artun3e/opencv | 524a2fffe96195b906a95b548b0a185d3251eb7e | [
"BSD-3-Clause"
] | 4 | 2020-06-29T20:14:08.000Z | 2020-12-12T20:04:25.000Z | modules/dnn/src/cuda/functors.hpp | artun3e/opencv | 524a2fffe96195b906a95b548b0a185d3251eb7e | [
"BSD-3-Clause"
] | null | null | null | modules/dnn/src/cuda/functors.hpp | artun3e/opencv | 524a2fffe96195b906a95b548b0a185d3251eb7e | [
"BSD-3-Clause"
] | 1 | 2022-01-19T15:08:40.000Z | 2022-01-19T15:08:40.000Z | // This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_DNN_SRC_CUDA_FUNCTORS_HPP
#define OPENCV_DNN_SRC_CUDA_FUNCTORS_HPP
#include <cuda_runtime.h>
#include "math.hpp"
namespace cv { namespace dnn { namespace cuda4dnn { namespace kernels {
template <class T>
struct abs_functor {
__device__ T operator()(T value) {
using csl::device::abs;
return abs(value);
}
};
template <class T>
struct tanh_functor {
__device__ T operator()(T value) {
using csl::device::tanh;
return tanh(value);
}
};
template <class T>
struct swish_functor {
__device__ T operator()(T value) {
// f(x) = x * sigmoid(x)
using csl::device::fast_divide;
using csl::device::fast_exp;
return fast_divide(value, static_cast<T>(1) + fast_exp(-value));
}
};
template <class T>
struct mish_functor {
__device__ T operator()(T value) {
using csl::device::tanh;
using csl::device::log1pexp;
return value * tanh(log1pexp(value));
}
};
template <>
struct mish_functor<float> {
__device__ float operator()(float value) {
// f(x) = x * tanh(log1pexp(x));
using csl::device::fast_divide;
using csl::device::fast_exp;
auto e = fast_exp(value);
auto n = e * e + 2 * e;
if (value <= -0.6f)
return value * fast_divide(n, n + 2);
return value - 2 * fast_divide(value, n + 2);
}
};
#if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 530)
template <>
struct mish_functor<__half> {
__device__ __half operator()(__half value) {
return mish_functor<float>()(value);
}
};
#endif
template <class T>
struct sigmoid_functor {
__device__ T operator()(T value) {
using csl::device::fast_sigmoid;
return fast_sigmoid(value);
}
};
template <class T>
struct bnll_functor {
__device__ T operator()(T value) {
using csl::device::log1pexp;
return value > T(0) ? value + log1pexp(-value) : log1pexp(value);
}
};
template <class T>
struct elu_functor {
__device__ T operator()(T value) {
using csl::device::expm1;
return value >= T(0) ? value : expm1(value);
}
};
template <class T>
struct relu_functor {
__device__ relu_functor(T slope_) : slope{slope_} { }
__device__ T operator()(T value) {
using csl::device::log1pexp;
return value >= T(0) ? value : slope * value;
}
T slope;
};
template <class T>
struct clipped_relu_functor {
__device__ clipped_relu_functor(T floor_, T ceiling_) : floor{floor_}, ceiling{ceiling_} { }
__device__ T operator()(T value) {
using csl::device::clamp;
return clamp(value, floor, ceiling);
}
T floor, ceiling;
};
template <class T>
struct power_functor {
__device__ power_functor(T exp_, T scale_, T shift_) : exp{exp_}, scale{scale_}, shift{shift_} { }
__device__ T operator()(T value) {
using csl::device::pow;
return pow(shift + scale * value, exp);
}
T exp, scale, shift;
};
template <class T>
struct max_functor {
__device__ T operator()(T x, T y) {
using csl::device::max;
return max(x, y);
}
};
template <class T>
struct sum_functor {
__device__ T operator()(T x, T y) { return x + y; }
};
template <class T>
struct scaled_sum_functor {
__device__ scaled_sum_functor(T scale_x_, T scale_y_)
: scale_x{scale_x_}, scale_y{scale_y_} { }
__device__ T operator()(T x, T y) { return scale_x * x + scale_y * y; }
T scale_x, scale_y;
};
template <class T>
struct product_functor {
__device__ T operator()(T x, T y) { return x * y; }
};
template <class T>
struct div_functor {
__device__ T operator()(T x, T y) { return x / y; }
};
}}}} /* namespace cv::dnn::cuda4dnn::kernels */
#endif /* OPENCV_DNN_SRC_CUDA_FUNCTORS_HPP */ | 24.278788 | 102 | 0.629056 | artun3e |
52093c109bab03ed6eecf1cbd7180560402e6d1b | 705 | cpp | C++ | Dataset/Leetcode/valid/66/644.cpp | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/valid/66/644.cpp | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/valid/66/644.cpp | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | class Solution {
public:
vector<int> XXX(vector<int>& digits) {
digits[digits.size() - 1] = digits[digits.size() - 1] + 1;
bool FLAG = false; //记录是否进位;
for (int i = digits.size() - 1; i > 0; i--)
{
if (digits[i] >= 10)
{
digits[i] = digits[i] - 10;
digits[i - 1] = digits[i - 1] + 1;
}
}
if (digits[0] >= 10)
{
digits[0] = digits[0] - 10;
FLAG = true;
}
vector<int> outcome;
if (FLAG) outcome.push_back(1);
for (int j = 0; j < digits.size(); j++) outcome.push_back(digits[j]);
return outcome;
}
};
| 25.178571 | 77 | 0.41844 | kkcookies99 |
52093ff0013f1a3c41a541c5edcf5e3dfc562a3b | 11,016 | hpp | C++ | Lib-Core/include/skipifzero_pool.hpp | PetorSFZ/sfz_tech | 0d4027ad2c2bb444b83e78f009b649478cb97a73 | [
"Zlib"
] | 2 | 2020-09-04T16:52:47.000Z | 2021-04-21T18:30:25.000Z | Lib-Core/include/skipifzero_pool.hpp | PetorSFZ/sfz_tech | 0d4027ad2c2bb444b83e78f009b649478cb97a73 | [
"Zlib"
] | null | null | null | Lib-Core/include/skipifzero_pool.hpp | PetorSFZ/sfz_tech | 0d4027ad2c2bb444b83e78f009b649478cb97a73 | [
"Zlib"
] | null | null | null | // Copyright (c) Peter Hillerström (skipifzero.com, peter@hstroem.se)
//
// 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 SKIPIFZERO_POOL_HPP
#define SKIPIFZERO_POOL_HPP
#pragma once
#include <new>
#include "skipifzero.hpp"
namespace sfz {
// PoolSlot
// ------------------------------------------------------------------------------------------------
constexpr u8 POOL_SLOT_ACTIVE_BIT_MASK = u8(0x80);
constexpr u8 POOL_SLOT_VERSION_MASK = u8(0x7F);
// Represents meta data about a slot in a Pool's value array.
//
// The first 7 bits stores the version of the slot. Each time the slot is "allocated" the version
// is increased. When it reaches 128 it wraps around to 1. Versions are in range [1, 127], 0 is
// reserved as invalid.
//
// The 8th bit is the "active" bit, i.e. whether the slot is currently in use (allocated) or not.
struct PoolSlot final {
u8 bits;
u8 version() const { return bits & POOL_SLOT_VERSION_MASK; }
bool active() const { return (bits & POOL_SLOT_ACTIVE_BIT_MASK) != u8(0); }
};
static_assert(sizeof(PoolSlot) == 1, "PoolSlot is padded");
// Pool
// ------------------------------------------------------------------------------------------------
constexpr u32 POOL_MAX_CAPACITY = 1u << SFZ_HANDLE_INDEX_NUM_BITS;
// An sfz::Pool is a datastructure that is somewhat a mix between an array, an allocator and the
// entity allocation part of an ECS system. Basically, it's an array from which you allocate
// slots from. The array can have holes where you have deallocated objects. Each slot have an
// associated version number so stale handles can't be used when a slot has been deallocated and
// then allocated again.
//
// It is more of a low-level datastructure than either sfz::Array or sfz::HashMap, it is not as
// general purpose as either of those. The following restrictions apply:
//
// * Will only call destructors when the entire pool is destroyed. When deallocating a slot it
// will be set to "{}", or a user-defined value. The type must support this.
// * Does not support resize, capacity must be specified in advance.
// * Pointers are guaranteed stable because values are never moved/copied, due to above.
// * There is no "_Local" variant, because then pointers would not be stable.
//
// It's possible to manually (and efficiently) iterate over the contents of a Pool. Example:
//
// T* values = pool.data();
// const PoolSlot* slots = pool.slots();
// const u32 arraySize = pool.arraySize();
// for (u32 idx = 0; idx < arraySize; idx++) {
// PoolSlot slot = slots[idx];
// T& value = values[idx];
// // "value" will always be initialized here, but depending on your use case it's probably
// // a bug to read/write to it. Mostly you will want to do the active check shown below.
// if (!slot.active()) continue;
// // Now value should be guaranteed safe to use regardless of your use case
// }
//
// A Pool will never "shrink", i.e. arraySize() will never return a smaller value than before until
// you destroy() the pool completely.
template<typename T>
class Pool final {
public:
SFZ_DECLARE_DROP_TYPE(Pool);
explicit Pool(u32 capacity, SfzAllocator* allocator, SfzDbgInfo allocDbg) noexcept
{
this->init(capacity, allocator, allocDbg);
}
// State methods
// --------------------------------------------------------------------------------------------
void init(u32 capacity, SfzAllocator* allocator, SfzDbgInfo allocDbg)
{
sfz_assert(capacity != 0); // We don't support resize, so this wouldn't make sense.
sfz_assert(capacity <= POOL_MAX_CAPACITY);
sfz_assert(alignof(T) <= 32);
// Destroy previous pool
this->destroy();
// Calculate offsets, allocate memory and clear it
const u32 alignment = 32;
const u32 slotsOffset = u32(roundUpAligned(sizeof(T) * capacity, alignment));
const u32 freeIndicesOffset =
slotsOffset + u32(roundUpAligned(sizeof(PoolSlot) * capacity, alignment));
const u32 numBytesNeeded =
freeIndicesOffset + u32(roundUpAligned(sizeof(u32) * capacity, alignment));
u8* memory = reinterpret_cast<u8*>(
allocator->alloc(allocDbg, numBytesNeeded, alignment));
memset(memory, 0, numBytesNeeded);
// Set members
mAllocator = allocator;
mCapacity = capacity;
mData = reinterpret_cast<T*>(memory);
mSlots = reinterpret_cast<PoolSlot*>(memory + slotsOffset);
mFreeIndices = reinterpret_cast<u32*>(memory + freeIndicesOffset);
}
void destroy()
{
if (mData != nullptr) {
// Only call destructors if T is not trivially destructible
if constexpr (!std::is_trivially_destructible_v<T>) {
for (u32 i = 0; i < mArraySize; i++) {
mData[i].~T();
}
}
mAllocator->dealloc(mData);
}
mNumAllocated = 0;
mArraySize = 0;
mCapacity = 0;
mData = nullptr;
mSlots = nullptr;
mFreeIndices = nullptr;
mAllocator = nullptr;
}
// Getters
// --------------------------------------------------------------------------------------------
u32 numAllocated() const { return mNumAllocated; }
u32 numHoles() const { return mArraySize - mNumAllocated; }
u32 arraySize() const { return mArraySize; }
u32 capacity() const { return mCapacity; }
bool isFull() const { return mNumAllocated >= mCapacity; }
const T* data() const { return mData; }
T* data() { return mData; }
const PoolSlot* slots() const { return mSlots; }
SfzAllocator* allocator() const { return mAllocator; }
PoolSlot getSlot(u32 idx) const { sfz_assert(idx < mArraySize); return mSlots[idx]; }
u8 getVersion(u32 idx) const { sfz_assert(idx < mArraySize); return mSlots[idx].version(); }
bool slotIsActive(u32 idx) const { sfz_assert(idx < mArraySize); return mSlots[idx].active(); }
bool handleIsValid(SfzHandle handle) const
{
const u32 idx = handle.idx();
if (idx >= mArraySize) return false;
PoolSlot slot = mSlots[idx];
if (!slot.active()) return false;
if (handle.version() != slot.version()) return false;
sfz_assert(slot.version() != u8(0));
return true;
}
T* get(SfzHandle handle)
{
const u8 version = handle.version();
const u32 idx = handle.idx();
if (idx >= mArraySize) return nullptr;
PoolSlot slot = mSlots[idx];
if (slot.version() != version) return nullptr;
if (!slot.active()) return nullptr;
return &mData[idx];
}
const T* get(SfzHandle handle) const { return const_cast<Pool<T>*>(this)->get(handle); }
T& operator[] (SfzHandle handle) { T* v = get(handle); sfz_assert(v != nullptr); return *v; }
const T& operator[] (SfzHandle handle) const { return (*const_cast<Pool<T>*>(this))[handle]; }
// Methods
// --------------------------------------------------------------------------------------------
SfzHandle allocate() { return allocateImpl<T>({}); }
SfzHandle allocate(const T& value) { return allocateImpl<const T&>(value); }
SfzHandle allocate(T&& value) { return allocateImpl<T>(sfz_move(value)); }
void deallocate(SfzHandle handle) { return deallocateImpl<T>(handle, {}); }
void deallocate(SfzHandle handle, const T& emptyValue) { return deallocateImpl<const T&>(handle, emptyValue); }
void deallocate(SfzHandle handle, T&& emptyValue) { return deallocateImpl<T>(handle, sfz_move(emptyValue)); }
void deallocate(u32 idx) { return deallocateImpl<T>(idx, {}); }
void deallocate(u32 idx, const T& emptyValue) { return deallocateImpl<const T&>(idx, emptyValue); }
void deallocate(u32 idx, T&& emptyValue) { return deallocateImpl<T>(idx, sfz_move(emptyValue)); }
private:
// Private methods
// --------------------------------------------------------------------------------------------
// Perfect forwarding: const reference: ForwardT == const T&, rvalue: ForwardT == T
// std::forward<ForwardT>(value) will then return the correct version of value
template<typename ForwardT>
SfzHandle allocateImpl(ForwardT&& value)
{
sfz_assert(mNumAllocated < mCapacity);
// Different path depending on if there are holes or not
const u32 holes = numHoles();
u32 idx = ~0u;
if (holes > 0) {
idx = mFreeIndices[holes - 1];
mFreeIndices[holes - 1] = 0;
// If we are reusing a slot the memory should already be constructed, therefore we
// should use move/copy assignment in order to make sure we don't skip running a
// destructor.
mData[idx] = sfz_forward(value);
}
else {
idx = mArraySize;
mArraySize += 1;
// First time we are using this slot, memory is uninitialized and need to be
// initialized before usage. Therefore use placement new move/copy constructor.
new (mData + idx) T(sfz_forward(value));
}
// Update number of allocated
mNumAllocated += 1;
sfz_assert(idx < mArraySize);
sfz_assert(mArraySize <= mCapacity);
sfz_assert(mNumAllocated <= mArraySize);
// Update active bit and version in slot
PoolSlot& slot = mSlots[idx];
sfz_assert(!slot.active());
u8 newVersion = slot.bits + 1;
if (newVersion > 127) newVersion = 1;
slot.bits = POOL_SLOT_ACTIVE_BIT_MASK | newVersion;
// Create and return handle
SfzHandle handle = SfzHandle::create(idx, newVersion);
return handle;
}
template<typename ForwardT>
void deallocateImpl(SfzHandle handle, ForwardT&& emptyValue)
{
const u32 idx = handle.idx();
sfz_assert(idx < mArraySize);
sfz_assert(handle.version() == getVersion(idx));
deallocateImpl<ForwardT>(idx, sfz_forward(emptyValue));
}
template<typename ForwardT>
void deallocateImpl(u32 idx, ForwardT&& emptyValue)
{
sfz_assert(mNumAllocated > 0);
sfz_assert(idx < mArraySize);
PoolSlot& slot = mSlots[idx];
sfz_assert(slot.active());
sfz_assert(slot.version() != 0);
// Set version and empty value
slot.bits = slot.version(); // Remove active bit
mData[idx] = sfz_forward(emptyValue);
mNumAllocated -= 1;
// Store the new hole in free indices
const u32 holes = numHoles();
sfz_assert(holes > 0);
mFreeIndices[holes - 1] = idx;
}
// Private members
// --------------------------------------------------------------------------------------------
u32 mNumAllocated = 0;
u32 mArraySize = 0;
u32 mCapacity = 0;
T* mData = nullptr;
PoolSlot* mSlots = nullptr;
u32* mFreeIndices = nullptr;
SfzAllocator* mAllocator = nullptr;
};
} // namespace sfz
#endif
| 36.842809 | 112 | 0.662763 | PetorSFZ |
5209f798b0fdddaf2e99a1830c64686aeb7cab41 | 1,278 | hpp | C++ | android-31/android/widget/FrameLayout.hpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 12 | 2020-03-26T02:38:56.000Z | 2022-03-14T08:17:26.000Z | android-31/android/widget/FrameLayout.hpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 1 | 2021-01-27T06:07:45.000Z | 2021-11-13T19:19:43.000Z | android-29/android/widget/FrameLayout.hpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 3 | 2021-02-02T12:34:55.000Z | 2022-03-08T07:45:57.000Z | #pragma once
#include "../view/ViewGroup.hpp"
namespace android::content
{
class Context;
}
namespace android::view
{
class ViewGroup_LayoutParams;
}
namespace android::widget
{
class FrameLayout_LayoutParams;
}
class JString;
namespace android::widget
{
class FrameLayout : public android::view::ViewGroup
{
public:
// Fields
// QJniObject forward
template<typename ...Ts> explicit FrameLayout(const char *className, const char *sig, Ts...agv) : android::view::ViewGroup(className, sig, std::forward<Ts>(agv)...) {}
FrameLayout(QJniObject obj);
// Constructors
FrameLayout(android::content::Context arg0);
FrameLayout(android::content::Context arg0, JObject arg1);
FrameLayout(android::content::Context arg0, JObject arg1, jint arg2);
FrameLayout(android::content::Context arg0, JObject arg1, jint arg2, jint arg3);
// Methods
android::widget::FrameLayout_LayoutParams generateLayoutParams(JObject arg0) const;
JString getAccessibilityClassName() const;
jboolean getConsiderGoneChildrenWhenMeasuring() const;
jboolean getMeasureAllChildren() const;
void setForegroundGravity(jint arg0) const;
void setMeasureAllChildren(jboolean arg0) const;
jboolean shouldDelayChildPressedState() const;
};
} // namespace android::widget
| 27.191489 | 169 | 0.758216 | YJBeetle |
520a20b05947e2ceb5ade199cb60f9b86fe1dd4a | 277 | hpp | C++ | include/RED4ext/Scripting/Natives/Generated/quest/VisionModeType.hpp | jackhumbert/RED4ext.SDK | 2c55eccb83beabbbe02abae7945af8efce638fca | [
"MIT"
] | 42 | 2020-12-25T08:33:00.000Z | 2022-03-22T14:47:07.000Z | include/RED4ext/Scripting/Natives/Generated/quest/VisionModeType.hpp | jackhumbert/RED4ext.SDK | 2c55eccb83beabbbe02abae7945af8efce638fca | [
"MIT"
] | 38 | 2020-12-28T22:36:06.000Z | 2022-02-16T11:25:47.000Z | include/RED4ext/Scripting/Natives/Generated/quest/VisionModeType.hpp | jackhumbert/RED4ext.SDK | 2c55eccb83beabbbe02abae7945af8efce638fca | [
"MIT"
] | 20 | 2020-12-28T22:17:38.000Z | 2022-03-22T17:19:01.000Z | #pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
namespace RED4ext
{
namespace quest {
enum class VisionModeType : uint32_t
{
Undefined = 0,
FocusMode = 1,
EnhancedMode = 2,
};
} // namespace quest
} // namespace RED4ext
| 16.294118 | 57 | 0.696751 | jackhumbert |
520a7d315c017eb83cd8c8537513b82b64f44da7 | 277 | cpp | C++ | Source/Client/Main.cpp | chahoseong/TinyHippo | 7153849337944f0459dfd24551f28e417314e2de | [
"Unlicense"
] | 1 | 2019-09-10T06:32:07.000Z | 2019-09-10T06:32:07.000Z | Source/Client/Main.cpp | chahoseong/TinyHippo | 7153849337944f0459dfd24551f28e417314e2de | [
"Unlicense"
] | null | null | null | Source/Client/Main.cpp | chahoseong/TinyHippo | 7153849337944f0459dfd24551f28e417314e2de | [
"Unlicense"
] | null | null | null | #include "stdafx.h"
#include "Engine/GameMain.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
return TinyHippo::GameMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
} | 27.7 | 75 | 0.732852 | chahoseong |
648c4345060f1628043a76e0230041d398586b45 | 1,388 | cp | C++ | validation/default/golomb4-salldiff-reverse.cp | kad15/SandBoxToulbar2 | 31430ec5e6c6cec1eabe6f5d04bfb8134777821c | [
"MIT"
] | 33 | 2018-08-16T18:14:35.000Z | 2022-03-14T10:26:18.000Z | validation/default/golomb4-salldiff-reverse.cp | kad15/SandBoxToulbar2 | 31430ec5e6c6cec1eabe6f5d04bfb8134777821c | [
"MIT"
] | 13 | 2018-08-09T06:53:08.000Z | 2022-03-28T10:26:24.000Z | validation/default/golomb4-salldiff-reverse.cp | kad15/SandBoxToulbar2 | 31430ec5e6c6cec1eabe6f5d04bfb8134777821c | [
"MIT"
] | 12 | 2018-06-06T15:19:46.000Z | 2022-02-11T17:09:27.000Z | # problem name and initial upper bound
GOLOMB_4_ALLDIFF_REVERSE 9
# variables for marks
g4 0 1 2 3 4 5 6 7 8
g3 0 1 2 3 4 5 6 7 8
g2 0 1 2 3 4 5 6 7 8
g1 0 1 2 3 4 5 6 7 8
# variables for mark differences
d3_4 0 1 2 3 4 5 6 7 8
d2_4 0 1 2 3 4 5 6 7 8
d2_3 0 1 2 3 4 5 6 7 8
d1_4 0 1 2 3 4 5 6 7 8
d1_3 0 1 2 3 4 5 6 7 8
d1_2 0 1 2 3 4 5 6 7 8
# optimization criterion: minimizes the last mark
g4
# channeling constraints to express mark differences
shared(hard(d1_2 == g2 - g1))
d1_3 g3 g1 defined by 1
d1_4 g4 g1 defined by 1
d2_3 g3 g2 defined by 1
d2_4 g4 g2 defined by 1
d3_4 g4 g3 defined by 1
# AllDifferent constraint on mark differences
# equivalent to: hard(alldiff(d1_2,d1_3,d1_4,d2_3,d2_4,d3_4))
d1_2 d1_3 d1_4 d2_3 d2_4 d3_4 -1 salldiff var -1
# first mark is fixed
hard(g1 == 0)
# g variables must be strictly increasing
shared(hard(d1_2 > 0))
d1_3 defined by 2
d1_4 defined by 2
d2_3 defined by 2
d2_4 defined by 2
d3_4 defined by 2
# breaking symmetries
# equivalent to: hard(g2 < d3_4)
g2 d3_4 -1 < 0 0
# redundant constraints
# equivalent to: hard(g4 >= d1_2 + 3)
g4 d1_2 -1 >= 3 0
# equivalent to: hard(g4 >= d1_3 + 1)
g4 d1_3 -1 >= 1 0
# equivalent to: hard(g4 >= d1_4 + 0)
g4 d1_4 -1 >= 0 0
# equivalent to: hard(g4 >= d2_3 + 3)
g4 d2_3 -1 >= 3 0
# equivalent to: hard(g4 >= d2_4 + 1)
g4 d2_4 -1 >= 1 0
# equivalent to: hard(g4 >= d3_4 + 3)
g4 d3_4 -1 >= 3 0
| 22.754098 | 61 | 0.680115 | kad15 |
648e5e816650f95b804c9b0220db80da664770ce | 1,891 | cc | C++ | examples/pulse_compression.cc | ShaneFlandermeyer/plasma-dsp | 50d969f3873052a582e2b17745c469a8d22f0fe1 | [
"MIT"
] | null | null | null | examples/pulse_compression.cc | ShaneFlandermeyer/plasma-dsp | 50d969f3873052a582e2b17745c469a8d22f0fe1 | [
"MIT"
] | 7 | 2022-01-12T19:04:37.000Z | 2022-01-16T15:07:41.000Z | examples/pulse_compression.cc | ShaneFlandermeyer/plasma-dsp | 50d969f3873052a582e2b17745c469a8d22f0fe1 | [
"MIT"
] | null | null | null | #include "linear_fm_waveform.h"
#include "pulse_doppler.h"
#include <matplot/matplot.h>
using namespace matplot;
using namespace plasma;
using namespace Eigen;
int main() {
// Waveform parameter
double B = 50e6;
double fs = 4 * B;
double ts = 1 / fs;
double Tp = 5e-6;
double prf = 20e3;
LinearFMWaveform wave(B, Tp, prf, fs);
VectorXcd x = wave.waveform();
// Target parameters
double range = 1e3;
double tau = 2 * range / physconst::c;
VectorXcd y; // = delay(x,5e-6,(size_t)(fs/prf),fs);
VectorXcd h = wave.MatchedFilter();
size_t num_samps_pri = (int)(fs / prf);
size_t num_range_bins = num_samps_pri + h.size() - 1;
size_t num_pulses = 32;
MatrixXcd fast_time_slow_time = MatrixXcd::Zero(num_samps_pri, num_pulses);
MatrixXcd range_pulse_map = MatrixXcd::Zero(num_range_bins, num_pulses);
MatrixXcd range_doppler_map = MatrixXcd::Zero(num_range_bins, num_pulses);
for (size_t m = 0; m < num_pulses; m++) {
y = delay(x, tau, num_samps_pri, fs);
// TODO: Add a scale factor
fast_time_slow_time.col(m) = y;
range_pulse_map.col(m) = conv(y, h);
}
// Range doppler map
range_doppler_map = fftshift(fft(range_pulse_map, 1), 1);
// Convert the Eigen matrix to a vector of vectors
figure();
std::vector<std::vector<double>> xv(
range_doppler_map.rows(), std::vector<double>(range_doppler_map.cols()));
for (size_t i = 0; i < xv.size(); i++) {
for (size_t j = 0; j < xv.front().size(); j++) {
xv[i][j] = abs(range_doppler_map(i, j));
}
}
// Plot the range doppler map
double ti = 0;
double min_range = physconst::c / 2 * (ts - Tp + ti);
double max_range = physconst::c / 2 * (ts*(num_range_bins-1) - Tp + ti);
double min_doppler = -prf / 2;
double max_doppler = prf / 2 - 1 / (double)num_pulses;
imagesc(min_doppler, max_doppler, min_range, max_range, xv);
show();
return 0;
} | 30.5 | 79 | 0.659439 | ShaneFlandermeyer |
648ec7580476982f69f82de1f20af95c502a408a | 2,694 | cpp | C++ | tests/Bootstrap.Tests/tests/TimerServiceTests.cpp | samcragg/Autocrat | 179e0b42ddd3ecbf75467e479cd8f2f6c67c82ec | [
"MIT"
] | null | null | null | tests/Bootstrap.Tests/tests/TimerServiceTests.cpp | samcragg/Autocrat | 179e0b42ddd3ecbf75467e479cd8f2f6c67c82ec | [
"MIT"
] | 2 | 2020-09-30T07:09:46.000Z | 2021-01-03T20:01:02.000Z | tests/Bootstrap.Tests/tests/TimerServiceTests.cpp | samcragg/Autocrat | 179e0b42ddd3ecbf75467e479cd8f2f6c67c82ec | [
"MIT"
] | null | null | null | #include "timer_service.h"
#include <chrono>
#include <gtest/gtest.h>
#include <cpp_mock.h>
#include "TestMocks.h"
#include "pal.h"
#include "pal_mock.h"
using namespace std::chrono_literals;
class MockPalService : public pal_service
{
public:
MockMethod(std::chrono::microseconds, current_time, ())
};
namespace
{
std::function<void(std::int32_t)> on_timer_callback;
void* timer_callback(std::int32_t handle)
{
on_timer_callback(handle);
return nullptr;
}
}
class TimerServiceTests : public testing::Test
{
protected:
TimerServiceTests() :
_service(&_thread_pool)
{
active_service_mock = &_pal;
}
~TimerServiceTests()
{
active_service_mock = nullptr;
on_timer_callback = nullptr;
}
autocrat::timer_service _service;
MockPalService _pal;
FakeThreadPool _thread_pool;
};
TEST_F(TimerServiceTests, ShouldInvokeTheCallbackAfterTheInitialDelay)
{
When(_pal.current_time).Return({ 0us, 5us, 10us });
bool timer_called = false;
on_timer_callback = [&](auto) { timer_called = true; };
_service.add_timer_callback(10us, 0us, &timer_callback);
_service.check_and_dispatch();
EXPECT_FALSE(timer_called);
_service.check_and_dispatch();
EXPECT_TRUE(timer_called);
}
TEST_F(TimerServiceTests, ShouldInvokeTheCallbackAfterTheRepeat)
{
// Add an initial 0 for when we add it to the service
When(_pal.current_time).Return({ 0us, 0us, 5us, 10us, 15us, 20us });
int timer_called_count = 0;
on_timer_callback = [&](auto) { timer_called_count++; };
_service.add_timer_callback(0us, 10us, &timer_callback);
// 0
_service.check_and_dispatch();
EXPECT_EQ(1, timer_called_count);
// 5
_service.check_and_dispatch();
EXPECT_EQ(1, timer_called_count);
// 10
_service.check_and_dispatch();
EXPECT_EQ(2, timer_called_count);
// 15
_service.check_and_dispatch();
EXPECT_EQ(2, timer_called_count);
// 20
_service.check_and_dispatch();
EXPECT_EQ(3, timer_called_count);
}
TEST_F(TimerServiceTests, ShouldInvokeTheCallbackWithTheUniqueHandle)
{
When(_pal.current_time).Return({ 0us, 0us, 3us, 5us });
std::uint32_t called_handle = 0u;
on_timer_callback = [&](std::uint32_t handle) { called_handle = static_cast<std::uint32_t>(handle); };
std::uint32_t five_handle = _service.add_timer_callback(0us, 5us, &timer_callback);
std::uint32_t three_handle = _service.add_timer_callback(0us, 3us, &timer_callback);
_service.check_and_dispatch();
EXPECT_EQ(three_handle, called_handle);
_service.check_and_dispatch();
EXPECT_EQ(five_handle, called_handle);
}
| 24.490909 | 106 | 0.703786 | samcragg |
648fd358cf12d13190a4d20eef10d8f38195a472 | 3,976 | cpp | C++ | common/OrderListImpl.cpp | caozhiyi/Hudp | 85108e675d90985666d1d2a8f364015a467ae72f | [
"BSD-3-Clause"
] | 57 | 2019-07-26T06:26:47.000Z | 2022-03-22T13:12:12.000Z | common/OrderListImpl.cpp | caozhiyi/Hudp | 85108e675d90985666d1d2a8f364015a467ae72f | [
"BSD-3-Clause"
] | 1 | 2019-12-09T11:16:06.000Z | 2020-04-09T12:22:23.000Z | common/OrderListImpl.cpp | caozhiyi/Hudp | 85108e675d90985666d1d2a8f364015a467ae72f | [
"BSD-3-Clause"
] | 20 | 2019-08-21T08:26:14.000Z | 2021-11-21T09:58:48.000Z | #include <cstring> //for memset
#include "IMsg.h"
#include "ISocket.h"
#include "HudpImpl.h"
#include "HudpConfig.h"
#include "OrderListImpl.h"
using namespace hudp;
CRecvList::CRecvList() : _discard_msg_count(0){
}
CRecvList::~CRecvList() {
}
uint16_t CRecvList::HashFunc(uint16_t id) {
return id & (__msx_cache_msg_num - 1);
}
CReliableOrderlyList::CReliableOrderlyList(uint16_t start_id) : _expect_id(start_id) {
memset(_order_list, 0, sizeof(_order_list));
}
CReliableOrderlyList::~CReliableOrderlyList() {
std::unique_lock<std::mutex> lock(_mutex);
for (size_t i = 0; i < __msx_cache_msg_num; i++) {
if (_order_list[i]) {
_order_list[i].reset();
}
}
}
void CReliableOrderlyList::Clear() {
std::unique_lock<std::mutex> lock(_mutex);
memset(_order_list, 0, sizeof(_order_list));
_recv_list.Clear();
}
uint16_t CReliableOrderlyList::Insert(std::shared_ptr<CMsg> msg) {
auto id = msg->GetId();
uint16_t index = HashFunc(id);
// too farm, discard this msg
if (std::abs(id - _expect_id) > __max_compare_num ||
(_expect_id > (__max_id - __max_compare_num / 2) && id < __max_compare_num / 2)) {
_discard_msg_count++;
if (_discard_msg_count >= __msg_discard_limit) {
return 2;
}
return 0;
}
{
std::unique_lock<std::mutex> lock(_mutex);
if (id == _expect_id) {
_order_list[index] = msg;
while (_order_list[index]) {
_expect_id++;
_recv_list.Push(_order_list[index]);
_order_list[index] = nullptr;
index++;
if (index >= __msx_cache_msg_num) {
index = 0;
}
}
// is't expect id
} else {
// a repeat bag
if (_order_list[index]) {
return 1;
} else {
_order_list[index] = msg;
}
}
}
if (_recv_list.Size() > 0) {
std::shared_ptr<CMsg> item;
while (_recv_list.Pop(item)) {
auto sock = item->GetSocket();
sock->ToRecv(item);
}
_recv_list.Clear();
}
return 0;
}
CReliableList::CReliableList(uint16_t start_id) : _expect_id(start_id) {
memset(_order_list, 0, sizeof(_order_list));
}
CReliableList::~CReliableList() {
}
// reliable list, only judgement repetition in msg cache
uint16_t CReliableList::Insert(std::shared_ptr<CMsg> msg) {
auto id = msg->GetId();
uint16_t index = HashFunc(id);
// too farm, discard this msg
/*if (std::abs(id - _expect_id) > __max_compare_num ||
(_expect_id > (__max_id - __max_compare_num / 2) && id < __max_compare_num / 2)) {
_discard_msg_count++;
if (_discard_msg_count >= __msg_discard_limit) {
return 2;
}
return 0;
}*/
{
std::unique_lock<std::mutex> lock(_mutex);
if (_order_list[index] == id) {
return 1;
} else {
_order_list[index] = id;
}
}
_expect_id = id;
auto sock = msg->GetSocket();
sock->ToRecv(msg);
return 0;
}
COrderlyList::COrderlyList(uint16_t start_id) : _expect_id(start_id) {
}
COrderlyList::~COrderlyList() {
}
// orderly list, if msg id is bigger than expect id, recv it.
uint16_t COrderlyList::Insert(std::shared_ptr<CMsg> msg) {
auto id = msg->GetId();
// too farm, discard this msg
if (std::abs(id - _expect_id) > __max_compare_num ||
(_expect_id > (__max_id - __max_compare_num / 2) && id < __max_compare_num / 2)) {
_discard_msg_count++;
if (_discard_msg_count >= __msg_discard_limit) {
return 2;
}
return 0;
}
if (id < _expect_id) {
return 0;
}
_expect_id = id;
auto sock = msg->GetSocket();
sock->ToRecv(msg);
return 0;
}
| 24.243902 | 90 | 0.56841 | caozhiyi |
64909f27347c233c60ec0b04c4df31908a4407a5 | 3,779 | cpp | C++ | src/visualizer/opengl/tiny_mac_opengl_window.cpp | sgillen/tiny-differentiable-simulator | 142f3b9e9b7e042c9298bc83ebbc08a9df7527af | [
"Apache-2.0"
] | 862 | 2020-05-14T19:22:27.000Z | 2022-03-20T20:23:24.000Z | src/visualizer/opengl/tiny_mac_opengl_window.cpp | sgillen/tiny-differentiable-simulator | 142f3b9e9b7e042c9298bc83ebbc08a9df7527af | [
"Apache-2.0"
] | 82 | 2020-05-26T11:41:33.000Z | 2022-03-15T16:46:00.000Z | src/visualizer/opengl/tiny_mac_opengl_window.cpp | sgillen/tiny-differentiable-simulator | 142f3b9e9b7e042c9298bc83ebbc08a9df7527af | [
"Apache-2.0"
] | 93 | 2020-05-15T05:37:59.000Z | 2022-03-03T09:09:50.000Z | #ifndef B3_USE_GLFW
#ifdef __APPLE__
#include "tiny_mac_opengl_window.h"
#include "tiny_mac_opengl_window_objc.h"
#include "tiny_opengl_include.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
MacOpenGLWindow::MacOpenGLWindow() : m_internalData(0) {
m_internalData = Mac_createData();
}
MacOpenGLWindow::~MacOpenGLWindow() { Mac_destroyData(m_internalData); }
void MacOpenGLWindow::close_window() {
Mac_destroyData(m_internalData);
m_internalData = Mac_createData();
}
bool MacOpenGLWindow::is_modifier_key_pressed(int key) {
return Mac_isModifierKeyPressed(m_internalData, key);
}
float MacOpenGLWindow::get_time_in_seconds() { return 0.f; }
void MacOpenGLWindow::set_render_callback(TinyRenderCallback renderCallback) {}
void MacOpenGLWindow::set_window_title(const char* windowTitle) {
Mac_setWindowTitle(m_internalData, windowTitle);
}
void MacOpenGLWindow::create_window(const TinyWindowConstructionInfo& ci) {
MacWindowConstructionInfo windowCI;
windowCI.m_width = ci.m_width;
windowCI.m_height = ci.m_height;
windowCI.m_fullscreen = ci.m_fullscreen;
windowCI.m_colorBitsPerPixel = ci.m_colorBitsPerPixel;
windowCI.m_windowHandle = ci.m_windowHandle;
windowCI.m_title = ci.m_title;
windowCI.m_openglVersion = ci.m_openglVersion;
windowCI.m_allowRetina = true;
Mac_createWindow(m_internalData, &windowCI);
}
void MacOpenGLWindow::run_main_loop() {}
void MacOpenGLWindow::start_rendering() { Mac_updateWindow(m_internalData); }
void MacOpenGLWindow::end_rendering() { Mac_swapBuffer(m_internalData); }
bool MacOpenGLWindow::requested_exit() const {
return Mac_requestedExit(m_internalData);
}
void MacOpenGLWindow::set_request_exit() { Mac_setRequestExit(m_internalData); }
int MacOpenGLWindow::file_open_dialog(char* filename, int maxNameLength) {
return Mac_fileOpenDialog(filename, maxNameLength);
}
void MacOpenGLWindow::get_mouse_coordinates(int& x, int& y) {
int* xPtr = &x;
int* yPtr = &y;
Mac_getMouseCoordinates(m_internalData, xPtr, yPtr);
}
int MacOpenGLWindow::get_width() const { return Mac_getWidth(m_internalData); }
int MacOpenGLWindow::get_height() const {
return Mac_getHeight(m_internalData);
}
void MacOpenGLWindow::set_resize_callback(TinyResizeCallback resizeCallback) {
Mac_setResizeCallback(m_internalData, resizeCallback);
}
TinyResizeCallback MacOpenGLWindow::get_resize_callback() {
return Mac_getResizeCallback(m_internalData);
}
void MacOpenGLWindow::set_mouse_button_callback(
TinyMouseButtonCallback mouseCallback) {
Mac_setMouseButtonCallback(m_internalData, mouseCallback);
}
void MacOpenGLWindow::set_mouse_move_callback(
TinyMouseMoveCallback mouseCallback) {
Mac_setMouseMoveCallback(m_internalData, mouseCallback);
}
void MacOpenGLWindow::set_keyboard_callback(
TinyKeyboardCallback keyboardCallback) {
Mac_setKeyboardCallback(m_internalData, keyboardCallback);
}
TinyMouseMoveCallback MacOpenGLWindow::get_mouse_move_callback() {
return Mac_getMouseMoveCallback(m_internalData);
}
TinyMouseButtonCallback MacOpenGLWindow::get_mouse_button_callback() {
return Mac_getMouseButtonCallback(m_internalData);
}
void MacOpenGLWindow::set_wheel_callback(TinyWheelCallback wheelCallback) {
Mac_setWheelCallback(m_internalData, wheelCallback);
}
TinyWheelCallback MacOpenGLWindow::get_wheel_callback() {
return Mac_getWheelCallback(m_internalData);
}
TinyKeyboardCallback MacOpenGLWindow::get_keyboard_callback() {
return Mac_getKeyboardCallback(m_internalData);
}
float MacOpenGLWindow::get_retina_scale() const {
return Mac_getRetinaScale(m_internalData);
}
void MacOpenGLWindow::set_allow_retina(bool allow) {
Mac_setAllowRetina(m_internalData, allow);
}
#endif //__APPLE__
#endif // B3_USE_GLFW
| 28.413534 | 80 | 0.807886 | sgillen |
649889497cf1f508fe74922469d0424f7a6199c6 | 13,705 | cpp | C++ | src/elona/lua_env/lua_api/lua_api_map.cpp | XrosFade/ElonaFoobar | c33880080e0b475103ae3ea7d546335f9d4abd02 | [
"MIT"
] | null | null | null | src/elona/lua_env/lua_api/lua_api_map.cpp | XrosFade/ElonaFoobar | c33880080e0b475103ae3ea7d546335f9d4abd02 | [
"MIT"
] | null | null | null | src/elona/lua_env/lua_api/lua_api_map.cpp | XrosFade/ElonaFoobar | c33880080e0b475103ae3ea7d546335f9d4abd02 | [
"MIT"
] | 1 | 2020-02-24T18:52:19.000Z | 2020-02-24T18:52:19.000Z | #include "lua_api_map.hpp"
#include "../../area.hpp"
#include "../../character.hpp"
#include "../../data/types/type_map.hpp"
#include "../../lua_env/enums/enums.hpp"
#include "../../map.hpp"
#include "../../map_cell.hpp"
#include "../../mapgen.hpp"
#include "../interface.hpp"
namespace elona
{
namespace lua
{
/**
* @luadoc
*
* Returns the current map's width. This is only valid until the map
* changes.
* @treturn num the current map's width in tiles
*/
int LuaApiMap::width()
{
return map_data.width;
}
/**
* @luadoc
*
* Returns the current map's height. This is only valid until the map
* changes.
* @treturn num the current map's height in tiles
*/
int LuaApiMap::height()
{
return map_data.height;
}
/**
* @luadoc
*
* Returns the current map's ID.
* @treturn[1] string the current map's ID
* @treturn[2] nil
*/
sol::optional<std::string> LuaApiMap::id()
{
auto legacy_id = LuaApiMap::legacy_id();
auto id = the_mapdef_db.get_id_from_legacy(legacy_id);
if (!legacy_id)
{
return sol::nullopt;
}
return id->get();
}
/**
* @luadoc
*
* Returns the current map's legacy ID.
* @treturn[1] num the current map's legacy ID
* @treturn[2] nil
*/
int LuaApiMap::legacy_id()
{
return area_data[game_data.current_map].id;
}
/**
* @luadoc
*
* Returns the ID of the current map's instance. There can be more than one
* instance of a map of the same kind, like player-owned buildings.
* @treturn num the current map's instance ID
*/
int LuaApiMap::instance_id()
{
return game_data.current_map;
}
/**
* @luadoc
*
* Returns the current dungeon level.
* TODO: unify with World.data or Map.data
*/
int LuaApiMap::current_dungeon_level()
{
return game_data.current_dungeon_level;
}
/**
* @luadoc
*
* Returns true if this map is the overworld.
* @treturn bool
*/
bool LuaApiMap::is_overworld()
{
return elona::map_data.atlas_number == 0;
}
/**
* @luadoc
*
* Checks if a position is inside the map. It might be blocked by something.
* @tparam LuaPosition position
* @treturn bool true if the position is inside the map.
*/
bool LuaApiMap::valid(const Position& position)
{
return LuaApiMap::valid_xy(position.x, position.y);
}
bool LuaApiMap::valid_xy(int x, int y)
{
return x >= 0 && y >= 0 && x < LuaApiMap::width() &&
y < LuaApiMap::height();
}
/**
* @luadoc
*
* Returns true if the map tile at the given position is solid.
* @tparam LuaPosition position
* @treturn bool
*/
bool LuaApiMap::is_solid(const Position& position)
{
return LuaApiMap::is_solid_xy(position.x, position.y);
}
bool LuaApiMap::is_solid_xy(int x, int y)
{
if (LuaApiMap::is_overworld())
{
return true;
}
if (!LuaApiMap::valid_xy(x, y))
{
return true;
}
return elona::chip_data.for_cell(x, y).effect & 4;
}
/**
* @luadoc
*
* Checks if a position is blocked and cannot be reached by walking.
* @tparam LuaPosition position
* @treturn bool
*/
bool LuaApiMap::is_blocked(const Position& position)
{
return LuaApiMap::is_blocked_xy(position.x, position.y);
}
bool LuaApiMap::is_blocked_xy(int x, int y)
{
if (LuaApiMap::is_overworld())
{
return true;
}
if (!LuaApiMap::valid_xy(x, y))
{
return true;
}
elona::cell_check(x, y);
return cellaccess == 0;
}
/**
* @luadoc
*
* Returns a random position in the current map. It might be blocked by
* something.
* @treturn LuaPosition a random position
*/
Position LuaApiMap::random_pos()
{
return Position{elona::rnd(map_data.width - 1),
elona::rnd(map_data.height - 1)};
}
/**
* @luadoc
*
* Generates a random tile ID from the current map's tileset.
* Tile kinds can contain one of several different tile variations.
* @tparam Enums.TileKind tile_kind the tile kind to set
* @treturn num the generated tile ID
* @see Enums.TileKind
*/
int LuaApiMap::generate_tile(const EnumString& tile_kind)
{
TileKind tile_kind_value =
LuaEnums::TileKindTable.ensure_from_string(tile_kind);
return elona::cell_get_type(tile_kind_value);
}
/**
* @luadoc
*
* Returns the type of chip for the given tile kind.
*/
int LuaApiMap::chip_type(int tile_id)
{
return elona::chip_data[tile_id].kind;
}
/**
* @luadoc
*
* Gets the tile type of a tile position.
* @tparam LuaPosition position
* @treturn num
*/
int LuaApiMap::get_tile(const Position& position)
{
return LuaApiMap::get_tile_xy(position.x, position.y);
}
int LuaApiMap::get_tile_xy(int x, int y)
{
if (LuaApiMap::is_overworld())
{
return -1;
}
if (!LuaApiMap::valid_xy(x, y))
{
return -1;
}
return elona::cell_data.at(x, y).chip_id_actual;
}
/**
* @luadoc
*
* Gets the player's memory of a tile position.
* @tparam LuaPosition position
* @treturn num
*/
int LuaApiMap::get_memory(const Position& position)
{
return LuaApiMap::get_memory_xy(position.x, position.y);
}
int LuaApiMap::get_memory_xy(int x, int y)
{
if (LuaApiMap::is_overworld())
{
return -1;
}
if (!LuaApiMap::valid_xy(x, y))
{
return -1;
}
return elona::cell_data.at(x, y).chip_id_memory;
}
/**
* @luadoc
*
* Returns a table containing map feature information at the given tile
* position.
* - id: Feature id.
* - param1: Extra parameter.
* - param2: Extra parameter.
* - param3: Extra parameter. (unused)
* @tparam LuaPosition position
* @treturn table
*/
sol::table LuaApiMap::get_feat(const Position& position)
{
return LuaApiMap::get_feat_xy(position.x, position.y);
}
sol::table LuaApiMap::get_feat_xy(int x, int y)
{
if (LuaApiMap::is_overworld())
{
return lua::create_table();
}
if (!LuaApiMap::valid_xy(x, y))
{
return lua::create_table();
}
auto feats = elona::cell_data.at(x, y).feats;
auto id = feats % 1000;
auto param1 = feats / 1000 % 100;
auto param2 = feats / 100000 % 100;
auto param3 = feats / 10000000;
return lua::create_table(
"id", id, "param1", param1, "param2", param2, "param3", param3);
}
/**
* @luadoc
*
* Returns the ID of the map effect at the given position.
* @tparam LuaPosition position
* @treturn num
*/
int LuaApiMap::get_mef(const Position& position)
{
return LuaApiMap::get_mef_xy(position.x, position.y);
}
int LuaApiMap::get_mef_xy(int x, int y)
{
if (LuaApiMap::is_overworld())
{
return 0;
}
if (!LuaApiMap::valid_xy(x, y))
{
return 0;
}
int index_plus_one = cell_data.at(x, y).mef_index_plus_one;
if (index_plus_one == 0)
{
return 0;
}
return mef(0, index_plus_one - 1);
}
/**
* @luadoc
*
* Gets the character standing at a tile position.
* @tparam LuaPosition position
* @treturn[opt] LuaCharacter
*/
sol::optional<LuaCharacterHandle> LuaApiMap::get_chara(const Position& position)
{
return LuaApiMap::get_chara_xy(position.x, position.y);
}
sol::optional<LuaCharacterHandle> LuaApiMap::get_chara_xy(int x, int y)
{
if (!LuaApiMap::valid_xy(x, y))
{
return sol::nullopt;
}
int index_plus_one = cell_data.at(x, y).chara_index_plus_one;
if (index_plus_one == 0)
{
return sol::nullopt;
}
return lua::handle(cdata[index_plus_one - 1]);
}
/**
* @luadoc
*
* Sets a tile of the current map. Only checks if the position is valid, not
* things like blocking objects.
* @tparam LuaPosition position
* @tparam num id the tile ID to set
* @usage Map.set_tile(10, 10, Map.generate_tile(Enums.TileKind.Room))
*/
void LuaApiMap::set_tile(const Position& position, int id)
{
LuaApiMap::set_tile_xy(position.x, position.y, id);
}
void LuaApiMap::set_tile_xy(int x, int y, int id)
{
if (LuaApiMap::is_overworld())
{
return;
}
if (!LuaApiMap::valid_xy(x, y))
{
return;
}
// TODO: check validity of tile ID
elona::cell_data.at(x, y).chip_id_actual = id;
}
/**
* @luadoc
*
* Sets the player's memory of a tile position to the given tile kind.
* @tparam LuaPosition position
* @tparam num id the tile ID to set
* @usage Map.set_memory(10, 10, Map.generate_tile(Enums.TileKind.Room))
*/
void LuaApiMap::set_memory(const Position& position, int id)
{
LuaApiMap::set_memory_xy(position.x, position.y, id);
}
void LuaApiMap::set_memory_xy(int x, int y, int id)
{
if (LuaApiMap::is_overworld())
{
return;
}
if (!LuaApiMap::valid_xy(x, y))
{
return;
}
elona::cell_data.at(x, y).chip_id_memory = id;
}
/**
* @luadoc
*
* Sets a feat at the given position.
* @tparam LuaPosition position (const) the map position
* @tparam num tile the tile ID of the feat
* @tparam num param1 a parameter of the feat
* @tparam num param2 a parameter of the feat
*/
void LuaApiMap::set_feat(
const Position& position,
int tile,
int param1,
int param2)
{
LuaApiMap::set_feat_xy(position.x, position.y, tile, param1, param2);
}
void LuaApiMap::set_feat_xy(int x, int y, int tile, int param1, int param2)
{
cell_featset(x, y, tile, param1, param2);
}
/**
* @luadoc
*
* Clears the feat at the given position.
* @tparam LuaPosition position (const) the map position
*/
void LuaApiMap::clear_feat(const Position& position)
{
LuaApiMap::clear_feat_xy(position.x, position.y);
}
void LuaApiMap::clear_feat_xy(int x, int y)
{
cell_featclear(x, y);
}
/**
* @ luadoc
*
* Randomly sprays the map with the given tile type;
*/
void LuaApiMap::spray_tile(int tile, int amount)
{
elona::map_randomtile(tile, amount);
}
void LuaApiMap::travel_to(const std::string& map_id)
{
LuaApiMap::travel_to_with_level(map_id, 1);
}
void LuaApiMap::travel_to_with_level(const std::string& map_id, int level)
{
auto map = the_mapdef_db.ensure(map_id);
game_data.player_x_on_map_leave = cdata.player().position.x;
game_data.player_y_on_map_leave = cdata.player().position.y;
game_data.previous_x = cdata.player().position.x;
game_data.previous_y = cdata.player().position.y;
// Set up the outer map of the map traveled to, such that the player will
// appear on top the map's area when they leave via the map's edge.
if (map.map_type != mdata_t::MapType::world_map)
{
auto outer_map = the_mapdef_db[map.outer_map];
if (outer_map)
{
game_data.previous_map2 = outer_map->legacy_id;
game_data.previous_dungeon_level = 1;
game_data.pc_x_in_world_map = map.outer_map_position.x;
game_data.pc_y_in_world_map = map.outer_map_position.y;
game_data.destination_outer_map = outer_map->legacy_id;
}
}
else
{
game_data.previous_map2 = map.legacy_id;
game_data.previous_dungeon_level = 1;
game_data.destination_outer_map = map.legacy_id;
}
map_prepare_for_travel(map.legacy_id, level);
exit_map();
initialize_map();
}
void LuaApiMap::bind(sol::table& api_table)
{
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, width);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, height);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, id);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, legacy_id);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, instance_id);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, is_overworld);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, current_dungeon_level);
api_table.set_function(
"valid", sol::overload(LuaApiMap::valid, LuaApiMap::valid_xy));
api_table.set_function(
"is_solid", sol::overload(LuaApiMap::is_solid, LuaApiMap::is_solid_xy));
api_table.set_function(
"is_blocked",
sol::overload(LuaApiMap::is_blocked, LuaApiMap::is_blocked_xy));
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, random_pos);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, generate_tile);
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, chip_type);
api_table.set_function(
"get_tile", sol::overload(LuaApiMap::get_tile, LuaApiMap::get_tile_xy));
api_table.set_function(
"get_memory",
sol::overload(LuaApiMap::get_memory, LuaApiMap::get_memory_xy));
api_table.set_function(
"get_feat", sol::overload(LuaApiMap::get_feat, LuaApiMap::get_feat_xy));
api_table.set_function(
"get_mef", sol::overload(LuaApiMap::get_mef, LuaApiMap::get_mef_xy));
api_table.set_function(
"get_chara",
sol::overload(LuaApiMap::get_chara, LuaApiMap::get_chara_xy));
api_table.set_function(
"set_tile", sol::overload(LuaApiMap::set_tile, LuaApiMap::set_tile_xy));
api_table.set_function(
"set_memory",
sol::overload(LuaApiMap::set_memory, LuaApiMap::set_memory_xy));
api_table.set_function(
"set_feat", sol::overload(LuaApiMap::set_feat, LuaApiMap::set_feat_xy));
api_table.set_function(
"clear_feat",
sol::overload(LuaApiMap::clear_feat, LuaApiMap::clear_feat_xy));
LUA_API_BIND_FUNCTION(api_table, LuaApiMap, spray_tile);
api_table.set_function(
"travel_to",
sol::overload(LuaApiMap::travel_to, LuaApiMap::travel_to_with_level));
/**
* @luadoc data field LuaMapData
*
* [R] The map data for the current map. This contains serialized values
* controlling various aspects of the current map.
*/
api_table.set("data", sol::property(&map_data));
/**
* @luadoc area function
*
* Returns the area in the world map that corresponds to this map.
*/
api_table.set("area", sol::property([]() { return &area_data.current(); }));
}
} // namespace lua
} // namespace elona
| 23.507719 | 80 | 0.664137 | XrosFade |
6498fd3507ae8f953ab56fd96ae658aaf43e1aac | 791 | cpp | C++ | UVa/AC/Maximum_Sum_II-10656.cpp | AHJenin/acm-type-problems | e2a6d58fe8872ceaed822f5ee8911bfc173c6192 | [
"MIT"
] | 4 | 2018-05-17T08:37:53.000Z | 2018-06-08T18:47:21.000Z | UVa/AC/Maximum_Sum_II-10656.cpp | arafat-hasan/acm-type-problems | e2a6d58fe8872ceaed822f5ee8911bfc173c6192 | [
"MIT"
] | null | null | null | UVa/AC/Maximum_Sum_II-10656.cpp | arafat-hasan/acm-type-problems | e2a6d58fe8872ceaed822f5ee8911bfc173c6192 | [
"MIT"
] | null | null | null | /*
* FILE: Maximum_Sum_II-10656.cpp
*
* @author: Md. Arafat Hasan Jenin <Opendoor.Arafat@gmail.com>
*
* LINK: https://uva.onlinejudge.org/external/106/10656.pdf
*
* Description:
*
* DEVELOPMENT HISTORY:
* Date Change Version Description
* --------------------------------------------------------------
* 3 Feb 2017 New 1.0 Completed, AC
*
*
*/
#include <iostream>
int main() {
bool flag;
int t, n;
while(std::cin >> t, t){
flag = false;
while(t-- > 0 && std::cin >> n) if (n){ std::cout << n; flag = true; break;}
while(t-- > 0 && std::cin >> n) if(n) std::cout << " " << n, flag = true;
if(!flag) std::cout << 0;
std::cout << std::endl;
}
return 0;
}
| 22.6 | 84 | 0.456384 | AHJenin |
6499afc7c0372b645f794f58c71b664d3f81e93c | 1,022 | cpp | C++ | src/lug/System/Exception.cpp | Lugdunum3D/Lugdunum3D | b6d6907d034fdba1ffc278b96598eba1d860f0d4 | [
"MIT"
] | 275 | 2016-10-08T15:33:17.000Z | 2022-03-30T06:11:56.000Z | src/lug/System/Exception.cpp | Lugdunum3D/Lugdunum3D | b6d6907d034fdba1ffc278b96598eba1d860f0d4 | [
"MIT"
] | 24 | 2016-09-29T20:51:20.000Z | 2018-05-09T21:41:36.000Z | src/lug/System/Exception.cpp | Lugdunum3D/Lugdunum3D | b6d6907d034fdba1ffc278b96598eba1d860f0d4 | [
"MIT"
] | 37 | 2017-02-25T05:03:48.000Z | 2021-05-10T19:06:29.000Z | #include <lug/System/Exception.hpp>
#include <sstream>
lug::System::Exception::Exception(const char* typeName, const std::string& description, const char* file, const char* function, uint32_t line)
: _typeName{typeName}, _description{description}, _file{file}, _function{function}, _line{line} {}
const std::string& lug::System::Exception::getTypeName() const {
return _typeName;
}
const std::string& lug::System::Exception::getDescription() const {
return _description;
}
const std::string& lug::System::Exception::getFile() const {
return _file;
}
const std::string& lug::System::Exception::getFunction() const {
return _function;
}
uint32_t lug::System::Exception::getLine() const {
return _line;
}
const char* lug::System::Exception::what() const noexcept {
std::stringstream msg;
msg << _typeName << ": " << _description << std::endl;
msg << "In " << _file;
msg << " at `" << _function << "` line " << _line;
_fullDesc = msg.str();
return _fullDesc.c_str();
}
| 27.621622 | 142 | 0.67319 | Lugdunum3D |
649d5fb9befe93d9df8863af6f5f77568dc3baec | 11,273 | cpp | C++ | src/vbk/test/unit/pop_service_tests.cpp | xagau/vbk-ri-btc | 9907b6ec54894c01e1f6dcfd80764f08ac84743a | [
"MIT"
] | 1 | 2020-04-20T15:20:23.000Z | 2020-04-20T15:20:23.000Z | src/vbk/test/unit/pop_service_tests.cpp | xagau/vbk-ri-btc | 9907b6ec54894c01e1f6dcfd80764f08ac84743a | [
"MIT"
] | null | null | null | src/vbk/test/unit/pop_service_tests.cpp | xagau/vbk-ri-btc | 9907b6ec54894c01e1f6dcfd80764f08ac84743a | [
"MIT"
] | null | null | null | #include <boost/test/unit_test.hpp>
#include <consensus/validation.h>
#include <shutdown.h>
#include <test/util/setup_common.h>
#include <validation.h>
#include <vbk/config.hpp>
#include <vbk/init.hpp>
#include <vbk/pop_service.hpp>
#include <vbk/pop_service/pop_service_impl.hpp>
#include <vbk/service_locator.hpp>
#include <vbk/test/util/mock.hpp>
#include <vbk/test/util/tx.hpp>
using ::testing::Return;
static CBlock createBlockWithPopTx(TestChain100Setup& test)
{
CMutableTransaction popTx = VeriBlockTest::makePopTx({1}, {{2}});
CScript scriptPubKey = CScript() << ToByteVector(test.coinbaseKey.GetPubKey()) << OP_CHECKSIG;
return test.CreateAndProcessBlock({popTx}, scriptPubKey);
}
inline void setPublicationData(VeriBlock::PublicationData& pub, const CDataStream& stream, const int64_t& index)
{
pub.set_identifier(index);
pub.set_header((void*)stream.data(), stream.size());
}
struct PopServiceFixture : public TestChain100Setup {
testing::NiceMock<VeriBlockTest::PopServiceImplMock> pop_service_impl_mock;
PopServiceFixture()
{
AbortShutdown();
VeriBlock::InitUtilService();
VeriBlock::InitConfig();
VeriBlockTest::setUpPopServiceMock(pop_service_mock);
ON_CALL(pop_service_impl_mock, parsePopTx)
.WillByDefault(
[](const CTransactionRef&, ScriptError* serror, VeriBlock::Publications*, VeriBlock::Context*, VeriBlock::PopTxType* type) -> bool {
if (type != nullptr) {
*type = VeriBlock::PopTxType::PUBLICATIONS;
}
if (serror != nullptr) {
*serror = ScriptError::SCRIPT_ERR_OK;
}
return true;
});
ON_CALL(pop_service_impl_mock, determineATVPlausibilityWithBTCRules)
.WillByDefault(Return(true));
ON_CALL(pop_service_impl_mock, addTemporaryPayloads)
.WillByDefault(
[&](const CTransactionRef& tx, const CBlockIndex& pindexPrev, const Consensus::Params& params, TxValidationState& state) {
return VeriBlock::addTemporaryPayloadsImpl(pop_service_impl_mock, tx, pindexPrev, params, state);
});
ON_CALL(pop_service_impl_mock, clearTemporaryPayloads)
.WillByDefault(
[&]() {
VeriBlock::clearTemporaryPayloadsImpl(pop_service_impl_mock);
});
VeriBlock::initTemporaryPayloadsMock(pop_service_impl_mock);
}
void setNoAddRemovePayloadsExpectations()
{
EXPECT_CALL(pop_service_impl_mock, addPayloads).Times(0);
EXPECT_CALL(pop_service_impl_mock, removePayloads).Times(0);
}
};
BOOST_AUTO_TEST_SUITE(pop_service_tests)
BOOST_FIXTURE_TEST_CASE(blockPopValidation_test, PopServiceFixture)
{
CBlock block = createBlockWithPopTx(*this);
CBlockIndex* endorsedBlockIndex = ChainActive().Tip()->pprev;
CBlock endorsedBlock;
BOOST_CHECK(ReadBlockFromDisk(endorsedBlock, endorsedBlockIndex, Params().GetConsensus()));
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << endorsedBlock.GetBlockHeader();
auto& config = VeriBlock::getService<VeriBlock::Config>();
ON_CALL(pop_service_impl_mock, getPublicationsData)
.WillByDefault(
[stream, config](const VeriBlock::Publications& pub, VeriBlock::PublicationData& publicationData) {
setPublicationData(publicationData, stream, config.index.unwrap());
});
BlockValidationState state;
{
LOCK(cs_main);
BOOST_CHECK(VeriBlock::blockPopValidationImpl(pop_service_impl_mock, block, *ChainActive().Tip()->pprev, Params().GetConsensus(), state));
}
}
BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_wrong_index, PopServiceFixture)
{
CBlock block = createBlockWithPopTx(*this);
CBlockIndex* endorsedBlockIndex = ChainActive().Tip()->pprev->pprev->pprev;
CBlock endorsedBlock;
BOOST_CHECK(ReadBlockFromDisk(endorsedBlock, endorsedBlockIndex, Params().GetConsensus()));
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << endorsedBlock.GetBlockHeader();
// make another index
ON_CALL(pop_service_impl_mock, getPublicationsData)
.WillByDefault(
[stream](const VeriBlock::Publications& pub, VeriBlock::PublicationData& publicationData) {
setPublicationData(publicationData, stream, -1);
});
ON_CALL(pop_service_impl_mock, determineATVPlausibilityWithBTCRules)
.WillByDefault(
[](VeriBlock::AltchainId altChainIdentifier, const CBlockHeader& popEndorsementHeader,
const Consensus::Params& params, TxValidationState& state) -> bool {
VeriBlock::PopServiceImpl pop_service_impl(false, false);
return pop_service_impl.determineATVPlausibilityWithBTCRules(altChainIdentifier, popEndorsementHeader, params, state);
});
setNoAddRemovePayloadsExpectations();
BlockValidationState state;
{
LOCK(cs_main);
BOOST_CHECK(!blockPopValidationImpl(pop_service_impl_mock, block, *ChainActive().Tip()->pprev, Params().GetConsensus(), state));
BOOST_CHECK_EQUAL(state.GetRejectReason(), "pop-tx-altchain-id");
}
testing::Mock::VerifyAndClearExpectations(&pop_service_impl_mock);
}
BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_endorsed_block_not_known_orphan_block, PopServiceFixture)
{
CBlockIndex* endorsedBlockIndex = ChainActive().Tip();
CBlock endorsedBlock;
BOOST_CHECK(ReadBlockFromDisk(endorsedBlock, endorsedBlockIndex, Params().GetConsensus()));
endorsedBlock.hashPrevBlock.SetHex("ff");
CBlock block = createBlockWithPopTx(*this);
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << endorsedBlock.GetBlockHeader();
auto& config = VeriBlock::getService<VeriBlock::Config>();
ON_CALL(pop_service_impl_mock, getPublicationsData)
.WillByDefault(
[stream, config](const VeriBlock::Publications& pub, VeriBlock::PublicationData& publicationData) {
setPublicationData(publicationData, stream, config.index.unwrap());
});
setNoAddRemovePayloadsExpectations();
{
BlockValidationState state;
LOCK(cs_main);
BOOST_CHECK(!blockPopValidationImpl(pop_service_impl_mock, block, *ChainActive().Tip()->pprev, Params().GetConsensus(), state));
BOOST_CHECK_EQUAL(state.GetRejectReason(), "pop-tx-endorsed-block-not-known-orphan-block");
}
testing::Mock::VerifyAndClearExpectations(&pop_service_impl_mock);
}
BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_endorsed_block_not_from_chain, PopServiceFixture)
{
CBlockIndex* endorsedBlockIndex = ChainActive().Tip()->pprev->pprev;
CBlock endorsedBlock;
BOOST_CHECK(ReadBlockFromDisk(endorsedBlock, endorsedBlockIndex, Params().GetConsensus()));
int prevHeight = endorsedBlockIndex->nHeight;
BlockValidationState state;
BOOST_CHECK(InvalidateBlock(state, Params(), endorsedBlockIndex->pprev));
BOOST_CHECK(ActivateBestChain(state, Params()));
BOOST_CHECK(ChainActive().Height() < prevHeight);
CScript scriptPubKey = CScript() << OP_CHECKSIG;
CreateAndProcessBlock({}, scriptPubKey);
CreateAndProcessBlock({}, scriptPubKey);
CreateAndProcessBlock({}, scriptPubKey);
CBlock block = createBlockWithPopTx(*this);
BOOST_CHECK(ChainActive().Height() > prevHeight);
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << endorsedBlock.GetBlockHeader();
auto& config = VeriBlock::getService<VeriBlock::Config>();
ON_CALL(pop_service_impl_mock, getPublicationsData)
.WillByDefault(
[stream, config](const VeriBlock::Publications& pub, VeriBlock::PublicationData& publicationData) {
setPublicationData(publicationData, stream, config.index.unwrap());
});
setNoAddRemovePayloadsExpectations();
{
LOCK(cs_main);
BOOST_CHECK(!blockPopValidationImpl(pop_service_impl_mock, block, *ChainActive().Tip()->pprev, Params().GetConsensus(), state));
BOOST_CHECK_EQUAL(state.GetRejectReason(), "pop-tx-endorsed-block-not-from-this-chain");
}
testing::Mock::VerifyAndClearExpectations(&pop_service_impl_mock);
}
BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_wrong_settlement_interval, PopServiceFixture)
{
CBlockIndex* endorsedBlockIndex = ChainActive().Tip()->pprev->pprev->pprev;
CBlock endorsedBlock;
BOOST_CHECK(ReadBlockFromDisk(endorsedBlock, endorsedBlockIndex, Params().GetConsensus()));
CBlock block = createBlockWithPopTx(*this);
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << endorsedBlock.GetBlockHeader();
auto& config = VeriBlock::getService<VeriBlock::Config>();
ON_CALL(pop_service_impl_mock, getPublicationsData)
.WillByDefault(
[stream, config](const VeriBlock::Publications& pub, VeriBlock::PublicationData& publicationData) {
setPublicationData(publicationData, stream, config.index.unwrap());
});
setNoAddRemovePayloadsExpectations();
config.POP_REWARD_SETTLEMENT_INTERVAL = 0;
VeriBlock::setService<VeriBlock::Config>(new VeriBlock::Config(config));
BlockValidationState state;
{
LOCK(cs_main);
BOOST_CHECK(!blockPopValidationImpl(pop_service_impl_mock, block, *ChainActive().Tip()->pprev, Params().GetConsensus(), state));
BOOST_CHECK_EQUAL(state.GetRejectReason(), "pop-tx-endorsed-block-too-old");
}
testing::Mock::VerifyAndClearExpectations(&pop_service_impl_mock);
}
BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_wrong_addPayloads, PopServiceFixture)
{
CBlockIndex* endorsedBlockIndex = ChainActive().Tip()->pprev->pprev->pprev;
CBlock endorsedBlock;
BOOST_CHECK(ReadBlockFromDisk(endorsedBlock, endorsedBlockIndex, Params().GetConsensus()));
CBlock block = createBlockWithPopTx(*this);
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << endorsedBlock.GetBlockHeader();
auto& config = VeriBlock::getService<VeriBlock::Config>();
ON_CALL(pop_service_impl_mock, getPublicationsData)
.WillByDefault(
[stream, config](const VeriBlock::Publications& pub, VeriBlock::PublicationData& publicationData) {
setPublicationData(publicationData, stream, config.index.unwrap());
});
ON_CALL(pop_service_impl_mock, addPayloads)
.WillByDefault(
[](std::string hash, const int& nHeight, const VeriBlock::Publications& publications) -> void {
throw VeriBlock::PopServiceException("fail");
});
EXPECT_CALL(pop_service_impl_mock, addPayloads).Times(1);
EXPECT_CALL(pop_service_impl_mock, removePayloads).Times(0);
BlockValidationState state;
{
LOCK(cs_main);
BOOST_CHECK(!blockPopValidationImpl(pop_service_impl_mock, block, *ChainActive().Tip()->pprev, Params().GetConsensus(), state));
BOOST_CHECK_EQUAL(state.GetRejectReason(), "pop-tx-add-payloads-failed");
}
testing::Mock::VerifyAndClearExpectations(&pop_service_impl_mock);
}
BOOST_AUTO_TEST_SUITE_END()
| 41.142336 | 148 | 0.710104 | xagau |
64a3fedb37e0b48e3c8fbb381d437f4235177d8c | 291 | cpp | C++ | Engine/Source/Developer/UnrealCodeAnalyzerTests/Private/UseClassWithNonStaticField.cpp | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | Engine/Source/Developer/UnrealCodeAnalyzerTests/Private/UseClassWithNonStaticField.cpp | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | 2 | 2015-06-21T17:38:11.000Z | 2015-06-22T20:54:42.000Z | Engine/Source/Developer/UnrealCodeAnalyzerTests/Private/UseClassWithNonStaticField.cpp | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "UnrealCodeAnalyzerTestsPCH.h"
#include "UseClassWithNonStaticField.h"
static void Function_UseClassWithNonStaticField()
{
#ifdef UNREAL_CODE_ANALYZER
FTestClassWithNonStaticField TestClassWithNonStaticField;
#endif
}
| 24.25 | 60 | 0.838488 | PopCap |
64a85296827d04ae1a601f09baa0866d3f88d07e | 1,167 | hpp | C++ | lib/generic/DemoController.hpp | ademuri/colordance-circle | fd680a45c32d6ebc2289cd8a8f6fc8bba2d0a43e | [
"Apache-2.0"
] | 2 | 2020-03-07T05:14:06.000Z | 2021-02-22T17:53:40.000Z | lib/generic/DemoController.hpp | ademuri/colordance-circle | fd680a45c32d6ebc2289cd8a8f6fc8bba2d0a43e | [
"Apache-2.0"
] | 1 | 2020-03-08T05:53:04.000Z | 2020-03-08T05:56:37.000Z | lib/generic/DemoController.hpp | ademuri/colordance-circle | fd680a45c32d6ebc2289cd8a8f6fc8bba2d0a43e | [
"Apache-2.0"
] | 1 | 2020-03-08T05:48:28.000Z | 2020-03-08T05:48:28.000Z | #ifndef DEMO_CONTROLLER_HPP_
#define DEMO_CONTROLLER_HPP_
#include <vector>
#include "ControlPole.hpp"
#include "Effect.hpp"
#include "Pole.hpp"
#include "LocalButtonController.hpp"
class DemoController : public Effect {
public:
DemoController(std::vector<Pole*> poles, LocalButtonController* paramController);
protected:
void DoRun() override;
private:
std::vector<ControlPole*> controlPoles;
uint16_t movementCount = 0;
uint32_t timerOffset = 0;
uint8_t bpm = 80;
static const uint16_t FRAMES_PER_LOOP = 840; // lcm(shiftsPerLoop of effects)
uint16_t lastFrame = 0;
uint8_t lastEffect = 0;
bool lastPrevious = false;
bool lastNext = false;
bool lastRandom = false;
uint8_t setPoles = 0;
uint8_t movementSpeed = 0;
uint8_t movementMode = 0;
uint8_t beatsPerLoop = 0;
uint8_t gridHueShift = 0;
uint8_t gridBackForth = 0;
uint8_t gridSmoothColor = 0;
bool reverse[4];
uint8_t staticShiftIndex[4] = {255, 255, 255, 255};
uint8_t modes[4];
uint8_t gridLightCount = 1;
uint8_t hues[4];
uint8_t hueDistances[4];
uint8_t vals[4] = {255, 255, 255, 255};
long randomAt = 0;
uint8_t effect = 0;
};
#endif | 22.018868 | 83 | 0.718081 | ademuri |
64abd26a4d2f35082486a3c26843733f29e118d9 | 75,963 | cpp | C++ | lib/crunch/crnlib/crn_comp.cpp | Wizermil/unordered_map | 4d60bf16384b7ea9db1d43d8b15313f8752490ee | [
"MIT"
] | null | null | null | lib/crunch/crnlib/crn_comp.cpp | Wizermil/unordered_map | 4d60bf16384b7ea9db1d43d8b15313f8752490ee | [
"MIT"
] | null | null | null | lib/crunch/crnlib/crn_comp.cpp | Wizermil/unordered_map | 4d60bf16384b7ea9db1d43d8b15313f8752490ee | [
"MIT"
] | null | null | null | // File: crn_comp.cpp
// This software is in the public domain. Please see license.txt.
#include "crn_core.h"
#include "crn_console.h"
#include "crn_comp.h"
#include "crn_zeng.h"
#include "crn_checksum.h"
#define CRNLIB_CREATE_DEBUG_IMAGES 0
#define CRNLIB_ENABLE_DEBUG_MESSAGES 0
namespace crnlib
{
static const uint cEncodingMapNumChunksPerCode = 3;
crn_comp::crn_comp() :
m_pParams(NULL)
{
}
crn_comp::~crn_comp()
{
}
float crn_comp::color_endpoint_similarity_func(uint index_a, uint index_b, void* pContext)
{
dxt_hc& hvq = *static_cast<dxt_hc*>(pContext);
uint endpoint_a = hvq.get_color_endpoint(index_a);
uint endpoint_b = hvq.get_color_endpoint(index_b);
color_quad_u8 a[2];
a[0] = dxt1_block::unpack_color((uint16)(endpoint_a & 0xFFFF), true);
a[1] = dxt1_block::unpack_color((uint16)((endpoint_a >> 16) & 0xFFFF), true);
color_quad_u8 b[2];
b[0] = dxt1_block::unpack_color((uint16)(endpoint_b & 0xFFFF), true);
b[1] = dxt1_block::unpack_color((uint16)((endpoint_b >> 16) & 0xFFFF), true);
uint total_error = color::elucidian_distance(a[0], b[0], false) + color::elucidian_distance(a[1], b[1], false);
float weight = 1.0f - math::clamp(total_error * 1.0f/8000.0f, 0.0f, 1.0f);
return weight;
}
float crn_comp::alpha_endpoint_similarity_func(uint index_a, uint index_b, void* pContext)
{
dxt_hc& hvq = *static_cast<dxt_hc*>(pContext);
uint endpoint_a = hvq.get_alpha_endpoint(index_a);
int endpoint_a_lo = dxt5_block::unpack_endpoint(endpoint_a, 0);
int endpoint_a_hi = dxt5_block::unpack_endpoint(endpoint_a, 1);
uint endpoint_b = hvq.get_alpha_endpoint(index_b);
int endpoint_b_lo = dxt5_block::unpack_endpoint(endpoint_b, 0);
int endpoint_b_hi = dxt5_block::unpack_endpoint(endpoint_b, 1);
int total_error = math::square(endpoint_a_lo - endpoint_b_lo) + math::square(endpoint_a_hi - endpoint_b_hi);
float weight = 1.0f - math::clamp(total_error * 1.0f/256.0f, 0.0f, 1.0f);
return weight;
}
void crn_comp::sort_color_endpoint_codebook(crnlib::vector<uint>& remapping, const crnlib::vector<uint>& endpoints)
{
remapping.resize(endpoints.size());
uint lowest_energy = UINT_MAX;
uint lowest_energy_index = 0;
for (uint i = 0; i < endpoints.size(); i++)
{
color_quad_u8 a(dxt1_block::unpack_color(static_cast<uint16>(endpoints[i] & 0xFFFF), true));
color_quad_u8 b(dxt1_block::unpack_color(static_cast<uint16>((endpoints[i] >> 16) & 0xFFFF), true));
uint total = a.r + a.g + a.b + b.r + b.g + b.b;
if (total < lowest_energy)
{
lowest_energy = total;
lowest_energy_index = i;
}
}
uint cur_index = lowest_energy_index;
crnlib::vector<bool> chosen_flags(endpoints.size());
uint n = 0;
for ( ; ; )
{
chosen_flags[cur_index] = true;
remapping[cur_index] = n;
n++;
if (n == endpoints.size())
break;
uint lowest_error = UINT_MAX;
uint lowest_error_index = 0;
color_quad_u8 a(dxt1_block::unpack_endpoint(endpoints[cur_index], 0, true));
color_quad_u8 b(dxt1_block::unpack_endpoint(endpoints[cur_index], 1, true));
for (uint i = 0; i < endpoints.size(); i++)
{
if (chosen_flags[i])
continue;
color_quad_u8 c(dxt1_block::unpack_endpoint(endpoints[i], 0, true));
color_quad_u8 d(dxt1_block::unpack_endpoint(endpoints[i], 1, true));
uint total = color::elucidian_distance(a, c, false) + color::elucidian_distance(b, d, false);
if (total < lowest_error)
{
lowest_error = total;
lowest_error_index = i;
}
}
cur_index = lowest_error_index;
}
}
void crn_comp::sort_alpha_endpoint_codebook(crnlib::vector<uint>& remapping, const crnlib::vector<uint>& endpoints)
{
remapping.resize(endpoints.size());
uint lowest_energy = UINT_MAX;
uint lowest_energy_index = 0;
for (uint i = 0; i < endpoints.size(); i++)
{
uint a = dxt5_block::unpack_endpoint(endpoints[i], 0);
uint b = dxt5_block::unpack_endpoint(endpoints[i], 1);
uint total = a + b;
if (total < lowest_energy)
{
lowest_energy = total;
lowest_energy_index = i;
}
}
uint cur_index = lowest_energy_index;
crnlib::vector<bool> chosen_flags(endpoints.size());
uint n = 0;
for ( ; ; )
{
chosen_flags[cur_index] = true;
remapping[cur_index] = n;
n++;
if (n == endpoints.size())
break;
uint lowest_error = UINT_MAX;
uint lowest_error_index = 0;
const int a = dxt5_block::unpack_endpoint(endpoints[cur_index], 0);
const int b = dxt5_block::unpack_endpoint(endpoints[cur_index], 1);
for (uint i = 0; i < endpoints.size(); i++)
{
if (chosen_flags[i])
continue;
const int c = dxt5_block::unpack_endpoint(endpoints[i], 0);
const int d = dxt5_block::unpack_endpoint(endpoints[i], 1);
uint total = math::square(a - c) + math::square(b - d);
if (total < lowest_error)
{
lowest_error = total;
lowest_error_index = i;
}
}
cur_index = lowest_error_index;
}
}
// The indices are only used for statistical purposes.
bool crn_comp::pack_color_endpoints(
crnlib::vector<uint8>& data,
const crnlib::vector<uint>& remapping,
const crnlib::vector<uint>& endpoint_indices,
uint trial_index)
{
trial_index;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("pack_color_endpoints: %u", trial_index);
#endif
crnlib::vector<uint> remapped_endpoints(m_hvq.get_color_endpoint_codebook_size());
for (uint i = 0; i < m_hvq.get_color_endpoint_codebook_size(); i++)
remapped_endpoints[remapping[i]] = m_hvq.get_color_endpoint(i);
const uint component_limits[6] = { 31, 63, 31, 31, 63, 31 };
symbol_histogram hist[2];
hist[0].resize(32);
hist[1].resize(64);
#if CRNLIB_CREATE_DEBUG_IMAGES
image_u8 endpoint_image(2, m_hvq.get_color_endpoint_codebook_size());
image_u8 endpoint_residual_image(2, m_hvq.get_color_endpoint_codebook_size());
#endif
crnlib::vector<uint> residual_syms;
residual_syms.reserve(m_hvq.get_color_endpoint_codebook_size()*2*3);
color_quad_u8 prev[2];
prev[0].clear();
prev[1].clear();
int total_residuals = 0;
for (uint endpoint_index = 0; endpoint_index < m_hvq.get_color_endpoint_codebook_size(); endpoint_index++)
{
const uint endpoint = remapped_endpoints[endpoint_index];
color_quad_u8 cur[2];
cur[0] = dxt1_block::unpack_color((uint16)(endpoint & 0xFFFF), false);
cur[1] = dxt1_block::unpack_color((uint16)((endpoint >> 16) & 0xFFFF), false);
#if CRNLIB_CREATE_DEBUG_IMAGES
endpoint_image(0, endpoint_index) = dxt1_block::unpack_color((uint16)(endpoint & 0xFFFF), true);
endpoint_image(1, endpoint_index) = dxt1_block::unpack_color((uint16)((endpoint >> 16) & 0xFFFF), true);
#endif
for (uint j = 0; j < 2; j++)
{
for (uint k = 0; k < 3; k++)
{
int delta = cur[j][k] - prev[j][k];
total_residuals += delta*delta;
int sym = delta & component_limits[j*3+k];
int table = (k == 1) ? 1 : 0;
hist[table].inc_freq(sym);
residual_syms.push_back(sym);
#if CRNLIB_CREATE_DEBUG_IMAGES
endpoint_residual_image(j, endpoint_index)[k] = static_cast<uint8>(sym);
#endif
}
}
prev[0] = cur[0];
prev[1] = cur[1];
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total endpoint residuals: %i", total_residuals);
#endif
if (endpoint_indices.size() > 1)
{
uint prev_index = remapping[endpoint_indices[0]];
int64 total_delta = 0;
for (uint i = 1; i < endpoint_indices.size(); i++)
{
uint cur_index = remapping[endpoint_indices[i]];
int delta = cur_index - prev_index;
prev_index = cur_index;
total_delta += delta * delta;
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total endpoint index delta: " CRNLIB_INT64_FORMAT_SPECIFIER, total_delta);
#endif
}
#if CRNLIB_CREATE_DEBUG_IMAGES
image_utils::write_to_file(dynamic_string(cVarArg, "color_endpoint_residuals_%u.tga", trial_index).get_ptr(), endpoint_residual_image);
image_utils::write_to_file(dynamic_string(cVarArg, "color_endpoints_%u.tga", trial_index).get_ptr(), endpoint_image);
#endif
static_huffman_data_model residual_dm[2];
symbol_codec codec;
codec.start_encoding(1024*1024);
// Transmit residuals
for (uint i = 0; i < 2; i++)
{
if (!residual_dm[i].init(true, hist[i], 15))
return false;
if (!codec.encode_transmit_static_huffman_data_model(residual_dm[i], false))
return false;
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Wrote %u bits for color endpoint residual Huffman tables", codec.encode_get_total_bits_written());
#endif
uint start_bits = codec.encode_get_total_bits_written();
start_bits;
for (uint i = 0; i < residual_syms.size(); i++)
{
const uint sym = residual_syms[i];
const uint table = ((i % 3) == 1) ? 1 : 0;
codec.encode(sym, residual_dm[table]);
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Wrote %u bits for color endpoint residuals", codec.encode_get_total_bits_written() - start_bits);
#endif
codec.stop_encoding(false);
data.swap(codec.get_encoding_buf());
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
{
console::debug("Wrote a total of %u bits for color endpoint codebook", codec.encode_get_total_bits_written());
console::debug("Wrote %f bits per each color endpoint", data.size() * 8.0f / m_hvq.get_color_endpoint_codebook_size());
}
#endif
return true;
}
// The indices are only used for statistical purposes.
bool crn_comp::pack_alpha_endpoints(
crnlib::vector<uint8>& data,
const crnlib::vector<uint>& remapping,
const crnlib::vector<uint>& endpoint_indices,
uint trial_index)
{
trial_index;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("pack_alpha_endpoints: %u", trial_index);
#endif
crnlib::vector<uint> remapped_endpoints(m_hvq.get_alpha_endpoint_codebook_size());
for (uint i = 0; i < m_hvq.get_alpha_endpoint_codebook_size(); i++)
remapped_endpoints[remapping[i]] = m_hvq.get_alpha_endpoint(i);
symbol_histogram hist;
hist.resize(256);
#if CRNLIB_CREATE_DEBUG_IMAGES
image_u8 endpoint_image(2, m_hvq.get_alpha_endpoint_codebook_size());
image_u8 endpoint_residual_image(2, m_hvq.get_alpha_endpoint_codebook_size());
#endif
crnlib::vector<uint> residual_syms;
residual_syms.reserve(m_hvq.get_alpha_endpoint_codebook_size()*2*3);
uint prev[2];
utils::zero_object(prev);
int total_residuals = 0;
for (uint endpoint_index = 0; endpoint_index < m_hvq.get_alpha_endpoint_codebook_size(); endpoint_index++)
{
const uint endpoint = remapped_endpoints[endpoint_index];
uint cur[2];
cur[0] = dxt5_block::unpack_endpoint(endpoint, 0);
cur[1] = dxt5_block::unpack_endpoint(endpoint, 1);
#if CRNLIB_CREATE_DEBUG_IMAGES
endpoint_image(0, endpoint_index) = cur[0];
endpoint_image(1, endpoint_index) = cur[1];
#endif
for (uint j = 0; j < 2; j++)
{
int delta = cur[j] - prev[j];
total_residuals += delta*delta;
int sym = delta & 255;
hist.inc_freq(sym);
residual_syms.push_back(sym);
#if CRNLIB_CREATE_DEBUG_IMAGES
endpoint_residual_image(j, endpoint_index) = static_cast<uint8>(sym);
#endif
}
prev[0] = cur[0];
prev[1] = cur[1];
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total endpoint residuals: %i", total_residuals);
#endif
if (endpoint_indices.size() > 1)
{
uint prev_index = remapping[endpoint_indices[0]];
int64 total_delta = 0;
for (uint i = 1; i < endpoint_indices.size(); i++)
{
uint cur_index = remapping[endpoint_indices[i]];
int delta = cur_index - prev_index;
prev_index = cur_index;
total_delta += delta * delta;
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total endpoint index delta: " CRNLIB_INT64_FORMAT_SPECIFIER, total_delta);
#endif
}
#if CRNLIB_CREATE_DEBUG_IMAGES
image_utils::write_to_file(dynamic_string(cVarArg, "alpha_endpoint_residuals_%u.tga", trial_index).get_ptr(), endpoint_residual_image);
image_utils::write_to_file(dynamic_string(cVarArg, "alpha_endpoints_%u.tga", trial_index).get_ptr(), endpoint_image);
#endif
static_huffman_data_model residual_dm;
symbol_codec codec;
codec.start_encoding(1024*1024);
// Transmit residuals
if (!residual_dm.init(true, hist, 15))
return false;
if (!codec.encode_transmit_static_huffman_data_model(residual_dm, false))
return false;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Wrote %u bits for alpha endpoint residual Huffman tables", codec.encode_get_total_bits_written());
#endif
uint start_bits = codec.encode_get_total_bits_written();
start_bits;
for (uint i = 0; i < residual_syms.size(); i++)
{
const uint sym = residual_syms[i];
codec.encode(sym, residual_dm);
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Wrote %u bits for alpha endpoint residuals", codec.encode_get_total_bits_written() - start_bits);
#endif
codec.stop_encoding(false);
data.swap(codec.get_encoding_buf());
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
{
console::debug("Wrote a total of %u bits for alpha endpoint codebook", codec.encode_get_total_bits_written());
console::debug("Wrote %f bits per each alpha endpoint", data.size() * 8.0f / m_hvq.get_alpha_endpoint_codebook_size());
}
#endif
return true;
}
float crn_comp::color_selector_similarity_func(uint index_a, uint index_b, void* pContext)
{
const crnlib::vector<dxt_hc::selectors>& selectors = *static_cast< const crnlib::vector<dxt_hc::selectors>* >(pContext);
const dxt_hc::selectors& selectors_a = selectors[index_a];
const dxt_hc::selectors& selectors_b = selectors[index_b];
int total = 0;
for (uint i = 0; i < 16; i++)
{
int a = g_dxt1_to_linear[selectors_a.get_by_index(i)];
int b = g_dxt1_to_linear[selectors_b.get_by_index(i)];
int delta = a - b;
total += delta*delta;
}
float weight = 1.0f - math::clamp(total * 1.0f/20.0f, 0.0f, 1.0f);
return weight;
}
float crn_comp::alpha_selector_similarity_func(uint index_a, uint index_b, void* pContext)
{
const crnlib::vector<dxt_hc::selectors>& selectors = *static_cast< const crnlib::vector<dxt_hc::selectors>* >(pContext);
const dxt_hc::selectors& selectors_a = selectors[index_a];
const dxt_hc::selectors& selectors_b = selectors[index_b];
int total = 0;
for (uint i = 0; i < 16; i++)
{
int a = g_dxt5_to_linear[selectors_a.get_by_index(i)];
int b = g_dxt5_to_linear[selectors_b.get_by_index(i)];
int delta = a - b;
total += delta*delta;
}
float weight = 1.0f - math::clamp(total * 1.0f/100.0f, 0.0f, 1.0f);
return weight;
}
void crn_comp::sort_selector_codebook(crnlib::vector<uint>& remapping, const crnlib::vector<dxt_hc::selectors>& selectors, const uint8* pTo_linear)
{
remapping.resize(selectors.size());
uint lowest_energy = UINT_MAX;
uint lowest_energy_index = 0;
for (uint i = 0; i < selectors.size(); i++)
{
uint total = 0;
for (uint j = 0; j < 16; j++)
{
int a = pTo_linear[selectors[i].get_by_index(j)];
total += a*a;
}
if (total < lowest_energy)
{
lowest_energy = total;
lowest_energy_index = i;
}
}
uint cur_index = lowest_energy_index;
crnlib::vector<bool> chosen_flags(selectors.size());
uint n = 0;
for ( ; ; )
{
chosen_flags[cur_index] = true;
remapping[cur_index] = n;
n++;
if (n == selectors.size())
break;
uint lowest_error = UINT_MAX;
uint lowest_error_index = 0;
for (uint i = 0; i < selectors.size(); i++)
{
if (chosen_flags[i])
continue;
uint total = 0;
for (uint j = 0; j < 16; j++)
{
int a = pTo_linear[selectors[cur_index].get_by_index(j)];
int b = pTo_linear[selectors[i].get_by_index(j)];
int delta = a - b;
total += delta*delta;
}
if (total < lowest_error)
{
lowest_error = total;
lowest_error_index = i;
}
}
cur_index = lowest_error_index;
}
}
// The indices are only used for statistical purposes.
bool crn_comp::pack_selectors(
crnlib::vector<uint8>& packed_data,
const crnlib::vector<uint>& selector_indices,
const crnlib::vector<dxt_hc::selectors>& selectors,
const crnlib::vector<uint>& remapping,
uint max_selector_value,
const uint8* pTo_linear,
uint trial_index)
{
trial_index;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("pack_selectors: %u", trial_index);
#endif
crnlib::vector<dxt_hc::selectors> remapped_selectors(selectors.size());
for (uint i = 0; i < selectors.size(); i++)
remapped_selectors[remapping[i]] = selectors[i];
#if CRNLIB_CREATE_DEBUG_IMAGES
image_u8 residual_image(16, selectors.size());;
image_u8 selector_image(16, selectors.size());;
#endif
crnlib::vector<uint> residual_syms;
residual_syms.reserve(selectors.size() * 8);
const uint num_baised_selector_values = (max_selector_value * 2 + 1);
symbol_histogram hist(num_baised_selector_values * num_baised_selector_values);
dxt_hc::selectors prev_selectors;
utils::zero_object(prev_selectors);
int total_residuals = 0;
for (uint selector_index = 0; selector_index < selectors.size(); selector_index++)
{
const dxt_hc::selectors& s = remapped_selectors[selector_index];
uint prev_sym = 0;
for (uint i = 0; i < 16; i++)
{
int p = pTo_linear[crnlib_assert_range_incl<uint>(prev_selectors.get_by_index(i), max_selector_value)];
int r = pTo_linear[crnlib_assert_range_incl<uint>(s.get_by_index(i), max_selector_value)] - p;
total_residuals += r*r;
uint sym = r + max_selector_value;
CRNLIB_ASSERT(sym < num_baised_selector_values);
if (i & 1)
{
uint paired_sym = (sym * num_baised_selector_values) + prev_sym;
residual_syms.push_back(paired_sym);
hist.inc_freq(paired_sym);
}
else
prev_sym = sym;
#if CRNLIB_CREATE_DEBUG_IMAGES
selector_image(i, selector_index) = (pTo_linear[crnlib_assert_range_incl<uint>(s.get_by_index(i), max_selector_value)] * 255) / max_selector_value;
residual_image(i, selector_index) = sym;
#endif
}
prev_selectors = s;
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total selector endpoint residuals: %u", total_residuals);
#endif
if (selector_indices.size() > 1)
{
uint prev_index = remapping[selector_indices[1]];
int64 total_delta = 0;
for (uint i = 1; i < selector_indices.size(); i++)
{
uint cur_index = remapping[selector_indices[i]];
int delta = cur_index - prev_index;
prev_index = cur_index;
total_delta += delta * delta;
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total selector index delta: " CRNLIB_INT64_FORMAT_SPECIFIER, total_delta);
#endif
}
#if CRNLIB_CREATE_DEBUG_IMAGES
image_utils::write_to_file(dynamic_string(cVarArg, "selectors_%u_%u.tga", trial_index, max_selector_value).get_ptr(), selector_image);
image_utils::write_to_file(dynamic_string(cVarArg, "selector_residuals_%u_%u.tga", trial_index, max_selector_value).get_ptr(), residual_image);
#endif
static_huffman_data_model residual_dm;
symbol_codec codec;
codec.start_encoding(1024*1024);
// Transmit residuals
if (!residual_dm.init(true, hist, 15))
return false;
if (!codec.encode_transmit_static_huffman_data_model(residual_dm, false))
return false;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Wrote %u bits for selector residual Huffman tables", codec.encode_get_total_bits_written());
#endif
uint start_bits = codec.encode_get_total_bits_written();
start_bits;
for (uint i = 0; i < residual_syms.size(); i++)
{
const uint sym = residual_syms[i];
codec.encode(sym, residual_dm);
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Wrote %u bits for selector residuals", codec.encode_get_total_bits_written() - start_bits);
#endif
codec.stop_encoding(false);
packed_data.swap(codec.get_encoding_buf());
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
{
console::debug("Wrote a total of %u bits for selector codebook", codec.encode_get_total_bits_written());
console::debug("Wrote %f bits per each selector codebook entry", packed_data.size() * 8.0f / selectors.size());
}
#endif
return true;
}
bool crn_comp::pack_chunks(
uint first_chunk, uint num_chunks,
bool clear_histograms,
symbol_codec* pCodec,
const crnlib::vector<uint>* pColor_endpoint_remap,
const crnlib::vector<uint>* pColor_selector_remap,
const crnlib::vector<uint>* pAlpha_endpoint_remap,
const crnlib::vector<uint>* pAlpha_selector_remap)
{
if (!pCodec)
{
m_chunk_encoding_hist.resize(1 << (3 * cEncodingMapNumChunksPerCode));
if (clear_histograms)
m_chunk_encoding_hist.set_all(0);
if (pColor_endpoint_remap)
{
CRNLIB_ASSERT(pColor_endpoint_remap->size() == m_hvq.get_color_endpoint_codebook_size());
m_endpoint_index_hist[0].resize(pColor_endpoint_remap->size());
if (clear_histograms)
m_endpoint_index_hist[0].set_all(0);
}
if (pColor_selector_remap)
{
CRNLIB_ASSERT(pColor_selector_remap->size() == m_hvq.get_color_selector_codebook_size());
m_selector_index_hist[0].resize(pColor_selector_remap->size());
if (clear_histograms)
m_selector_index_hist[0].set_all(0);
}
if (pAlpha_endpoint_remap)
{
CRNLIB_ASSERT(pAlpha_endpoint_remap->size() == m_hvq.get_alpha_endpoint_codebook_size());
m_endpoint_index_hist[1].resize(pAlpha_endpoint_remap->size());
if (clear_histograms)
m_endpoint_index_hist[1].set_all(0);
}
if (pAlpha_selector_remap)
{
CRNLIB_ASSERT(pAlpha_selector_remap->size() == m_hvq.get_alpha_selector_codebook_size());
m_selector_index_hist[1].resize(pAlpha_selector_remap->size());
if (clear_histograms)
m_selector_index_hist[1].set_all(0);
}
}
uint prev_endpoint_index[cNumComps];
utils::zero_object(prev_endpoint_index);
uint prev_selector_index[cNumComps];
utils::zero_object(prev_selector_index);
uint num_encodings_left = 0;
for (uint chunk_index = first_chunk; chunk_index < (first_chunk + num_chunks); chunk_index++)
{
if (!num_encodings_left)
{
uint index = 0;
for (uint i = 0; i < cEncodingMapNumChunksPerCode; i++)
if ((chunk_index + i) < (first_chunk + num_chunks))
index |= (m_hvq.get_chunk_encoding(chunk_index + i).m_encoding_index << (i * 3));
if (pCodec)
pCodec->encode(index, m_chunk_encoding_dm);
else
m_chunk_encoding_hist.inc_freq(index);
num_encodings_left = cEncodingMapNumChunksPerCode;
}
num_encodings_left--;
const dxt_hc::chunk_encoding& encoding = m_hvq.get_chunk_encoding(chunk_index);
const chunk_detail& details = m_chunk_details[chunk_index];
const uint comp_order[3] = { cAlpha0, cAlpha1, cColor };
for (uint c = 0; c < 3; c++)
{
const uint comp_index = comp_order[c];
if (!m_has_comp[comp_index])
continue;
// endpoints
if (comp_index == cColor)
{
if (pColor_endpoint_remap)
{
for (uint i = 0; i < encoding.m_num_tiles; i++)
{
uint cur_endpoint_index = (*pColor_endpoint_remap)[ m_endpoint_indices[cColor][details.m_first_endpoint_index + i] ];
int endpoint_delta = cur_endpoint_index - prev_endpoint_index[cColor];
int sym = endpoint_delta;
if (sym < 0)
sym += pColor_endpoint_remap->size();
CRNLIB_ASSERT(sym >= 0 && sym < (int)pColor_endpoint_remap->size());
if (!pCodec)
m_endpoint_index_hist[cColor].inc_freq(sym);
else
pCodec->encode(sym, m_endpoint_index_dm[0]);
prev_endpoint_index[cColor] = cur_endpoint_index;
}
}
}
else
{
if (pAlpha_endpoint_remap)
{
for (uint i = 0; i < encoding.m_num_tiles; i++)
{
uint cur_endpoint_index = (*pAlpha_endpoint_remap)[m_endpoint_indices[comp_index][details.m_first_endpoint_index + i]];
int endpoint_delta = cur_endpoint_index - prev_endpoint_index[comp_index];
int sym = endpoint_delta;
if (sym < 0)
sym += pAlpha_endpoint_remap->size();
CRNLIB_ASSERT(sym >= 0 && sym < (int)pAlpha_endpoint_remap->size());
if (!pCodec)
m_endpoint_index_hist[1].inc_freq(sym);
else
pCodec->encode(sym, m_endpoint_index_dm[1]);
prev_endpoint_index[comp_index] = cur_endpoint_index;
}
}
}
} // c
// selectors
for (uint y = 0; y < 2; y++)
{
for (uint x = 0; x < 2; x++)
{
for (uint c = 0; c < 3; c++)
{
const uint comp_index = comp_order[c];
if (!m_has_comp[comp_index])
continue;
if (comp_index == cColor)
{
if (pColor_selector_remap)
{
uint cur_selector_index = (*pColor_selector_remap)[ m_selector_indices[cColor][details.m_first_selector_index + x + y * 2] ];
int selector_delta = cur_selector_index - prev_selector_index[cColor];
int sym = selector_delta;
if (sym < 0)
sym += pColor_selector_remap->size();
CRNLIB_ASSERT(sym >= 0 && sym < (int)pColor_selector_remap->size());
if (!pCodec)
m_selector_index_hist[cColor].inc_freq(sym);
else
pCodec->encode(sym, m_selector_index_dm[cColor]);
prev_selector_index[cColor] = cur_selector_index;
}
}
else if (pAlpha_selector_remap)
{
uint cur_selector_index = (*pAlpha_selector_remap)[ m_selector_indices[comp_index][details.m_first_selector_index + x + y * 2] ];
int selector_delta = cur_selector_index - prev_selector_index[comp_index];
int sym = selector_delta;
if (sym < 0)
sym += pAlpha_selector_remap->size();
CRNLIB_ASSERT(sym >= 0 && sym < (int)pAlpha_selector_remap->size());
if (!pCodec)
m_selector_index_hist[1].inc_freq(sym);
else
pCodec->encode(sym, m_selector_index_dm[1]);
prev_selector_index[comp_index] = cur_selector_index;
}
} // c
} // x
} // y
} // chunk_index
return true;
}
bool crn_comp::pack_chunks_simulation(
uint first_chunk, uint num_chunks,
uint& total_bits,
const crnlib::vector<uint>* pColor_endpoint_remap,
const crnlib::vector<uint>* pColor_selector_remap,
const crnlib::vector<uint>* pAlpha_endpoint_remap,
const crnlib::vector<uint>* pAlpha_selector_remap)
{
if (!pack_chunks(first_chunk, num_chunks, true, NULL, pColor_endpoint_remap, pColor_selector_remap, pAlpha_endpoint_remap, pAlpha_selector_remap))
return false;
symbol_codec codec;
codec.start_encoding(2*1024*1024);
codec.encode_enable_simulation(true);
m_chunk_encoding_dm.init(true, m_chunk_encoding_hist, 16);
for (uint i = 0; i < 2; i++)
{
if (m_endpoint_index_hist[i].size())
{
m_endpoint_index_dm[i].init(true, m_endpoint_index_hist[i], 16);
codec.encode_transmit_static_huffman_data_model(m_endpoint_index_dm[i], false);
}
if (m_selector_index_hist[i].size())
{
m_selector_index_dm[i].init(true, m_selector_index_hist[i], 16);
codec.encode_transmit_static_huffman_data_model(m_selector_index_dm[i], false);
}
}
if (!pack_chunks(first_chunk, num_chunks, false, &codec, pColor_endpoint_remap, pColor_selector_remap, pAlpha_endpoint_remap, pAlpha_selector_remap))
return false;
codec.stop_encoding(false);
total_bits = codec.encode_get_total_bits_written();
return true;
}
void crn_comp::append_vec(crnlib::vector<uint8>& a, const void* p, uint size)
{
if (size)
{
uint ofs = a.size();
a.resize(ofs + size);
memcpy(&a[ofs], p, size);
}
}
void crn_comp::append_vec(crnlib::vector<uint8>& a, const crnlib::vector<uint8>& b)
{
if (!b.empty())
{
uint ofs = a.size();
a.resize(ofs + b.size());
memcpy(&a[ofs], &b[0], b.size());
}
}
#if 0
bool crn_comp::init_chunk_encoding_dm()
{
symbol_histogram hist(1 << (3 * cEncodingMapNumChunksPerCode));
for (uint chunk_index = 0; chunk_index < m_hvq.get_num_chunks(); chunk_index += cEncodingMapNumChunksPerCode)
{
uint index = 0;
for (uint i = 0; i < cEncodingMapNumChunksPerCode; i++)
{
if ((chunk_index + i) >= m_hvq.get_num_chunks())
break;
const dxt_hc::chunk_encoding& encoding = m_hvq.get_chunk_encoding(chunk_index + i);
index |= (encoding.m_encoding_index << (i * 3));
}
hist.inc_freq(index);
}
if (!m_chunk_encoding_dm.init(true, hist, 16))
return false;
return true;
}
#endif
bool crn_comp::alias_images()
{
for (uint face_index = 0; face_index < m_pParams->m_faces; face_index++)
{
for (uint level_index = 0; level_index < m_pParams->m_levels; level_index++)
{
const uint width = math::maximum(1U, m_pParams->m_width >> level_index);
const uint height = math::maximum(1U, m_pParams->m_height >> level_index);
if (!m_pParams->m_pImages[face_index][level_index])
return false;
m_images[face_index][level_index].alias((color_quad_u8*)m_pParams->m_pImages[face_index][level_index], width, height);
}
}
image_utils::conversion_type conv_type = image_utils::get_image_conversion_type_from_crn_format((crn_format)m_pParams->m_format);
if (conv_type != image_utils::cConversion_Invalid)
{
for (uint face_index = 0; face_index < m_pParams->m_faces; face_index++)
{
for (uint level_index = 0; level_index < m_pParams->m_levels; level_index++)
{
image_u8 cooked_image(m_images[face_index][level_index]);
image_utils::convert_image(cooked_image, conv_type);
m_images[face_index][level_index].swap(cooked_image);
}
}
}
m_mip_groups.clear();
m_mip_groups.resize(m_pParams->m_levels);
utils::zero_object(m_levels);
uint mip_group = 0;
uint chunk_index = 0;
uint mip_group_chunk_index = 0; (void)mip_group_chunk_index;
for (uint level_index = 0; level_index < m_pParams->m_levels; level_index++)
{
const uint width = math::maximum(1U, m_pParams->m_width >> level_index);
const uint height = math::maximum(1U, m_pParams->m_height >> level_index);
const uint chunk_width = math::align_up_value(width, cChunkPixelWidth) / cChunkPixelWidth;
const uint chunk_height = math::align_up_value(height, cChunkPixelHeight) / cChunkPixelHeight;
const uint num_chunks = m_pParams->m_faces * chunk_width * chunk_height;
m_mip_groups[mip_group].m_first_chunk = chunk_index;
mip_group_chunk_index = 0;
m_mip_groups[mip_group].m_num_chunks += num_chunks;
m_levels[level_index].m_width = width;
m_levels[level_index].m_height = height;
m_levels[level_index].m_chunk_width = chunk_width;
m_levels[level_index].m_chunk_height = chunk_height;
m_levels[level_index].m_first_chunk = chunk_index;
m_levels[level_index].m_num_chunks = num_chunks;
m_levels[level_index].m_group_index = mip_group;
m_levels[level_index].m_group_first_chunk = 0;
chunk_index += num_chunks;
mip_group++;
}
m_total_chunks = chunk_index;
return true;
}
void crn_comp::append_chunks(const image_u8& img, uint num_chunks_x, uint num_chunks_y, dxt_hc::pixel_chunk_vec& chunks, float weight)
{
for (uint y = 0; y < num_chunks_y; y++)
{
int x_start = 0;
int x_end = num_chunks_x;
int x_dir = 1;
if (y & 1)
{
x_start = num_chunks_x - 1;
x_end = -1;
x_dir = -1;
}
for (int x = x_start; x != x_end; x += x_dir)
{
chunks.resize(chunks.size() + 1);
dxt_hc::pixel_chunk& chunk = chunks.back();
chunk.m_weight = weight;
for (uint cy = 0; cy < cChunkPixelHeight; cy++)
{
uint py = y * cChunkPixelHeight + cy;
py = math::minimum(py, img.get_height() - 1);
for (uint cx = 0; cx < cChunkPixelWidth; cx++)
{
uint px = x * cChunkPixelWidth + cx;
px = math::minimum(px, img.get_width() - 1);
chunk(cx, cy) = img(px, py);
}
}
}
}
}
void crn_comp::create_chunks()
{
m_chunks.reserve(m_total_chunks);
m_chunks.resize(0);
for (uint level = 0; level < m_pParams->m_levels; level++)
{
for (uint face = 0; face < m_pParams->m_faces; face++)
{
if (!face)
{
CRNLIB_ASSERT(m_levels[level].m_first_chunk == m_chunks.size());
}
float mip_weight = math::minimum(12.0f, powf( 1.3f, static_cast<float>(level) ) );
//float mip_weight = 1.0f;
append_chunks(m_images[face][level], m_levels[level].m_chunk_width, m_levels[level].m_chunk_height, m_chunks, mip_weight);
}
}
CRNLIB_ASSERT(m_chunks.size() == m_total_chunks);
}
void crn_comp::clear()
{
m_pParams = NULL;
for (uint f = 0; f < cCRNMaxFaces; f++)
for (uint l = 0; l < cCRNMaxLevels; l++)
m_images[f][l].clear();
utils::zero_object(m_levels);
m_mip_groups.clear();
utils::zero_object(m_has_comp);
m_chunk_details.clear();
for (uint i = 0; i < cNumComps; i++)
{
m_endpoint_indices[i].clear();
m_selector_indices[i].clear();
}
m_total_chunks = 0;
m_chunks.clear();
utils::zero_object(m_crn_header);
m_comp_data.clear();
m_hvq.clear();
m_chunk_encoding_hist.clear();
m_chunk_encoding_dm.clear();
for (uint i = 0; i < 2; i++)
{
m_endpoint_index_hist[i].clear();
m_endpoint_index_dm[i].clear();
m_selector_index_hist[i].clear();
m_selector_index_dm[i].clear();
}
for (uint i = 0; i < cCRNMaxLevels; i++)
m_packed_chunks[i].clear();
m_packed_data_models.clear();
m_packed_color_endpoints.clear();
m_packed_color_selectors.clear();
m_packed_alpha_endpoints.clear();
m_packed_alpha_selectors.clear();
}
bool crn_comp::quantize_chunks()
{
dxt_hc::params params;
params.m_adaptive_tile_alpha_psnr_derating = m_pParams->m_crn_adaptive_tile_alpha_psnr_derating;
params.m_adaptive_tile_color_psnr_derating = m_pParams->m_crn_adaptive_tile_color_psnr_derating;
if (m_pParams->m_flags & cCRNCompFlagManualPaletteSizes)
{
params.m_color_endpoint_codebook_size = math::clamp<int>(m_pParams->m_crn_color_endpoint_palette_size, cCRNMinPaletteSize, cCRNMaxPaletteSize);
params.m_color_selector_codebook_size = math::clamp<int>(m_pParams->m_crn_color_selector_palette_size, cCRNMinPaletteSize, cCRNMaxPaletteSize);
params.m_alpha_endpoint_codebook_size = math::clamp<int>(m_pParams->m_crn_alpha_endpoint_palette_size, cCRNMinPaletteSize, cCRNMaxPaletteSize);
params.m_alpha_selector_codebook_size = math::clamp<int>(m_pParams->m_crn_alpha_selector_palette_size, cCRNMinPaletteSize, cCRNMaxPaletteSize);
}
else
{
uint max_codebook_entries = ((m_pParams->m_width + 3) / 4) * ((m_pParams->m_height + 3) / 4);
max_codebook_entries = math::clamp<uint>(max_codebook_entries, cCRNMinPaletteSize, cCRNMaxPaletteSize);
float quality = math::clamp<float>((float)m_pParams->m_quality_level / cCRNMaxQualityLevel, 0.0f, 1.0f);
float color_quality_power_mul = 1.0f;
float alpha_quality_power_mul = 1.0f;
if (m_pParams->m_format == cCRNFmtDXT5_CCxY)
{
color_quality_power_mul = 3.5f;
alpha_quality_power_mul = .35f;
params.m_adaptive_tile_color_psnr_derating = 5.0f;
}
else if (m_pParams->m_format == cCRNFmtDXT5)
color_quality_power_mul = .75f;
float color_endpoint_quality = powf(quality, 1.8f * color_quality_power_mul);
float color_selector_quality = powf(quality, 1.65f * color_quality_power_mul);
params.m_color_endpoint_codebook_size = math::clamp<uint>(math::float_to_uint(.5f + math::lerp<float>(math::maximum<float>(64, cCRNMinPaletteSize), (float)max_codebook_entries, color_endpoint_quality)), cCRNMinPaletteSize, cCRNMaxPaletteSize);
params.m_color_selector_codebook_size = math::clamp<uint>(math::float_to_uint(.5f + math::lerp<float>(math::maximum<float>(96, cCRNMinPaletteSize), (float)max_codebook_entries, color_selector_quality)), cCRNMinPaletteSize, cCRNMaxPaletteSize);
float alpha_endpoint_quality = powf(quality, 2.1f * alpha_quality_power_mul);
float alpha_selector_quality = powf(quality, 1.65f * alpha_quality_power_mul);
params.m_alpha_endpoint_codebook_size = math::clamp<uint>(math::float_to_uint(.5f + math::lerp<float>(math::maximum<float>(24, cCRNMinPaletteSize), (float)max_codebook_entries, alpha_endpoint_quality)), cCRNMinPaletteSize, cCRNMaxPaletteSize);;
params.m_alpha_selector_codebook_size = math::clamp<uint>(math::float_to_uint(.5f + math::lerp<float>(math::maximum<float>(48, cCRNMinPaletteSize), (float)max_codebook_entries, alpha_selector_quality)), cCRNMinPaletteSize, cCRNMaxPaletteSize);;
}
if (m_pParams->m_flags & cCRNCompFlagDebugging)
{
console::debug("Color endpoints: %u", params.m_color_endpoint_codebook_size);
console::debug("Color selectors: %u", params.m_color_selector_codebook_size);
console::debug("Alpha endpoints: %u", params.m_alpha_endpoint_codebook_size);
console::debug("Alpha selectors: %u", params.m_alpha_selector_codebook_size);
}
params.m_hierarchical = (m_pParams->m_flags & cCRNCompFlagHierarchical) != 0;
params.m_perceptual = (m_pParams->m_flags & cCRNCompFlagPerceptual) != 0;
params.m_pProgress_func = m_pParams->m_pProgress_func;
params.m_pProgress_func_data = m_pParams->m_pProgress_func_data;
switch (m_pParams->m_format)
{
case cCRNFmtDXT1:
{
params.m_format = cDXT1;
m_has_comp[cColor] = true;
break;
}
case cCRNFmtDXT3:
{
m_has_comp[cAlpha0] = true;
return false;
}
case cCRNFmtDXT5:
{
params.m_format = cDXT5;
params.m_alpha_component_indices[0] = m_pParams->m_alpha_component;
m_has_comp[cColor] = true;
m_has_comp[cAlpha0] = true;
break;
}
case cCRNFmtDXT5_CCxY:
{
params.m_format = cDXT5;
params.m_alpha_component_indices[0] = 3;
m_has_comp[cColor] = true;
m_has_comp[cAlpha0] = true;
params.m_perceptual = false;
//params.m_adaptive_tile_color_alpha_weighting_ratio = 1.0f;
params.m_adaptive_tile_color_alpha_weighting_ratio = 1.5f;
break;
}
case cCRNFmtDXT5_xGBR:
case cCRNFmtDXT5_AGBR:
case cCRNFmtDXT5_xGxR:
{
params.m_format = cDXT5;
params.m_alpha_component_indices[0] = 3;
m_has_comp[cColor] = true;
m_has_comp[cAlpha0] = true;
params.m_perceptual = false;
break;
}
case cCRNFmtDXN_XY:
{
params.m_format = cDXN_XY;
params.m_alpha_component_indices[0] = 0;
params.m_alpha_component_indices[1] = 1;
m_has_comp[cAlpha0] = true;
m_has_comp[cAlpha1] = true;
params.m_perceptual = false;
break;
}
case cCRNFmtDXN_YX:
{
params.m_format = cDXN_YX;
params.m_alpha_component_indices[0] = 1;
params.m_alpha_component_indices[1] = 0;
m_has_comp[cAlpha0] = true;
m_has_comp[cAlpha1] = true;
params.m_perceptual = false;
break;
}
case cCRNFmtDXT5A:
{
params.m_format = cDXT5A;
params.m_alpha_component_indices[0] = m_pParams->m_alpha_component;
m_has_comp[cAlpha0] = true;
params.m_perceptual = false;
break;
}
case cCRNFmtETC1:
{
console::warning("crn_comp::quantize_chunks: This class does not support ETC1");
return false;
}
default:
{
return false;
}
}
params.m_debugging = (m_pParams->m_flags & cCRNCompFlagDebugging) != 0;
params.m_num_levels = m_pParams->m_levels;
for (uint i = 0; i < m_pParams->m_levels; i++)
{
params.m_levels[i].m_first_chunk = m_levels[i].m_first_chunk;
params.m_levels[i].m_num_chunks = m_levels[i].m_num_chunks;
}
if (!m_hvq.compress(params, m_total_chunks, &m_chunks[0], m_task_pool))
return false;
#if CRNLIB_CREATE_DEBUG_IMAGES
if (params.m_debugging)
{
const dxt_hc::pixel_chunk_vec& pixel_chunks = m_hvq.get_compressed_chunk_pixels_final();
image_u8 img;
dxt_hc::create_debug_image_from_chunks((m_pParams->m_width+7)>>3, (m_pParams->m_height+7)>>3, pixel_chunks, &m_hvq.get_chunk_encoding_vec(), img, true, -1);
image_utils::write_to_file("quantized_chunks.tga", img);
}
#endif
return true;
}
void crn_comp::create_chunk_indices()
{
m_chunk_details.resize(m_total_chunks);
for (uint i = 0; i < cNumComps; i++)
{
m_endpoint_indices[i].clear();
m_selector_indices[i].clear();
}
for (uint chunk_index = 0; chunk_index < m_total_chunks; chunk_index++)
{
const dxt_hc::chunk_encoding& chunk_encoding = m_hvq.get_chunk_encoding(chunk_index);
for (uint i = 0; i < cNumComps; i++)
{
if (m_has_comp[i])
{
m_chunk_details[chunk_index].m_first_endpoint_index = m_endpoint_indices[i].size();
m_chunk_details[chunk_index].m_first_selector_index = m_selector_indices[i].size();
break;
}
}
for (uint i = 0; i < cNumComps; i++)
{
if (!m_has_comp[i])
continue;
for (uint tile_index = 0; tile_index < chunk_encoding.m_num_tiles; tile_index++)
m_endpoint_indices[i].push_back(chunk_encoding.m_endpoint_indices[i][tile_index]);
for (uint y = 0; y < cChunkBlockHeight; y++)
for (uint x = 0; x < cChunkBlockWidth; x++)
m_selector_indices[i].push_back(chunk_encoding.m_selector_indices[i][y][x]);
}
}
}
struct optimize_color_endpoint_codebook_params
{
crnlib::vector<uint>* m_pTrial_color_endpoint_remap;
uint m_iter_index;
uint m_max_iter_index;
};
void crn_comp::optimize_color_endpoint_codebook_task(uint64 data, void* pData_ptr)
{
data;
optimize_color_endpoint_codebook_params* pParams = reinterpret_cast<optimize_color_endpoint_codebook_params*>(pData_ptr);
if (pParams->m_iter_index == pParams->m_max_iter_index)
{
sort_color_endpoint_codebook(*pParams->m_pTrial_color_endpoint_remap, m_hvq.get_color_endpoint_vec());
}
else
{
float f = pParams->m_iter_index / static_cast<float>(pParams->m_max_iter_index - 1);
create_zeng_reorder_table(
m_hvq.get_color_endpoint_codebook_size(),
m_endpoint_indices[cColor].size(),
&m_endpoint_indices[cColor][0],
*pParams->m_pTrial_color_endpoint_remap,
pParams->m_iter_index ? color_endpoint_similarity_func : NULL,
&m_hvq,
f);
}
crnlib_delete(pParams);
}
bool crn_comp::optimize_color_endpoint_codebook(crnlib::vector<uint>& remapping)
{
if (m_pParams->m_flags & cCRNCompFlagQuick)
{
remapping.resize(m_hvq.get_color_endpoint_vec().size());
for (uint i = 0; i < m_hvq.get_color_endpoint_vec().size(); i++)
remapping[i] = i;
if (!pack_color_endpoints(m_packed_color_endpoints, remapping, m_endpoint_indices[cColor], 0))
return false;
return true;
}
const uint cMaxEndpointRemapIters = 3;
uint best_bits = UINT_MAX;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("----- Begin optimization of color endpoint codebook");
#endif
crnlib::vector<uint> trial_color_endpoint_remaps[cMaxEndpointRemapIters + 1];
for (uint i = 0; i <= cMaxEndpointRemapIters; i++)
{
optimize_color_endpoint_codebook_params* pParams = crnlib_new<optimize_color_endpoint_codebook_params>();
pParams->m_iter_index = i;
pParams->m_max_iter_index = cMaxEndpointRemapIters;
pParams->m_pTrial_color_endpoint_remap = &trial_color_endpoint_remaps[i];
m_task_pool.queue_object_task(this, &crn_comp::optimize_color_endpoint_codebook_task, 0, pParams);
}
m_task_pool.join();
for (uint i = 0; i <= cMaxEndpointRemapIters; i++)
{
if (!update_progress(20, i, cMaxEndpointRemapIters+1))
return false;
crnlib::vector<uint>& trial_color_endpoint_remap = trial_color_endpoint_remaps[i];
crnlib::vector<uint8> packed_data;
if (!pack_color_endpoints(packed_data, trial_color_endpoint_remap, m_endpoint_indices[cColor], i))
return false;
uint total_packed_chunk_bits;
if (!pack_chunks_simulation(0, m_total_chunks, total_packed_chunk_bits, &trial_color_endpoint_remap, NULL, NULL, NULL))
return false;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Pack chunks simulation: %u bits", total_packed_chunk_bits);
#endif
uint total_bits = packed_data.size() * 8 + total_packed_chunk_bits;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total bits: %u", total_bits);
#endif
if (total_bits < best_bits)
{
m_packed_color_endpoints.swap(packed_data);
remapping.swap(trial_color_endpoint_remap);
best_bits = total_bits;
}
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("End optimization of color endpoint codebook");
#endif
return true;
}
struct optimize_color_selector_codebook_params
{
crnlib::vector<uint>* m_pTrial_color_selector_remap;
uint m_iter_index;
uint m_max_iter_index;
};
void crn_comp::optimize_color_selector_codebook_task(uint64 data, void* pData_ptr)
{
data;
optimize_color_selector_codebook_params* pParams = reinterpret_cast<optimize_color_selector_codebook_params*>(pData_ptr);
if (pParams->m_iter_index == pParams->m_max_iter_index)
{
sort_selector_codebook(*pParams->m_pTrial_color_selector_remap, m_hvq.get_color_selectors_vec(), g_dxt1_to_linear);
}
else
{
float f = pParams->m_iter_index / static_cast<float>(pParams->m_max_iter_index - 1);
create_zeng_reorder_table(
m_hvq.get_color_selector_codebook_size(),
m_selector_indices[cColor].size(),
&m_selector_indices[cColor][0],
*pParams->m_pTrial_color_selector_remap,
pParams->m_iter_index ? color_selector_similarity_func : NULL,
(void*)&m_hvq.get_color_selectors_vec(),
f);
}
crnlib_delete(pParams);
}
bool crn_comp::optimize_color_selector_codebook(crnlib::vector<uint>& remapping)
{
if (m_pParams->m_flags & cCRNCompFlagQuick)
{
remapping.resize(m_hvq.get_color_selectors_vec().size());
for (uint i = 0; i < m_hvq.get_color_selectors_vec().size(); i++)
remapping[i] = i;
if (!pack_selectors(
m_packed_color_selectors,
m_selector_indices[cColor],
m_hvq.get_color_selectors_vec(),
remapping,
3,
g_dxt1_to_linear, 0))
{
return false;
}
return true;
}
const uint cMaxSelectorRemapIters = 3;
uint best_bits = UINT_MAX;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("----- Begin optimization of color selector codebook");
#endif
crnlib::vector<uint> trial_color_selector_remaps[cMaxSelectorRemapIters + 1];
for (uint i = 0; i <= cMaxSelectorRemapIters; i++)
{
optimize_color_selector_codebook_params* pParams = crnlib_new<optimize_color_selector_codebook_params>();
pParams->m_iter_index = i;
pParams->m_max_iter_index = cMaxSelectorRemapIters;
pParams->m_pTrial_color_selector_remap = &trial_color_selector_remaps[i];
m_task_pool.queue_object_task(this, &crn_comp::optimize_color_selector_codebook_task, 0, pParams);
}
m_task_pool.join();
for (uint i = 0; i <= cMaxSelectorRemapIters; i++)
{
if (!update_progress(21, i, cMaxSelectorRemapIters+1))
return false;
crnlib::vector<uint>& trial_color_selector_remap = trial_color_selector_remaps[i];
crnlib::vector<uint8> packed_data;
if (!pack_selectors(
packed_data,
m_selector_indices[cColor],
m_hvq.get_color_selectors_vec(),
trial_color_selector_remap,
3,
g_dxt1_to_linear, i))
{
return false;
}
uint total_packed_chunk_bits;
if (!pack_chunks_simulation(0, m_total_chunks, total_packed_chunk_bits, NULL, &trial_color_selector_remap, NULL, NULL))
return false;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Pack chunks simulation: %u bits", total_packed_chunk_bits);
#endif
uint total_bits = packed_data.size() * 8 + total_packed_chunk_bits;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total bits: %u", total_bits);
#endif
if (total_bits < best_bits)
{
m_packed_color_selectors.swap(packed_data);
remapping.swap(trial_color_selector_remap);
best_bits = total_bits;
}
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("End optimization of color selector codebook");
#endif
return true;
}
struct optimize_alpha_endpoint_codebook_params
{
crnlib::vector<uint>* m_pAlpha_indices;
crnlib::vector<uint>* m_pTrial_alpha_endpoint_remap;
uint m_iter_index;
uint m_max_iter_index;
};
void crn_comp::optimize_alpha_endpoint_codebook_task(uint64 data, void* pData_ptr)
{
data;
optimize_alpha_endpoint_codebook_params* pParams = reinterpret_cast<optimize_alpha_endpoint_codebook_params*>(pData_ptr);
if (pParams->m_iter_index == pParams->m_max_iter_index)
{
sort_alpha_endpoint_codebook(*pParams->m_pTrial_alpha_endpoint_remap, m_hvq.get_alpha_endpoint_vec());
}
else
{
float f = pParams->m_iter_index / static_cast<float>(pParams->m_max_iter_index - 1);
create_zeng_reorder_table(
m_hvq.get_alpha_endpoint_codebook_size(),
pParams->m_pAlpha_indices->size(),
&(*pParams->m_pAlpha_indices)[0],
*pParams->m_pTrial_alpha_endpoint_remap,
pParams->m_iter_index ? alpha_endpoint_similarity_func : NULL,
&m_hvq,
f);
}
crnlib_delete(pParams);
}
bool crn_comp::optimize_alpha_endpoint_codebook(crnlib::vector<uint>& remapping)
{
crnlib::vector<uint> alpha_indices;
alpha_indices.reserve(m_endpoint_indices[cAlpha0].size() + m_endpoint_indices[cAlpha1].size());
for (uint i = 0; i < m_endpoint_indices[cAlpha0].size(); i++)
alpha_indices.push_back(m_endpoint_indices[cAlpha0][i]);
for (uint i = 0; i < m_endpoint_indices[cAlpha1].size(); i++)
alpha_indices.push_back(m_endpoint_indices[cAlpha1][i]);
if (m_pParams->m_flags & cCRNCompFlagQuick)
{
remapping.resize(m_hvq.get_alpha_endpoint_vec().size());
for (uint i = 0; i < m_hvq.get_alpha_endpoint_vec().size(); i++)
remapping[i] = i;
if (!pack_alpha_endpoints(m_packed_alpha_endpoints, remapping, alpha_indices, 0))
return false;
return true;
}
const uint cMaxEndpointRemapIters = 3;
uint best_bits = UINT_MAX;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("----- Begin optimization of alpha endpoint codebook");
#endif
crnlib::vector<uint> trial_alpha_endpoint_remaps[cMaxEndpointRemapIters + 1];
for (uint i = 0; i <= cMaxEndpointRemapIters; i++)
{
optimize_alpha_endpoint_codebook_params* pParams = crnlib_new<optimize_alpha_endpoint_codebook_params>();
pParams->m_pAlpha_indices = &alpha_indices;
pParams->m_iter_index = i;
pParams->m_max_iter_index = cMaxEndpointRemapIters;
pParams->m_pTrial_alpha_endpoint_remap = &trial_alpha_endpoint_remaps[i];
m_task_pool.queue_object_task(this, &crn_comp::optimize_alpha_endpoint_codebook_task, 0, pParams);
}
m_task_pool.join();
for (uint i = 0; i <= cMaxEndpointRemapIters; i++)
{
if (!update_progress(22, i, cMaxEndpointRemapIters+1))
return false;
crnlib::vector<uint>& trial_alpha_endpoint_remap = trial_alpha_endpoint_remaps[i];
crnlib::vector<uint8> packed_data;
if (!pack_alpha_endpoints(packed_data, trial_alpha_endpoint_remap, alpha_indices, i))
return false;
uint total_packed_chunk_bits;
if (!pack_chunks_simulation(0, m_total_chunks, total_packed_chunk_bits, NULL, NULL, &trial_alpha_endpoint_remap, NULL))
return false;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Pack chunks simulation: %u bits", total_packed_chunk_bits);
#endif
uint total_bits = packed_data.size() * 8 + total_packed_chunk_bits;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total bits: %u", total_bits);
#endif
if (total_bits < best_bits)
{
m_packed_alpha_endpoints.swap(packed_data);
remapping.swap(trial_alpha_endpoint_remap);
best_bits = total_bits;
}
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("End optimization of alpha endpoint codebook");
#endif
return true;
}
struct optimize_alpha_selector_codebook_params
{
crnlib::vector<uint>* m_pAlpha_indices;
crnlib::vector<uint>* m_pTrial_alpha_selector_remap;
uint m_iter_index;
uint m_max_iter_index;
};
void crn_comp::optimize_alpha_selector_codebook_task(uint64 data, void* pData_ptr)
{
data;
optimize_alpha_selector_codebook_params* pParams = reinterpret_cast<optimize_alpha_selector_codebook_params*>(pData_ptr);
if (pParams->m_iter_index == pParams->m_max_iter_index)
{
sort_selector_codebook(*pParams->m_pTrial_alpha_selector_remap, m_hvq.get_alpha_selectors_vec(), g_dxt5_to_linear);
}
else
{
float f = pParams->m_iter_index / static_cast<float>(pParams->m_max_iter_index - 1);
create_zeng_reorder_table(
m_hvq.get_alpha_selector_codebook_size(),
pParams->m_pAlpha_indices->size(),
&(*pParams->m_pAlpha_indices)[0],
*pParams->m_pTrial_alpha_selector_remap,
pParams->m_iter_index ? alpha_selector_similarity_func : NULL,
(void*)&m_hvq.get_alpha_selectors_vec(),
f);
}
}
bool crn_comp::optimize_alpha_selector_codebook(crnlib::vector<uint>& remapping)
{
crnlib::vector<uint> alpha_indices;
alpha_indices.reserve(m_selector_indices[cAlpha0].size() + m_selector_indices[cAlpha1].size());
for (uint i = 0; i < m_selector_indices[cAlpha0].size(); i++)
alpha_indices.push_back(m_selector_indices[cAlpha0][i]);
for (uint i = 0; i < m_selector_indices[cAlpha1].size(); i++)
alpha_indices.push_back(m_selector_indices[cAlpha1][i]);
if (m_pParams->m_flags & cCRNCompFlagQuick)
{
remapping.resize(m_hvq.get_alpha_selectors_vec().size());
for (uint i = 0; i < m_hvq.get_alpha_selectors_vec().size(); i++)
remapping[i] = i;
if (!pack_selectors(
m_packed_alpha_selectors,
alpha_indices,
m_hvq.get_alpha_selectors_vec(),
remapping,
7,
g_dxt5_to_linear, 0))
{
return false;
}
return true;
}
const uint cMaxSelectorRemapIters = 3;
uint best_bits = UINT_MAX;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("----- Begin optimization of alpha selector codebook");
#endif
crnlib::vector<uint> trial_alpha_selector_remaps[cMaxSelectorRemapIters + 1];
for (uint i = 0; i <= cMaxSelectorRemapIters; i++)
{
optimize_alpha_selector_codebook_params* pParams = crnlib_new<optimize_alpha_selector_codebook_params>();
pParams->m_pAlpha_indices = &alpha_indices;
pParams->m_iter_index = i;
pParams->m_max_iter_index = cMaxSelectorRemapIters;
pParams->m_pTrial_alpha_selector_remap = &trial_alpha_selector_remaps[i];
m_task_pool.queue_object_task(this, &crn_comp::optimize_alpha_selector_codebook_task, 0, pParams);
}
m_task_pool.join();
for (uint i = 0; i <= cMaxSelectorRemapIters; i++)
{
if (!update_progress(23, i, cMaxSelectorRemapIters+1))
return false;
crnlib::vector<uint>& trial_alpha_selector_remap = trial_alpha_selector_remaps[i];
crnlib::vector<uint8> packed_data;
if (!pack_selectors(
packed_data,
alpha_indices,
m_hvq.get_alpha_selectors_vec(),
trial_alpha_selector_remap,
7,
g_dxt5_to_linear, i))
{
return false;
}
uint total_packed_chunk_bits;
if (!pack_chunks_simulation(0, m_total_chunks, total_packed_chunk_bits, NULL, NULL, NULL, &trial_alpha_selector_remap))
return false;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Pack chunks simulation: %u bits", total_packed_chunk_bits);
#endif
uint total_bits = packed_data.size() * 8 + total_packed_chunk_bits;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("Total bits: %u", total_bits);
#endif
if (total_bits < best_bits)
{
m_packed_alpha_selectors.swap(packed_data);
remapping.swap(trial_alpha_selector_remap);
best_bits = total_bits;
}
}
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
console::debug("End optimization of alpha selector codebook");
#endif
return true;
}
bool crn_comp::pack_data_models()
{
symbol_codec codec;
codec.start_encoding(1024*1024);
if (!codec.encode_transmit_static_huffman_data_model(m_chunk_encoding_dm, false))
return false;
for (uint i = 0; i < 2; i++)
{
if (m_endpoint_index_dm[i].get_total_syms())
{
if (!codec.encode_transmit_static_huffman_data_model(m_endpoint_index_dm[i], false))
return false;
}
if (m_selector_index_dm[i].get_total_syms())
{
if (!codec.encode_transmit_static_huffman_data_model(m_selector_index_dm[i], false))
return false;
}
}
codec.stop_encoding(false);
m_packed_data_models.swap(codec.get_encoding_buf());
return true;
}
bool crn_comp::create_comp_data()
{
utils::zero_object(m_crn_header);
m_crn_header.m_width = static_cast<uint16>(m_pParams->m_width);
m_crn_header.m_height = static_cast<uint16>(m_pParams->m_height);
m_crn_header.m_levels = static_cast<uint8>(m_pParams->m_levels);
m_crn_header.m_faces = static_cast<uint8>(m_pParams->m_faces);
m_crn_header.m_format = static_cast<uint8>(m_pParams->m_format);
m_crn_header.m_userdata0 = m_pParams->m_userdata0;
m_crn_header.m_userdata1 = m_pParams->m_userdata1;
m_comp_data.clear();
m_comp_data.reserve(2*1024*1024);
append_vec(m_comp_data, &m_crn_header, sizeof(m_crn_header));
// tack on the rest of the variable size m_level_ofs array
m_comp_data.resize( m_comp_data.size() + sizeof(m_crn_header.m_level_ofs[0]) * (m_pParams->m_levels - 1) );
if (m_packed_color_endpoints.size())
{
m_crn_header.m_color_endpoints.m_num = static_cast<uint16>(m_hvq.get_color_endpoint_codebook_size());
m_crn_header.m_color_endpoints.m_size = m_packed_color_endpoints.size();
m_crn_header.m_color_endpoints.m_ofs = m_comp_data.size();
append_vec(m_comp_data, m_packed_color_endpoints);
}
if (m_packed_color_selectors.size())
{
m_crn_header.m_color_selectors.m_num = static_cast<uint16>(m_hvq.get_color_selector_codebook_size());
m_crn_header.m_color_selectors.m_size = m_packed_color_selectors.size();
m_crn_header.m_color_selectors.m_ofs = m_comp_data.size();
append_vec(m_comp_data, m_packed_color_selectors);
}
if (m_packed_alpha_endpoints.size())
{
m_crn_header.m_alpha_endpoints.m_num = static_cast<uint16>(m_hvq.get_alpha_endpoint_codebook_size());
m_crn_header.m_alpha_endpoints.m_size = m_packed_alpha_endpoints.size();
m_crn_header.m_alpha_endpoints.m_ofs = m_comp_data.size();
append_vec(m_comp_data, m_packed_alpha_endpoints);
}
if (m_packed_alpha_selectors.size())
{
m_crn_header.m_alpha_selectors.m_num = static_cast<uint16>(m_hvq.get_alpha_selector_codebook_size());
m_crn_header.m_alpha_selectors.m_size = m_packed_alpha_selectors.size();
m_crn_header.m_alpha_selectors.m_ofs = m_comp_data.size();
append_vec(m_comp_data, m_packed_alpha_selectors);
}
m_crn_header.m_tables_ofs = m_comp_data.size();
m_crn_header.m_tables_size = m_packed_data_models.size();
append_vec(m_comp_data, m_packed_data_models);
uint level_ofs[cCRNMaxLevels];
for (uint i = 0; i < m_mip_groups.size(); i++)
{
level_ofs[i] = m_comp_data.size();
append_vec(m_comp_data, m_packed_chunks[i]);
}
crnd::crn_header& dst_header = *(crnd::crn_header*)&m_comp_data[0];
// don't change the m_comp_data vector - or dst_header will be invalidated!
memcpy(&dst_header, &m_crn_header, sizeof(dst_header));
for (uint i = 0; i < m_mip_groups.size(); i++)
dst_header.m_level_ofs[i] = level_ofs[i];
const uint actual_header_size = sizeof(crnd::crn_header) + sizeof(dst_header.m_level_ofs[0]) * (m_mip_groups.size() - 1);
dst_header.m_sig = crnd::crn_header::cCRNSigValue;
dst_header.m_data_size = m_comp_data.size();
dst_header.m_data_crc16 = crc16(&m_comp_data[actual_header_size], m_comp_data.size() - actual_header_size);
dst_header.m_header_size = actual_header_size;
dst_header.m_header_crc16 = crc16(&dst_header.m_data_size, actual_header_size - (uint)((uint8*)&dst_header.m_data_size - (uint8*)&dst_header));
return true;
}
bool crn_comp::update_progress(uint phase_index, uint subphase_index, uint subphase_total)
{
if (!m_pParams->m_pProgress_func)
return true;
#if CRNLIB_ENABLE_DEBUG_MESSAGES
if (m_pParams->m_flags & cCRNCompFlagDebugging)
return true;
#endif
return (*m_pParams->m_pProgress_func)(phase_index, cTotalCompressionPhases, subphase_index, subphase_total, m_pParams->m_pProgress_func_data) != 0;
}
bool crn_comp::compress_internal()
{
if (!alias_images())
return false;
create_chunks();
if (!quantize_chunks())
return false;
create_chunk_indices();
crnlib::vector<uint> endpoint_remap[2];
crnlib::vector<uint> selector_remap[2];
if (m_has_comp[cColor])
{
if (!optimize_color_endpoint_codebook(endpoint_remap[0]))
return false;
if (!optimize_color_selector_codebook(selector_remap[0]))
return false;
}
if (m_has_comp[cAlpha0])
{
if (!optimize_alpha_endpoint_codebook(endpoint_remap[1]))
return false;
if (!optimize_alpha_selector_codebook(selector_remap[1]))
return false;
}
m_chunk_encoding_hist.clear();
for (uint i = 0; i < 2; i++)
{
m_endpoint_index_hist[i].clear();
m_endpoint_index_dm[i].clear();
m_selector_index_hist[i].clear();
m_selector_index_dm[i].clear();
}
for (uint pass = 0; pass < 2; pass++)
{
for (uint mip_group = 0; mip_group < m_mip_groups.size(); mip_group++)
{
symbol_codec codec;
codec.start_encoding(2*1024*1024);
if (!pack_chunks(
m_mip_groups[mip_group].m_first_chunk, m_mip_groups[mip_group].m_num_chunks,
!pass && !mip_group, pass ? &codec : NULL,
m_has_comp[cColor] ? &endpoint_remap[0] : NULL, m_has_comp[cColor] ? &selector_remap[0] : NULL,
m_has_comp[cAlpha0] ? &endpoint_remap[1] : NULL, m_has_comp[cAlpha0] ? &selector_remap[1] : NULL))
{
return false;
}
codec.stop_encoding(false);
if (pass)
m_packed_chunks[mip_group].swap(codec.get_encoding_buf());
}
if (!pass)
{
m_chunk_encoding_dm.init(true, m_chunk_encoding_hist, 16);
for (uint i = 0; i < 2; i++)
{
if (m_endpoint_index_hist[i].size())
m_endpoint_index_dm[i].init(true, m_endpoint_index_hist[i], 16);
if (m_selector_index_hist[i].size())
m_selector_index_dm[i].init(true, m_selector_index_hist[i], 16);
}
}
}
if (!pack_data_models())
return false;
if (!create_comp_data())
return false;
if (!update_progress(24, 1, 1))
return false;
if (m_pParams->m_flags & cCRNCompFlagDebugging)
{
crnlib_print_mem_stats();
}
return true;
}
bool crn_comp::compress_init(const crn_comp_params& params)
{
params;
return true;
}
bool crn_comp::compress_pass(const crn_comp_params& params, float *pEffective_bitrate)
{
clear();
if (pEffective_bitrate) *pEffective_bitrate = 0.0f;
m_pParams = ¶ms;
if ((math::minimum(m_pParams->m_width, m_pParams->m_height) < 1) || (math::maximum(m_pParams->m_width, m_pParams->m_height) > cCRNMaxLevelResolution))
return false;
if (!m_task_pool.init(params.m_num_helper_threads))
return false;
bool status = compress_internal();
m_task_pool.deinit();
if ((status) && (pEffective_bitrate))
{
uint total_pixels = 0;
for (uint f = 0; f < m_pParams->m_faces; f++)
for (uint l = 0; l < m_pParams->m_levels; l++)
total_pixels += m_images[f][l].get_total_pixels();
*pEffective_bitrate = (m_comp_data.size() * 8.0f) / total_pixels;
}
return status;
}
void crn_comp::compress_deinit()
{
}
} // namespace crnlib
| 34.861404 | 254 | 0.606874 | Wizermil |
64ac45c288b314da154353a0f7330e5ea04fd07e | 705 | cpp | C++ | apps/demo/DemoWidget.cpp | Rix565/skiftos-dailybuild | ef3abf0dda028b6d7b3e658946a031b1a1ba44c9 | [
"MIT"
] | 2 | 2020-10-07T14:17:15.000Z | 2021-05-09T20:35:35.000Z | apps/demo/DemoWidget.cpp | Rix565/skiftos-dailybuild | ef3abf0dda028b6d7b3e658946a031b1a1ba44c9 | [
"MIT"
] | null | null | null | apps/demo/DemoWidget.cpp | Rix565/skiftos-dailybuild | ef3abf0dda028b6d7b3e658946a031b1a1ba44c9 | [
"MIT"
] | null | null | null | #include <libsystem/eventloop/Timer.h>
#include <libwidget/Application.h>
#include "demo/DemoWidget.h"
void demo_widget_on_timer_tick(DemoWidget *widget)
{
widget->tick();
widget->should_repaint();
}
DemoWidget::DemoWidget(Widget *parent)
: Widget(parent)
{
_demo = nullptr;
_timer = own<Timer>(1000 / 60, [this]() {
tick();
should_repaint();
});
_timer->start();
}
void DemoWidget::paint(Painter &painter, const Recti &)
{
if (_demo)
{
_demo->callback(painter, bound(), _time);
}
painter.draw_string(*font(), _demo->name, Vec2i(9, 17), Colors::BLACK);
painter.draw_string(*font(), _demo->name, Vec2i(8, 16), Colors::WHITE);
}
| 20.735294 | 75 | 0.631206 | Rix565 |
64b183354e28288c28d848e6eede8233df72e8c7 | 2,649 | cpp | C++ | src/TSWXKernel.cpp | pavanad/language-tools | e431f547161583b17046aa2952bd0bd435842155 | [
"MIT"
] | 3 | 2018-08-16T20:15:42.000Z | 2021-06-13T06:47:06.000Z | src/TSWXKernel.cpp | pavanad/language-tools | e431f547161583b17046aa2952bd0bd435842155 | [
"MIT"
] | null | null | null | src/TSWXKernel.cpp | pavanad/language-tools | e431f547161583b17046aa2952bd0bd435842155 | [
"MIT"
] | 2 | 2018-07-24T19:13:29.000Z | 2019-04-06T17:36:18.000Z | //---------------------------------------------------------------------------
#pragma hdrstop
#include "TSWXKernel.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
TSWXKernel::TSWXKernel(TSWXMainDT * data, TAnalysis * analysis)
{
m_data = data;
m_analysis = analysis;
this->Compute();
}
//---------------------------------------------------------------------------
void TSWXKernel::Compute()
{
int nodes=0, files;
const int max = 200;
char buff[max];
char arq[max];
UnicodeString value,temp1, temp2, object;
std::vector<UnicodeString> list;
std::vector< std::vector<UnicodeString> > result (3);
//recebe os dados do data tranfer
list = m_data->GetData();
//habilita o progress bar
m_analysis->m_progress->Visible = true;
//conta os arquivos selecionados
files = list.size();
//percorre o vector e abre os arquivos
for(int i = 0; i < files; i++)
{
ifstream arquivo;
arquivo.open(list[i].c_str());
while(arquivo)
{
arquivo.getline(buff,max);
line = buff;
object = this->GetObject();
value = this->GetValue();
if (!object.IsEmpty()) {
temp1 = object;
}
if (!value.IsEmpty()) {
temp2 = value;
}
if (!temp1.IsEmpty() && !temp2.IsEmpty()){
nodes++;
result[0].push_back(nodes);
result[1].push_back(temp1);
result[2].push_back(temp2);
temp1 = "";
temp2 = "";
}
object = NULL;
value = NULL;
}
arquivo.close();
delete arquivo;
m_analysis->m_progress->Position = (i+1)*(100/files);
m_analysis->Update();
}
m_ResultsData = new TSWXResultsDT();
m_ResultsData->SetData(files,nodes,result);
m_analysis->SetData(m_ResultsData);
m_analysis->m_progress->Position = 0;
m_analysis->m_progress->Visible = false;
}
//------------------------------------------------------------------------------
UnicodeString TSWXKernel::GetObject()
{
int start, qtd;
for(int j = 0; j < line.Length(); j++)
{
if (line.SubString(j,6)=="object")
{
start = (j+6)+1;
}
if (line.SubString(j,1)==":")
{
qtd = j - start;
return line.SubString(start,qtd);
}
}
}
//------------------------------------------------------------------------------
UnicodeString TSWXKernel::GetValue()
{
int start, qtd;
for(int j = 0; j < line.Length(); j++)
{
if (line.SubString(j,7)=="Caption")
{
start = (j+7)+4;
}
}
qtd = line.Length() - start;
return line.SubString(start,qtd);
}
//------------------------------------------------------------------------------
| 22.075 | 81 | 0.489996 | pavanad |
64b236409d2b24202c4aa6c2c79cb9ade94f2552 | 40,253 | cxx | C++ | src/tamgutable.cxx | naver/tamgu | 9532edc82aa90f7610dbd98dc379e0631de4b252 | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | 192 | 2019-07-10T15:47:11.000Z | 2022-03-10T09:26:31.000Z | src/tamgutable.cxx | naver/tamgu | 9532edc82aa90f7610dbd98dc379e0631de4b252 | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | 5 | 2019-10-01T13:17:28.000Z | 2021-01-05T15:31:39.000Z | src/tamgutable.cxx | naver/tamgu | 9532edc82aa90f7610dbd98dc379e0631de4b252 | [
"BSD-3-Clause-Clear",
"BSD-3-Clause"
] | 14 | 2019-09-23T03:39:59.000Z | 2021-09-02T12:20:14.000Z | /*
* Tamgu (탐구)
*
* Copyright 2019-present NAVER Corp.
* under BSD 3-clause
*/
/* --- CONTENTS ---
Project : Tamgu (탐구)
Version : See tamgu.cxx for the version number
filename : tamgutable.cxx
Date : 2017/09/01
Purpose : vector implementation
Programmer : Claude ROUX (claude.roux@naverlabs.com)
Reviewer :
*/
#include "tamgu.h"
#include "tamgutaskell.h"
#include "tamgutable.h"
#include "tamguvector.h"
#include "tamguivector.h"
#include "tamgumap.h"
#include "tamgulist.h"
#include "instructions.h"
#include "constobjects.h"
#include "tamguuvector.h"
#include "tamgufvector.h"
#include "tamgubyte.h"
//We need to declare once again our local definitions.
Exporting basebin_hash<tableMethod> Tamgutable::methods;
Exporting hmap<string, string> Tamgutable::infomethods;
Exporting basebin_hash<unsigned long> Tamgutable::exported;
Exporting short Tamgutable::idtype = 0;
//MethodInitialization will add the right references to "name", which is always a new method associated to the object we are creating
void Tamgutable::AddMethod(TamguGlobal* global, string name, tableMethod func, unsigned long arity, string infos) {
short idname = global->Getid(name);
methods[idname] = func;
infomethods[name] = infos;
exported[idname] = arity;
}
void Tamgutable::Setidtype(TamguGlobal* global) {
Tamgutable::InitialisationModule(global,"");
}
bool Tamgutable::InitialisationModule(TamguGlobal* global, string version) {
methods.clear();
infomethods.clear();
exported.clear();
Tamgutable::idtype = global->Getid("table");
Tamgutable::AddMethod(global, "clear", &Tamgutable::MethodClear, P_NONE, "clear(): clear the container.");
Tamgutable::AddMethod(global, "flatten", &Tamgutable::MethodFlatten, P_NONE, "flatten(): flatten a table structure.");
Tamgutable::AddMethod(global, "remove", &Tamgutable::MethodRemove, P_ONE, "remove(e): remove 'e' from the table.");
Tamgutable::AddMethod(global, "reverse", &Tamgutable::MethodReverse, P_NONE, "reverse(): reverse a table.");
Tamgutable::AddMethod(global, "unique", &Tamgutable::MethodUnique, P_NONE, "unique(): remove duplicate elements.");
Tamgutable::AddMethod(global, "_initial", &Tamgutable::MethodReserve, P_ONE, "_initial(int sz): Reserve a size of 'sz' potential element in the table.");
Tamgutable::AddMethod(global, "reserve", &Tamgutable::MethodReserve, P_ONE, "reserve(int sz): Reserve a size of 'sz' potential element in the table.");
Tamgutable::AddMethod(global, "resize", &Tamgutable::MethodReserve, P_ONE, "resize(int sz): Resize a table.");
Tamgutable::AddMethod(global, "join", &Tamgutable::MethodJoin, P_ONE, "join(string sep): Produce a string representation for the container.");
Tamgutable::AddMethod(global, "shuffle", &Tamgutable::MethodShuffle, P_NONE, "shuffle(): shuffle the values in the table.");
Tamgutable::AddMethod(global, "last", &Tamgutable::MethodLast, P_NONE, "last(): return the last element.");
Tamgutable::AddMethod(global, "sum", &Tamgutable::MethodSum, P_NONE, "sum(): return the sum of elements.");
Tamgutable::AddMethod(global, "product", &Tamgutable::MethodProduct, P_NONE, "product(): return the product of elements.");
Tamgutable::AddMethod(global, "push", &Tamgutable::MethodPush, P_ATLEASTONE, "push(v): Push a value into the table.");
Tamgutable::AddMethod(global, "pop", &Tamgutable::MethodPop, P_NONE | P_ONE, "pop(i): Erase an element from the table");
Tamgutable::AddMethod(global, "poplast", &Tamgutable::MethodPoplast, P_NONE, "poplast(): remove and return the last element from the vector");
Tamgutable::AddMethod(global, "merge", &Tamgutable::MethodMerge, P_ONE, "merge(v): Merge v into the table.");
Tamgutable::AddMethod(global, "editdistance", &Tamgutable::MethodEditDistance, P_ONE, "editdistance(v): Compute the edit distance with table 'v'.");
Tamgutable::AddMethod(global, "insert", &Tamgutable::MethodInsert, P_TWO, "insert(int i,v): Insert v at position i.");
if (version != "") {
global->newInstance[Tamgutable::idtype] = new Tamgutable(global);
global->RecordMethods(Tamgutable::idtype, Tamgutable::exported);
}
return true;
}
Exporting TamguIteration* Tamgutable::Newiteration(bool direction) {
return new TamguIterationtable(this, direction);
}
Exporting void Tamgutable::Insert(long idx, Tamgu* ke) {
if (idx < 0 || (idx + 1) >= size) {
globalTamgu->Returnerror("table is full or wrong index", globalTamgu->GetThreadid());
return;
}
ke = ke->Atom();
ke->Addreference(investigate,reference+1);
if (values[idx] == aNOELEMENT) {
values[idx] = ke;
return;
}
for (long i = size - 1; i >= idx; i++) {
values[i].exchange(values[i - 1]);
}
values[idx] = ke;
if (idx >= position)
position = idx+1;
}
Exporting void Tamgutable::Cleanreference(short inc) {
Tamgu* e;
for (long i=0;i<size;i++) {
e = values[i];
e->Removecontainerreference(inc);
}
}
Exporting void Tamgutable::Setreference(short inc) {
locking();
reference += inc;
protect=false;
Tamgu* e;
for (long i = 0; i< size; i++) {
e = values[i];
e->Addreference(investigate,inc);
}
unlocking();
}
Exporting void Tamgutable::Setreference() {
locking();
++reference;
protect=false;
Tamgu* e;
for (long i = 0; i< size; i++) {
e = values[i];
e->Addreference(investigate,1);
}
unlocking();
}
static void resetTable(Tamgutable* kvect, short inc) {
kvect->reference -= inc;
if (kvect->size == 0)
return;
Tamgu* e;
for (int itx = 0; itx < kvect->size; itx++) {
e = kvect->values[itx];
e->Removereference(inc);
}
}
Exporting void Tamgutable::Resetreference(short inc) {
if ((reference + containerreference - inc) > 0)
resetTable(this, inc);
else {
resetTable(this, inc + 1 - protect);
if (!protect) {
if (idtracker != -1)
globalTamgu->RemoveFromTracker(idtracker);
delete this;
}
}
}
Exporting Tamgu* Tamgutable::in(Tamgu* context, Tamgu* a, short idthread) {
//Three cases along the container type...
//It is a Boolean, we expect false or true
//It is an integer, we expect a position in v
//It is a container, we are looking for all positions...
if (context->isVectorContainer()) {
Tamguivector* v = (Tamguivector*)Selectaivector(context);
Locking _lock(v);
for (size_t i = 0; i < size; i++) {
if (a->same(values[i]) == aTRUE)
v->values.push_back(i);
}
return v;
}
if (context->isNumber()) {
for (size_t i = 0; i < size; i++) {
if (a->same(values[i]) == aTRUE)
return globalTamgu->ProvideConstint(i);
}
return aMINUSONE;
}
for (size_t i = 0; i < size; i++) {
if (a->same(values[i]) == aTRUE)
return aTRUE;
}
return aFALSE;
}
Exporting Tamgu* Tamgutable::Push(Tamgu* a) {
if (push(a) == aNOELEMENT)
return globalTamgu->Returnerror("Could not push this value into the table", globalTamgu->GetThreadid());
return aTRUE;
}
Exporting Tamgu* Tamgutable::Push(TamguGlobal* g, Tamgu* a, short idhtread) {
if (push(a) == aNOELEMENT)
return globalTamgu->Returnerror("Could not push this value into the table", globalTamgu->GetThreadid());
return aTRUE;
}
Exporting Tamgu* Tamgutable::Pop(Tamgu* idx) {
if (!size)
return aFALSE;
BLONG v = idx->Integer();
if (v == -1) {
if (!position)
return aFALSE;
while (position > 0) {
idx = values[--position];
if (idx != aNOELEMENT) {
idx = values[position].exchange(aNOELEMENT);
break;
}
}
}
else {
if (v < 0 || v >= (BLONG)size)
return aFALSE;
idx = values[v].exchange(aNOELEMENT);
if (v == position - 1)
position--;
}
idx->Removereference(reference + 1);
return aTRUE;
}
Exporting Tamgu* Tamgutable::Poplast() {
if (!size)
return aFALSE;
Tamgu* idx;
if (position > 0)
idx = values[--position].exchange(aNOELEMENT);
else
return aFALSE;
idx->Removereference(reference);
idx->Protect();
return idx;
}
Exporting string Tamgutable::String() {
if (!lockingmark())
return("[...]");
string res;
int it;
res = "[";
bool beg = true;
string sx;
Tamgu* element;
for (it = 0; it < size; it++) {
element = values[it];
sx = element->StringToDisplay();
if (!element->isString() || element->isContainer()) {
if (sx == "")
sx = "''";
if (beg == false) {
if (sx[0] != '|')
res += ",";
}
res += sx;
}
else {
if (beg == false)
res += ",";
stringing(res, sx);
}
beg = false;
}
res += "]";
unlockingmark();
return res;
}
void Tamgutable::Setstring(string& res, short idthread) {
if (!lockingmark()) {
res = "[...]";
return;
}
int it;
res = "[";
bool beg = true;
string sx;
Tamgu* element;
for (it = 0; it < size; it++) {
element = values[it];
sx = element->StringToDisplay();
if (!element->isString() || element->isContainer()) {
if (sx == "")
sx = "''";
if (beg == false) {
if (sx[0] != '|')
res += ",";
}
res += sx;
}
else {
if (beg == false)
res += ",";
stringing(res, sx);
}
beg = false;
}
res += "]";
unlockingmark();
}
Exporting Tamgu* Tamgutable::Map(short idthread) {
if (!lockingmark())
return aNULL;
Tamgumap* kmap = globalTamgu->Providemap();
char ch[20];
for (int it = 0; it < size; it++) {
sprintf_s(ch, 20, "%d", it);
kmap->Push(ch, values[it]);
}
unlockingmark();
return kmap;
}
Exporting string Tamgutable::JSonString() {
if (!lockingmark())
return "";
string res;
int it;
res = "[";
bool beg = true;
string sx;
Tamgu* element;
for (it = 0; it < size; it++) {
element = values[it];
sx = element->JSonString();
if (!element->isString() || element->isContainer()) {
if (beg == false) {
if (sx[0] != '|')
res += ",";
}
}
else {
if (beg == false)
res += ",";
}
res += sx;
beg = false;
}
res += "]";
unlockingmark();
return res;
}
Exporting long Tamgutable::Integer() {
return size;
}
Exporting double Tamgutable::Float() {
return size;
}
Exporting BLONG Tamgutable::Long() {
return size;
}
Exporting bool Tamgutable::Boolean() {
if (!size)
return false;
return true;
}
//Basic operations
Exporting long Tamgutable::Size() {
return size;
}
Exporting Tamgu* Tamgutable::andset(Tamgu *b, bool itself) {
Tamgutable* ref;
long size = Size();
size_t it;
Tamgu* ke;
Tamgu* e;
if (!b->isContainer()) {
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->andset(b, true);
if (ke->isError()) {
ref->Release();
return ke;
}
}
return ref;
}
ref = new Tamgutable(b->Size());
Locking((TamguObject*)b);
TamguIteration* itr = b->Newiteration(false);
for (itr->Begin(); itr->End() == aFALSE; itr->Next()) {
for (it = 0; it < size; it++) {
ke = itr->IteratorValue();
e = values[it];
if (e->same(ke) == aTRUE) {
ref->Push(ke);
break;
}
}
}
itr->Release();
return ref;
}
Exporting Tamgu* Tamgutable::orset(Tamgu *b, bool itself) {
Tamgutable* ref;
long size = Size();
size_t it;
Tamgu* ke;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
Tamgu* e;
if (!b->isContainer()) {
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->orset(b, true);
if (ke->isError()) {
ref->Release();
return ke;
}
}
return ref;
}
ref->Merging(b);
return ref;
}
Exporting Tamgu* Tamgutable::xorset(Tamgu *b, bool itself) {
Tamgutable* ref;
long size = Size();
size_t it;
Tamgu* ke;
Tamgu* e;
if (!b->isContainer()) {
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->xorset(b, true);
if (ke->isError()) {
ref->Release();
return ke;
}
}
return ref;
}
ref = new Tamgutable(b->Size());
Locking((TamguObject*)b);
TamguIteration* itr = b->Newiteration(false);
bool found;
for (itr->Begin(); itr->End() == aFALSE; itr->Next()) {
found = false;
for (it = 0; it < size; it++) {
ke = itr->IteratorValue();
e = values[it];
if (e->same(ke) == aTRUE) {
found = true;
break;
}
}
if (!found) {
ke = itr->IteratorValue();
ref->Push(ke);
}
}
itr->Release();
return ref;
}
Exporting Tamgu* Tamgutable::plus(Tamgu* b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* ke;
Tamgu* kv;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->plus(kv, true);
if (ke->isError()) {
itr->Release();
ref->Release();
unlockingmark();
return ke;
}
itr->Next();
}
itr->Release();
unlockingmark();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->plus(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::minus(Tamgu *b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* ke;
Tamgu* kv;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->minus(kv, true);
if (ke->isError()) {
itr->Release();
ref->Release();
unlockingmark();
return ke;
}
itr->Next();
}
itr->Release();
unlockingmark();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->minus(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::multiply(Tamgu *b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* ke;
Tamgu* kv;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->multiply(kv, true);
if (ke->isError()) {
ref->Release();
itr->Release();
unlockingmark();
return ke;
}
itr->Next();
}
itr->Release();
unlockingmark();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->multiply(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::divide(Tamgu *b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* ke;
Tamgu* kv;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->divide(kv, true);
if (ke->isError()) {
ref->Release();
itr->Release();
unlockingmark();
return ke;
}
itr->Next();
}
itr->Release();
unlockingmark();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->divide(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::power(Tamgu *b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* ke;
Tamgu* kv;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->power(kv, true);
if (ke->isError()) {
ref->Release();
itr->Release();
unlockingmark();
return ke;
}
itr->Next();
}
itr->Release();
unlockingmark();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->power(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::shiftleft(Tamgu *b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* ke;
Tamgu* kv;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->shiftleft(kv, true);
if (ke->isError()) {
itr->Release();
ref->Release();
unlockingmark();
return ke;
}
itr->Next();
}
itr->Release();
unlockingmark();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->shiftleft(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::shiftright(Tamgu *b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* kv;
Tamgu* ke;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->shiftright(kv, true);
if (ke->isError()) {
itr->Release();
ref->Release();
unlockingmark();
return ke;
}
itr->Next();
}
itr->Release();
unlockingmark();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->shiftright(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::mod(Tamgu *b, bool itself) {
Tamgutable* ref;
if (itself)
ref = this;
else
ref = (Tamgutable*)Atom(true);
int it;
Tamgu* ke;
Tamgu* kv;
if (!lockingmark())
return aNULL;
Tamgu* e;
if (b->isContainer()) {
Locking _lock(b);
TamguIteration* itr = b->Newiteration(false);
itr->Begin();
for (it = 0; it < size; it++) {
if (itr->End() == aTRUE)
break;
kv = itr->IteratorValue();
e = ref->values[it];
ke = e->mod(kv, true);
if (ke->isError()) {
ref->Release();
itr->Release();
unlockingmark();
return ke;
}
itr->Next();
}
unlockingmark();
itr->Release();
return ref;
}
for (it = 0; it < size; it++) {
e = ref->values[it];
ke = e->mod(b, true);
if (ke->isError()) {
ref->Release();
unlockingmark();
return ke;
}
}
unlockingmark();
return ref;
}
Exporting Tamgu* Tamgutable::Put(Tamgu* idx, Tamgu* value, short idthread) {
if (!idx->isIndex()) {
if (value == this)
return aTRUE;
if (value == aNULL) {
Clear();
return aTRUE;
}
if (value->Type() == a_list) {
Tamgulist* kvect = (Tamgulist*)value;
Locking _lock(kvect);
//We copy all values from value to this
Clear();
Resize(value->Size());
{
for (auto& it : kvect->values)
Pushing(it);
}
return aTRUE;
}
if (value->isVectorContainer()) {
//We copy all values from value to this
Clear();
long sz = value->Size();
Resize(sz);
for (long it = 0; it < sz; it++)
Pushing(value->getvalue(it));
return aTRUE;
}
//We gather all the keys from the MAP
if (value->isMapContainer()) {
Locking _lock(value);
Clear();
Resize(value->Size());
TamguIteration* itr = value->Newiteration(false);
for (itr->Begin(); itr->End() == aFALSE; itr->Next()) {
if (!Pushing(itr->Key()))
break;
}
itr->Release();
return aTRUE;
}
value = value->Vector(idthread);
if (!value->isVectorContainer())
return globalTamgu->Returnerror("Cannot set this value", idthread);
long sz = value->Size();
Clear();
Resize(sz);
//We copy all values from ke to this
for (long it = 0; it < sz; ++it) {
if (!Pushing(value->getvalue(it))) {
value->Releasenonconst();
return globalTamgu->Returnerror("Maximum size of table reached", idthread);
}
}
value->Releasenonconst();
return aTRUE;
}
//In this specific case, we try to replace a bloc of values with a new bloc
if (idx->isInterval()) {
//First we remove the values...
long lkey = idx->Getinteger(idthread);
if (lkey < 0)
lkey = size + lkey;
long rkey = ((TamguIndex*)idx)->right->Getinteger(idthread);
if (rkey < 0)
rkey = size + rkey;
if (rkey < lkey || rkey >= size || lkey >= size) {
if (globalTamgu->erroronkey)
globalTamgu->Returnerror("Wrong index", idthread);
return aTRUE;
}
if (rkey != lkey)
rkey--;
Tamgu* krkey = aZERO;
while (rkey >= lkey) {
krkey = values[rkey].exchange(aNOELEMENT);
krkey->Removereference(reference + 1);
rkey--;
}
if (value->isVectorContainer()) {
for (long i = value->Size() - 1; i >= 0; i--) {
krkey = value->getvalue(i);
Insert(lkey, krkey);
}
return aTRUE;
}
if (value->isContainer()) {
TamguIteration* itr = value->Newiteration(false);
for (itr->Begin(); itr->End() == aFALSE; itr->Next()) {
krkey = itr->Value();
Insert(lkey, krkey);
}
itr->Release();
return aTRUE;
}
Insert(lkey, krkey);
return aTRUE;
}
long ikey = idx->Getinteger(idthread);
if (ikey >= size)
return globalTamgu->Returnerror("Table is full", idthread);
if (ikey < 0) {
ikey = size + ikey;
if (ikey < 0)
return globalTamgu->Returnerror("Cannot set this value", idthread);
}
value = value->Atom();
value->Addreference(investigate,reference+1);
Tamgu* e = values[ikey].exchange(value);
e->Removereference(reference + 1);
if (ikey >= position)
position = ikey+1;
return aTRUE;
}
Exporting Tamgu* Tamgutable::Eval(Tamgu* contextualpattern, Tamgu* idx, short idthread) {
if (!idx->isIndex()) {
Tamgu* ke;
//In this case, we copy the elements from the vector to the map, using the position as index
if (contextualpattern->isMapContainer()) {
Tamgu* map = Selectamap(contextualpattern);
size_t i = 0;
char ch[20];
for (int it = 0; it < size; it++) {
sprintf_s(ch, 20, "%ld", i);
ke = values[it];
map->Push(ch, ke);
i++;
}
return map;
}
if (contextualpattern->Type() == a_int || contextualpattern->Type() == a_float)
return globalTamgu->ProvideConstint(size);
return this;
}
Tamgu* key;
Tamgu* keyright = NULL;
TamguIndex* kind = (TamguIndex*)idx;
key = kind->left->Eval(aNULL, aNULL, idthread);
if (kind->interval == true)
keyright = kind->right->Eval(aNULL, aNULL, idthread);
long ikey;
Tamgu* e;
bool stringkey = false;
if (key->isString()) {
string sf = key->String();
stringkey = true;
bool found = false;
if (kind->signleft) {
for (ikey = size - 1; ikey >= 0; ikey--) {
e = values[ikey];
if (sf == e->String()) {
found = true;
break;
}
}
}
else {
for (ikey = 0; ikey < size; ikey++) {
e = values[ikey];
if (sf == e->String()) {
found = true;
break;
}
}
}
if (!found) {
if (globalTamgu->erroronkey)
return globalTamgu->Returnerror("Wrong index", idthread);
return aNOELEMENT;
}
}
else
ikey = key->Integer();
key->Release();
if (ikey < 0)
ikey = size + ikey;
if (ikey < 0 || ikey >= size) {
if (ikey != size || keyright == NULL) {
if (globalTamgu->erroronkey)
return globalTamgu->Returnerror("Wrong index", idthread);
return aNOELEMENT;
}
}
if (keyright == NULL)
return values[ikey];
Tamgutable* kvect;
long iright;
if (keyright->isString()) {
string sf = keyright->String();
bool found = false;
if (kind->signright) {
for (iright = size - 1; iright >= 0; iright--) {
e = values[iright];
if (sf == e->String()) {
found = true;
iright++;
break;
}
}
}
else {
for (iright = 0; iright < size; iright++) {
e = values[iright];
if (sf == e->String()) {
found = true;
iright++;
break;
}
}
}
if (!found) {
if (globalTamgu->erroronkey)
return globalTamgu->Returnerror("Wrong index", idthread);
return aNOELEMENT;
}
}
else {
if (keyright == aNULL)
iright = 0;
else {
iright = keyright->Integer();
if (stringkey && iright >= 0)
iright = ikey + iright + 1;
}
}
if (keyright != kind->right)
keyright->Release();
if (iright < 0 || keyright == aNULL) {
iright = size + iright;
if (iright<ikey) {
if (globalTamgu->erroronkey)
return globalTamgu->Returnerror("Wrong index", idthread);
return aNOELEMENT;
}
}
else {
if (iright>size) {
if (globalTamgu->erroronkey)
return globalTamgu->Returnerror("Wrong index", idthread);
return aNOELEMENT;
}
}
//In this case, we must create a new vector
kvect = new Tamgutable(size);
for (long i = ikey; i < iright; i++) {
e = values[i];
kvect->values[i] = e;
}
return kvect;
}
Exporting void Tamgutable::Shuffle() {
size_t sz = size;
size_t i, f;
long mx = sz;
Tamgu* v;
for (i = 0; i < sz; i++) {
f = localrandom(mx--);
if (mx != f) {
v = values[mx].exchange(values[f]);
values[f] = v;
}
}
}
Exporting Tamgu* Tamgutable::Unique() {
Tamgutable* kvect = new Tamgutable(size);
map<string, Tamgu*> inter;
string k;
Tamgu* e;
for (int i = 0; i < size; i++) {
e = values[i];
k = e->String();
try {
if (inter.at(k)->same(values[i])->Boolean() == false)
kvect->Push(values[i]);
}
catch(const std::out_of_range& oor) {
inter[k] = values[i];
kvect->Push(values[i]);
}
}
return kvect;
}
Exporting void Tamgutable::Clear() {
Tamgu* e;
for (int itx = 0; itx < size; itx++) {
e = values[itx].exchange(aNOELEMENT);
e->Removereference(reference + 1);
}
position = 0;
}
Exporting Tamgu* Tamgutable::Merging(Tamgu* ke) {
if (!ke->isContainer()) {
Push(ke);
return this;
}
if (ke->Size() == 0)
return this;
Locking _lock((TamguObject*)ke);
//Two cases:
if (ke->Type() == idtype) {
Tamgutable* kvect = (Tamgutable*)ke;
for (long i = 0; i < kvect->size; i++)
Push(kvect->values[i]);
return this;
}
TamguIteration* itr = ke->Newiteration(false);
for (itr->Begin(); itr->End() == aFALSE; itr->Next())
Push(itr->Value());
itr->Release();
return this;
}
Exporting Tamgu* Tamgutable::Combine(Tamgu* ke) {
if (ke->Size() == 0)
return this;
Tamguvector* vect = globalTamgu->Providevector();
long i;
Tamgu* val;
if (!ke->isContainer()) {
for (i=0; i< size ;i++) {
val=new Tamguvector;
val->Push(values[i]);
val->Push(ke);
vect->Push(val);
}
return vect;
}
Locking _lock(ke);
i = 0;
TamguIteration* itr = (TamguIteration*)ke->Newiteration(false);
for (itr->Begin(); itr->End() == aFALSE; itr->Next()) {
if (i == size) {
val=new Tamguvector;
val->Push(itr->IteratorValue());
vect->Push(val);
continue;
}
val=new Tamguvector;
val->Push(values[i]);
val->Push(itr->IteratorValue());
vect->Push(val);
i++;
}
itr->Release();
for (;i<size;i++) {
val=new Tamguvector;
val->Push(values[i]);
vect->Push(val);
}
return vect;
}
Exporting Tamgu* Tamgutable::same(Tamgu* a) {
if (a->Type() != idtype) {
if (a->isVectorContainer()) {
if (a->Size() != size)
return aFALSE;
Tamgu* v;
for (int i = 0; i < size; i++) {
v = a->getvalue(i);
if (!v->same(values[i])->Boolean()) {
v->Release();
return aFALSE;
}
v->Release();
}
return aTRUE;
}
return aFALSE;
}
Tamgutable* v = (Tamgutable*)a;
if (size != v->size)
return aFALSE;
Tamgu* e;
for (int i = 0; i < size; i++) {
e = values[i];
if (e->same(v->values[i]) == aFALSE)
return aFALSE;
}
return aTRUE;
}
Exporting unsigned long Tamgutable::EditDistance(Tamgu* e) {
unsigned long s1len, s2len, x, y, lastdiag, olddiag;
s1len = Size();
s2len = e->Size();
Tamgu** v1 = new Tamgu*[s1len + 1];
Tamgu** v2 = new Tamgu*[s2len + 1];
y = maxlocal(s1len, s2len);
for (x = 0; x < y; x++) {
if (x < s1len)
v1[x] = getvalue(x);
if (x < s2len)
v2[x] = e->getvalue(x);
}
size_t* column = new size_t[s1len + 1];
for (y = 1; y <= s1len; y++)
column[y] = y;
unsigned long ed;
for (x = 1; x <= s2len; x++) {
column[0] = x;
for (y = 1, lastdiag = x - 1; y <= s1len; y++) {
olddiag = column[y];
ed = v1[y - 1]->EditDistance(v2[x - 1]);
column[y] = MIN3(column[y] + 1, column[y - 1] + 1, lastdiag + ed);
lastdiag = olddiag;
}
}
y = maxlocal(s1len, s2len);
for (x = 0; x < y; x++) {
if (x < s1len)
v1[x]->Release();
if (x < s2len)
v2[x]->Release();
}
delete[] v1;
delete[] v2;
s2len = column[s1len];
delete[] column;
return s2len;
}
//---------------------------------------------------------------------------------------
Exporting Tamgu* Tamgutable::Looptaskell(Tamgu* recipient, Tamgu* context, Tamgu* environment, TamguFunctionLambda* bd, short idthread) {
Tamgu* a;
uchar addvalue = 0;
if (context != aNOELEMENT)
addvalue = Selecttype(context);
for (size_t i = 0; i < size; i++) {
if (values[i] == aNOELEMENT)
continue;
recipient->Putvalue(values[i], idthread);
a = bd->DirectEval(environment, aNULL, idthread);
if (a->isNULL())
continue;
if (globalTamgu->Error(idthread) || a->needInvestigate()) {
if (a == aBREAK)
break;
recipient->Forcedclean();
a->Release();
context->Release();
return globalTamgu->Errorobject(idthread);
}
context = Storealongtype(context, a, idthread, addvalue);
a->Release();
}
recipient->Forcedclean();
return context;
}
Exporting Tamgu* Tamgutable::Filter(short idthread, Tamgu* env, TamguFunctionLambda* bd, Tamgu* var, Tamgu* kcont, Tamgu* accu, Tamgu* init, bool direct) {
Tamgu* returnval;
bool first = false;
Tamgu* key;
if (init != aNOELEMENT) {
accu->Putvalue(init, idthread);
if (kcont != NULL) {
if (direct)
kcont->Insert(0, init);
else
kcont->Push(init);
}
}
else
first = true; //we are dealing with a foldr1 or a foldl1
for (size_t i = 0; i < size; i++) {
key = values[i];
if (key == aNOELEMENT)
continue;
if (first) {
returnval = key->Atom();//We use the first value of the list to seed our accumulator variable
first = false;
}
else {
var->Putvalue(key, idthread);
returnval = bd->DirectEval(env, aNULL, idthread);
if (returnval == aBREAK) {
accu = returnval;
break;
}
if (globalTamgu->Error(idthread)) {
var->Forcedclean();
if (kcont != NULL)
kcont->Release();
return globalTamgu->Errorobject(idthread);
}
}
if (returnval != aNULL) {
accu->Putvalue(returnval, idthread);
if (kcont != NULL) {
if (direct)
kcont->Insert(0, returnval);
else
kcont->Push(returnval);
}
returnval->Release();
}
}
var->Forcedclean();
if (kcont != NULL)
return kcont;
return accu->Value();
}
//----------------------------------------------------------------------------------
Exporting void Tamgutable::Storevalue(string& u) {
Tamgu* a = globalTamgu->Providewithstring(u);
push(a);
}
Exporting void Tamgutable::Storevalue(wstring& u) {
Tamgu* a = globalTamgu->Providewithustring(u);
push(a);
}
Exporting void Tamgutable::storevalue(string u) {
Tamgu* a = globalTamgu->Providewithstring(u);
push(a);
}
Exporting void Tamgutable::storevalue(wstring u) {
Tamgu* a = globalTamgu->Providewithustring(u);
push(a);
}
Exporting void Tamgutable::storevalue(long u) {
Tamgu* a = globalTamgu->ProvideConstint(u);
push(a);
}
Exporting void Tamgutable::storevalue(short u) {
Tamgu* a = new Tamgushort(u);
push(a);
}
Exporting void Tamgutable::storevalue(BLONG u) {
Tamgu* a = globalTamgu->Providelong(u);
push(a);
}
Exporting void Tamgutable::storevalue(float u) {
Tamgu* a = new Tamgudecimal(u);
push(a);
}
Exporting void Tamgutable::storevalue(double u) {
Tamgu* a = globalTamgu->Providefloat(u);
push(a);
}
Exporting void Tamgutable::storevalue(unsigned char u) {
Tamgu* a = new Tamgubyte(u);
push(a);
}
Exporting void Tamgutable::storevalue(wchar_t u) {
wstring w;
w = u;
Tamgu* a = globalTamgu->Providewithustring(w);
push(a);
}
| 24.649724 | 157 | 0.489603 | naver |
64b9802d6088f22721eb36a90d0fc693e318718a | 10,219 | cpp | C++ | code/wxWidgets/src/mac/carbon/dcclient.cpp | Bloodknight/NeuTorsion | a5890e9ca145a8c1b6bec7b70047a43d9b1c29ea | [
"MIT"
] | 38 | 2016-02-20T02:46:28.000Z | 2021-11-17T11:39:57.000Z | code/wxWidgets/src/mac/carbon/dcclient.cpp | Dwarf-King/TorsionEditor | e6887d1661ebaf4ccbf1d09f2690e2bf805fbb50 | [
"MIT"
] | 17 | 2016-02-20T02:19:55.000Z | 2021-02-08T15:15:17.000Z | code/wxWidgets/src/mac/carbon/dcclient.cpp | Dwarf-King/TorsionEditor | e6887d1661ebaf4ccbf1d09f2690e2bf805fbb50 | [
"MIT"
] | 46 | 2016-02-20T02:47:33.000Z | 2021-01-31T15:46:05.000Z | /////////////////////////////////////////////////////////////////////////////
// Name: dcclient.cpp
// Purpose: wxClientDC class
// Author: Stefan Csomor
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: dcclient.cpp,v 1.38 2005/05/10 06:28:21 SC Exp $
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dcclient.h"
#endif
#include "wx/wxprec.h"
#include "wx/dcclient.h"
#include "wx/dcmemory.h"
#include "wx/region.h"
#include "wx/window.h"
#include "wx/toplevel.h"
#include "wx/settings.h"
#include "wx/math.h"
#include "wx/mac/private.h"
#include "wx/log.h"
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
#define RAD2DEG 57.2957795131
//-----------------------------------------------------------------------------
// wxPaintDC
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
/*
* wxWindowDC
*/
#include "wx/mac/uma.h"
#include "wx/notebook.h"
#include "wx/tabctrl.h"
static wxBrush MacGetBackgroundBrush( wxWindow* window )
{
wxBrush bkdBrush = window->MacGetBackgroundBrush() ;
#if !TARGET_API_MAC_OSX
// transparency cannot be handled by the OS when not using composited windows
wxWindow* parent = window->GetParent() ;
// if we have some 'pseudo' transparency
if ( ! bkdBrush.Ok() || bkdBrush.GetStyle() == wxTRANSPARENT || window->GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
{
// walk up until we find something
while( parent != NULL )
{
if ( parent->GetBackgroundColour() != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
{
// if we have any other colours in the hierarchy
bkdBrush.SetColour( parent->GetBackgroundColour() ) ;
break ;
}
if ( parent->IsKindOf( CLASSINFO(wxTopLevelWindow) ) )
{
bkdBrush = parent->MacGetBackgroundBrush() ;
break ;
}
if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ) )
{
Rect extent = { 0 , 0 , 0 , 0 } ;
int x , y ;
x = y = 0 ;
wxSize size = parent->GetSize() ;
parent->MacClientToRootWindow( &x , &y ) ;
extent.left = x ;
extent.top = y ;
extent.top-- ;
extent.right = x + size.x ;
extent.bottom = y + size.y ;
bkdBrush.MacSetThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ;
break ;
}
parent = parent->GetParent() ;
}
}
if ( !bkdBrush.Ok() || bkdBrush.GetStyle() == wxTRANSPARENT )
{
// if we did not find something, use a default
bkdBrush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
}
#endif
return bkdBrush ;
}
wxWindowDC::wxWindowDC()
{
m_window = NULL ;
}
wxWindowDC::wxWindowDC(wxWindow *window)
{
m_window = window ;
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
if (!rootwindow)
return;
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
int x , y ;
x = y = 0 ;
wxSize size = window->GetSize() ;
window->MacWindowToRootWindow( &x , &y ) ;
m_macPort = UMAGetWindowPort( windowref ) ;
#if wxMAC_USE_CORE_GRAPHICS
m_macLocalOriginInPort.x = x ;
m_macLocalOriginInPort.y = y ;
if ( window->MacGetCGContextRef() )
{
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
m_graphicContext->SetPen( m_pen ) ;
m_graphicContext->SetBrush( m_brush ) ;
SetBackground(MacGetBackgroundBrush(window));
}
else
{
// as out of order redraw is not supported under CQ, we have to create a qd port for these
// situations
m_macLocalOrigin.x = x ;
m_macLocalOrigin.y = y ;
m_graphicContext = new wxMacCGContext( (CGrafPtr) m_macPort ) ;
m_graphicContext->SetPen( m_pen ) ;
m_graphicContext->SetBrush( m_brush ) ;
SetBackground(MacGetBackgroundBrush(window));
}
// there is no out-of-order drawing on OSX
#else
m_macLocalOrigin.x = x ;
m_macLocalOrigin.y = y ;
CopyRgn( (RgnHandle) window->MacGetVisibleRegion(true).GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
SetBackground(MacGetBackgroundBrush(window));
#endif
m_ok = TRUE ;
SetFont( window->GetFont() ) ;
}
wxWindowDC::~wxWindowDC()
{
}
void wxWindowDC::DoGetSize( int* width, int* height ) const
{
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
m_window->GetSize(width, height);
}
/*
* wxClientDC
*/
wxClientDC::wxClientDC()
{
m_window = NULL ;
}
wxClientDC::wxClientDC(wxWindow *window)
{
m_window = window ;
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
if (!rootwindow)
return;
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
wxPoint origin = window->GetClientAreaOrigin() ;
wxSize size = window->GetClientSize() ;
int x , y ;
x = origin.x ;
y = origin.y ;
window->MacWindowToRootWindow( &x , &y ) ;
m_macPort = UMAGetWindowPort( windowref ) ;
#if wxMAC_USE_CORE_GRAPHICS
m_macLocalOriginInPort.x = x ;
m_macLocalOriginInPort.y = y ;
if ( window->MacGetCGContextRef() )
{
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
m_graphicContext->SetPen( m_pen ) ;
m_graphicContext->SetBrush( m_brush ) ;
m_ok = TRUE ;
SetClippingRegion( 0 , 0 , size.x , size.y ) ;
SetBackground(MacGetBackgroundBrush(window));
}
else
{
// as out of order redraw is not supported under CQ, we have to create a qd port for these
// situations
m_macLocalOrigin.x = x ;
m_macLocalOrigin.y = y ;
m_graphicContext = new wxMacCGContext( (CGrafPtr) m_macPort ) ;
m_graphicContext->SetPen( m_pen ) ;
m_graphicContext->SetBrush( m_brush ) ;
m_ok = TRUE ;
}
#else
m_macLocalOrigin.x = x ;
m_macLocalOrigin.y = y ;
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
m_ok = TRUE ;
#endif
SetBackground(MacGetBackgroundBrush(window));
SetFont( window->GetFont() ) ;
}
wxClientDC::~wxClientDC()
{
#if wxMAC_USE_CORE_GRAPHICS
/*
if ( m_window->MacGetCGContextRef() == 0)
{
CGContextRef cgContext = (wxMacCGContext*)(m_graphicContext)->GetNativeContext() ;
CGContextFlush( cgContext ) ;
}
*/
#endif
}
void wxClientDC::DoGetSize(int *width, int *height) const
{
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
m_window->GetClientSize( width, height );
}
/*
* wxPaintDC
*/
wxPaintDC::wxPaintDC()
{
m_window = NULL ;
}
wxPaintDC::wxPaintDC(wxWindow *window)
{
m_window = window ;
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
wxPoint origin = window->GetClientAreaOrigin() ;
wxSize size = window->GetClientSize() ;
int x , y ;
x = origin.x ;
y = origin.y ;
window->MacWindowToRootWindow( &x , &y ) ;
m_macPort = UMAGetWindowPort( windowref ) ;
#if wxMAC_USE_CORE_GRAPHICS
m_macLocalOriginInPort.x = x ;
m_macLocalOriginInPort.y = y ;
if ( window->MacGetCGContextRef() )
{
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
m_graphicContext->SetPen( m_pen ) ;
m_graphicContext->SetBrush( m_brush ) ;
m_ok = TRUE ;
SetClippingRegion( 0 , 0 , size.x , size.y ) ;
SetBackground(MacGetBackgroundBrush(window));
}
else
{
wxLogDebug(wxT("You cannot create a wxPaintDC outside an OS-draw event") ) ;
m_graphicContext = NULL ;
m_ok = TRUE ;
}
// there is no out-of-order drawing on OSX
#else
m_macLocalOrigin.x = x ;
m_macLocalOrigin.y = y ;
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
SetBackground(MacGetBackgroundBrush(window));
m_ok = TRUE ;
#endif
SetFont( window->GetFont() ) ;
}
wxPaintDC::~wxPaintDC()
{
}
void wxPaintDC::DoGetSize(int *width, int *height) const
{
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
m_window->GetClientSize( width, height );
}
| 32.236593 | 152 | 0.608279 | Bloodknight |
64ba2650b392bb85157bc79c84bdfc4d6271d775 | 924 | cpp | C++ | online_judges/ac/513B1.cpp | miaortizma/competitive-programming | ea5adfc07e49935acfc0697eeb0a12c7dc6cd8cc | [
"MIT"
] | 2 | 2018-02-20T14:44:57.000Z | 2018-02-20T14:45:03.000Z | online_judges/ac/513B1.cpp | miaortizma/competitive-programming | ea5adfc07e49935acfc0697eeb0a12c7dc6cd8cc | [
"MIT"
] | null | null | null | online_judges/ac/513B1.cpp | miaortizma/competitive-programming | ea5adfc07e49935acfc0697eeb0a12c7dc6cd8cc | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#ifdef PAPITAS
#define DEBUG 1
#else
#define DEBUG 0
#endif
#define _DO_(x) if(DEBUG) x
int check(vector<int> v, int tetra){
int n = v.size();
int ans = 0;
for(int i = 0; i < n; i++){
int temp = v[i];
for(int j = i; j < n; j++){
temp = min(temp, v[j]);
ans += temp;
}
}
if(tetra == ans){
for(int i = 0; i < n; i++){
cout << v[i] << ' ';
}
cout << "\n value: " << ans << '\n';
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(NULL);
#ifdef PAPITAS
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
ll n, m;
cin >> n >> m;
m--;
deque<int> v;
v.push_back(n);
for(ll i = 0; i < n - 1; i++){
if((m & (1LL << i))){
v.push_back(n - 1LL - i);
}else{
v.push_front(n - 1LL - i);
}
}
for(int i = 0; i < n; i++){
cout << v[i] << ' ';
}
return 0;
}
| 16.210526 | 43 | 0.514069 | miaortizma |
64ba8d65849c855dda320dd863706df83ed9ea3b | 5,263 | cpp | C++ | test/test_no_self_trade.cpp | liutongwei/ft | c75c1ea6b4e53128248113f9810b997d2f7ff236 | [
"MIT"
] | null | null | null | test/test_no_self_trade.cpp | liutongwei/ft | c75c1ea6b4e53128248113f9810b997d2f7ff236 | [
"MIT"
] | null | null | null | test/test_no_self_trade.cpp | liutongwei/ft | c75c1ea6b4e53128248113f9810b997d2f7ff236 | [
"MIT"
] | null | null | null | // Copyright [2020] <Copyright Kevin, kevin.lau.gd@gmail.com>
#include <gtest/gtest.h>
#include "trader/risk_management/common/no_self_trade.h"
static uint64_t order_id = 1;
void GenLO(ft::Order* order, ft::Direction direction, ft::Offset offset, double price) {
order->req.direction = direction;
order->req.offset = offset;
order->req.price = price;
order->req.order_id = order_id++;
order->req.type = ft::OrderType::kLimit;
}
void GenMO(ft::Order* order, ft::Direction direction, ft::Offset offset) {
order->req.direction = direction;
order->req.offset = offset;
order->req.price = 0;
order->req.order_id = order_id++;
order->req.type = ft::OrderType::kMarket;
}
TEST(RMS, NoSelfTrade) {
ft::RiskRuleParams params{};
ft::OrderMap order_map;
ft::Contract contract{};
ft::Order order{};
params.order_map = &order_map;
contract.ticker = "ticker001";
order.req.contract = &contract;
order.req.volume = 1;
ft::NoSelfTradeRule rule;
rule.Init(¶ms);
GenLO(&order, ft::Direction::kBuy, ft::Offset::kOpen, 100.1);
order_map.emplace(static_cast<uint64_t>(order.req.order_id), order);
GenLO(&order, ft::Direction::kBuy, ft::Offset::kOpen, 100.1);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kOpen, 99.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kOpen, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kClose, 100.1);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kClose, 99.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kClose, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kCloseToday, 100.1);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kCloseToday, 99.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kCloseToday, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kCloseYesterday, 100.1);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kCloseYesterday, 99.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kBuy, ft::Offset::kCloseYesterday, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kOpen, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kOpen, 100.1);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kOpen, 99.0);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kClose, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kClose, 100.1);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kClose, 99.0);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kCloseToday, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kCloseToday, 100.1);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kCloseToday, 99.0);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kCloseYesterday, 110.0);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kCloseYesterday, 100.1);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenLO(&order, ft::Direction::kSell, ft::Offset::kCloseYesterday, 99.0);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kBuy, ft::Offset::kOpen);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kBuy, ft::Offset::kClose);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kBuy, ft::Offset::kCloseToday);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kBuy, ft::Offset::kCloseYesterday);
ASSERT_EQ(ft::NO_ERROR, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kSell, ft::Offset::kOpen);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kSell, ft::Offset::kClose);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kSell, ft::Offset::kCloseToday);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
GenMO(&order, ft::Direction::kSell, ft::Offset::kCloseYesterday);
ASSERT_EQ(ft::ERR_SELF_TRADE, rule.CheckOrderRequest(&order));
}
| 38.137681 | 88 | 0.714801 | liutongwei |
64bf749522e131dda2ce01b960f8814b85de976f | 2,798 | cpp | C++ | 2DGame/terrainImpactSystem.cpp | Cimera42/2DGame | 9135e3dbed8a909357d57e227ecaba885982e8dc | [
"MIT"
] | 3 | 2015-08-18T12:59:29.000Z | 2015-12-15T08:11:10.000Z | 2DGame/terrainImpactSystem.cpp | Cimera42/2DGame | 9135e3dbed8a909357d57e227ecaba885982e8dc | [
"MIT"
] | null | null | null | 2DGame/terrainImpactSystem.cpp | Cimera42/2DGame | 9135e3dbed8a909357d57e227ecaba885982e8dc | [
"MIT"
] | null | null | null | #include "terrainImpactSystem.h"
#include "globals.h"
#include "colliderComponent.h"
#include "worldComponent.h"
#include "physicsComponent.h"
#include "terrainComponent.h"
#include "logger.h"
//Unique system ID
SystemID TerrainImpactSystem::ID;
TerrainImpactSystem::TerrainImpactSystem()
{
std::vector<ComponentID> subList1;
//Components needed to subscribe to system
subList1.push_back(WorldComponent::getStaticID());
subList1.push_back(TerrainComponent::getStaticID());
addSubList(subList1);
}
TerrainImpactSystem::~TerrainImpactSystem(){}
void TerrainImpactSystem::update()
{
for(int subID = 0; subID < subscribedEntities[0].size(); subID++)
{
//Get terrain component
Entity * terrainEnt = entities[subscribedEntities[0][subID]];
TerrainComponent* terrainComp = static_cast<TerrainComponent*>(terrainEnt->getComponent(TerrainComponent::getStaticID()));
WorldComponent * terrainWorldComp = static_cast<WorldComponent*>(terrainEnt->getComponent(WorldComponent::getStaticID()));
//Check projectile for collisions
for(int i = 0; i < terrainComp->collisionData.size(); i++)
{
std::shared_ptr<CollisionPair> collision = terrainComp->collisionData[i];
int terrainPairID = collision->getCollisionPairID(subscribedEntities[0][subID]);//Terrains's CollisionPairID
int collidingPairID = collision->getOppositePairID(terrainPairID);//The Colliding Ent's CollisionPairID
Entity * collidingEnt = entities[collision->getCollisionEntityID(collidingPairID)]; //The Colliding Entity
//Check the type of the collided entity and perform action
if(collidingEnt->hasComponent(PhysicsComponent::getStaticID()) && collidingEnt->hasComponent(ColliderComponent::getStaticID()))
{
glm::vec2 col = collision->getNormal(terrainPairID);
PhysicsComponent* physicsComp = static_cast<PhysicsComponent*>(collidingEnt->getComponent(PhysicsComponent::getStaticID()));
//apply an upwards impulse to keep object above ground
float normalMag = glm::dot(physicsComp->velocity*physicsComp->mass,glm::normalize(col));
float j = -(1+physicsComp->coefficientRestitution)*normalMag;
float impulseMag = glm::max(j, 0.0f);
physicsComp->impulse(impulseMag*glm::normalize(col));
//apply friction
/*glm::vec2 dir = -glm::normalize(col);
glm::vec2 friction = 5.0f * normalMag * glm::vec2(-dir.y,dir.x);
Logger()<<friction.x<<" "<<friction.y<<std::endl;
physicsComp->force += friction;*/
}
}
}
}
| 46.633333 | 141 | 0.657255 | Cimera42 |
64c2482c1c040909cefae9c1de19c0349f2e8f03 | 496 | cpp | C++ | 01-operadores-aritmeticos/17_conversion_de_modeda.cpp | gemboedu/ejercicios-basicos-c- | 648e2abe4c8e7f51bbfb1d21032eeeee3f5b9343 | [
"MIT"
] | 1 | 2021-12-03T03:37:04.000Z | 2021-12-03T03:37:04.000Z | 01-operadores-aritmeticos/17_conversion_de_modeda.cpp | gemboedu/ejercicios-basicos-c- | 648e2abe4c8e7f51bbfb1d21032eeeee3f5b9343 | [
"MIT"
] | null | null | null | 01-operadores-aritmeticos/17_conversion_de_modeda.cpp | gemboedu/ejercicios-basicos-c- | 648e2abe4c8e7f51bbfb1d21032eeeee3f5b9343 | [
"MIT"
] | null | null | null | /*
17. Juana viajará a EEUU y luego a Europa, por tanto, requiere un programa que convierta x cantidad de Bs a dólares y a euros.
$1 = Bs. 6.90
1 euro = Bs. 7.79
*/
#include <iostream>
using namespace std;
int main()
{
float bolivianos, dolares, euros;
cout << "Ingrese la moneda boliviana: ";
cin >> bolivianos;
dolares = bolivianos / 6.90;
euros = bolivianos / 7.79;
cout << "En dolares: " << dolares << endl;
cout << "En euros: " << euros << endl;
return 0;
}
| 26.105263 | 126 | 0.625 | gemboedu |
64c297186805285fdf248cc03771da2730d288f2 | 764 | hpp | C++ | Source/Console/ConsoleFrame.hpp | gunstarpl/Game-Engine-12-2013 | bfc53f5c998311c17e97c1b4d65792d615c51d36 | [
"MIT",
"Unlicense"
] | 6 | 2017-12-31T17:28:40.000Z | 2021-12-04T06:11:34.000Z | Source/Console/ConsoleFrame.hpp | gunstarpl/Game-Engine-12-2013 | bfc53f5c998311c17e97c1b4d65792d615c51d36 | [
"MIT",
"Unlicense"
] | null | null | null | Source/Console/ConsoleFrame.hpp | gunstarpl/Game-Engine-12-2013 | bfc53f5c998311c17e97c1b4d65792d615c51d36 | [
"MIT",
"Unlicense"
] | null | null | null | #pragma once
#include "Precompiled.hpp"
#include "Graphics/Font.hpp"
//
// Console Frame
// Displays and lets user interact with the console system.
//
class ConsoleFrame
{
public:
ConsoleFrame();
~ConsoleFrame();
bool Initialize();
void Cleanup();
void Open();
void Close();
bool Process(const SDL_Event& event);
void Draw(const glm::mat4& transform, glm::vec2 targetSize);
bool IsOpen() const
{
return m_open;
}
private:
void ClearInput();
private:
// Current input.
std::string m_input;
// Input cursor position.
int m_cursorPosition;
// History positions.
int m_historyOutput;
int m_historyInput;
// Frame state.
bool m_open;
bool m_initialized;
};
| 14.980392 | 64 | 0.636126 | gunstarpl |
64c3882a867fe012e561dc7ed693eef7bfa71de0 | 11,064 | hpp | C++ | inetsrv/query/filters/office/src/findfast/dmiwd8st.hpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | inetsrv/query/filters/office/src/findfast/dmiwd8st.hpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | inetsrv/query/filters/office/src/findfast/dmiwd8st.hpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | #ifndef _WRD8STM_HPP
#define _WRD8STM_HPP
#if !VIEWER
#include "dmifstrm.hpp"
#include "dmfltinc.h"
#include "clidrun.h"
class CWord8Stream : public IFilterStream
{
friend class CLidRun8;
public:
CWord8Stream();
~CWord8Stream();
ULONG AddRef() { return 1; }
#ifdef MAC
HRESULT Load(FSSpec *pfss);
#else // WIN
HRESULT Load(LPTSTR pszFileName);
#endif // MAC
HRESULT LoadStg(IStorage * pstg);
HRESULT ReadContent(VOID *pv, ULONG cb,
ULONG *pcbRead);
HRESULT GetNextEmbedding(IStorage ** ppstg);
HRESULT Unload();
ULONG Release() { return 0; }
// Positions the filter at the beginning of the next chunk
// and returns the description of the chunk in pStat
HRESULT GetChunk(STAT_CHUNK * pStat);
private:
typedef ULONG FC;
// BTE is 2 bytes in Word 6/7, and 4 bytes in Word 8.
typedef ULONG BTE;
typedef struct _STSHI
{
//WORD cbStshi;
WORD cstd;
WORD csSTDBaseInFile;
WORD fStdStylenamesWrite: 1;
WORD fRes: 15;
WORD stiMaxWhenSaved;
WORD istdMaxFixedWhenSaved;
WORD nVerBuiltInNamesWhenSaved;
WORD ftsStandartChpStsh;
} STSHI, FAR * lpSTHI;
typedef struct _STD
{
//WORD cbStd;
WORD sti : 12;
WORD fScrath : 1;
WORD fInvalHeight: 1;
WORD fHasUpe : 1;
WORD fMassCopy : 1;
WORD sgc : 4;
WORD istdBase : 12;
WORD cupx : 4;
WORD istdNext : 12;
WORD bchUpe;
WORD fAutoRedef : 1;
WORD fHidden : 1;
WORD unused : 14;
BYTE xstzName[2];
} STD;
// The following are values that STD->sgc can take for determining if it's a Para style or Char style
#define stkPara 1
#define stkChar 2
int m_nLangRunSize;
CLidRun8 * m_pLangRuns;
LCID m_currentLid;
LCID m_FELid;
BOOL m_bFEDoc;
#pragma pack(1)
// Simple PRM. Note that isprm is an index into rgsprmPrm in W96.
struct PRM1
{
BYTE fComplex:1;
BYTE isprm:7;
BYTE val;
};
// Complex PRM.
struct PRM2
{
WORD fComplex:1;
WORD igrpprl:15;
};
struct PCD
{
WORD :16; // don't care.
union
{
FC fcNotCompressed;
struct
{
DWORD :1;
DWORD fcCompressed :29;
DWORD fCompressed :1;
DWORD :1;
};
};
union
{
PRM1 prm1;
PRM2 prm2;
};
FC GetFC() const
{return fCompressed ? fcCompressed : fcNotCompressed; }
int CbChar() const
{return fCompressed ? sizeof(CHAR) : sizeof(WCHAR); }
};
#pragma pack()
enum FSPEC_STATE
{
FSPEC_ALL,
FSPEC_NONE,
FSPEC_EITHER
};
enum {FKP_PAGE_SIZE = 512};
HRESULT ReadFileInfo();
HRESULT ReadBinTable();
HRESULT FindNextSpecialCharacter (BOOL fFirstChar=fFalse);
HRESULT ParseGrpPrls();
HRESULT Read (VOID *pv, ULONG cbToRead, IStream *pStm);
HRESULT Seek (ULONG cbSeek, STREAM_SEEK origin, IStream *pStm);
HRESULT SeekAndRead (ULONG cbSeek, STREAM_SEEK origin,
VOID *pv, ULONG cbToRead, IStream *pStm);
BYTE *GrpprlCacheGet (short igrpprl, USHORT *pcb);
BYTE *GrpprlCacheAllocNew (int cb, short igrpprl);
LCID GetDocLanguage(void);
HRESULT CreateLidsTable(void);
HRESULT CheckLangID(FC fcCur, ULONG * pcbToRead, LCID * plid, BOOL fUpdate = TRUE);
HRESULT GetLidFromSyle(short istd, WORD * pLID, WORD * pLIDFE, WORD * pbUseFE,
WORD * pLIDBi, WORD * pbUseBi, BOOL fParaBidi=FALSE);
void ScanGrpprl(WORD cbgrpprl, BYTE * pgrpprl, WORD * plid, WORD * plidFE, WORD * bUseFE,
WORD * pLIDBi, WORD * pbUseBi, BOOL *pfParaBidi=NULL);
HRESULT ProcessCharacterBinTable(void);
HRESULT ProcessParagraphBinTable(void);
HRESULT ProcessPieceTable(void);
HRESULT ScanLidsForFE(void);
IStorage * m_pStg; // IStorage for file
IStream * m_pStmMain; // IStream for WordDocument stream.
IStream * m_pStmTable; // IStream for the TableX stream.
IStorage * m_pstgEmbed; // IStorage for the current embedding
IEnumSTATSTG * m_pestatstg; // storage enumerator for embeddings
IStorage * m_pstgOP; // IStorage for the object pool (embeddings)
FC m_fcClx; // offset of the complex part of the file
FC * m_rgcp; // Character positions in the main docfile.
PCD * m_rgpcd; // The corresponding piece descriptor array
// to go with m_rgcp.
ULONG m_cpcd; // This is the count of piece descriptors in
// m_rgpcd. The count of cps in m_rgcp is
// m_cpcd + 1.
ULONG m_ipcd; // The current index into both m_rgcp and
// m_rgpcd.
ULONG m_ccpRead; // count of characters read so
long m_cbte; // count of BTE's in char bin table
long m_cbtePap; // count of BTE's in paragraph bin table
FC * m_rgfcBinTable; // only used if m_fComplex.
// size is m_cbte + 1
FC * m_rgfcBinTablePap; // only used if m_fComplex.
// size is m_cbte + 1
BTE * m_rgbte; // The BTE array from the char bin table
BTE * m_rgbtePap; // The BTE array from the paragraph bin table
long m_ibte; // The current index into m_rgbte.
BYTE m_fkp[FKP_PAGE_SIZE]; // current character fkp
BYTE m_fkpPap[FKP_PAGE_SIZE]; // current paragraph fkp
BYTE m_ifcfkp; // index into m_fkp that indicates next special
// character range.
FSPEC_STATE m_fsstate; // Keeps track of whether the rest of the
// characters (in the current piece, if a
// complex file) are special characters, not
// special characters, or either, depending on
// the FKP.
BOOL m_fStruckOut; // Whether struck-out text or "true" special
// characters follow our text.
// Some flags we should read from the document's file information block.
// Below is the contents of bytes 10 and 11 of Word 96 FIB.
union
{
struct
{
BF m_fDot :1; // file is a DOT
BF m_fGlsy :1; // file is a glossary co-doc
BF m_fComplex :1; // file pice table/etc stored (FastSave)
BF m_fHasPic :1; // one or more graphics in file
BF m_cQuickSaves :4; // count of times file quicksaved
BF m_fEncrypted :1; // Is file encrypted?
BF m_fWhichTblStm :1; // Is the bin table stored in docfile 1Table or 0Table?
BF m_fReadOnlyRecommended :1; // user recommends opening R/O
BF m_fWriteReservation :1; // owner made file write-reserved
BF m_fExtChar :1; // extended character set;
BF m_fLoadOverride :1; // for internation use, settable by debug .exe only
// override doc's margins, lang with internal defaults
BF m_fFarEast :1; // doc written by FarEast version of W96
BF m_fCrypto :1; // Encrypted using the Microsoft Cryptography APIs
};
WORD m_wFlagsAt10;
};
DWORD m_FIB_OFFSET_rgfclcb;
// LRU Cache for the incoming grpprls.
struct CacheGrpprl
{
enum {CACHE_SIZE = 1024};
enum {CACHE_MAX = 64};
BYTE rgb[CACHE_SIZE]; // The buffer.
int ibFirst[CACHE_MAX+1]; // Boundaries between items.
short rgIdItem[CACHE_MAX]; // # in the file, used as an ID.
long rglLastAccTmItem[CACHE_MAX]; // Last time an item was accessed.
long lLastAccTmCache; // Max over all items.
int cItems; // # items in cache
BYTE *pbExcLarge; // an item larger than the cache.
long cbExcLarge;
short idExcLarge;
// Constructor.
CacheGrpprl () :
cItems(0), lLastAccTmCache(0L), pbExcLarge(0)
{ibFirst[0] = 0; }
} *m_pCache;
// doc lid
WORD m_lid;
BYTE * m_pSTSH;
STSHI * m_pSTSHI;
unsigned long m_lcbStshf;
// Buffer used for ANSI->UNICODE conversion.
char *m_rgchANSIBuffer;
};
#endif // !VIEWER
#endif
| 39.095406 | 135 | 0.450018 | npocmaka |
64c444ea6f51e4df3c08916ff98b277fc179396f | 1,489 | hpp | C++ | addons/CBRN_units/units/NATO/unarmed.hpp | ASO-TheM/ChemicalWarfare | 51322934ef1da7ba0f3bb04c1d537767d8e48cc4 | [
"MIT"
] | null | null | null | addons/CBRN_units/units/NATO/unarmed.hpp | ASO-TheM/ChemicalWarfare | 51322934ef1da7ba0f3bb04c1d537767d8e48cc4 | [
"MIT"
] | null | null | null | addons/CBRN_units/units/NATO/unarmed.hpp | ASO-TheM/ChemicalWarfare | 51322934ef1da7ba0f3bb04c1d537767d8e48cc4 | [
"MIT"
] | null | null | null | class B_Soldier_unarmed_F;
class B_CBRN_Unarmed: B_Soldier_unarmed_F
{
scope = 1;
editorSubcategory = "CBRN";
//editorPreview = "\bonusUnits_CSF\editorPreviews\O_CSF_Unarmed.jpg";
author = "Assaultboy";
hiddenSelections[] = {"camo"};
hiddenSelectionsTextures[] = {"\skn_nbc_units\data_m50\NBC_M50_Uniform_CO.paa"};
modelSides[] = {0, 1, 2, 3};
model = "\skn_nbc_units\models\skn_b_nbc_uniform.p3d";
uniformClass = "U_B_CBRN";
class EventHandlers
{
class CBRN_giveMask
{
init = "(_this select 0) addItem 'G_CBRN_M50_Hood'";
};
};
};
class B_CBRN_CTRG_GER_S_Arid_Unarmed: B_Soldier_unarmed_F
{
scope = 1;
editorSubcategory = "CBRN";
//editorPreview = "\bonusUnits_CSF\editorPreviews\O_CSF_Unarmed.jpg";
author = "The_M";
hiddenSelections[] = {"camo"};
hiddenSelectionsTextures[] = {"\CBRN_gear\data\clothing1_CTRG_GER_arid_co.paa"};
modelSides[] = {0, 1, 2, 3};
model = "\A3\Characters_F_Exp\BLUFOR\B_CTRG_Soldier_01_F.p3d";
uniformClass = "U_B_CBRN_CTRG_GER_S_Arid";
};
class B_CBRN_CTRG_GER_S_Tropic_Unarmed: B_Soldier_unarmed_F
{
scope = 1;
editorSubcategory = "CBRN";
//editorPreview = "\bonusUnits_CSF\editorPreviews\O_CSF_Unarmed.jpg";
author = "The_M";
hiddenSelections[] = {"camo"};
hiddenSelectionsTextures[] = {"\CBRN_gear\data\clothing1_CTRG_GER_tropic_co.paa"};
modelSides[] = {0, 1, 2, 3};
model = "\A3\Characters_F_Exp\BLUFOR\B_CTRG_Soldier_01_F.p3d";
uniformClass = "U_B_CBRN_CTRG_GER_S_Tropic";
};
| 22.560606 | 83 | 0.723976 | ASO-TheM |
64c47577cd6e7377f1e1989c5ee8c523428a64af | 3,032 | cpp | C++ | EasyFramework3d/managed/al/SoundManager.cpp | sizilium/FlexChess | f12b94e800ddcb00535067eca3b560519c9122e0 | [
"MIT"
] | null | null | null | EasyFramework3d/managed/al/SoundManager.cpp | sizilium/FlexChess | f12b94e800ddcb00535067eca3b560519c9122e0 | [
"MIT"
] | null | null | null | EasyFramework3d/managed/al/SoundManager.cpp | sizilium/FlexChess | f12b94e800ddcb00535067eca3b560519c9122e0 | [
"MIT"
] | null | null | null | #include <vs/managed/al/SoundManager.h>
#include <vs/managed/al/AlException.h>
#include <vs/base/interfaces/AbstractManaged.h>
#include <vs/base/util/IOStream.h>
namespace vs
{
namespace managed
{
namespace al
{
using namespace base::interfaces;
using namespace base::util;
SoundManager::SoundManager()
{
int error;
alutInit(NULL, 0);
error = alGetError();
if (error != AL_NO_ERROR)
{
throw ALException ( "SoundManager.cpp", "SoundManager::SoundManager",
"Could not init alut!", error, ALUT_ERROR);
}
// set default listener attributes
ALfloat listenerPos[] =
{
0.0, 0.0, 0.0
};
ALfloat listenerVel[] =
{
0.0, 0.0, 0.0
};
ALfloat listenerOri[] =
{
0.0, 0.0, -1.0, 0.0, 1.0, 0.0
};
alListenerfv(AL_POSITION, listenerPos);
alListenerfv(AL_VELOCITY, listenerVel);
alListenerfv(AL_ORIENTATION, listenerOri);
// set cleanup function on exit
atexit( killALData );
// set the default distance model (can be changed by SoundListener.h)
alDistanceModel(AL_LINEAR_DISTANCE);
}
SoundManager::~SoundManager()
{
map<string, ALuint>::iterator it = buffers.begin();
while (it != buffers.end() )
{
alDeleteBuffers(1, &it->second );
++it;
}
buffers.clear();
alutExit();
}
void SoundManager::update(double time)
{
}
ALuint SoundManager::getBuffer(string path)
{
int error;
// falls buffer noch nicht vorhanden ist neuen buffer anlegen und laden
if (!buffers[path])
{
ALuint newBuffer;
alGenBuffers(1, &newBuffer);
error = alGetError();
if (error != AL_NO_ERROR)
{
throw ALException ( "SoundManager.cpp", "SoundManager::getBuffer",
"Could not generate buffer!", error, AL_ERROR);
}
// sound datei in buffer laden
newBuffer = alutCreateBufferFromFile(path.c_str() );
if (newBuffer == AL_NONE)
{
ALenum error;
error = alutGetError ();
throw ALException("SoundManager.cpp", "SoundManager::getBuffer",
"Could not create buffer from file: " + path +
"(\nis the path and filename correct? is the wav format correct?)"
, error, ALUT_ERROR);
}
return buffers[path] = newBuffer;
}
// falls buffer schon vorhanden war den alten buffer verwenden
else
return buffers[path];
}
void SoundManager::delBuffer(ALuint fd)
{
--refCounts[fd];
// falls buffer nicht mehr gebraucht wird, l�schen
if (refCounts[fd] <= 0)
{
map<string, ALuint>::iterator it = buffers.begin();
while (it != buffers.end())
{
if (it->second == fd)
break;
it++;
}
alDeleteBuffers(1, &it->second); // buffer aus al l�schen
buffers.erase(it); // buffer aus verwaltung l�schen
refCounts.erase(fd); // refCounter l�schen
}
ALenum error;
if (error = alGetError () != AL_NO_ERROR)
{
throw ALException( "SoundManager.cpp", "SoundManager::delBuffer",
"Could not delete buffer", error, AL_ERROR);
}
}
void SoundManager::outDebug() const
{
}
void killALData()
{
// TODO (Administrator#1#): funktion �berhaupt notwendig?
}
} // al
} // managed
} // vs
| 19.069182 | 75 | 0.66128 | sizilium |
64c4c68adb0be5c06237e11d15fecfbbccff5595 | 1,814 | cpp | C++ | CPP/OJ problems/Graph Without Long Directed Paths.cpp | kratikasinghal/OJ-problems | fc5365cb4db9da780779e9912aeb2a751fe4517c | [
"MIT"
] | null | null | null | CPP/OJ problems/Graph Without Long Directed Paths.cpp | kratikasinghal/OJ-problems | fc5365cb4db9da780779e9912aeb2a751fe4517c | [
"MIT"
] | null | null | null | CPP/OJ problems/Graph Without Long Directed Paths.cpp | kratikasinghal/OJ-problems | fc5365cb4db9da780779e9912aeb2a751fe4517c | [
"MIT"
] | null | null | null |
// Problem: F. Graph Without Long Directed Paths
// Contest: Codeforces - Codeforces Round #550 (Div. 3)
// URL: https://codeforces.com/contest/1144/problem/F
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long int
#define vi vector<int>
#define vii vector<int, int>
#define vc vector<char>
#define vl vector<ll>
#define mod 1000000007
#define INF 1000000009
using namespace std;
vi adj[200005];
bool color[200005];
bool vis[200005];
bool dfs(int node, bool col) {
vis[node] = true;
for(int child : adj[node]) {
if(!vis[child]) {
color[child] = col^1;
bool res = dfs(child, col^1);
if(res == false) return false;
}
else {
if(color[child] == color[node]) {
return false;
}
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
// cin >> t;
while(t--) {
int n, m;
cin >> n >> m;
int a, b;
vector<pair<int, int> > A;
for(int i = 1; i <= m; i++) {
cin >> a >> b;
A.push_back({a, b});
adj[a].PB(b);
adj[b].PB(a);
}
bool flag = true;
for(int i = 0; i <= n; i++) {
bool res = dfs(i, 0);
if(res == false) {
flag = false;
break;
}
}
if(flag) {
cout << "YES\n";
for(int i = 0; i < (int)A.size(); i++) {
if(color[A[i].first] == 0) {
cout << "1";
}
else {
cout << "0";
}
}
cout << "\n";
}
else {
cout << "NO\n";
}
}
return 0;
} | 17.960396 | 62 | 0.492282 | kratikasinghal |
64c5baab3c5713cb2bcd2ac42e6b8b0235c5c7b1 | 43,463 | cpp | C++ | sdk/cpp/tests/testsanitynctest.cpp | ygorelik/pydk | 42ac7f2b33006c3ea99d07eb9f405346d35c6614 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | sdk/cpp/tests/testsanitynctest.cpp | ygorelik/pydk | 42ac7f2b33006c3ea99d07eb9f405346d35c6614 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | sdk/cpp/tests/testsanitynctest.cpp | ygorelik/pydk | 42ac7f2b33006c3ea99d07eb9f405346d35c6614 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | /// YANG Development Kit
// Copyright 2016 Cisco Systems. All rights reserved
//
////////////////////////////////////////////////////////////////
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
//////////////////////////////////////////////////////////////////
#include <iostream>
#include "../core/src/path_api.hpp"
#include "config.hpp"
#include "catch.hpp"
#include "../core/src/netconf_provider.hpp"
//test_sanity_types begin
TEST_CASE("test_sanity_types_int8 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & number8 = runner.create("ytypes/built-in-t/number8", "0");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
//find the number8 node
auto number8_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/number8");
REQUIRE(!number8_read_vec.empty());
auto number8_read = number8_read_vec[0];
REQUIRE(number8.get() == number8_read->get() );
}
TEST_CASE("test_sanity_types_int16 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & number16 = runner.create("ytypes/built-in-t/number16", "126");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
//find the number8 node
auto number16_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/number16");
REQUIRE(!number16_read_vec.empty());
auto & number16_read = number16_read_vec[0];
REQUIRE(number16.get() == number16_read->get() );
}
TEST_CASE("test_sanity_types_int32 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & number32 = runner.create("ytypes/built-in-t/number32", "200000");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto number32_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/number32");
REQUIRE(!number32_read_vec.empty());
auto number32_read = number32_read_vec[0];
REQUIRE(number32.get() == number32_read->get() );
}
TEST_CASE("test_sanity_types_int64 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & number64 = runner.create("ytypes/built-in-t/number64", "-9223372036854775808");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto number64_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/number64");
REQUIRE(!number64_read_vec.empty());
auto number64_read = number64_read_vec[0];
REQUIRE(number64.get() == number64_read->get() );
}
TEST_CASE("test_sanity_types_uint8 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & unumber8 = runner.create("ytypes/built-in-t/u_number8", "0");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto unumber8_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/u_number8");
REQUIRE(!unumber8_read_vec.empty());
auto unumber8_read = unumber8_read_vec[0];
REQUIRE(unumber8.get() == unumber8_read->get() );
}
TEST_CASE("test_sanity_types_uint16 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & unumber16 = runner.create("ytypes/built-in-t/u_number16", "65535");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty()
);
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto unumber16_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/u_number16");
REQUIRE(!unumber16_read_vec.empty());
auto unumber16_read = unumber16_read_vec[0];
REQUIRE(unumber16.get() == unumber16_read->get() );
}
TEST_CASE("test_sanity_types_uint32 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & unumber32 = runner.create("ytypes/built-in-t/u_number32", "5927");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty()
);
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto unumber32_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/u_number32");
REQUIRE(!unumber32_read_vec.empty());
auto unumber32_read = unumber32_read_vec[0];
REQUIRE(unumber32.get() == unumber32_read->get() );
}
TEST_CASE("test_sanity_types_uint64 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & unumber64 = runner.create("ytypes/built-in-t/u_number64", "18446744073709551615");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto unumber64_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/u_number64");
REQUIRE(!unumber64_read_vec.empty());
auto unumber64_read = unumber64_read_vec[0];
REQUIRE(unumber64.get() == unumber64_read->get() );
}
TEST_CASE("test_sanity_types_bits ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & bits = runner.create("ytypes/built-in-t/bits-value", "disable-nagle");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto bits_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/bits-value");
REQUIRE(!bits_read_vec.empty());
auto bits_read = bits_read_vec[0];
REQUIRE(bits.get() == bits_read->get() );
}
TEST_CASE("test_sanity_types_decimal64 ")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & deci64 = runner.create("ytypes/built-in-t/deci64", "2.14");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto deci64_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/deci64");
REQUIRE(!deci64_read_vec.empty());
auto deci64_read = deci64_read_vec[0];
//TODO log this
//std::cout << deci64_read->get() << std::endl;
REQUIRE(deci64.get() == deci64_read->get() );
}
TEST_CASE("test_sanity_types_string")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & str = runner.create("ytypes/built-in-t/name", "name_str");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto str_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/name");
REQUIRE(!str_read_vec.empty());
auto str_read = str_read_vec[0];
//std::cout << str_read->get() << std::endl;
REQUIRE(str.get() == str_read->get() );
}
TEST_CASE("test_sanity_types_empty")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & emptee = runner.create("ytypes/built-in-t/emptee", "");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto emptee_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/emptee");
REQUIRE(!emptee_read_vec.empty());
auto emptee_read = emptee_read_vec[0];
REQUIRE(emptee_read );
}
TEST_CASE("test_sanity_types_boolean")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & bool_val = runner.create("ytypes/built-in-t/bool-value", "true");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto bool_val_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/bool-value");
REQUIRE(!bool_val_read_vec.empty());
auto bool_val_read = bool_val_read_vec[0];
REQUIRE(bool_val.get() == bool_val_read->get() );
}
TEST_CASE("test_sanity_types_embedded_enum")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & embedded_enum = runner.create("ytypes/built-in-t/embeded-enum", "zero");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto embedded_enum_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/embeded-enum");
REQUIRE(!embedded_enum_read_vec.empty());
auto embedded_enum_read = embedded_enum_read_vec[0];
REQUIRE(embedded_enum.get() == embedded_enum_read->get() );
}
TEST_CASE("test_sanity_types_enum")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & enum_value = runner.create("ytypes/built-in-t/enum-value", "none");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto enum_value_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/enum-value");
REQUIRE(!enum_value_read_vec.empty());
auto enum_value_read = enum_value_read_vec[0];
REQUIRE(enum_value.get() == enum_value_read->get() );
}
TEST_CASE("test_sanity_types_union")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & union_value = runner.create("ytypes/built-in-t/younion", "none");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto union_value_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/younion");
REQUIRE(!union_value_read_vec.empty());
auto union_value_read = union_value_read_vec[0];
REQUIRE(union_value.get() == union_value_read->get() );
}
TEST_CASE("test_sanity_types_union_enum")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & enum_int_value = runner.create("ytypes/built-in-t/enum-int-value", "any");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto enum_int_value_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/enum-int-value");
REQUIRE(!enum_int_value_read_vec.empty());
auto enum_int_value_read = enum_int_value_read_vec[0];
REQUIRE(enum_int_value.get() == enum_int_value_read->get() );
}
TEST_CASE("test_sanity_types_union_int")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & enum_int_value = runner.create("ytypes/built-in-t/enum-int-value", "2");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto enum_int_value_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/enum-int-value");
REQUIRE(!enum_int_value_read_vec.empty());
auto enum_int_value_read = enum_int_value_read_vec[0];
REQUIRE(enum_int_value.get() == enum_int_value_read->get() );
}
TEST_CASE("test_union_leaflist")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & llunion1 = runner.create("ytypes/built-in-t/llunion[.='1']", "");
auto & llunion2 = runner.create("ytypes/built-in-t/llunion[.='2']", "");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto llunion1_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/llunion[.='1']");
REQUIRE(!llunion1_read_vec.empty());
auto llunion2_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/llunion[.='2']");
REQUIRE(!llunion2_read_vec.empty());
}
TEST_CASE("test_enum_leaflist")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & local = runner.create("ytypes/built-in-t/enum-llist[.='local']", "");
auto & remote = runner.create("ytypes/built-in-t/enum-llist[.='remote']", "");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto enumllist_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/enum-llist[.='local']");
REQUIRE(!enumllist_read_vec.empty());
enumllist_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/enum-llist[.='remote']");
REQUIRE(!enumllist_read_vec.empty());
}
TEST_CASE("test_identity_leaflist")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & child_identity = runner.create("ytypes/built-in-t/identity-llist[.='ydktest-sanity:child-identity']", "");
auto & child_child_identity = runner.create("ytypes/built-in-t/identity-llist[.='ydktest-sanity:child-child-identity']", "");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto identityllist_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/identity-llist[.='ydktest-sanity:child-identity']");
REQUIRE(!identityllist_read_vec.empty());
identityllist_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/identity-llist[.='ydktest-sanity:child-child-identity']");
REQUIRE(!identityllist_read_vec.empty());
}
TEST_CASE("test_union_complex_list")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & younion = runner.create("ytypes/built-in-t/younion-list[.='123:45']", "");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto younionlist_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/younion-list[.='123:45']");
REQUIRE(!younionlist_read_vec.empty());
}
TEST_CASE("test_identityref")
{
std::string searchdir{TEST_HOME};
ydk::path::Repository repo{TEST_HOME};
ydk::NetconfServiceProvider sp{repo,"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& schema = sp.get_root_schema();
ydk::path::CodecService s{};
auto & runner = schema.create("ydktest-sanity:runner", "");
//get the root
std::shared_ptr<const ydk::path::DataNode> data_root{&runner.root()};
REQUIRE( data_root != nullptr );
//first delete
std::shared_ptr<ydk::path::Rpc> delete_rpc { schema.rpc("ydk:delete") };
auto xml = s.encode(runner, ydk::EncodingFormat::XML, false);
delete_rpc->input().create("entity", xml);
//call delete
(*delete_rpc)(sp);
auto & identity_ref_value = runner.create("ytypes/built-in-t/identity-ref-value", "ydktest-sanity:child-child-identity");
xml = s.encode(runner, ydk::EncodingFormat::XML, false);
CHECK( !xml.empty());
//call create
std::shared_ptr<ydk::path::Rpc> create_rpc { schema.rpc("ydk:create") };
create_rpc->input().create("entity", xml);
(*create_rpc)(sp);
//call read
std::shared_ptr<ydk::path::Rpc> read_rpc { schema.rpc("ydk:read") };
auto & runner_read = schema.create("ydktest-sanity:runner", "");
std::shared_ptr<const ydk::path::DataNode> data_root2{&runner_read.root()};
xml = s.encode(runner_read, ydk::EncodingFormat::XML, false);
REQUIRE( !xml.empty() );
read_rpc->input().create("filter", xml);
auto read_result = (*read_rpc)(sp);
REQUIRE(read_result != nullptr);
auto identityref_value_read_vec = read_result->find("ydktest-sanity:runner/ytypes/built-in-t/identity-ref-value");
REQUIRE(!identityref_value_read_vec.empty());
auto val = identityref_value_read_vec[0]->get();
//std::cout << val << std::endl;
REQUIRE(val == "ydktest-sanity:child-child-identity");
}
| 27.860897 | 146 | 0.653383 | ygorelik |
64c7e5a918c73f7b940dfa25d9cf64c823900070 | 157 | cpp | C++ | Boost/The Boost C++ Libraries/src/13.2.2/main.cpp | goodspeed24e/Programming | ae73fad022396ea03105aad83293facaeea561ae | [
"MIT"
] | 1 | 2021-03-12T19:29:33.000Z | 2021-03-12T19:29:33.000Z | Boost/The Boost C++ Libraries/src/13.2.2/main.cpp | goodspeed24e/Programming | ae73fad022396ea03105aad83293facaeea561ae | [
"MIT"
] | 1 | 2019-03-13T01:36:12.000Z | 2019-03-13T01:36:12.000Z | Boost/The Boost C++ Libraries/src/13.2.2/main.cpp | goodspeed24e/Programming | ae73fad022396ea03105aad83293facaeea561ae | [
"MIT"
] | null | null | null | #include <boost/array.hpp>
#include <string>
int main()
{
typedef boost::array<std::string, 3> array;
array a = { "Boris", "Anton", "Caesar" };
} | 19.625 | 46 | 0.598726 | goodspeed24e |
64ca80d8ea5a2602035e6a05f685edadd30642e9 | 164 | cpp | C++ | GameServer/main.cpp | joyate/EjoyServer | e27da5a26189b9313df6378bd1194845eae45646 | [
"MIT"
] | 3 | 2017-03-27T03:13:41.000Z | 2019-12-24T00:18:14.000Z | GameServer/main.cpp | joyate/EjoyServer | e27da5a26189b9313df6378bd1194845eae45646 | [
"MIT"
] | null | null | null | GameServer/main.cpp | joyate/EjoyServer | e27da5a26189b9313df6378bd1194845eae45646 | [
"MIT"
] | null | null | null | #include "type_common.h"
#include "Server.h"
Server svr;
int main(int argc,const char* argv[])
{
if (!svr.Init())
{
return 0;
}
svr.Run();
return 0;
} | 9.647059 | 37 | 0.597561 | joyate |
64d15d4ecfe0e8d0205c8f8bbb0abe3b079ea45a | 2,581 | cpp | C++ | src/programm.cpp | Yperidis/bvd_agent_based_model | a42ae72ca05d966015bab92afd20130a2c6d848a | [
"MIT"
] | 1 | 2020-11-11T09:27:02.000Z | 2020-11-11T09:27:02.000Z | src/programm.cpp | Yperidis/bvd_agent_based_model | a42ae72ca05d966015bab92afd20130a2c6d848a | [
"MIT"
] | 8 | 2018-06-13T12:41:23.000Z | 2019-11-14T05:26:34.000Z | src/programm.cpp | Yperidis/bvd_agent_based_model | a42ae72ca05d966015bab92afd20130a2c6d848a | [
"MIT"
] | null | null | null | #include "Initializer.h"
#include "System.h"
//#include "Output.h"
#include <iostream>
#include "BVD_Random_Number_Generator.h"
#include <chrono>
#include "AdvancedOutput.h"
#include "BVDOptions.h"
#include "projectImports/inih/cpp/INIReader.h"
#pragma mark - main
/* actual program code */
int main(int argnum, char *arguments[], char *environment[])
{
BVDOptions opt = BVDOptions();
opt.handleCommandLineArguments(argnum, arguments);
if(BVDOptions::iniFilePath.compare("NONE") == 0){
std::cerr << "Supply path to ini-file in order to start the simulation or use --help to get information on the proper use of this program." << std::endl;
exit(1);
}
INIReader reader(BVDOptions::iniFilePath);
if (reader.ParseError() < 0) {
std::cout << "Can't load ini file supposedly located at " << BVDOptions::iniFilePath << std::endl;
exit(2);
}
double t_end = reader.GetReal("simulation", "t_end", 1000.0);
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
System * s = System::getInstance(&reader);
Initializer init = *new Initializer(&reader);
#ifdef _DEBUG_
std::cout << "set init stuff" << std::endl;
#endif
std::cout << "Initializing (blurb)..." << std::endl;
//init.set_number_of_farms( 3 );
//init.set_number_of_slaughterhouses( 2 );
//init.set_number_of_PI_animals_in_farm( 20, 0); // No PI in the system should result in a very different trajectory..
//init.set_age_distribution_in_farm( 0, 4 , 2000, 800 );
#ifdef _DEBUG_
std::cout << "initialize system" << std::endl;
#endif
init.initialize_system ( s );
// Step 3: Log initial state
s->log_state();
//s->output->write_to_file();
if(reader.GetBoolean("modelparam", "inputCows", false)){
s->scheduleFutureCowIntros();
}
std::cout << "Beginning simulation" << std::endl;
s->run_until(t_end);
std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::minutes>( t2 - t1 ).count();
std::cout << "The simulation took " << duration << " minutes" << std::endl;
//Step 5: The system s now contains all cows, farms, events etc. as they result from the run.
// Output has been written to a file as desired and can be used.
// Tests on the system state, further runs continuing from this state are possible.
// However, we quit here, by explicitly deleting s, which prints one line of total stats (how many events and cows have been processed.)
// through the System destructor (see System.cpp).
}
| 34.413333 | 157 | 0.697017 | Yperidis |
64d1e6e1d074cb947df7e9129fd70664dec6801f | 2,589 | cc | C++ | ui/gl/gl_fence_android_native_fence_sync.cc | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | ui/gl/gl_fence_android_native_fence_sync.cc | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | ui/gl/gl_fence_android_native_fence_sync.cc | mghgroup/Glide-Browser | 6a4c1eaa6632ec55014fee87781c6bbbb92a2af5 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2021-01-05T23:43:46.000Z | 2021-01-07T23:36:34.000Z | // Copyright 2017 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 "ui/gl/gl_fence_android_native_fence_sync.h"
#include <sync/sync.h>
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/time/time.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gl/gl_surface_egl.h"
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
#include <unistd.h>
#include "base/posix/eintr_wrapper.h"
#endif
namespace gl {
GLFenceAndroidNativeFenceSync::GLFenceAndroidNativeFenceSync() {}
GLFenceAndroidNativeFenceSync::~GLFenceAndroidNativeFenceSync() {}
// static
std::unique_ptr<GLFenceAndroidNativeFenceSync>
GLFenceAndroidNativeFenceSync::CreateInternal(EGLenum type, EGLint* attribs) {
DCHECK(GLSurfaceEGL::IsAndroidNativeFenceSyncSupported());
// Can't use MakeUnique, the no-args constructor is private.
auto fence = base::WrapUnique(new GLFenceAndroidNativeFenceSync());
if (!fence->InitializeInternal(type, attribs))
return nullptr;
return fence;
}
// static
std::unique_ptr<GLFenceAndroidNativeFenceSync>
GLFenceAndroidNativeFenceSync::CreateForGpuFence() {
return CreateInternal(EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr);
}
// static
std::unique_ptr<GLFenceAndroidNativeFenceSync>
GLFenceAndroidNativeFenceSync::CreateFromGpuFence(
const gfx::GpuFence& gpu_fence) {
gfx::GpuFenceHandle handle =
gfx::CloneHandleForIPC(gpu_fence.GetGpuFenceHandle());
DCHECK_GE(handle.native_fd.fd, 0);
EGLint attribs[] = {EGL_SYNC_NATIVE_FENCE_FD_ANDROID, handle.native_fd.fd,
EGL_NONE};
return CreateInternal(EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
}
std::unique_ptr<gfx::GpuFence> GLFenceAndroidNativeFenceSync::GetGpuFence() {
DCHECK(GLSurfaceEGL::IsAndroidNativeFenceSyncSupported());
EGLint sync_fd = eglDupNativeFenceFDANDROID(display_, sync_);
if (sync_fd < 0)
return nullptr;
gfx::GpuFenceHandle handle;
handle.type = gfx::GpuFenceHandleType::kAndroidNativeFenceSync;
handle.native_fd = base::FileDescriptor(sync_fd, /*auto_close=*/true);
return std::make_unique<gfx::GpuFence>(handle);
}
base::TimeTicks GLFenceAndroidNativeFenceSync::GetStatusChangeTime() {
EGLint sync_fd = eglDupNativeFenceFDANDROID(display_, sync_);
if (sync_fd < 0)
return base::TimeTicks();
base::ScopedFD scoped_fd(sync_fd);
base::TimeTicks time;
gfx::GpuFence::GetStatusChangeTime(sync_fd, &time);
return time;
}
} // namespace gl
| 30.104651 | 78 | 0.769795 | mghgroup |
64d3263e6f48aa065231180afeb61d19a5fea2d4 | 1,080 | hpp | C++ | include/fcppt/math/next_power_of_2.hpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | include/fcppt/math/next_power_of_2.hpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | include/fcppt/math/next_power_of_2.hpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | // Copyright Carl Philipp Reh 2009 - 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef FCPPT_MATH_NEXT_POWER_OF_2_HPP_INCLUDED
#define FCPPT_MATH_NEXT_POWER_OF_2_HPP_INCLUDED
#include <fcppt/literal.hpp>
#include <fcppt/math/is_power_of_2.hpp>
#include <fcppt/config/external_begin.hpp>
#include <type_traits>
#include <fcppt/config/external_end.hpp>
namespace fcppt
{
namespace math
{
/**
\brief Calculates the next power of 2 for an unsigned value
\ingroup fcpptmath
\tparam T An unsigned type
*/
template<
typename T
>
T
next_power_of_2(
T const _value
)
{
static_assert(
std::is_unsigned<
T
>::value,
"next_power_of_2 can only be used on unsigned types"
);
T const two(
fcppt::literal<T>(2)
);
if(
fcppt::math::is_power_of_2(
_value
)
)
return _value * two;
T counter(
_value
);
T ret(
fcppt::literal<T>(1u)
);
while(
counter /= two
)
ret *= two;
return ret * two;
}
}
}
#endif
| 14.794521 | 61 | 0.69537 | vinzenz |
64d36602afc8872cfd6532fef70113ea50f00f3d | 12,200 | hpp | C++ | src/nark/circular_queue.hpp | rockeet/nark-bone | 11263ff5a192c85e4a2776aac1096d01138483d2 | [
"BSD-3-Clause"
] | 18 | 2015-02-12T04:41:22.000Z | 2018-08-22T07:44:13.000Z | src/nark/circular_queue.hpp | rockeet/nark-bone | 11263ff5a192c85e4a2776aac1096d01138483d2 | [
"BSD-3-Clause"
] | null | null | null | src/nark/circular_queue.hpp | rockeet/nark-bone | 11263ff5a192c85e4a2776aac1096d01138483d2 | [
"BSD-3-Clause"
] | 13 | 2015-05-24T12:24:46.000Z | 2021-01-05T10:59:40.000Z | /* vim: set tabstop=4 : */
/********************************************************************
@file circular_queue.hpp
@brief 循环队列的实现
@date 2006-9-28 12:07
@author Lei Peng
@{
*********************************************************************/
#ifndef __circular_queue_hpp_
#define __circular_queue_hpp_
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//#include <vector>
#include <boost/swap.hpp>
namespace nark {
/**
@brief 使用一个用户指定的 vector 类容器实现循环队列
- 循环队列的大小是固定的,其结构是一个环状数组,最少会浪费一个元素的存储空间
- 循环队列可以提供 serial/real_index 序列号,可用于元素的标识(如网络协议中的帧序号)
- 所有输入参数均需要满足其前条件,如果不满足,
Debug 版会引发断言失败,Release 版会导致未定义行为
*/
template<class ElemT>
class circular_queue
{
// valid element count is (m_vec.size() - 1)
ElemT* m_vec;
ptrdiff_t m_head; // point to next pop_front position
ptrdiff_t m_tail; // point to next push_back position
ptrdiff_t m_nlen;
ptrdiff_t prev(ptrdiff_t current) const throw()
{
ptrdiff_t i = current - 1;
return i >=0 ? i : i + m_nlen; // == (i + m_nlen) % m_nlen, but more fast
// return (current + m_vec.size() - 1) % m_vec.size();
}
ptrdiff_t next(ptrdiff_t current) const throw()
{
ptrdiff_t i = current + 1;
return i < m_nlen ? i : i - m_nlen; // == i % m_nlen, but more fast
// return (current + 1) % m_vec.size();
}
ptrdiff_t prev_n(ptrdiff_t current, ptrdiff_t n) const throw()
{
assert(n < m_nlen);
ptrdiff_t i = current - n;
return i >=0 ? i : i + m_nlen; // == i % c, but more fast
// return (current + m_vec.size() - n) % m_vec.size();
}
ptrdiff_t next_n(ptrdiff_t current, ptrdiff_t n) const throw()
{
assert(n < m_nlen);
ptrdiff_t c = m_nlen;
ptrdiff_t i = current + n;
return i < c ? i : i - c; // == i % c, but more fast
// return (current + n) % m_vec.size();
}
public:
typedef ElemT value_type;
typedef ElemT& reference;
typedef const ElemT& const_reference;
typedef ElemT* pointer;
typedef const ElemT* const_pointer;
typedef uintptr_t size_type;
class const_iterator
{
friend class circular_queue;
const ElemT* p;
const circular_queue* queue;
const ElemT* base() const throw() { return &queue->m_vec[0]; }
typedef const_iterator my_type;
public:
my_type operator++() const throw()
{ p = base() + queue->next(p - base()); return *this; }
my_type operator++(int) const throw()
{ my_type temp = ++(*this); return temp; }
my_type operator--() const throw()
{ p = base() + queue->prev(p - base()); return *this; }
my_type operator--(int) const throw()
{ my_type temp = --(*this); return temp; }
my_type& operator+=(ptrdiff_t distance) throw()
{ p = base() + queue->next_n(p - base()); return *this; }
my_type& operator-=(ptrdiff_t distance) throw()
{ p = base() + queue->prev_n(p - base()); return *this; }
my_type operator+(ptrdiff_t distance) throw()
{ my_type temp = *this; temp += distance; return temp; }
my_type operator-(ptrdiff_t distance) throw()
{ my_type temp = *this; temp -= distance; return temp; }
bool operator==(const my_type& r) const throw() { return p == r.p; }
bool operator!=(const my_type& r) const throw() { return p != r.p; }
bool operator< (const my_type& r) const throw()
{
return queue->virtual_index(p - base()) <
queue->virtual_index(r.p - base());
}
bool operator> (const my_type& r) const throw()
{
return queue->virtual_index(p - base()) >
queue->virtual_index(r.p - base());
}
bool operator<=(const my_type& r) const throw()
{
return queue->virtual_index(p - base()) <=
queue->virtual_index(r.p - base());
}
bool operator>=(const my_type& r) const throw()
{
return queue->virtual_index(p - base()) >=
queue->virtual_index(r.p - base());
}
const ElemT& operator *() const throw() { return *p; }
const ElemT* operator->() const throw() { return p; }
};
class iterator
{
friend class circular_queue;
ElemT* p;
circular_queue* queue;
ElemT* base() const throw() { return &queue->m_vec[0]; }
typedef iterator my_type;
public:
my_type operator++() const throw()
{ p = base() + queue->next(p - base()); return *this; }
my_type operator++(int) const throw()
{ my_type temp = ++(*this); return temp; }
my_type operator--() const throw()
{ p = base() + queue->prev(p - base()); return *this; }
my_type operator--(int) const throw()
{ my_type temp = --(*this); return temp; }
my_type& operator+=(ptrdiff_t distance) throw()
{ p = base() + queue->next_n(p - base()); return *this; }
my_type& operator-=(ptrdiff_t distance) throw()
{ p = base() + queue->prev_n(p - base()); return *this; }
my_type operator+(ptrdiff_t distance) throw()
{ my_type temp = *this; temp += distance; return temp; }
my_type operator-(ptrdiff_t distance) throw()
{ my_type temp = *this; temp -= distance; return temp; }
bool operator==(const my_type& r) const throw() { return p == r.p; }
bool operator!=(const my_type& r) const throw() { return p != r.p; }
bool operator< (const my_type& r) const throw()
{
return queue->virtual_index(p - base()) <
queue->virtual_index(r.p - base());
}
bool operator> (const my_type& r) const throw()
{
return queue->virtual_index(p - base()) >
queue->virtual_index(r.p - base());
}
bool operator<=(const my_type& r) const throw()
{
return queue->virtual_index(p - base()) <=
queue->virtual_index(r.p - base());
}
bool operator>=(const my_type& r) const throw()
{
return queue->virtual_index(p - base()) >=
queue->virtual_index(r.p - base());
}
ElemT& operator *() const throw() { return *p; }
ElemT* operator->() const throw() { return p; }
operator const const_iterator&() const throw()
{ return *reinterpret_cast<const const_iterator*>(this); }
};
friend class const_iterator;
friend class iterator;
/**
@brief 构造最多能容纳 capacity 个有效元素的循环队列
*/
explicit circular_queue(ptrdiff_t capacity) : m_nlen(capacity + 1)
{
assert(capacity != 0);
m_vec = (ElemT*)malloc(sizeof(ElemT) * m_nlen);
if (NULL == m_vec) throw std::bad_alloc();
m_head = m_tail = 0;
}
circular_queue() {
m_vec = NULL;
m_nlen = m_head = m_tail = 0;
}
void init(ptrdiff_t capacity) {
assert(0 == m_nlen);
new(this)circular_queue(capacity);
}
~circular_queue() {
clear();
if (m_vec) ::free(m_vec);
}
/**
@brief 清除队列中的有效元素
- 前条件:无
- 操作结果:队列为空
*/
void clear()
{
while (!empty())
pop_front();
m_head = m_tail = 0;
}
/**
@brief 测试队列是否为空
- 前条件:无
@return true 表示队列为空,false 表示非空
*/
bool empty() const throw() { return m_head == m_tail; }
/**
@brief 测试队列是否已满
- 前条件:无
@return true 表示队列已满,false 表示未满
*/
bool full() const throw() { return next(m_tail) == m_head; }
// bool full() const throw() { return m_tail+1==m_head || (m_head+m_nlen-1==m_tail); }
/**
@brief 返回队列当前尺寸
- 前条件:无
@return 队列中有效元素的个数,总小于等于 capacity
*/
size_type size() const throw() { return m_head <= m_tail ? m_tail - m_head : m_tail + m_nlen - m_head; }
/**
@brief 返回队列容量
- 前条件:无
@return 即构造该对象时传入的参数,或者 resize 后的新容量
*/
size_type capacity() const throw() { return m_nlen - 1; }
/**
@brief 在队列尾部加入一个新元素
- 前条件:队列不满
- 操作结果:新元素被添加到队列尾部
*/
void push_back(const ElemT& val)
{
assert(!full());
new(&m_vec[m_tail])ElemT(val);
m_tail = next(m_tail);
}
//@{
/**
@brief 返回队列头部的那个元素
- 前条件:队列不空
*/
const ElemT& front() const throw()
{
assert(!empty());
return m_vec[m_head];
}
ElemT& front() throw()
{
assert(!empty());
return m_vec[m_head];
}
//@}
/**
@brief 弹出队列头部的那个元素并通过 out 参数 val 返回
- 前条件:队列不空
@param[out] val 队列头部元素将被复制进 val
*/
void pop_front(ElemT& val)
{
assert(!empty());
boost::swap(val, m_vec);
m_vec[m_head].~ElemT();
m_head = next(m_head);
}
/**
@brief 弹出队列头部的那个元素
- 前条件:队列不空
该函数与 stl vector/list/deque 兼容
*/
void pop_front()
{
assert(!empty());
m_vec[m_head].~ElemT();
m_head = next(m_head);
}
/**
@brief 弹出序列号小于等于输入参数 real_index 的所有元素
pop all elements which real_index is earlier or equal than real_index
- 前条件:队列不空,且参数 real_index 代表的元素必须在队列中
*/
void pop_lower(ptrdiff_t real_index)
{
assert(!empty());
// because poped elements can be equal with real_index
// poped elements count is (virtual_index(real_index) + 1)
ptrdiff_t count = virtual_index(real_index) + 1;
assert(count <= size());
while (count-- > 0)
{
pop_front();
}
}
/**
@name 不是队列操作的成员
none queue operations.
只是为了功能扩展
@{
*/
/**
@brief 在队列头部加入新元素
- 前条件:队列不满
- 操作结果:队列中现存元素的 real_index 均增一,新元素 val 成为新的队头
*/
void push_front(const ElemT& val)
{
assert(!full());
m_head = prev(m_head);
new(&m_vec[m_head])ElemT(val);
}
//@{
/** 返回队列尾部元素 前条件:队列不空 */
ElemT& back() throw()
{
assert(!empty());
return m_vec[prev(m_tail)];
}
const ElemT& back() const throw()
{
assert(!empty());
return m_vec[prev(m_tail)];
}
//@}
/**
@brief 弹出队列尾部元素
- 前条件:队列不空
*/
void pop_back(ElemT& val)
{
assert(!empty());
m_tail = prev(m_tail);
boost::swap(val, m_vec[m_tail]);
m_vec[m_tail].~ElemT();
}
/**
@brief 弹出队列尾部元素
- 前条件:队列不空
*/
void pop_back()
{
assert(!empty());
m_tail = prev(m_tail);
m_vec[m_tail].~ElemT();
}
/**
@brief 弹出序列号比大于等于输入参数 real_index 的所有元素
pop elements which real_index is later or equal than real_index
- 前条件:队列不空,且参数 real_index 代表的元素必须在队列中
*/
void pop_upper(ptrdiff_t real_index)
{
assert(!empty());
// because poped elements can be equal with real_index
// if not include the equal one, count is (size() - virtual_index(real_index) - 1);
ptrdiff_t count = size() - virtual_index(real_index);
assert(count <= size());
while (count-- > 0)
{
pop_back();
}
}
//@} // name 不是队列操作的成员
/**
@name iterator 相关成员
@{
*/
iterator begin() throw()
{
iterator iter;
iter.queue = this;
iter.p = m_vec + m_head;
return iter;
}
const_iterator begin() const throw()
{
iterator iter;
iter.queue = this;
iter.p = m_vec + m_head;
return iter;
}
iterator end() throw()
{
iterator iter;
iter.queue = this;
iter.p = m_vec + m_tail;
return iter;
}
const_iterator end() const throw()
{
iterator iter;
iter.queue = this;
iter.p = m_vec + m_tail;
return iter;
}
//@}
/**
@brief 通过real_index取得元素相对于队头的偏移
*/
ptrdiff_t virtual_index(ptrdiff_t real_index) const throw()
{
assert(real_index >= 0);
assert(real_index < (ptrdiff_t)size());
ptrdiff_t i = real_index - m_head;
return i >= 0 ? i : i + m_nlen;
// return (m_vec.size() + real_index - m_head) % m_vec.size();
}
/**
@brief 通过virtual_index取得元素的序列号
*/
ptrdiff_t real_index(ptrdiff_t virtual_index) const throw()
{
assert(virtual_index >= 0);
assert(virtual_index < size());
ptrdiff_t i = virtual_index + m_head;
return i < m_nlen ? i : i - m_nlen;
// return (virtual_index + m_head) % m_vec.size();
}
/**
@brief 队头的序列号
*/
ptrdiff_t head_real_index() const throw() { return m_head; }
/**
@brief 队尾的序列号
*/
ptrdiff_t tail_real_index() const throw() { return m_tail; }
/**
@brief 通过 virtual_index 取得元素
@{
*/
ElemT& operator[](ptrdiff_t virtual_index)
{
assert(virtual_index >= 0);
assert(virtual_index < size());
ptrdiff_t c = m_nlen;
ptrdiff_t i = m_head + virtual_index;
ptrdiff_t j = i < c ? i : i - c;
return m_vec[j];
// return m_vec[(m_head + virtual_index) % m_vec.size()];
}
const ElemT& operator[](ptrdiff_t virtual_index) const
{
assert(virtual_index >= 0);
assert(virtual_index < size());
ptrdiff_t c = m_nlen;
ptrdiff_t i = m_head + virtual_index;
ptrdiff_t j = i < c ? i : i - c;
return m_vec[j];
// return m_vec[(m_head + virtual_index) % m_vec.size()];
}
//@}
};
/*
template<class ElemT, class VectorT>
inline
circular_queue<ElemT, VectorT>::const_iterator
operator+(ptrdiff_t n, const circular_queue<ElemT, VectorT>::const_iterator& iter)
{
return iter + n;
}
template<class ElemT, class VectorT>
inline
circular_queue<ElemT, VectorT>::iterator
operator+(ptrdiff_t n, const circular_queue<ElemT, VectorT>::iterator& iter)
{
return iter + n;
}
*/
} // namespace nark
#endif
// @} end file circular_queue.hpp
| 22.426471 | 105 | 0.629344 | rockeet |
64d5fd430e8bd0617350ac39defc8981f14ea986 | 555 | hpp | C++ | include/alx/UserEvent.hpp | SpaceManiac/ALX | d0d6b17be43fbd533f05f79c630dcd3ebf0a21e6 | [
"BSD-3-Clause"
] | null | null | null | include/alx/UserEvent.hpp | SpaceManiac/ALX | d0d6b17be43fbd533f05f79c630dcd3ebf0a21e6 | [
"BSD-3-Clause"
] | null | null | null | include/alx/UserEvent.hpp | SpaceManiac/ALX | d0d6b17be43fbd533f05f79c630dcd3ebf0a21e6 | [
"BSD-3-Clause"
] | null | null | null | #ifndef ALX_USEREVENT_HPP
#define ALX_USEREVENT_HPP
namespace alx {
/**
Base class for user events.
*/
class UserEvent {
public:
/**
constructor.
@param type event type.
*/
UserEvent(int type) : m_type(type) {
}
/**
destructor.
*/
virtual ~UserEvent() {
}
/**
Returns the type of event.
@return the type of event.
*/
int getType() const {
return m_type;
}
private:
//type
int m_type;
};
} //namespace alx
#endif //ALX_USEREVENT_HPP
| 12.613636 | 40 | 0.545946 | SpaceManiac |
64d6e51067ebce9bacbd43ac1c8ba145e77c379a | 675 | cpp | C++ | code-samples/Conditionals/Exercise_6.cpp | csdeptku/cs141 | befd96cb22bccc9b1561224967c9feafd2a550e4 | [
"Apache-2.0"
] | null | null | null | code-samples/Conditionals/Exercise_6.cpp | csdeptku/cs141 | befd96cb22bccc9b1561224967c9feafd2a550e4 | [
"Apache-2.0"
] | null | null | null | code-samples/Conditionals/Exercise_6.cpp | csdeptku/cs141 | befd96cb22bccc9b1561224967c9feafd2a550e4 | [
"Apache-2.0"
] | null | null | null | /*
Write a function word_check that takes in a string word and returns a string.
The function should return the string "long" if the word is longer than 6 characters,
"short" if it is less than 6 characters, and "medium" if it is exactly 6 characters long.
*/
#include <iostream>
using namespace std;
string word_check(string word)
{
int length = word.length();
if (length > 6)
return "long";
else if (length < 6)
return "short";
else
return "medium";
}
int main(void)
{
cout << word_check("contraption") << endl;
cout << word_check("fruit") << endl;
cout << word_check("puzzle") << endl;
return 0;
} | 23.275862 | 93 | 0.634074 | csdeptku |
64d7abf482cd886893df1d97ba95505b45bb3081 | 3,086 | cpp | C++ | samples/MDDSSample/src/MDDSSampleApp.cpp | heisters/Cinder-MDDS | 2531ea668eff1aef8e98ca76863242e0bb3a2c54 | [
"MIT"
] | 2 | 2015-03-10T17:51:49.000Z | 2015-04-29T14:34:00.000Z | samples/MDDSSample/src/MDDSSampleApp.cpp | heisters/Cinder-MDDS | 2531ea668eff1aef8e98ca76863242e0bb3a2c54 | [
"MIT"
] | null | null | null | samples/MDDSSample/src/MDDSSampleApp.cpp | heisters/Cinder-MDDS | 2531ea668eff1aef8e98ca76863242e0bb3a2c54 | [
"MIT"
] | null | null | null | #include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"
#include "cinder/Utilities.h"
#include "cinder/Text.h"
#include "cinder/Rand.h"
#include <boost/format.hpp>
#include "MDDSMovie.h"
class MDDSSampleApp : public ci::app::AppNative {
public:
MDDSSampleApp();
// Lifecycle ---------------------------------------------------------------
void prepareSettings( Settings *settings );
void setup();
void update();
void draw();
// Events ------------------------------------------------------------------
void keyDown( ci::app::KeyEvent event );
protected:
mdds::MovieRef mMovie;
ci::Font mFont;
};
using namespace ci;
using namespace ci::app;
using namespace std;
MDDSSampleApp::MDDSSampleApp() :
mFont( "Helvetica", 14 )
{
}
void
MDDSSampleApp::prepareSettings( Settings *settings )
{
settings->setWindowSize( 1920, 1080 );
settings->setFrameRate( 60 );
}
void
MDDSSampleApp::setup()
{
try
{
mMovie = mdds::Movie::create( getFolderPath(), ".DDS", 29.97 );
}
catch ( mdds::Movie::LoadError boom )
{
console() << "Error loading movie: " << boom.what() << endl;
}
}
void
MDDSSampleApp::update()
{
if ( mMovie ) mMovie->update();
}
void
MDDSSampleApp::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );
if ( mMovie ) mMovie->draw();
TextLayout info;
info.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
info.setColor( ColorA::white() );
info.setBorder( 4, 2 );
info.setFont( mFont );
info.addLine( (boost::format( "App FPS: %.2d" ) % getAverageFps()).str() );
info.addLine( (boost::format( "Movie FPS: %.2d" ) % mMovie->getFrameRate()).str() );
info.addLine( (boost::format( "Play rate: %.2d" ) % mMovie->getPlayRate()).str() );
info.addLine( (boost::format( "Average playback FPS: %.2d" ) % mMovie->getAverageFps()).str() );
info.addLine( "Controls:" );
info.addLine( "↑: double playback rate" );
info.addLine( "↓: halve playback rate" );
info.addLine( "f: play forward at normal rate" );
info.addLine( "r: play reverse at normal rate" );
info.addLine( "space: pause" );
info.addLine( "↵: jump to random frame" );
gl::draw( gl::Texture( info.render( true ) ), Vec2f( 10, 10 ) );
}
void
MDDSSampleApp::keyDown( KeyEvent event )
{
if ( event.getChar() == 'f' )
mMovie->setPlayRate( 1.0 );
else if ( event.getChar() == 'r' )
mMovie->setPlayRate( -1.0 );
else if ( event.getCode() == KeyEvent::KEY_UP )
mMovie->setPlayRate( mMovie->getPlayRate() * 2.0 );
else if ( event.getCode() == KeyEvent::KEY_DOWN )
mMovie->setPlayRate( mMovie->getPlayRate() * 0.5 );
else if ( event.getCode() == KeyEvent::KEY_SPACE )
mMovie->setPlayRate( 0.0 );
else if ( event.getCode() == KeyEvent::KEY_RETURN )
mMovie->seekToFrame( Rand::randInt( mMovie->getNumFrames() ) );
}
CINDER_APP_NATIVE( MDDSSampleApp, RendererGl )
| 26.834783 | 100 | 0.568049 | heisters |
64d96398fd9eec516cb2142498338c782b41ada1 | 947 | hpp | C++ | examples/saber-salient/include/saber-salient.hpp | achirkin/real-salient | e3bceca601562aa03ee4261ba41709b63cc5286b | [
"BSD-3-Clause"
] | 9 | 2020-07-05T08:21:39.000Z | 2021-10-30T09:52:43.000Z | examples/saber-salient/include/saber-salient.hpp | achirkin/real-salient | e3bceca601562aa03ee4261ba41709b63cc5286b | [
"BSD-3-Clause"
] | null | null | null | examples/saber-salient/include/saber-salient.hpp | achirkin/real-salient | e3bceca601562aa03ee4261ba41709b63cc5286b | [
"BSD-3-Clause"
] | 1 | 2020-07-05T10:45:12.000Z | 2020-07-05T10:45:12.000Z | #pragma once
#include "salient/salient_structs.hpp"
extern "C"
{
struct SaberSalient;
__declspec(dllexport) int SaberSalient_init(SaberSalient** out_SaberSalient, void (*in_loadColor)(uint8_t*), void (*in_loadDepth)(float*));
__declspec(dllexport) void SaberSalient_destroy(SaberSalient *in_SaberSalient);
__declspec(dllexport) int SaberSalient_cameraIntrinsics(SaberSalient *in_SaberSalient, salient::CameraIntrinsics *out_intrinsics);
__declspec(dllexport) int SaberSalient_currentTransform(SaberSalient* in_SaberSalient, float *out_mat44);
__declspec(dllexport) int SaberSalient_currentPosition(SaberSalient* in_SaberSalient, float* out_vec3);
__declspec(dllexport) int SaberSalient_currentRotation(SaberSalient* in_SaberSalient, float* out_mat33);
__declspec(dllexport) uint8_t* SaberSalient_getColorBuf(SaberSalient* in_SaberSalient);
__declspec(dllexport) float* SaberSalient_getDepthBuf(SaberSalient* in_SaberSalient);
} | 37.88 | 140 | 0.832101 | achirkin |
64dae19794cdf5135cfd229799f8817dfc574153 | 294 | cxx | C++ | src/gtbary/gtbary.cxx | fermi-lat/timeSystem | ae46f5863bc345ed9491a53fa9af611536c7f41c | [
"BSD-3-Clause"
] | null | null | null | src/gtbary/gtbary.cxx | fermi-lat/timeSystem | ae46f5863bc345ed9491a53fa9af611536c7f41c | [
"BSD-3-Clause"
] | null | null | null | src/gtbary/gtbary.cxx | fermi-lat/timeSystem | ae46f5863bc345ed9491a53fa9af611536c7f41c | [
"BSD-3-Clause"
] | null | null | null | /** \file gtbary.cxx
\brief Factory for gtbary application.
\authors Masaharu Hirayama, GSSC,
James Peachey, HEASARC/GSSC
*/
#include "timeSystem/TimeCorrectorApp.h"
#include "st_app/StAppFactory.h"
st_app::StAppFactory<timeSystem::TimeCorrectorApp> g_factory("gtbary");
| 26.727273 | 71 | 0.727891 | fermi-lat |
64dc3178a38f6c13407c3d84a4880b8359e6f9ba | 5,799 | hpp | C++ | AutomatedScheduler/include/TextHandler.hpp | Electrux/CCPP-Code | 3c5e5b866cf050c11bced9651b112eb31dd2465d | [
"BSD-3-Clause"
] | 6 | 2019-08-29T23:31:17.000Z | 2021-11-14T20:35:47.000Z | AutomatedScheduler/include/TextHandler.hpp | Electrux/CCPP-Code | 3c5e5b866cf050c11bced9651b112eb31dd2465d | [
"BSD-3-Clause"
] | null | null | null | AutomatedScheduler/include/TextHandler.hpp | Electrux/CCPP-Code | 3c5e5b866cf050c11bced9651b112eb31dd2465d | [
"BSD-3-Clause"
] | 1 | 2019-09-01T12:22:58.000Z | 2019-09-01T12:22:58.000Z | #ifndef TEXT_HANDLER_HPP
#define TEXT_HANDLER_HPP
#include <SFML/Graphics.hpp>
#include "Data.hpp"
class TextHandler : public sf::Drawable
{
std::string text, typwhat, typwhat2, _count, _time;
sf::Text temptext, typehere, typewhat, typewhat2, counts, time;
std::vector<sf::Text> drawtext;
int count;
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(typehere, states);
target.draw(typewhat, states);
target.draw(typewhat2, states);
target.draw(counts, states);
target.draw(time, states);
for (auto it = drawtext.begin(); it != drawtext.end(); ++it)
{
target.draw(*it, states);
}nn
}
void SetDrawText(std::string &text, float variation = 0)
{
temptext.setString(text);
temptext.setPosition((float)10 + variation, (float)470);
drawtext.push_back(temptext);
int tempcount = count;
bool deletefront = false;
for (auto it = drawtext.begin(); it != drawtext.end(); ++it)
{
if ((470 - (tempcount * 20)) <= 20)
{
deletefront = true;
}
else
it->setPosition(it->getPosition().x, (float)(470 - (tempcount * 20)));
tempcount--;
}
if (deletefront == true)
{
drawtext.erase(drawtext.begin());
}
else
count++;
}
public:
TextHandler()
{
count = 0;
temptext.setFont(font);
temptext.setFillColor(sf::Color::White);
temptext.setCharacterSize(15);
typehere.setFont(font);
typehere.setFillColor(sf::Color::White);
typehere.setCharacterSize(15);
typehere.setPosition((float)10, (float)510);
typewhat.setFont(font);
typewhat.setFillColor(sf::Color::White);
typewhat.setCharacterSize(15);
typewhat.setPosition((float)10, (float)530);
typewhat2.setFont(font);
typewhat2.setFillColor(sf::Color::White);
typewhat2.setCharacterSize(15);
typewhat2.setPosition((float)10, (float)550);
counts.setFont(font);
counts.setFillColor(sf::Color::Green);
counts.setCharacterSize(15);
counts.setPosition((float)10, (float)10);
_count = "Jobs: Updating...";
counts.setString(_count);
time.setFont(font);
time.setFillColor(sf::Color::Green);
time.setCharacterSize(15);
time.setPosition((float)550, (float)10);
_time = "Time: Updating...";
time.setString(_time);
typehere.setString("Command:");
typewhat.setString("");
typewhat.setString("");
typwhat.clear();
typwhat2.clear();
}
void AddText(std::string &ttext)
{
text = ttext;
std::string linetext;
std::vector<std::string> alllines;
bool firstline = false;
int linecount = 0, letters = 0, netletters = GetStringSize(text), templinecount = 1;
if (netletters <= 90)
{
alllines.push_back(text);
}
else
{
for (auto it = text.begin(); it != text.end(); ++it)
{
if (letters > 90 && firstline == false)
{
letters = 0;
alllines.push_back(linetext);
linetext.clear();
linecount++;
firstline = true;
}
else if (letters >= 84 && firstline == true)
{
letters = 0;
alllines.push_back(linetext);
linetext.clear();
linecount++;
}
else if ((netletters - ((linecount * 84))) <= 84)
{
linetext += FetchFrom(text, it);
alllines.push_back(linetext);
linecount++;
break;
}
linetext += *it;
letters++;
}
}
for (auto it = alllines.begin(); it != alllines.end(); ++it)
{
if (templinecount > 1)
SetDrawText(*it, 80);
else
SetDrawText(*it);
templinecount++;
}
}
std::string FetchFrom(std::string &_text, std::string::iterator _it)
{
std::string temp;
bool found = false;
for (auto it = _text.begin(); it != text.end(); ++it)
{
if (found == true)
temp += *it;
if (it == _it)
{
temp += *it;
found = true;
}
}
return temp;
}
void UpdateCount(std::string &__count)
{
_count = "Jobs: " + __count;
counts.setString(_count);
}
void UpdateTime(std::string &__time)
{
_time = "Time: " + __time;
time.setString(_time);
}
void UpdateTypeWhat(char c)
{
if (c != 8)
{
if (GetStringSize(typwhat) >= 90)
{
typwhat2 += c;
}
else
{
typwhat += c;
}
}
else if (!typwhat.empty())
{
if (!typwhat2.empty())
{
typwhat2.pop_back();
}
else
{
typwhat.pop_back();
}
}
typewhat.setString(typwhat);
typewhat2.setString(typwhat2);
}
int GetStringSize(std::string &str)
{
int num = 0;
for (auto it = str.begin(); it != str.end(); ++it)
{
num++;
}
return num;
}
void ClearTyped()
{
typwhat.clear();
typewhat.setString("");
typwhat2.clear();
typewhat2.setString("");
}
std::string GetTyped()
{
return typwhat + typwhat2;
}
bool getDelimitedStrings(std::string &str, std::vector<std::string> *_dest, int args = 3, char delim = ' ')
{
std::string temp;
int delimcounter = 0;
for (std::string::iterator it = str.begin(); it != str.end(); it++)
{
if ((*it == delim || delimcounter == args - 1))
{
if (delimcounter == args - 1)
{
_dest->push_back(cutStringFrom(&str, &it));
delimcounter++;
break;
}
_dest->push_back(temp);
temp.clear();
delimcounter++;
}
else
{
temp += (*it);
}
}
return (delimcounter == args) ? true : false;
}
std::string cutStringFrom(std::string *str, std::string::iterator *it)
{
std::string temp;
int reach = 0;
for (std::string::iterator it2 = str->begin(); it2 != str->end(); it2++)
{
if (!reach)
{
if (*it == it2)
{
reach = 1;
temp += *it2;
}
}
else
temp += *it2;
}
return temp;
}
};
#endif // TEXT_HANDLER_HPP
| 22.04943 | 109 | 0.583032 | Electrux |
64e1c2b4ba3a945831eeb80a7d9b65338f08b00c | 8,821 | cpp | C++ | runtime/device.cpp | fletcherjiang/ssm-alipay | d7cd911c72c2538859597b9ed3c96d02693febf2 | [
"Apache-2.0"
] | 169 | 2021-10-07T03:50:42.000Z | 2021-12-20T01:55:51.000Z | runtime/device.cpp | fletcherjiang/ssm-alipay | d7cd911c72c2538859597b9ed3c96d02693febf2 | [
"Apache-2.0"
] | 11 | 2021-10-09T01:53:49.000Z | 2021-10-09T01:53:49.000Z | runtime/device.cpp | JoeAnimation/ssm-alipay | d7cd911c72c2538859597b9ed3c96d02693febf2 | [
"Apache-2.0"
] | 56 | 2021-10-07T03:50:53.000Z | 2021-10-12T00:41:59.000Z | /**
* @file device.cpp
*
* Copyright (C) Huawei Technologies Co., Ltd. 2019-2020. All Rights Reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "acl/acl_rt.h"
#include <cstring>
#include "runtime/dev.h"
#include "runtime/context.h"
#include "framework/executor/ge_executor.h"
#include "log_inner.h"
#include "error_codes_inner.h"
#include "toolchain/profiling_manager.h"
#include "toolchain/resource_statistics.h"
#include "set_device_vxx.h"
#include "common_inner.h"
namespace {
std::map<int32_t, uint64_t> g_deviceCounterMap;
std::mutex g_deviceCounterMutex;
void IncDeviceCounter(const int32_t deviceId)
{
std::unique_lock<std::mutex> lk(g_deviceCounterMutex);
auto iter = g_deviceCounterMap.find(deviceId);
if (iter == g_deviceCounterMap.end()) {
g_deviceCounterMap[deviceId] = 1U;
} else {
++iter->second;
}
}
bool DecDeviceCounter(const int32_t deviceId)
{
std::unique_lock<std::mutex> lk(g_deviceCounterMutex);
auto iter = g_deviceCounterMap.find(deviceId);
if (iter != g_deviceCounterMap.end()) {
if (iter->second != 0U) {
--iter->second;
if (iter->second == 0U) {
return true;
}
}
} else {
ACL_LOG_INFO("device %d has not been set.", deviceId);
}
return false;
}
}
aclError aclrtSetDevice(int32_t deviceId)
{
ACL_PROFILING_REG(ACL_PROF_FUNC_RUNTIME);
ACL_ADD_APPLY_TOTAL_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
ACL_LOG_INFO("start to execute aclrtSetDevice, deviceId = %d.", deviceId);
rtError_t rtErr = rtSetDevice(deviceId);
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("open device %d failed, runtime result = %d.", deviceId, static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
IncDeviceCounter(deviceId);
ACL_LOG_INFO("successfully execute aclrtSetDevice, deviceId = %d", deviceId);
ACL_ADD_APPLY_SUCCESS_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
return ACL_SUCCESS;
}
aclError aclrtSetDeviceWithoutTsdVXX(int32_t deviceId)
{
ACL_PROFILING_REG(ACL_PROF_FUNC_RUNTIME);
ACL_ADD_APPLY_TOTAL_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
ACL_LOG_INFO("start to execute aclrtSetDeviceWithoutTsdVXX, deviceId = %d.", deviceId);
const std::string socVersion = GetSocVersion();
if (strncmp(socVersion.c_str(), "Ascend910", strlen("Ascend910")) != 0) {
ACL_LOG_INFO("The soc version is not Ascend910, not support");
return ACL_ERROR_API_NOT_SUPPORT;
}
rtError_t rtErr = rtSetDeviceWithoutTsd(deviceId);
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("open device %d failed, runtime result = %d.", deviceId, static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
IncDeviceCounter(deviceId);
ACL_LOG_INFO("open device %d successfully.", deviceId);
ACL_ADD_APPLY_SUCCESS_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
return ACL_SUCCESS;
}
aclError aclrtResetDevice(int32_t deviceId)
{
ACL_PROFILING_REG(ACL_PROF_FUNC_RUNTIME);
ACL_ADD_RELEASE_TOTAL_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
ACL_LOG_INFO("start to execute aclrtResetDevice, deviceId = %d.", deviceId);
if (DecDeviceCounter(deviceId)) {
ACL_LOG_INFO("device %d reference count is 0.", deviceId);
// get default context
rtContext_t rtDefaultCtx = nullptr;
rtError_t rtErr = rtGetPriCtxByDeviceId(deviceId, &rtDefaultCtx);
if ((rtErr == RT_ERROR_NONE) && (rtDefaultCtx != nullptr)) {
ACL_LOG_INFO("try release op resource for device %d.", deviceId);
(void) ge::GeExecutor::ReleaseSingleOpResource(rtDefaultCtx);
}
}
rtError_t rtErr = rtDeviceReset(deviceId);
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("reset device %d failed, runtime result = %d.", deviceId, static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
ACL_LOG_INFO("successfully execute aclrtResetDevice, reset device %d.", deviceId);
ACL_ADD_RELEASE_SUCCESS_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
return ACL_SUCCESS;
}
aclError aclrtResetDeviceWithoutTsdVXX(int32_t deviceId)
{
ACL_PROFILING_REG(ACL_PROF_FUNC_RUNTIME);
ACL_ADD_RELEASE_TOTAL_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
ACL_LOG_INFO("start to execute aclrtResetDeviceWithoutTsdVXX, deviceId = %d.", deviceId);
const std::string socVersion = GetSocVersion();
if (strncmp(socVersion.c_str(), "Ascend910", strlen("Ascend910")) != 0) {
ACL_LOG_INNER_ERROR("The soc version is not Ascend910, not support");
return ACL_ERROR_API_NOT_SUPPORT;
}
if (DecDeviceCounter(deviceId)) {
ACL_LOG_INFO("device %d reference count is 0.", deviceId);
// get default context
rtContext_t rtDefaultCtx = nullptr;
rtError_t rtErr = rtGetPriCtxByDeviceId(deviceId, &rtDefaultCtx);
if ((rtErr == RT_ERROR_NONE) && (rtDefaultCtx != nullptr)) {
ACL_LOG_INFO("try release op resource for device %d.", deviceId);
(void) ge::GeExecutor::ReleaseSingleOpResource(rtDefaultCtx);
}
}
rtError_t rtErr = rtDeviceResetWithoutTsd(deviceId);
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("reset device %d failed, runtime result = %d.", deviceId, static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
ACL_LOG_INFO("successfully execute aclrtResetDeviceWithoutTsdVXX, reset device %d", deviceId);
ACL_ADD_RELEASE_SUCCESS_COUNT(ACL_STATISTICS_SET_RESET_DEVICE);
return ACL_SUCCESS;
}
aclError aclrtGetDevice(int32_t *deviceId)
{
ACL_LOG_INFO("start to execute aclrtGetDevice");
ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(deviceId);
rtError_t rtErr = rtGetDevice(deviceId);
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_WARN("get device failed, runtime result = %d.", static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
ACL_LOG_DEBUG("successfully execute aclrtGetDevice, get device id is %d.", *deviceId);
return ACL_SUCCESS;
}
aclError aclrtGetRunMode(aclrtRunMode *runMode)
{
ACL_LOG_INFO("start to execute aclrtGetRunMode");
ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(runMode);
rtRunMode rtMode;
rtError_t rtErr = rtGetRunMode(&rtMode);
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("get runMode failed, runtime result = %d.", static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
if (rtMode == RT_RUN_MODE_OFFLINE) {
*runMode = ACL_DEVICE;
return ACL_SUCCESS;
}
*runMode = ACL_HOST;
ACL_LOG_INFO("successfully execute aclrtGetRunMode, current runMode is %d.", static_cast<int32_t>(*runMode));
return ACL_SUCCESS;
}
aclError aclrtSynchronizeDevice()
{
ACL_PROFILING_REG(ACL_PROF_FUNC_RUNTIME);
ACL_LOG_INFO("start to execute aclrtSynchronizeDevice");
rtError_t rtErr = rtDeviceSynchronize();
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("wait for compute device to finish failed, runtime result = %d.",
static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
ACL_LOG_INFO("device synchronize successfully.");
return ACL_SUCCESS;
}
aclError aclrtSetTsDevice(aclrtTsId tsId)
{
ACL_PROFILING_REG(ACL_PROF_FUNC_RUNTIME);
ACL_LOG_INFO("start to execute aclrtSetTsDevice, tsId = %d.", static_cast<int32_t>(tsId));
if ((tsId != ACL_TS_ID_AICORE) && (tsId != ACL_TS_ID_AIVECTOR)) {
ACL_LOG_INNER_ERROR("invalid tsId, tsID is %d.", static_cast<int32_t>(tsId));
return ACL_ERROR_INVALID_PARAM;
}
rtError_t rtErr = rtSetTSDevice(static_cast<uint32_t>(tsId));
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("set device ts %d failed, runtime result = %d.", static_cast<int32_t>(tsId), rtErr);
return ACL_GET_ERRCODE_RTS(rtErr);
}
ACL_LOG_INFO("successfully execute aclrtSetTsDevice, set device ts %d", static_cast<int32_t>(tsId));
return ACL_SUCCESS;
}
aclError aclrtGetDeviceCount(uint32_t *count)
{
ACL_LOG_INFO("start to execute aclrtGetDeviceCount");
ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(count);
rtError_t rtErr = rtGetDeviceCount(reinterpret_cast<int32_t *>(count));
if (rtErr != RT_ERROR_NONE) {
ACL_LOG_CALL_ERROR("get device count failed, runtime result = %d.", static_cast<int32_t>(rtErr));
return ACL_GET_ERRCODE_RTS(rtErr);
}
ACL_LOG_INFO("successfully execute aclrtGetDeviceCount, get device count is %u.", *count);
return ACL_SUCCESS;
}
| 38.688596 | 114 | 0.701961 | fletcherjiang |
64ea0f4c80afa7839f4b8ce7366f4a249103dc15 | 1,181 | cpp | C++ | codeforce6/1006D. Two Strings Swaps.cpp | khaled-farouk/My_problem_solving_solutions | 46ed6481fc9b424d0714bc717cd0ba050a6638ef | [
"MIT"
] | null | null | null | codeforce6/1006D. Two Strings Swaps.cpp | khaled-farouk/My_problem_solving_solutions | 46ed6481fc9b424d0714bc717cd0ba050a6638ef | [
"MIT"
] | null | null | null | codeforce6/1006D. Two Strings Swaps.cpp | khaled-farouk/My_problem_solving_solutions | 46ed6481fc9b424d0714bc717cd0ba050a6638ef | [
"MIT"
] | null | null | null | /*
Idea:
- Each 2 mirror indexes in `a` and `b` are solvable alone,
in other words they does not affect the other indexes.
- We can use the fact in the previous point and solve each
2 mirror indexes and add the result of them to the solution
of the problem.
*/
#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 10;
char a[N], b[N];
int n;
int main() {
scanf("%d", &n);
scanf("%s", a + 1);
scanf("%s", b + 1);
int res = 0;
for(int i = 1, j = n; i <= j; ++i, --j) {
if(i == j) {
if(a[i] != b[i])
++res;
continue;
}
if(a[i] == b[j] && b[i] == a[j])
continue;
if(a[i] == a[j] && b[i] == b[j])
continue;
if(a[i] == b[i] && a[j] == b[j])
continue;
if(a[i] != a[j] && a[i] != b[i] && a[i] != b[j] && a[j] != b[i] && a[j] != b[j] && b[i] != b[j]) {
res += 2;
continue;
}
if(a[i] != a[j] && b[i] == b[j] && a[i] != b[i] && a[j] != b[i]) {
res += 1;
continue;
}
if(a[i] == a[j] && b[i] != b[j] && a[i] != b[i] && a[i] != b[j]) {
res += 2;
continue;
}
++res;
}
printf("%d\n", res);
return 0;
}
| 19.683333 | 102 | 0.421677 | khaled-farouk |
64ebf495a4d7c5a3c0dfcd93ecca0cb12a0eddb4 | 7,736 | cpp | C++ | src/tools/SxStructPatch.cpp | ashtonmv/sphinx_vdw | 5896fee0d92c06e883b72725cb859d732b8b801f | [
"Apache-2.0"
] | 1 | 2020-02-29T03:26:32.000Z | 2020-02-29T03:26:32.000Z | src/tools/SxStructPatch.cpp | ashtonmv/sphinx_vdw | 5896fee0d92c06e883b72725cb859d732b8b801f | [
"Apache-2.0"
] | null | null | null | src/tools/SxStructPatch.cpp | ashtonmv/sphinx_vdw | 5896fee0d92c06e883b72725cb859d732b8b801f | [
"Apache-2.0"
] | null | null | null | // ---------------------------------------------------------------------------
//
// The ab-initio based multiscale library
//
// S / P H I / n X
//
// Copyright: Max-Planck-Institute for Iron Research
// 40237 Duesseldorf, Germany
//
// Contact: https://sxlib.mpie.de
// Authors: see sphinx/AUTHORS
// License: see sphinx/LICENSE
//
// ---------------------------------------------------------------------------
#include <SxCLI.h>
#include <SxConfig.h>
#include <SxParser.h>
#include <SxAtomicStructure.h>
#include <SxNeighbors.h>
#include <SxGrid.h>
#include <SxFileIO.h>
SxVector3<Double> toCoords (const SxString &s)
{
SxList<SxString> coords
= s.substitute ("{","")
.substitute ("}","")
.substitute (" ","")
.tokenize (',');
if (coords.getSize () != 3) {
throw SxException (("Cannot extract coordinates from " + s).ascii ());
}
// => might throw an exception, too
Coord pos(coords(0).toDouble (),
coords(1).toDouble (),
coords(2).toDouble ());
return pos;
}
int main (int argc, char **argv)
{
// --- init S/PHI/nX Utilities
initSPHInXMath ();
// --- parse command line
SxCLI cli (argc, argv);
cli.preUsageMessage =
"This add-on modifies the structure according to the structure patch "
"file as produced by sxstructdiff.";
cli.authors = "C. Freysoldt";
SxString inFile
= cli.option ("-i|--input", "input file",
"take original input file")
.toString ("input.sx");
SxString outFile
= cli.option ("-o","filename", "output file name (screen otherwise)")
.toString ("");
SxString patchFile
= cli.option ("-p","filename", "patch file name")
.toString ();
double distMax = cli.option ("-d|--dmax","distance",
"tolerance for finding atoms").toDouble (0.);
bool labels = cli.option ("-l|--labels", "transfer labels").toBool ();
cli.finalize ();
// --- read input
SxAtomicStructure structure;
SxArray<SxString> chemNames;
{
SxParser parser;
SxConstPtr<SxSymbolTable> tree;
tree = parser.read (inFile, "std/structure.std");
structure = SxAtomicStructure (&*tree);
chemNames = SxSpeciesData::getElements (&*tree);
}
if (!structure.hasLabels ()) labels=false;
SxArray<bool> keep(structure.getNAtoms ());
keep.set (true);
SxArray<SxString> patch = SxString(SxFileIO::readBinary (patchFile,-1))
.tokenize ('\n');
SxGrid grid(structure, 10);
SxArray<SxList<Coord> > addedAtoms(structure.getNSpecies ());
for (int ip = 0; ip < patch.getSize (); ++ip) {
if (patch(ip).getSize () == 0) continue;
if (patch(ip)(0) != '>') continue;
if (patch(ip).contains ("> new")) {
// --- additional atom
SxList<SxString> split = patch(ip).tokenize ('@');
if (split.getSize () != 2) {
if (split.getSize () > 0) {
cout << "Cannot parse this line (ignored):" << endl;
cout << patch(ip) << endl;
}
continue;
}
SxString element = split(0).right ("new").substitute (" ","");
int is = (int)chemNames.findPos (element);
if (is == -1) {
is = (int)chemNames.getSize ();
chemNames.resize (is + 1, true);
chemNames(is) = element;
addedAtoms.resize (is + 1, true);
}
Coord pos;
try {
pos = toCoords (split(1));
} catch (SxException e) {
e.print ();
continue;
}
addedAtoms(is) << pos;
cout << "Adding " << element << " atom @ " << pos << endl;
}
// --- atoms were deleted, shifted, or changed species
SxList<SxString> split = patch(ip).tokenize (':');
if (split.getSize () != 2) {
if (split.getSize () > 2) {
cout << "Cannot parse this line (ignored):" << endl;
cout << patch(ip) << endl;
}
continue;
}
// --- find the relevant atom
Coord pos;
try {
pos = toCoords (split(0).right ("@"));
} catch (SxException e) {
e.print ();
continue;
}
int iTlAtom = structure.find (pos, grid);
if (iTlAtom == -1 && distMax > 0.) {
// --- try atoms nearby
SxNeighbors nn;
nn.compute (grid, structure, pos, distMax, SxNeighbors::StoreIdx | SxNeighbors::StoreAbs);
if (nn.getSize () == 1) iTlAtom = nn.idx(0);
else if (nn.getSize () > 0) cout << nn.absPositions << endl;
}
if (iTlAtom == -1) {
cout << "Could not find atom @ " << pos << endl;
continue;
}
// --- now apply the patch
//
// --- delete atom
if (split(1).contains ("delete")) {
keep(iTlAtom) = false;
cout << "Deleting atom " << (iTlAtom+1) << " @ "
<< structure.getAtom (iTlAtom) << endl;
continue;
}
// --- shift atom
if (split(1).contains ("shift")) {
Coord by;
try {
by = toCoords (split(1).right ("shift"));
} catch (SxException e) {
e.print ();
continue;
}
cout << "Shifting atom " << (iTlAtom+1) << " @ "
<< structure.getAtom (iTlAtom)
<< " by " << by
<< endl;
structure.ref (iTlAtom) += by;
continue;
}
// --- change species (delete and add)
if (split(1).contains ("new species")) {
keep(iTlAtom) = false;
SxString element = split(1).right ("species").substitute (" ","");
int is = (int)chemNames.findPos (element);
if (is == -1) {
is = (int)chemNames.getSize ();
chemNames.resize (is + 1, true);
chemNames(is) = element;
addedAtoms.resize (is + 1, true);
}
addedAtoms(is) << structure.getAtom (iTlAtom);
cout << "Changing species for atom " << (iTlAtom+1)
<< " @ " << structure.getAtom (iTlAtom) << " from "
<< chemNames(structure.getISpecies(iTlAtom)) << " to "
<< element << endl;
}
}
// --- copy atoms that have not been deleted
SxAtomicStructure result(structure.cell);
SxStack<SxString> newLabels;
const SxArray<SxString> *oldLabels = labels ? &structure.getLabels () : NULL;
for (int is = 0, iTl = 0; is < chemNames.getSize (); ++is) {
result.newSpecies ();
if (is < structure.getNSpecies ()) {
for (int ia = 0; ia < structure.getNAtoms (is); ++ia, ++iTl) {
if (keep(iTl)) {
result.addAtom (structure.getAtom (is, ia));
if (oldLabels) newLabels << (*oldLabels)(iTl);
}
}
}
for (int ia = 0; ia < addedAtoms(is).getSize (); ++ia) {
result.addAtom (addedAtoms(is)(ia));
newLabels << "";
}
}
result.endCreation ();
result.atomInfo->meta.attach (SxAtomicStructure::Elements, chemNames);
if (labels) {
result.atomInfo->meta.update (SxAtomicStructure::Labels,
SxArray<SxString> (newLabels));
}
// --- output
{
FILE *file;
if (outFile.getSize () > 0) {
file = fopen(outFile.ascii(),"w");
if (file == NULL) {
cout << "Can't open '" << outFile << "'." << endl;
SX_EXIT;
}
} else {
file = stdout;
}
result.fprint (file);
if (file != stdout) fclose (file);
}
}
| 30.944 | 99 | 0.496768 | ashtonmv |
64edbf53d0c907a17531b431824a0921b05e2927 | 6,536 | hh | C++ | GeneralUtilities/inc/OwningPointerCollection.hh | lborrel/Offline | db9f647bad3c702171ab5ffa5ccc04c82b3f8984 | [
"Apache-2.0"
] | 9 | 2020-03-28T00:21:41.000Z | 2021-12-09T20:53:26.000Z | GeneralUtilities/inc/OwningPointerCollection.hh | lborrel/Offline | db9f647bad3c702171ab5ffa5ccc04c82b3f8984 | [
"Apache-2.0"
] | 684 | 2019-08-28T23:37:43.000Z | 2022-03-31T22:47:45.000Z | GeneralUtilities/inc/OwningPointerCollection.hh | lborrel/Offline | db9f647bad3c702171ab5ffa5ccc04c82b3f8984 | [
"Apache-2.0"
] | 61 | 2019-08-16T23:28:08.000Z | 2021-12-20T08:29:48.000Z | #ifndef GeneralUtilities_OwningPointerCollection_hh
#define GeneralUtilities_OwningPointerCollection_hh
//
// A class template to take ownership of a collection of bare pointers to
// objects, to provide access to those objects and to delete them when the
// container object goes out of scope.
//
// This is designed to allow complex objects made on the heap to be used
// as transient-only data products.
//
// The original use is for BaBar tracks.
//
//
// Original author Rob Kutschke
//
// Notes:
// 1) I believe it would be wise to make the underlying container:
// std::vector<boost::right_kind_of_smart_pointer<T>>.
// scoped_ptr will not work since they are not copyable ( needed for vector ).
// unique_ptr seems mostly concerned with threads.
// I tried shared_ptr but I could not make it play nice with genreflex.
//
#include <vector>
#include <memory>
#include "canvas/Persistency/Common/detail/maybeCastObj.h"
namespace mu2e {
template<typename T>
class OwningPointerCollection{
public:
typedef typename std::vector<const T*>::const_iterator const_iterator;
typedef T const* value_type;
OwningPointerCollection():v_(){}
// Caller transfers ownership of the pointees to us.
explicit OwningPointerCollection( std::vector<T*>& v ):
v_(v.begin(), v.end() ){
}
// Caller transfers ownership of the pointees to us.
explicit OwningPointerCollection( std::vector<value_type>& v ):
v_(v){
}
// We own the pointees so delete them when our destructor is called.
~OwningPointerCollection(){
for( typename std::vector<value_type>::iterator i=v_.begin();
i!=v_.end(); ++i ){
delete *i;
}
}
#ifndef __GCCXML__
// GCCXML does not know about move syntax - so hide it.
OwningPointerCollection( OwningPointerCollection && rhs ):
v_(std::move(rhs.v_)){
rhs.v_.clear();
}
OwningPointerCollection& operator=( OwningPointerCollection && rhs ){
v_ = std::move(rhs.v_);
rhs.v_.clear();
return *this;
}
#endif /* GCCXML */
// Caller transfers ownership of the pointee to us.
void push_back( T* t){
v_.push_back(t);
}
void push_back( value_type t){
v_.push_back(t);
}
typename std::vector<value_type>::const_iterator begin() const{
return v_.begin();
}
typename std::vector<value_type>::const_iterator end() const{
return v_.end();
}
typename std::vector<value_type>::const_iterator cbegin() const{
return v_.cbegin();
}
typename std::vector<value_type>::const_iterator cend() const{
return v_.cend();
}
// Possibly needed by producer modules?
/*
void pop_back( ){
delete v_.back();
v_.pop_back();
}
*/
// Needed for event.put().
void swap( OwningPointerCollection& rhs){
std::swap( this->v_, rhs.v_);
}
// Accessors: this container retains ownership of the pointees.
size_t size() const { return v_.size(); }
T const& operator[](std::size_t i) const { return *v_.at(i); }
T const& at (std::size_t i) const { return *v_.at(i); }
value_type get (std::size_t i) const { return v_.at(i); }
value_type operator()(std::size_t i) const { return v_.at(i); }
// const access to the underlying container.
std::vector<value_type> const& getAll(){ return v_; }
private:
// Not copy-copyable or copy-assignable; this is needed to ensure exactly one delete.
// GCCXML does not know about =delete so leave these private and unimplemented.
OwningPointerCollection( OwningPointerCollection const& );
OwningPointerCollection& operator=( OwningPointerCollection const& );
// Owning pointers to the objects.
std::vector<value_type> v_;
};
} // namespace mu2e
// Various template specializations needed to make an art::Ptr<T> into an OwningPointerCollection<T>
// work.
//
// ItemGetter - return a bare pointer to an requested by giving its index.
// has_setPtr - do specializations exists for setPtr and getElementAddresses
// setPtr - return a bare pointer to an requested by giving its index.
// getElementAddresses - return a vector of bare pointers to a vector of elements requested by index.
//
#ifndef __GCCXML__
#include "canvas/Persistency/Common/Ptr.h"
namespace art {
namespace detail {
template <typename T>
class ItemGetter<T, mu2e::OwningPointerCollection<T> >;
}
template <class T>
struct has_setPtr<mu2e::OwningPointerCollection<T> >;
}
namespace mu2e {
template <class T>
void
setPtr(OwningPointerCollection<T> const & coll,
const std::type_info & iToType,
unsigned long iIndex,
void const *& oPtr);
template <typename T>
void
getElementAddresses(OwningPointerCollection<T> const & obj,
const std::type_info & iToType,
const std::vector<unsigned long>& iIndices,
std::vector<void const *>& oPtr);
}
template <typename T>
class art::detail::ItemGetter<T, mu2e::OwningPointerCollection<T> > {
public:
T const * operator()(mu2e::OwningPointerCollection<T> const * product,
typename art::Ptr<T>::key_type iKey) const;
};
template <typename T>
inline
T const *
art::detail::ItemGetter<T, mu2e::OwningPointerCollection<T> >::
operator()(mu2e::OwningPointerCollection<T> const * product,
typename art::Ptr<T>::key_type iKey) const
{
assert(product != 0);
std::size_t i(iKey);
return product->get(i);
}
namespace art {
template <class T>
struct has_setPtr<mu2e::OwningPointerCollection<T> >
{
static bool const value = true;
};
}
namespace mu2e {
template <class T>
void
setPtr(OwningPointerCollection<T> const & coll,
const std::type_info & iToType,
unsigned long iIndex,
void const *& oPtr)
{
oPtr = art::detail::maybeCastObj(coll.get(iIndex),iToType);
}
template <typename T>
void
getElementAddresses(OwningPointerCollection<T> const & obj,
const std::type_info & iToType,
const std::vector<unsigned long>& iIndices,
std::vector<void const *>& oPtr)
{
oPtr.reserve(iIndices.size());
for ( auto i : iIndices ){
oPtr.push_back(art::detail::maybeCastObj(obj.get(i),iToType));
}
}
}
#endif // __GCCXML__
#endif /* GeneralUtilities_OwningPointerCollection_hh */
| 27.812766 | 101 | 0.655141 | lborrel |
64ee53277ab5a72163a299848984f1413a0c879b | 1,777 | hpp | C++ | shared_model/backend/plain/engine_log.hpp | Insafin/iroha | 5e3c3252b2a62fa887274bdf25547dc264c10c26 | [
"Apache-2.0"
] | 1,467 | 2016-10-25T12:27:19.000Z | 2022-03-28T04:32:05.000Z | shared_model/backend/plain/engine_log.hpp | Insafin/iroha | 5e3c3252b2a62fa887274bdf25547dc264c10c26 | [
"Apache-2.0"
] | 2,366 | 2016-10-25T10:07:57.000Z | 2022-03-31T22:03:24.000Z | shared_model/backend/plain/engine_log.hpp | Insafin/iroha | 5e3c3252b2a62fa887274bdf25547dc264c10c26 | [
"Apache-2.0"
] | 662 | 2016-10-26T04:41:22.000Z | 2022-03-31T04:15:02.000Z | /**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef IROHA_SHARED_MODEL_PLAIN_ENGINE_LOG_HPP
#define IROHA_SHARED_MODEL_PLAIN_ENGINE_LOG_HPP
#include "interfaces/query_responses/engine_log.hpp"
#include "interfaces/common_objects/types.hpp"
namespace shared_model {
namespace plain {
class EngineLog final : public interface::EngineLog {
public:
EngineLog() = delete;
EngineLog(EngineLog const &) = delete;
EngineLog &operator=(EngineLog const &) = delete;
EngineLog(interface::types::EvmAddressHexString const &address,
interface::types::EvmDataHexString const &data)
: address_(address), data_(data) {}
EngineLog(interface::types::EvmAddressHexString &&address,
interface::types::EvmDataHexString &&data)
: address_(std::move(address)), data_(std::move(data)) {}
interface::types::EvmAddressHexString const &getAddress() const {
return address_;
}
interface::types::EvmDataHexString const &getData() const {
return data_;
}
interface::EngineLog::TopicsCollectionType const &getTopics() const {
return topics_;
}
void addTopic(interface::types::EvmTopicsHexString &&topic) {
topics_.emplace_back(std::move(topic));
}
void addTopic(interface::types::EvmTopicsHexString const &topic) {
topics_.emplace_back(topic);
}
private:
interface::types::EvmAddressHexString const address_;
interface::types::EvmDataHexString const data_;
interface::EngineLog::TopicsCollectionType topics_;
};
} // namespace plain
} // namespace shared_model
#endif // IROHA_SHARED_MODEL_PLAIN_ENGINE_LOG_HPP
| 29.616667 | 75 | 0.684299 | Insafin |
64f16b150a5787b3cee60de5b57c74eeadffac73 | 195 | cpp | C++ | Code full house/buoi17-nguyendinhtrungduc dequy/dequy/bai2.cpp | ducyb2001/CbyTrungDuc | 0e93394dce600876a098b90ae969575bac3788e1 | [
"Apache-2.0"
] | null | null | null | Code full house/buoi17-nguyendinhtrungduc dequy/dequy/bai2.cpp | ducyb2001/CbyTrungDuc | 0e93394dce600876a098b90ae969575bac3788e1 | [
"Apache-2.0"
] | null | null | null | Code full house/buoi17-nguyendinhtrungduc dequy/dequy/bai2.cpp | ducyb2001/CbyTrungDuc | 0e93394dce600876a098b90ae969575bac3788e1 | [
"Apache-2.0"
] | null | null | null | /*bai 2 S=1^2+2^2+3^2+.....+n^2 */
#include<stdio.h>
int tong(int n){
if(n==1) return 1;
else return n*n+tong(n-1);
}
int main(){
int n;
scanf("%d",&n);
int a = tong(n);
printf("%d",a);
}
| 13.928571 | 34 | 0.517949 | ducyb2001 |
64f860a1779dd6f62b10b8bd6b8e7cb980053d67 | 14,853 | cc | C++ | components/viz/service/display/display_resource_provider_gl.cc | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2020-10-18T02:33:40.000Z | 2020-10-18T02:33:40.000Z | components/viz/service/display/display_resource_provider_gl.cc | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 3 | 2021-05-17T16:28:52.000Z | 2021-05-21T22:42:22.000Z | components/viz/service/display/display_resource_provider_gl.cc | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2021 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/viz/service/display/display_resource_provider_gl.h"
#include <vector>
#include "base/dcheck_is_on.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/viz/common/gpu/context_provider.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "ui/gfx/gpu_fence.h"
using gpu::gles2::GLES2Interface;
namespace viz {
namespace {
class ScopedSetActiveTexture {
public:
ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit)
: gl_(gl), unit_(unit) {
#if DCHECK_IS_ON()
GLint active_unit = 0;
gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
DCHECK_EQ(GL_TEXTURE0, active_unit);
#endif
if (unit_ != GL_TEXTURE0)
gl_->ActiveTexture(unit_);
}
~ScopedSetActiveTexture() {
// Active unit being GL_TEXTURE0 is effectively the ground state.
if (unit_ != GL_TEXTURE0)
gl_->ActiveTexture(GL_TEXTURE0);
}
private:
GLES2Interface* gl_;
GLenum unit_;
};
} // namespace
DisplayResourceProviderGL::DisplayResourceProviderGL(
ContextProvider* compositor_context_provider,
bool enable_shared_images)
: DisplayResourceProvider(DisplayResourceProvider::kGpu),
compositor_context_provider_(compositor_context_provider),
enable_shared_images_(enable_shared_images) {
DCHECK(compositor_context_provider_);
}
DisplayResourceProviderGL::~DisplayResourceProviderGL() {
Destroy();
GLES2Interface* gl = ContextGL();
if (gl)
gl->Finish();
while (!resources_.empty())
DeleteResourceInternal(resources_.begin());
}
void DisplayResourceProviderGL::DeleteResourceInternal(
ResourceMap::iterator it) {
TRACE_EVENT0("viz", "DisplayResourceProvider::DeleteResourceInternal");
ChildResource* resource = &it->second;
if (resource->gl_id) {
GLES2Interface* gl = ContextGL();
DCHECK(gl);
gl->DeleteTextures(1, &resource->gl_id);
}
resources_.erase(it);
}
GLES2Interface* DisplayResourceProviderGL::ContextGL() const {
DCHECK(compositor_context_provider_);
return compositor_context_provider_->ContextGL();
}
const DisplayResourceProvider::ChildResource*
DisplayResourceProviderGL::LockForRead(ResourceId id, bool overlay_only) {
// TODO(ericrk): We should never fail TryGetResource, but we appear to be
// doing so on Android in rare cases. Handle this gracefully until a better
// solution can be found. https://crbug.com/811858
ChildResource* resource = TryGetResource(id);
if (!resource)
return nullptr;
// Mailbox sync_tokens must be processed by a call to WaitSyncToken() prior to
// calling LockForRead().
DCHECK_NE(NEEDS_WAIT, resource->synchronization_state());
DCHECK(resource->is_gpu_resource_type());
const gpu::Mailbox& mailbox = resource->transferable.mailbox_holder.mailbox;
GLES2Interface* gl = ContextGL();
DCHECK(gl);
if (!resource->gl_id) {
if (mailbox.IsSharedImage() && enable_shared_images_) {
resource->gl_id =
gl->CreateAndTexStorage2DSharedImageCHROMIUM(mailbox.name);
} else {
resource->gl_id = gl->CreateAndConsumeTextureCHROMIUM(
resource->transferable.mailbox_holder.mailbox.name);
}
resource->SetLocallyUsed();
}
if (mailbox.IsSharedImage() && enable_shared_images_) {
if (overlay_only) {
if (resource->lock_for_overlay_count == 0) {
// If |lock_for_read_count| > 0, then BeginSharedImageAccess has
// already been called with READ, so don't re-lock with OVERLAY.
if (resource->lock_for_read_count == 0) {
gl->BeginSharedImageAccessDirectCHROMIUM(
resource->gl_id, GL_SHARED_IMAGE_ACCESS_MODE_OVERLAY_CHROMIUM);
}
}
} else {
if (resource->lock_for_read_count == 0) {
// If |lock_for_overlay_count| > 0, then we have already begun access
// for OVERLAY. End this access and "upgrade" it to READ.
// See https://crbug.com/1113925 for how this can go wrong.
if (resource->lock_for_overlay_count > 0)
gl->EndSharedImageAccessDirectCHROMIUM(resource->gl_id);
gl->BeginSharedImageAccessDirectCHROMIUM(
resource->gl_id, GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM);
}
}
}
if (overlay_only)
resource->lock_for_overlay_count++;
else
resource->lock_for_read_count++;
if (resource->transferable.read_lock_fences_enabled) {
if (current_read_lock_fence_.get())
current_read_lock_fence_->Set();
resource->read_lock_fence = current_read_lock_fence_;
}
return resource;
}
void DisplayResourceProviderGL::UnlockForRead(ResourceId id,
bool overlay_only) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
ChildResource* resource = TryGetResource(id);
// TODO(ericrk): We should never fail to find id, but we appear to be
// doing so on Android in rare cases. Handle this gracefully until a better
// solution can be found. https://crbug.com/811858
if (!resource)
return;
DCHECK(resource->is_gpu_resource_type());
if (resource->transferable.mailbox_holder.mailbox.IsSharedImage() &&
enable_shared_images_) {
// If this is the last READ or OVERLAY access, then end access.
if (resource->lock_for_read_count + resource->lock_for_overlay_count == 1) {
DCHECK(resource->gl_id);
GLES2Interface* gl = ContextGL();
DCHECK(gl);
if (!resource->release_fence.is_null()) {
auto fence = gfx::GpuFence(resource->release_fence.Clone());
auto id = gl->CreateClientGpuFenceCHROMIUM(fence.AsClientGpuFence());
gl->WaitGpuFenceCHROMIUM(id);
gl->DestroyGpuFenceCHROMIUM(id);
}
gl->EndSharedImageAccessDirectCHROMIUM(resource->gl_id);
}
}
if (overlay_only) {
DCHECK_GT(resource->lock_for_overlay_count, 0);
resource->lock_for_overlay_count--;
} else {
DCHECK_GT(resource->lock_for_read_count, 0);
resource->lock_for_read_count--;
}
TryReleaseResource(id, resource);
}
std::vector<ReturnedResource>
DisplayResourceProviderGL::DeleteAndReturnUnusedResourcesToChildImpl(
Child& child_info,
DeleteStyle style,
const std::vector<ResourceId>& unused) {
std::vector<ReturnedResource> to_return;
// Reserve enough space to avoid re-allocating, so we can keep item pointers
// for later using.
to_return.reserve(unused.size());
std::vector<ReturnedResource*> need_synchronization_resources;
std::vector<GLbyte*> unverified_sync_tokens;
GLES2Interface* gl = ContextGL();
DCHECK(gl);
DCHECK(can_access_gpu_thread_);
for (ResourceId local_id : unused) {
auto it = resources_.find(local_id);
CHECK(it != resources_.end());
ChildResource& resource = it->second;
DCHECK(resource.is_gpu_resource_type());
ResourceId child_id = resource.transferable.id;
DCHECK(child_info.child_to_parent_map.count(child_id));
auto can_delete = CanDeleteNow(child_info, resource, style);
if (can_delete == CanDeleteNowResult::kNo) {
// Defer this resource deletion.
resource.marked_for_deletion = true;
continue;
}
const bool is_lost = can_delete == CanDeleteNowResult::kYesButLoseResource;
if (resource.gl_id && resource.filter != resource.transferable.filter) {
DCHECK(resource.transferable.mailbox_holder.texture_target);
DCHECK(!resource.ShouldWaitSyncToken());
gl->BindTexture(resource.transferable.mailbox_holder.texture_target,
resource.gl_id);
gl->TexParameteri(resource.transferable.mailbox_holder.texture_target,
GL_TEXTURE_MIN_FILTER, resource.transferable.filter);
gl->TexParameteri(resource.transferable.mailbox_holder.texture_target,
GL_TEXTURE_MAG_FILTER, resource.transferable.filter);
resource.SetLocallyUsed();
}
to_return.emplace_back(child_id, resource.sync_token(),
std::move(resource.release_fence),
resource.imported_count, is_lost);
auto& returned = to_return.back();
if (resource.needs_sync_token()) {
need_synchronization_resources.push_back(&returned);
} else if (returned.sync_token.HasData() &&
!returned.sync_token.verified_flush()) {
unverified_sync_tokens.push_back(returned.sync_token.GetData());
}
child_info.child_to_parent_map.erase(child_id);
resource.imported_count = 0;
DeleteResourceInternal(it);
}
gpu::SyncToken new_sync_token;
if (!need_synchronization_resources.empty()) {
gl->GenUnverifiedSyncTokenCHROMIUM(new_sync_token.GetData());
unverified_sync_tokens.push_back(new_sync_token.GetData());
}
if (!unverified_sync_tokens.empty()) {
gl->VerifySyncTokensCHROMIUM(unverified_sync_tokens.data(),
unverified_sync_tokens.size());
}
// Set sync token after verification.
for (ReturnedResource* returned : need_synchronization_resources)
returned->sync_token = new_sync_token;
return to_return;
}
GLenum DisplayResourceProviderGL::GetResourceTextureTarget(ResourceId id) {
return GetResource(id)->transferable.mailbox_holder.texture_target;
}
void DisplayResourceProviderGL::WaitSyncToken(ResourceId id) {
ChildResource* resource = TryGetResource(id);
// TODO(ericrk): We should never fail TryGetResource, but we appear to
// be doing so on Android in rare cases. Handle this gracefully until a
// better solution can be found. https://crbug.com/811858
if (!resource)
return;
WaitSyncTokenInternal(resource);
}
GLenum DisplayResourceProviderGL::BindForSampling(ResourceId resource_id,
GLenum unit,
GLenum filter) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
GLES2Interface* gl = ContextGL();
auto it = resources_.find(resource_id);
// TODO(ericrk): We should never fail to find resource_id, but we appear to
// be doing so on Android in rare cases. Handle this gracefully until a
// better solution can be found. https://crbug.com/811858
if (it == resources_.end())
return GL_TEXTURE_2D;
ChildResource* resource = &it->second;
DCHECK(resource->lock_for_read_count);
ScopedSetActiveTexture scoped_active_tex(gl, unit);
GLenum target = resource->transferable.mailbox_holder.texture_target;
gl->BindTexture(target, resource->gl_id);
// Texture parameters can be modified by concurrent reads so reset them
// before binding the texture. See https://crbug.com/1092080.
gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
resource->filter = filter;
return target;
}
void DisplayResourceProviderGL::WaitSyncTokenInternal(ChildResource* resource) {
DCHECK(resource);
if (!resource->ShouldWaitSyncToken())
return;
GLES2Interface* gl = ContextGL();
DCHECK(gl);
// In the case of context lost, this sync token may be empty (see comment in
// the UpdateSyncToken() function). The WaitSyncTokenCHROMIUM() function
// handles empty sync tokens properly so just wait anyways and update the
// state the synchronized.
gl->WaitSyncTokenCHROMIUM(resource->sync_token().GetConstData());
resource->SetSynchronized();
}
DisplayResourceProviderGL::ScopedReadLockGL::ScopedReadLockGL(
DisplayResourceProviderGL* resource_provider,
ResourceId resource_id)
: resource_provider_(resource_provider), resource_id_(resource_id) {
const ChildResource* resource =
resource_provider->LockForRead(resource_id, false /* overlay_only */);
// TODO(ericrk): We should never fail LockForRead, but we appear to be
// doing so on Android in rare cases. Handle this gracefully until a better
// solution can be found. https://crbug.com/811858
if (!resource)
return;
texture_id_ = resource->gl_id;
target_ = resource->transferable.mailbox_holder.texture_target;
size_ = resource->transferable.size;
color_space_ = resource->transferable.color_space;
hdr_metadata_ = resource->transferable.hdr_metadata;
}
DisplayResourceProviderGL::ScopedReadLockGL::~ScopedReadLockGL() {
resource_provider_->UnlockForRead(resource_id_, false /* overlay_only */);
}
DisplayResourceProviderGL::ScopedSamplerGL::ScopedSamplerGL(
DisplayResourceProviderGL* resource_provider,
ResourceId resource_id,
GLenum filter)
: resource_lock_(resource_provider, resource_id),
unit_(GL_TEXTURE0),
target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {}
DisplayResourceProviderGL::ScopedSamplerGL::ScopedSamplerGL(
DisplayResourceProviderGL* resource_provider,
ResourceId resource_id,
GLenum unit,
GLenum filter)
: resource_lock_(resource_provider, resource_id),
unit_(unit),
target_(resource_provider->BindForSampling(resource_id, unit_, filter)) {}
DisplayResourceProviderGL::ScopedSamplerGL::~ScopedSamplerGL() = default;
DisplayResourceProviderGL::ScopedOverlayLockGL::ScopedOverlayLockGL(
DisplayResourceProviderGL* resource_provider,
ResourceId resource_id)
: resource_provider_(resource_provider), resource_id_(resource_id) {
const ChildResource* resource =
resource_provider->LockForRead(resource_id, true /* overlay_only */);
if (!resource)
return;
texture_id_ = resource->gl_id;
}
DisplayResourceProviderGL::ScopedOverlayLockGL::~ScopedOverlayLockGL() {
resource_provider_->UnlockForRead(resource_id_, true /* overlay_only */);
}
void DisplayResourceProviderGL::ScopedOverlayLockGL::SetReleaseFence(
gfx::GpuFenceHandle release_fence) {
auto* resource = resource_provider_->GetResource(resource_id_);
DCHECK(resource);
resource->release_fence = std::move(release_fence);
}
bool DisplayResourceProviderGL::ScopedOverlayLockGL::HasReadLockFence() const {
auto* resource = resource_provider_->GetResource(resource_id_);
DCHECK(resource);
return resource->transferable.read_lock_fences_enabled;
}
DisplayResourceProviderGL::SynchronousFence::SynchronousFence(
gpu::gles2::GLES2Interface* gl)
: gl_(gl), has_synchronized_(true) {}
DisplayResourceProviderGL::SynchronousFence::~SynchronousFence() = default;
void DisplayResourceProviderGL::SynchronousFence::Set() {
has_synchronized_ = false;
}
bool DisplayResourceProviderGL::SynchronousFence::HasPassed() {
if (!has_synchronized_) {
has_synchronized_ = true;
Synchronize();
}
return true;
}
void DisplayResourceProviderGL::SynchronousFence::Synchronize() {
TRACE_EVENT0("viz", "DisplayResourceProvider::SynchronousFence::Synchronize");
gl_->Finish();
}
} // namespace viz
| 35.533493 | 80 | 0.729415 | DamieFC |
64fe14f3c6c3dc538ce9704a42d673d26f307aa9 | 844 | cpp | C++ | problems/483.Smallest_Good_Base/yin_opt_1.cpp | subramp-prep/leetcode | d125201d9021ab9b1eea5e5393c2db4edd84e740 | [
"Unlicense"
] | null | null | null | problems/483.Smallest_Good_Base/yin_opt_1.cpp | subramp-prep/leetcode | d125201d9021ab9b1eea5e5393c2db4edd84e740 | [
"Unlicense"
] | null | null | null | problems/483.Smallest_Good_Base/yin_opt_1.cpp | subramp-prep/leetcode | d125201d9021ab9b1eea5e5393c2db4edd84e740 | [
"Unlicense"
] | null | null | null | // Optimized Brute Force
// Time Complexity O(1)
// Space Complexity O(1)
class Solution {
public:
string smallestGoodBase(string n)
{
unsigned long long val = stoull(n);
int maxdigits = 60; // log(10^18, 2) <= 60
// int maxdigits = ceil((long double)log(val) / (long double)log(2)); // min base is 2 => max digit number is log(val, 2)
for (int i = maxdigits; i > 2; --i) // at least 2 digits when k = val - 1
{
int k = floor(pow((long double)(val), 1.0 / (i - 1))); // k <= i - 1 root square of val
if (k == 1) continue;
unsigned long long sum = (pow((long double)k, (long double)i) - 1) / (long double)(k - 1); // geometric sequence sum formulae
if (sum == val)
return to_string(k);
}
return to_string(val - 1);
}
}; | 40.190476 | 137 | 0.542654 | subramp-prep |
64ff2b7560463b0cc2cfd8afa46d17f74d3bddfe | 3,308 | cpp | C++ | ocs2_robotic_examples/ocs2_nadia/src/constraint/EndEffectorLinearConstraint.cpp | james-p-foster/ocs2 | 8f1da414ba9ebb94ad1e8dd9bd513dbb9cc462fa | [
"BSD-3-Clause"
] | null | null | null | ocs2_robotic_examples/ocs2_nadia/src/constraint/EndEffectorLinearConstraint.cpp | james-p-foster/ocs2 | 8f1da414ba9ebb94ad1e8dd9bd513dbb9cc462fa | [
"BSD-3-Clause"
] | null | null | null | ocs2_robotic_examples/ocs2_nadia/src/constraint/EndEffectorLinearConstraint.cpp | james-p-foster/ocs2 | 8f1da414ba9ebb94ad1e8dd9bd513dbb9cc462fa | [
"BSD-3-Clause"
] | null | null | null | #include "ocs2_nadia/constraint/EndEffectorLinearConstraint.h"
namespace ocs2 {
namespace legged_robot {
EndEffectorLinearConstraint::EndEffectorLinearConstraint(const EndEffectorKinematics<scalar_t>& endEffectorKinematics,
size_t numConstraints, Config config)
: StateInputConstraint(ConstraintOrder::Linear),
endEffectorKinematicsPtr_(endEffectorKinematics.clone()),
numConstraints_(numConstraints),
config_(std::move(config)) {
if (endEffectorKinematicsPtr_->getIds().size() != 1) {
throw std::runtime_error("[EndEffectorLinearConstraint] this class only accepts a single end-effector!");
}
}
EndEffectorLinearConstraint::EndEffectorLinearConstraint(const EndEffectorLinearConstraint& rhs)
: StateInputConstraint(rhs),
endEffectorKinematicsPtr_(rhs.endEffectorKinematicsPtr_->clone()),
numConstraints_(rhs.numConstraints_),
config_(rhs.config_) {}
void EndEffectorLinearConstraint::configure(Config&& config) {
assert(config.b.rows() == numConstraints_);
assert(config.Ax.size() > 0 || config.Av.size() > 0);
assert((config.Ax.size() > 0 && config.Ax.rows() == numConstraints_) || config.Ax.size() == 0);
assert((config.Ax.size() > 0 && config.Ax.cols() == 3) || config.Ax.size() == 0);
assert((config.Av.size() > 0 && config.Av.rows() == numConstraints_) || config.Av.size() == 0);
assert((config.Av.size() > 0 && config.Av.cols() == 3) || config.Av.size() == 0);
config_ = std::move(config);
}
vector_t EndEffectorLinearConstraint::getValue(scalar_t time, const vector_t& state, const vector_t& input,
const PreComputation& preComp) const {
vector_t f = config_.b;
if (config_.Ax.size() > 0) {
f.noalias() += config_.Ax * endEffectorKinematicsPtr_->getPosition(state).front();
}
if (config_.Av.size() > 0) {
f.noalias() += config_.Av * endEffectorKinematicsPtr_->getVelocity(state, input).front();
}
return f;
}
VectorFunctionLinearApproximation EndEffectorLinearConstraint::getLinearApproximation(scalar_t time, const vector_t& state,
const vector_t& input,
const PreComputation& preComp) const {
VectorFunctionLinearApproximation linearApproximation =
VectorFunctionLinearApproximation::Zero(getNumConstraints(time), state.size(), input.size());
linearApproximation.f = config_.b;
if (config_.Ax.size() > 0) {
const auto positionApprox = endEffectorKinematicsPtr_->getPositionLinearApproximation(state).front();
linearApproximation.f.noalias() += config_.Ax * positionApprox.f;
linearApproximation.dfdx.noalias() += config_.Ax * positionApprox.dfdx;
}
if (config_.Av.size() > 0) {
const auto velocityApprox = endEffectorKinematicsPtr_->getVelocityLinearApproximation(state, input).front();
linearApproximation.f.noalias() += config_.Av * velocityApprox.f;
linearApproximation.dfdx.noalias() += config_.Av * velocityApprox.dfdx;
linearApproximation.dfdu.noalias() += config_.Av * velocityApprox.dfdu;
}
return linearApproximation;
}
} // namespace legged_robot
} // namespace ocs2
| 46.591549 | 124 | 0.674123 | james-p-foster |
64ff86bb1abd98bcc80d11f3bf21964ffda6bf5d | 102 | hpp | C++ | include/libelfxx/sys_types.hpp | syoch/libelfxx | b8717d48f21012df079a05956186296f434f82bc | [
"MIT"
] | null | null | null | include/libelfxx/sys_types.hpp | syoch/libelfxx | b8717d48f21012df079a05956186296f434f82bc | [
"MIT"
] | 1 | 2021-07-04T09:16:49.000Z | 2021-07-04T09:16:49.000Z | include/libelfxx/sys_types.hpp | syoch/libelfxx | b8717d48f21012df079a05956186296f434f82bc | [
"MIT"
] | 1 | 2021-11-26T23:14:02.000Z | 2021-11-26T23:14:02.000Z | #pragma once
enum ClassType
{
class32 = 1,
class64 = 2
};
enum Endian
{
Little = 1,
Big = 2
}; | 9.272727 | 14 | 0.588235 | syoch |
64ffedd24923217129d2d81a58942531afcfffaa | 13,569 | cpp | C++ | cpp/tests/experimental/mg_bfs_test.cpp | goncaloperes/cugraph | d4decff28d1f9b15a95c4bd25a6da21c2ed42ce0 | [
"Apache-2.0"
] | null | null | null | cpp/tests/experimental/mg_bfs_test.cpp | goncaloperes/cugraph | d4decff28d1f9b15a95c4bd25a6da21c2ed42ce0 | [
"Apache-2.0"
] | null | null | null | cpp/tests/experimental/mg_bfs_test.cpp | goncaloperes/cugraph | d4decff28d1f9b15a95c4bd25a6da21c2ed42ce0 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <utilities/high_res_clock.h>
#include <utilities/base_fixture.hpp>
#include <utilities/test_utilities.hpp>
#include <utilities/thrust_wrapper.hpp>
#include <algorithms.hpp>
#include <experimental/graph.hpp>
#include <experimental/graph_functions.hpp>
#include <experimental/graph_view.hpp>
#include <partition_manager.hpp>
#include <raft/comms/comms.hpp>
#include <raft/comms/mpi_comms.hpp>
#include <raft/handle.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>
#include <gtest/gtest.h>
#include <random>
// do the perf measurements
// enabled by command line parameter s'--perf'
//
static int PERF = 0;
typedef struct BFS_Usecase_t {
cugraph::test::input_graph_specifier_t input_graph_specifier{};
size_t source{0};
bool check_correctness{false};
BFS_Usecase_t(std::string const& graph_file_path, size_t source, bool check_correctness = true)
: source(source), check_correctness(check_correctness)
{
std::string graph_file_full_path{};
if ((graph_file_path.length() > 0) && (graph_file_path[0] != '/')) {
graph_file_full_path = cugraph::test::get_rapids_dataset_root_dir() + "/" + graph_file_path;
} else {
graph_file_full_path = graph_file_path;
}
input_graph_specifier.tag = cugraph::test::input_graph_specifier_t::MATRIX_MARKET_FILE_PATH;
input_graph_specifier.graph_file_full_path = graph_file_full_path;
};
BFS_Usecase_t(cugraph::test::rmat_params_t rmat_params,
size_t source,
bool check_correctness = true)
: source(source), check_correctness(check_correctness)
{
input_graph_specifier.tag = cugraph::test::input_graph_specifier_t::RMAT_PARAMS;
input_graph_specifier.rmat_params = rmat_params;
}
} BFS_Usecase;
template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
std::tuple<cugraph::experimental::graph_t<vertex_t, edge_t, weight_t, false, multi_gpu>,
rmm::device_uvector<vertex_t>>
read_graph(raft::handle_t const& handle, BFS_Usecase const& configuration, bool renumber)
{
auto& comm = handle.get_comms();
auto const comm_size = comm.get_size();
auto const comm_rank = comm.get_rank();
std::vector<size_t> partition_ids(multi_gpu ? size_t{1} : static_cast<size_t>(comm_size));
std::iota(partition_ids.begin(),
partition_ids.end(),
multi_gpu ? static_cast<size_t>(comm_rank) : size_t{0});
return configuration.input_graph_specifier.tag ==
cugraph::test::input_graph_specifier_t::MATRIX_MARKET_FILE_PATH
? cugraph::test::
read_graph_from_matrix_market_file<vertex_t, edge_t, weight_t, false, multi_gpu>(
handle, configuration.input_graph_specifier.graph_file_full_path, false, renumber)
: cugraph::test::
generate_graph_from_rmat_params<vertex_t, edge_t, weight_t, false, multi_gpu>(
handle,
configuration.input_graph_specifier.rmat_params.scale,
configuration.input_graph_specifier.rmat_params.edge_factor,
configuration.input_graph_specifier.rmat_params.a,
configuration.input_graph_specifier.rmat_params.b,
configuration.input_graph_specifier.rmat_params.c,
configuration.input_graph_specifier.rmat_params.seed,
configuration.input_graph_specifier.rmat_params.undirected,
configuration.input_graph_specifier.rmat_params.scramble_vertex_ids,
false,
renumber,
partition_ids,
static_cast<size_t>(comm_size));
}
class Tests_MGBFS : public ::testing::TestWithParam<BFS_Usecase> {
public:
Tests_MGBFS() {}
static void SetupTestCase() {}
static void TearDownTestCase() {}
virtual void SetUp() {}
virtual void TearDown() {}
// Compare the results of running BFS on multiple GPUs to that of a single-GPU run
template <typename vertex_t, typename edge_t>
void run_current_test(BFS_Usecase const& configuration)
{
using weight_t = float;
// 1. initialize handle
raft::handle_t handle{};
HighResClock hr_clock{};
raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD);
auto& comm = handle.get_comms();
auto const comm_size = comm.get_size();
auto const comm_rank = comm.get_rank();
auto row_comm_size = static_cast<int>(sqrt(static_cast<double>(comm_size)));
while (comm_size % row_comm_size != 0) { --row_comm_size; }
cugraph::partition_2d::subcomm_factory_t<cugraph::partition_2d::key_naming_t, vertex_t>
subcomm_factory(handle, row_comm_size);
// 2. create MG graph
if (PERF) {
CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
hr_clock.start();
}
cugraph::experimental::graph_t<vertex_t, edge_t, weight_t, false, true> mg_graph(handle);
rmm::device_uvector<vertex_t> d_mg_renumber_map_labels(0, handle.get_stream());
std::tie(mg_graph, d_mg_renumber_map_labels) =
read_graph<vertex_t, edge_t, weight_t, true>(handle, configuration, true);
if (PERF) {
CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
double elapsed_time{0.0};
hr_clock.stop(&elapsed_time);
std::cout << "MG read_graph took " << elapsed_time * 1e-6 << " s.\n";
}
auto mg_graph_view = mg_graph.view();
ASSERT_TRUE(static_cast<vertex_t>(configuration.source) >= 0 &&
static_cast<vertex_t>(configuration.source) <
mg_graph_view.get_number_of_vertices())
<< "Invalid starting source.";
// 3. run MG BFS
rmm::device_uvector<vertex_t> d_mg_distances(mg_graph_view.get_number_of_local_vertices(),
handle.get_stream());
rmm::device_uvector<vertex_t> d_mg_predecessors(mg_graph_view.get_number_of_local_vertices(),
handle.get_stream());
if (PERF) {
CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
hr_clock.start();
}
cugraph::experimental::bfs(handle,
mg_graph_view,
d_mg_distances.data(),
d_mg_predecessors.data(),
static_cast<vertex_t>(configuration.source),
false,
std::numeric_limits<vertex_t>::max());
if (PERF) {
CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
double elapsed_time{0.0};
hr_clock.stop(&elapsed_time);
std::cout << "MG BFS took " << elapsed_time * 1e-6 << " s.\n";
}
// 5. copmare SG & MG results
if (configuration.check_correctness) {
// 5-1. create SG graph
cugraph::experimental::graph_t<vertex_t, edge_t, weight_t, false, false> sg_graph(handle);
std::tie(sg_graph, std::ignore) =
read_graph<vertex_t, edge_t, weight_t, false>(handle, configuration, false);
auto sg_graph_view = sg_graph.view();
std::vector<vertex_t> vertex_partition_lasts(comm_size);
for (size_t i = 0; i < vertex_partition_lasts.size(); ++i) {
vertex_partition_lasts[i] = mg_graph_view.get_vertex_partition_last(i);
}
rmm::device_scalar<vertex_t> d_source(static_cast<vertex_t>(configuration.source),
handle.get_stream());
cugraph::experimental::unrenumber_int_vertices<vertex_t, true>(
handle,
d_source.data(),
size_t{1},
d_mg_renumber_map_labels.data(),
mg_graph_view.get_local_vertex_first(),
mg_graph_view.get_local_vertex_last(),
vertex_partition_lasts,
true);
auto unrenumbered_source = d_source.value(handle.get_stream());
// 5-2. run SG BFS
rmm::device_uvector<vertex_t> d_sg_distances(sg_graph_view.get_number_of_local_vertices(),
handle.get_stream());
rmm::device_uvector<vertex_t> d_sg_predecessors(sg_graph_view.get_number_of_local_vertices(),
handle.get_stream());
cugraph::experimental::bfs(handle,
sg_graph_view,
d_sg_distances.data(),
d_sg_predecessors.data(),
unrenumbered_source,
false,
std::numeric_limits<vertex_t>::max());
// 5-3. compare
std::vector<edge_t> h_sg_offsets(sg_graph_view.get_number_of_vertices() + 1);
std::vector<vertex_t> h_sg_indices(sg_graph_view.get_number_of_edges());
raft::update_host(h_sg_offsets.data(),
sg_graph_view.offsets(),
sg_graph_view.get_number_of_vertices() + 1,
handle.get_stream());
raft::update_host(h_sg_indices.data(),
sg_graph_view.indices(),
sg_graph_view.get_number_of_edges(),
handle.get_stream());
std::vector<vertex_t> h_sg_distances(sg_graph_view.get_number_of_vertices());
std::vector<vertex_t> h_sg_predecessors(sg_graph_view.get_number_of_vertices());
raft::update_host(
h_sg_distances.data(), d_sg_distances.data(), d_sg_distances.size(), handle.get_stream());
raft::update_host(h_sg_predecessors.data(),
d_sg_predecessors.data(),
d_sg_predecessors.size(),
handle.get_stream());
std::vector<vertex_t> h_mg_distances(mg_graph_view.get_number_of_local_vertices());
std::vector<vertex_t> h_mg_predecessors(mg_graph_view.get_number_of_local_vertices());
raft::update_host(
h_mg_distances.data(), d_mg_distances.data(), d_mg_distances.size(), handle.get_stream());
cugraph::experimental::unrenumber_int_vertices<vertex_t, true>(
handle,
d_mg_predecessors.data(),
d_mg_predecessors.size(),
d_mg_renumber_map_labels.data(),
mg_graph_view.get_local_vertex_first(),
mg_graph_view.get_local_vertex_last(),
vertex_partition_lasts,
true);
raft::update_host(h_mg_predecessors.data(),
d_mg_predecessors.data(),
d_mg_predecessors.size(),
handle.get_stream());
std::vector<vertex_t> h_mg_renumber_map_labels(d_mg_renumber_map_labels.size());
raft::update_host(h_mg_renumber_map_labels.data(),
d_mg_renumber_map_labels.data(),
d_mg_renumber_map_labels.size(),
handle.get_stream());
handle.get_stream_view().synchronize();
for (vertex_t i = 0; i < mg_graph_view.get_number_of_local_vertices(); ++i) {
auto mapped_vertex = h_mg_renumber_map_labels[i];
ASSERT_TRUE(h_mg_distances[i] == h_sg_distances[mapped_vertex])
<< "MG BFS distance for vertex: " << mapped_vertex << " in rank: " << comm_rank
<< " has value: " << h_mg_distances[i]
<< " different from the corresponding SG value: " << h_sg_distances[mapped_vertex];
if (h_mg_predecessors[i] == cugraph::invalid_vertex_id<vertex_t>::value) {
ASSERT_TRUE(h_sg_predecessors[mapped_vertex] == h_mg_predecessors[i])
<< "vertex reachability does not match with the SG result.";
} else {
ASSERT_TRUE(h_sg_distances[h_mg_predecessors[i]] + 1 == h_sg_distances[mapped_vertex])
<< "distances to this vertex != distances to the predecessor vertex + 1.";
bool found{false};
for (auto j = h_sg_offsets[h_mg_predecessors[i]];
j < h_sg_offsets[h_mg_predecessors[i] + 1];
++j) {
if (h_sg_indices[j] == mapped_vertex) {
found = true;
break;
}
}
ASSERT_TRUE(found) << "no edge from the predecessor vertex to this vertex.";
}
}
}
}
};
TEST_P(Tests_MGBFS, CheckInt32Int32) { run_current_test<int32_t, int32_t>(GetParam()); }
INSTANTIATE_TEST_CASE_P(
simple_test,
Tests_MGBFS,
::testing::Values(
// enable correctness checks
BFS_Usecase("test/datasets/karate.mtx", 0),
BFS_Usecase("test/datasets/web-Google.mtx", 0),
BFS_Usecase("test/datasets/ljournal-2008.mtx", 0),
BFS_Usecase("test/datasets/webbase-1M.mtx", 0),
BFS_Usecase(cugraph::test::rmat_params_t{10, 16, 0.57, 0.19, 0.19, 0, false, false}, 0),
// disable correctness checks for large graphs
BFS_Usecase(cugraph::test::rmat_params_t{20, 32, 0.57, 0.19, 0.19, 0, false, false},
0,
false)));
CUGRAPH_MG_TEST_PROGRAM_MAIN()
| 41.495413 | 99 | 0.644336 | goncaloperes |
8f0319c8fc93b9a0d9f9a1eb51b7f3a9146c280c | 275 | hpp | C++ | simulator/version.hpp | xuanruiqi/et2-java | 1e82b3a26f6eeb1054da8244173666d107de38ca | [
"BSD-2-Clause"
] | 1 | 2019-05-29T06:35:58.000Z | 2019-05-29T06:35:58.000Z | simulator/version.hpp | xuanruiqi/et2-java | 1e82b3a26f6eeb1054da8244173666d107de38ca | [
"BSD-2-Clause"
] | 22 | 2018-04-04T23:05:09.000Z | 2019-04-20T00:04:03.000Z | simulator/version.hpp | RedlineResearch/QTR-tool | 7838a726b66c990b5278e7f9f5d4c642ed43775d | [
"BSD-2-Clause"
] | 2 | 2018-03-30T19:35:07.000Z | 2019-04-19T23:38:17.000Z | #ifndef _VERSION_H
#define _VERSION_H
extern const char *build_git_time;
extern const char *build_git_sha;
// From Stackoverflow:
// http://stackoverflow.com/questions/1704907/how-can-i-get-my-c-code-to-automatically-print-out-its-git-version-hash
#endif /* _VERSION_H */
| 25 | 117 | 0.778182 | xuanruiqi |
8f07528ecd91228eef5326d3d528862b1f6ffe35 | 170 | cpp | C++ | CodeChef/Easy-Problems/TEST.cpp | annukamat/My-Competitive-Journey | adb13a5723483cde13e5f3859b3a7ad840b86c97 | [
"MIT"
] | 7 | 2018-11-08T11:39:27.000Z | 2020-09-10T17:50:57.000Z | CodeChef/Easy-Problems/TEST.cpp | annukamat/My-Competitive-Journey | adb13a5723483cde13e5f3859b3a7ad840b86c97 | [
"MIT"
] | null | null | null | CodeChef/Easy-Problems/TEST.cpp | annukamat/My-Competitive-Journey | adb13a5723483cde13e5f3859b3a7ad840b86c97 | [
"MIT"
] | 2 | 2019-09-16T14:34:03.000Z | 2019-10-12T19:24:00.000Z | #include <iostream>
using namespace std;
int main(){
int num;
cin>>num;
while(!(num == 42)){
cout<<num<<"\n";
cin>>num;
}
return 0;
} | 14.166667 | 24 | 0.482353 | annukamat |
8f0790cc93f4d594f6f87818ee8d2261670fd344 | 12,406 | cpp | C++ | test/StressTestClients/TestStressTestClient.cpp | natronkeltner/openpegasus | e64f383c1ed37826041fc63e83b4e65fc1c679ae | [
"ICU",
"Unlicense",
"OpenSSL",
"MIT"
] | 1 | 2021-11-12T21:28:50.000Z | 2021-11-12T21:28:50.000Z | test/StressTestClients/TestStressTestClient.cpp | natronkeltner/openpegasus | e64f383c1ed37826041fc63e83b4e65fc1c679ae | [
"ICU",
"Unlicense",
"OpenSSL",
"MIT"
] | 39 | 2021-01-18T19:28:41.000Z | 2022-03-27T20:55:36.000Z | test/StressTestClients/TestStressTestClient.cpp | natronkeltner/openpegasus | e64f383c1ed37826041fc63e83b4e65fc1c679ae | [
"ICU",
"Unlicense",
"OpenSSL",
"MIT"
] | 4 | 2021-07-09T12:52:33.000Z | 2021-12-21T15:05:59.000Z | //%LICENSE////////////////////////////////////////////////////////////////
//
// Licensed to The Open Group (TOG) under one or more contributor license
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
// this work for additional information regarding copyright ownership.
// Each contributor licenses this file to you under the OpenPegasus Open
// Source License; you may not use this file except in compliance with the
// License.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////
//
//%/////////////////////////////////////////////////////////////////////////////
#include "TestStressTestClient.h"
PEGASUS_USING_PEGASUS;
PEGASUS_USING_STD;
/** Constructor - Initializes the time variables and defines the Options
Table.
*/
TestStressTestClient::TestStressTestClient()
{
startMilliseconds = 0;
nowMilliseconds = 0;
nextCheckupInMillisecs = 0;
static struct OptionRow testOptionsTable[] = {
{"namespace", "", false, Option::STRING, 0, 0, "namespace",
"specifies namespace to be used for the test"},
{"classname", "", false, Option::STRING, 0, 0, "classname",
"specifies classname to be used for the test"},
{"verbose", "false", false, Option::BOOLEAN, 0, 0, "verbose",
"If set, outputs extra information "},
{"help", "false", false, Option::BOOLEAN, 0, 0, "help",
"Prints help message with command line options "},
#ifdef PEGASUS_HAS_SSL
{"ssl", "false", false, Option::BOOLEAN, 0, 0, "ssl", "use SSL"},
#endif
{"username", "", false, Option::STRING, 0, 0, "username",
"Specifies user name"},
{"password", "", false, Option::STRING, 0, 0, "password",
"Specifies password"},
{"port", "", false, Option::STRING, 0, 0, "port",
"Port number on host"},
{"clientid", "", true, Option::STRING, 0, 0, "clientid",
"Client identification by controller"},
{"pidfile", "", true, Option::STRING, 0, 0, "pidfile",
"Client process log file"},
{"clientlog", "", true, Option::STRING, 0, 0, "clientlog",
"Client error log file"},
{"hostname", "", false, Option::STRING, 0, 0, "hostname",
"Host name"}
};
optionCount = sizeof(testOptionsTable) / sizeof(testOptionsTable[0]);
optionsTable = testOptionsTable;
}
/**
OPTION MANAGEMENT
*/
/** GetOptions function - This function sets up the options from
testOptionsTable which is initialized through constructor
using the option manager.
const char* optionName;
const char* defaultValue;
int required;
Option::Type type;
char** domain;
Uint32 domainSize;
const char* commandLineOptionName;
const char* optionHelpMessage;
*/
int TestStressTestClient::GetOptions(
OptionManager& om,
int& argc,
char** argv,
OptionRow* newOptionsTable, Uint32 cOptionCount)
{
char **argvv;
int counter = 0;
String argument = String::EMPTY;
//
// om.registerOptions(newOptionsTable, (const)cOptionCount);
//
om.registerOptions(newOptionsTable, cOptionCount);
argvv = argv;
//
// Following section is introduced to ignore options not
// required by a client.
//
for (int i = 1; i < argc; i++)
{
argument = String::EMPTY;
const char* arg = argv[i];
//
// Check for - option.
//
if (*arg == '-')
{
//
// Look for the option.
//
argument.append(arg + 1);
const Option* option = om.lookupOption(argument);
//
// Get the option argument if any.
//
if (option)
{
argvv[++counter]=argv[i];
if (option->getType() != Option::BOOLEAN)
{
if (i + 1 != argc)
{
argvv[++counter] = argv[++i];
}
}
}
}
}
++counter;
om.mergeCommandLine(counter, argvv);
om.checkRequiredOptions();
return counter;
}
/** This method is used by clients to register client specific required
options to the option table. All these options are taken as mandatory one.
*/
OptionRow *TestStressTestClient::generateClientOptions(
OptionRow* clientOptionsTable,
Uint32 clientOptionCount,
Uint32& totalOptions)
{
Uint32 currOptionCount = 0;
static struct OptionRow *newOptionsTable = 0;
totalOptions = optionCount + clientOptionCount;
newOptionsTable = new struct OptionRow[totalOptions];
for (; currOptionCount < optionCount; currOptionCount++)
{
newOptionsTable[currOptionCount] = optionsTable[currOptionCount];
}
for (Uint32 i =0; i < clientOptionCount; i++)
{
newOptionsTable[currOptionCount] = clientOptionsTable[i];
currOptionCount++;
}
return newOptionsTable;
}
/** This method is used by the clients to log information which are required
for controller reference. It logs the information with Client ID and
status of the client in the PID File log file.
*/
void TestStressTestClient::logInfo(
String clientId,
pid_t clientPid,
int clientStatus,
String &pidFile)
{
char pid_str[15];
char status_str[15];
char time_str[32];
#ifdef PEGASUS_OS_TYPE_WINDOWS
int offset = 2;
#else
int offset = 1;
#endif
//
// Get current time for time stamp
//
nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds();
sprintf(pid_str, "%d", clientPid);
sprintf(status_str, "%d", clientStatus);
sprintf(time_str, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u",
nowMilliseconds);
fstream pFile(pidFile.getCString(),ios::in|ios::out);
Boolean addClient= false;
if (!!pFile)
{
String line;
while(!pFile.eof() && GetLine(pFile, line))
{
String subLine;
Uint32 indx=line.find(':');
if (indx != PEG_NOT_FOUND)
{
subLine = line.subString(0, indx);
}
if (String::compare(subLine, clientId) == 0)
{
long pos;
addClient = true;
pos = (long)pFile.tellp();
pFile.seekp(pos - line.size()-offset);
String newLine = clientId;
newLine.append("::");
newLine.append(pid_str);
newLine.append("::");
newLine.append(status_str);
newLine.append("::");
newLine.append(time_str);
Sint32 jSize = line.size() - newLine.size();
CString newLineCString = newLine.getCString();
pFile.write(newLineCString, strlen(newLineCString));
for (Sint32 i = 0; i < jSize; i++)
{
pFile.write(" ",1);
}
break;
}
}
if(!addClient)
{
pFile.close();
fstream newPidFile(pidFile.getCString(),ios::out|ios::app);
newPidFile<<clientId<<"::"<<clientPid<<"::"<<clientStatus<<"::"
<<time_str<<"\n";
}
}
pFile.close();
}
/** This method is used to take the client process start time.*/
void TestStressTestClient::startTime()
{
startMilliseconds = TimeValue::getCurrentTime().toMilliseconds();
nowMilliseconds = startMilliseconds;
}
/** This method is used to check the time stamp for logging information about
the success or failure.
*/
Boolean TestStressTestClient::checkTime()
{
nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds();
if (nowMilliseconds >= nextCheckupInMillisecs)
{
nextCheckupInMillisecs = (Uint64)convertmin2millisecs(CHECKUP_INTERVAL)
+ nowMilliseconds;
return true;
}
return false;
}
/** This method is used to log the information about the client's success or
failure percentage at a specific interval of time.
*/
void TestStressTestClient::logErrorPercentage(
Uint32 successCount,
Uint32 totalCount,
pid_t clientPid,
String &clientLog,
char client[])
{
Uint32 successPercentage, errorPercentage;
successPercentage = (successCount/totalCount)*100;
errorPercentage = 100 - successPercentage;
//
// loging details here
//
ofstream errorLog_File(clientLog.getCString(), ios::app);
errorLog_File<<client<<" PID#"<<clientPid<<" ran "<<totalCount
<<" times with a "<<errorPercentage<<"% failure"<<"\n";
errorLog_File.close();
}
/** This method is used to log the informations of client logs to the client
log file.
*/
void TestStressTestClient::errorLog(
pid_t clientPid,
String &clientLog,
String &message)
{
//
// loging details here .
//
ofstream errorLog_File(clientLog.getCString(), ios::app);
errorLog_File<<" PID#"<<clientPid<<"::"<<message<<"\n";
errorLog_File.close();
}
/** This method handles the SSLCertificate verification part. */
static Boolean verifyCertificate(SSLCertificateInfo &certInfo)
{
//
// Add code to handle server certificate verification.
//
return true;
}
/** This method is used by the clients to connect to the server. If useSSL is
true then an SSL connection will be atemped with the userName and passWord
that is passed in. Otherwise connection will be established using
localhost. All parameters are required.
*/
void TestStressTestClient::connectClient(
CIMClient *client,
String host,
Uint32 portNumber,
String userName,
String password,
Boolean useSSL,
Uint32 timeout,
Boolean verboseTest)
{
if (useSSL)
{
#ifdef PEGASUS_HAS_SSL
//
// Get environment variables.
//
const char* pegasusHome = getenv("PEGASUS_HOME");
String trustpath = FileSystem::getAbsolutePath(
pegasusHome, PEGASUS_SSLCLIENT_CERTIFICATEFILE);
String randFile = String::EMPTY;
#ifdef PEGASUS_SSL_RANDOMFILE
randFile = FileSystem::getAbsolutePath(
pegasusHome,
PEGASUS_SSLCLIENT_RANDOMFILE);
#endif
SSLContext sslContext(
trustpath, verifyCertificate, randFile);
if (verboseTest)
{
cout << "connecting to " << host << ":"
<< portNumber << " using SSL"
<< endl;
}
client->connect (host, portNumber, sslContext, userName, password);
#else
PEGASUS_TEST_ASSERT(false);
#endif
} /* useSSL. */
else
{
if (verboseTest)
{
cout << "Connecting to " << host << ":" << portNumber
<< endl;
}
client->connect (host, portNumber, userName, password);
}
if (verboseTest)
{
cout << "Client Connected" << endl;
}
}
| 30.784119 | 80 | 0.586249 | natronkeltner |
8f07dfbf5bfa333b4f55400f2924f908231cecb4 | 5,557 | cpp | C++ | iceoryx_utils/test/moduletests/test_cxx_helplets.cpp | dotChris90/iceoryx | 9a71b9274d60f5665375e67d142e79660c4c8365 | [
"Apache-2.0"
] | null | null | null | iceoryx_utils/test/moduletests/test_cxx_helplets.cpp | dotChris90/iceoryx | 9a71b9274d60f5665375e67d142e79660c4c8365 | [
"Apache-2.0"
] | null | null | null | iceoryx_utils/test/moduletests/test_cxx_helplets.cpp | dotChris90/iceoryx | 9a71b9274d60f5665375e67d142e79660c4c8365 | [
"Apache-2.0"
] | null | null | null | // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#include "iceoryx_utils/cxx/helplets.hpp"
#include "test.hpp"
#include <type_traits>
namespace
{
using namespace ::testing;
using namespace iox::cxx;
namespace
{
struct Bar
{
alignas(8) uint8_t m_dummy[73];
};
struct Foo
{
uint8_t m_dummy[73];
};
struct FooBar
{
alignas(32) uint8_t m_dummy[73];
};
struct FuBar
{
alignas(32) uint8_t m_dummy[73];
};
} // namespace
class Helplets_test : public Test
{
public:
void SetUp() override
{
}
void TearDown() override
{
}
};
TEST_F(Helplets_test, maxSize)
{
EXPECT_THAT(iox::cxx::maxSize<Foo>(), Eq(sizeof(Foo)));
EXPECT_THAT(sizeof(Bar), Ne(sizeof(Foo)));
EXPECT_THAT((iox::cxx::maxSize<Bar, Foo>()), Eq(sizeof(Bar)));
EXPECT_THAT(sizeof(Bar), Ne(sizeof(FooBar)));
EXPECT_THAT(sizeof(Foo), Ne(sizeof(FooBar)));
EXPECT_THAT((iox::cxx::maxSize<Bar, Foo, FooBar>()), Eq(sizeof(FooBar)));
EXPECT_THAT(sizeof(FooBar), Eq(sizeof(FuBar)));
EXPECT_THAT((iox::cxx::maxSize<FooBar, FuBar>()), Eq(sizeof(FooBar)));
}
TEST_F(Helplets_test, maxAlignment)
{
EXPECT_THAT(iox::cxx::maxAlignment<Foo>(), Eq(alignof(Foo)));
EXPECT_THAT(alignof(Bar), Ne(alignof(Foo)));
EXPECT_THAT((iox::cxx::maxAlignment<Bar, Foo>()), Eq(alignof(Bar)));
EXPECT_THAT(alignof(Bar), Ne(alignof(FooBar)));
EXPECT_THAT(alignof(Foo), Ne(alignof(FooBar)));
EXPECT_THAT((iox::cxx::maxAlignment<Bar, Foo, FooBar>()), Eq(alignof(FooBar)));
EXPECT_THAT(alignof(FooBar), Eq(alignof(FuBar)));
EXPECT_THAT((iox::cxx::maxAlignment<FooBar, FuBar>()), Eq(alignof(FooBar)));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint8WhenValueSmaller256)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<123U>, uint8_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint8WhenValueEqualTo255)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<255U>, uint8_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint16WhenValueEqualTo256)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<256U>, uint16_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint16WhenValueBetween256And65535)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<8172U>, uint16_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint16WhenValueEqualTo65535)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<65535U>, uint16_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint32WhenValueEqualTo65536)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<65536U>, uint32_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint32WhenValueBetween2p16And2p32)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<81721U>, uint32_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint32WhenValueEqualTo4294967295)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<4294967295U>, uint32_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint64WhenValueEqualTo4294967296)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<4294967296U>, uint64_t>::value));
}
TEST_F(Helplets_test, bestFittingTypeUsesUint32WhenValueGreater2p32)
{
EXPECT_TRUE((std::is_same<BestFittingType_t<42949672961U>, uint64_t>::value));
}
template <class T>
class Helplets_test_isPowerOfTwo : public Helplets_test
{
public:
using CurrentType = T;
static constexpr T MAX = std::numeric_limits<T>::max();
static constexpr T MAX_POWER_OF_TWO = MAX / 2U + 1U;
};
using HelpletsIsPowerOfTwoTypes = Types<uint8_t, uint16_t, uint32_t, uint64_t, size_t>;
/// we require TYPED_TEST since we support gtest 1.8 for our safety targets
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
TYPED_TEST_CASE(Helplets_test_isPowerOfTwo, HelpletsIsPowerOfTwoTypes);
#pragma GCC diagnostic pop
TYPED_TEST(Helplets_test_isPowerOfTwo, OneIsPowerOfTwo)
{
EXPECT_TRUE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(1)));
}
TYPED_TEST(Helplets_test_isPowerOfTwo, TwoIsPowerOfTwo)
{
EXPECT_TRUE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(2)));
}
TYPED_TEST(Helplets_test_isPowerOfTwo, FourIsPowerOfTwo)
{
EXPECT_TRUE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(4)));
}
TYPED_TEST(Helplets_test_isPowerOfTwo, MaxPossiblePowerOfTwoForTypeIsPowerOfTwo)
{
EXPECT_TRUE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(TestFixture::MAX_POWER_OF_TWO)));
}
TYPED_TEST(Helplets_test_isPowerOfTwo, ZeroIsNotPowerOfTwo)
{
EXPECT_FALSE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(0)));
}
TYPED_TEST(Helplets_test_isPowerOfTwo, FourtyTwoIsNotPowerOfTwo)
{
EXPECT_FALSE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(42)));
}
TYPED_TEST(Helplets_test_isPowerOfTwo, MaxValueForTypeIsNotPowerOfTwo)
{
EXPECT_FALSE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(TestFixture::MAX)));
}
} // namespace
| 28.792746 | 109 | 0.755983 | dotChris90 |
8f089cd4b779573677570eeb9519ee49c84f0435 | 795 | cpp | C++ | src/gui/widget/BodyWidget/RawBodyTab/RawBodyTabView.cpp | bartkessels/GetIt | 8adde91005d00d83a73227a91b08706657513f41 | [
"MIT"
] | 16 | 2020-09-07T18:53:39.000Z | 2022-03-21T08:15:55.000Z | src/gui/widget/BodyWidget/RawBodyTab/RawBodyTabView.cpp | bartkessels/GetIt | 8adde91005d00d83a73227a91b08706657513f41 | [
"MIT"
] | 23 | 2017-03-29T21:21:43.000Z | 2022-03-23T07:27:55.000Z | src/gui/widget/BodyWidget/RawBodyTab/RawBodyTabView.cpp | bartkessels/GetIt | 8adde91005d00d83a73227a91b08706657513f41 | [
"MIT"
] | 4 | 2020-06-15T12:51:10.000Z | 2021-09-05T20:50:46.000Z | #include "gui/widget/BodyWidget/RawBodyTab/RawBodyTabView.hpp"
#include "./ui_RawBodyTabView.h"
using namespace getit::gui::widget::BodyWidget;
RawBodyTabView::RawBodyTabView(QWidget* parent):
QWidget(parent),
ui(new Ui::RawBodyTabView())
{
ui->setupUi(this);
}
RawBodyTabView::~RawBodyTabView()
{
delete ui;
}
std::string RawBodyTabView::getContentType()
{
return ui->contentType->text().toStdString();
}
std::string RawBodyTabView::getBody()
{
return ui->rawBody->document()->toPlainText().toStdString();
}
void RawBodyTabView::setContentType(std::string contentType)
{
ui->contentType->setText(QString::fromStdString(contentType));
}
void RawBodyTabView::setBody(std::string body)
{
ui->rawBody->document()->setPlainText(QString::fromStdString(body));
} | 22.083333 | 72 | 0.72956 | bartkessels |
8f0aae5ef2fb431e62be4fae3a33b1d5bd52d29e | 1,174 | hh | C++ | gazebo/gui/model/GraphScene_TEST.hh | traversaro/gazebo | 6fd426b3949c4ca73fa126cde68f5cc4a59522eb | [
"ECL-2.0",
"Apache-2.0"
] | 887 | 2020-04-18T08:43:06.000Z | 2022-03-31T11:58:50.000Z | gazebo/gui/model/GraphScene_TEST.hh | traversaro/gazebo | 6fd426b3949c4ca73fa126cde68f5cc4a59522eb | [
"ECL-2.0",
"Apache-2.0"
] | 462 | 2020-04-21T21:59:19.000Z | 2022-03-31T23:23:21.000Z | gazebo/gui/model/GraphScene_TEST.hh | traversaro/gazebo | 6fd426b3949c4ca73fa126cde68f5cc4a59522eb | [
"ECL-2.0",
"Apache-2.0"
] | 421 | 2020-04-21T09:13:03.000Z | 2022-03-30T02:22:01.000Z | /*
* Copyright (C) 2015 Open Source Robotics Foundation
*
* 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 _GAZEBO_GRAPHSCENE_TEST_HH_
#define _GAZEBO_GRAPHSCENE_TEST_HH_
#include "gazebo/gui/QTestFixture.hh"
/// \brief A test class for GraphScene class.
class GraphScene_TEST : public QTestFixture
{
Q_OBJECT
/// \brief Test initialization.
private slots: void Initialization();
/// \brief Test addition and removal of nodes.
private slots: void NodeUpdates();
/// \brief Test addition and removal of edges.
private slots: void EdgeUpdates();
/// \brief Test setting of edge color.
private slots: void EdgeColor();
};
#endif
| 27.952381 | 75 | 0.736797 | traversaro |
557f2b58794d0d4e0f9604d125de0a6bc6e95df8 | 1,830 | cpp | C++ | Source/Tetris3D/Tetris3DSpawner.cpp | dingjun/Tetris3D | 66adfa23a8fb94376553dcc890fd0a61d9e8c297 | [
"MIT"
] | null | null | null | Source/Tetris3D/Tetris3DSpawner.cpp | dingjun/Tetris3D | 66adfa23a8fb94376553dcc890fd0a61d9e8c297 | [
"MIT"
] | null | null | null | Source/Tetris3D/Tetris3DSpawner.cpp | dingjun/Tetris3D | 66adfa23a8fb94376553dcc890fd0a61d9e8c297 | [
"MIT"
] | null | null | null | // Fill out your copyright notice in the Description page of Project Settings.
#include "Tetris3DSpawner.h"
#include "Tetris3DTetromino.h"
#include "Tetris3DGameMode.h"
#include "Engine/World.h"
// Sets default values
ATetris3DSpawner::ATetris3DSpawner()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
// Create dummy root scene component
DummyRoot = CreateDefaultSubobject<USceneComponent>(TEXT("Dummy0"));
RootComponent = DummyRoot;
}
// Called when the game starts or when spawned
void ATetris3DSpawner::BeginPlay()
{
Super::BeginPlay();
GameMode = (ATetris3DGameMode*)(GetWorld()->GetAuthGameMode());
}
void ATetris3DSpawner::SpawnTetromino()
{
if (GameMode->GetCurrentState() != ETetris3DPlayState::EPlaying)
{
return;
}
ATetris3DTetromino* Tetromino;
int32 RandIndex = FMath::RandHelper(3);
switch (RandIndex)
{
case 0:
Tetromino = GetWorld()->SpawnActor<ATetris3DTetromino>(TetrominoI, GetActorLocation(), FRotator(0, 0, 0));
break;
case 1:
Tetromino = GetWorld()->SpawnActor<ATetris3DTetromino>(TetrominoO, GetActorLocation(), FRotator(0, 0, 0));
break;
case 2:
Tetromino = GetWorld()->SpawnActor<ATetris3DTetromino>(TetrominoT, GetActorLocation(), FRotator(0, 0, 0));
break;
}
TetrominoArray.Push(Tetromino);
}
void ATetris3DSpawner::Init()
{
for (auto Tetromino : TetrominoArray)
{
Tetromino->Destroy();
}
TetrominoArray.SetNum(0);
SpawnTetromino();
}
void ATetris3DSpawner::MoveActiveTetrominoLeft()
{
TetrominoArray.Top()->MoveLeft();
}
void ATetris3DSpawner::MoveActiveTetrominoRight()
{
TetrominoArray.Top()->MoveRight();
}
void ATetris3DSpawner::MoveActiveTetrominoDown()
{
TetrominoArray.Top()->MoveDown();
}
| 24.4 | 115 | 0.727322 | dingjun |
557f74abe6322e2eeeab60c9ae0dfc457bcfa204 | 1,304 | cpp | C++ | CMinus/CMinus/node/list_node.cpp | benbraide/CMinus | 3b845e0bc22840b549f108bf6600f1f34d865e7b | [
"MIT"
] | null | null | null | CMinus/CMinus/node/list_node.cpp | benbraide/CMinus | 3b845e0bc22840b549f108bf6600f1f34d865e7b | [
"MIT"
] | null | null | null | CMinus/CMinus/node/list_node.cpp | benbraide/CMinus | 3b845e0bc22840b549f108bf6600f1f34d865e7b | [
"MIT"
] | null | null | null | #include "../logic/runtime.h"
#include "list_node.h"
cminus::node::list::list(object *parent, const std::vector<std::shared_ptr<object>> &value)
: object(parent), value_(value){}
cminus::node::list::list(object *parent, std::vector<std::shared_ptr<object>> &&value)
: object(parent), value_(std::move(value)){}
cminus::node::list::~list() = default;
const cminus::node::object::index_info &cminus::node::list::get_index() const{
return value_[0]->get_index();
}
std::shared_ptr<cminus::node::object> cminus::node::list::clone() const{
std::vector<std::shared_ptr<object>> value;
value.reserve(value_.size());
for (auto item : value_)
value.push_back(item->clone());
return std::make_shared<list>(nullptr, value);
}
void cminus::node::list::print(logic::runtime &runtime) const{
auto is_first = true;
for (auto item : value_){
if (!is_first)
runtime.writer.write_scalar(', ');
else
is_first = false;
item->print(runtime);
}
}
std::shared_ptr<cminus::memory::reference> cminus::node::list::evaluate(logic::runtime &runtime) const{
std::shared_ptr<memory::reference> result;
for (auto item : value_)
result = item->evaluate(runtime);
return result;
}
const std::vector<std::shared_ptr<cminus::node::object>> &cminus::node::list::get_value() const{
return value_;
}
| 26.612245 | 103 | 0.697853 | benbraide |
557fc58ce0b623b4afaa2af211a1f90c521732bd | 1,924 | hpp | C++ | Sniper.hpp | dvirs12345/cpp-wargame2 | 084f93e124b723730d716379282bdd1bf394d3ea | [
"MIT"
] | null | null | null | Sniper.hpp | dvirs12345/cpp-wargame2 | 084f93e124b723730d716379282bdd1bf394d3ea | [
"MIT"
] | null | null | null | Sniper.hpp | dvirs12345/cpp-wargame2 | 084f93e124b723730d716379282bdd1bf394d3ea | [
"MIT"
] | null | null | null | // Author - Dvir Sadon
#include "Soldier.hpp"
#include "Board.hpp"
#define MAX_HEALTHS 100
#define DPAS 50
#pragma once
using namespace std;
namespace WarGame
{
class Sniper : public Soldier
{
public:
int dpa;
Sniper(){ this->hp = MAX_HEALTHS; this->dpa = DPAS; this->maxHP = MAX_HEALTHS; this->type = 2; }
Sniper(int player) { this->player = player; this->hp = MAX_HEALTHS; this->dpa = DPAS; this->maxHP = MAX_HEALTHS; this->type = 2; }
void MAction(std::vector<std::vector<Soldier*>> &board, std::pair<int,int> dest_location) override
{
auto close = strongest(board, board[dest_location.first][dest_location.second]->player, dest_location);
board[close.first][close.second]->hp = board[close.first][close.second]->hp - this->dpa; // Shoot!
if(board[close.first][close.second]->hp <= 0)
board[close.first][close.second] = nullptr;
}
private:
pair<int, int> strongest(std::vector<std::vector<Soldier*>> &board, int playernum, pair<int, int> loc1)
{
int max = 0;
int temp;
pair<int, int> sol;
for(int i= 0; i < board.size(); ++i)
{
for(int j = 0; j < board[0].size(); ++j)
{
if(board[i][j] != nullptr)
{
temp = board[i][j]->hp;
if(temp >= max && board[i][j]->player != playernum)
{
max = temp;
sol.first = i;
sol.second = j;
}
}
}
}
return sol;
}
};
} | 37 | 143 | 0.43815 | dvirs12345 |
55820b931ae22cd1c3a397d4abb4bb91b4f731c3 | 1,515 | cpp | C++ | src/utils/ComplexCalculator.cpp | nolasconapoleao/complex-library | cbf4ee14739a42a9f6880440ad37a1854cbad8f5 | [
"MIT"
] | null | null | null | src/utils/ComplexCalculator.cpp | nolasconapoleao/complex-library | cbf4ee14739a42a9f6880440ad37a1854cbad8f5 | [
"MIT"
] | 1 | 2020-02-19T21:12:21.000Z | 2020-02-19T21:12:21.000Z | src/utils/ComplexCalculator.cpp | nolasconapoleao/complex-library | cbf4ee14739a42a9f6880440ad37a1854cbad8f5 | [
"MIT"
] | null | null | null | #include "../complex/RectangularComplex.h"
#include "../complex/PolarComplex.h"
#include "ComplexConverter.cpp"
namespace complex {
inline RectangularComplex operator+(RectangularComplex rc1, RectangularComplex rc2) {
const double real = rc1.getReal() + rc2.getReal();
const double imaginary = rc1.getImaginary() + rc2.getImaginary();
return RectangularComplex(real, imaginary);
}
inline RectangularComplex operator+(RectangularComplex rc, PolarComplex pc) {
auto rc2 = toRectangular(pc);
const double real = rc.getReal() + rc2.getReal();
const double iamginary = rc.getImaginary() + rc2.getImaginary();
return RectangularComplex(real, iamginary);
}
inline PolarComplex operator+(PolarComplex pc1, PolarComplex pc2) {
auto rc1 = toRectangular(pc1);
auto rc2 = toRectangular(pc2);
const double real = rc1.getReal() + rc2.getReal();
const double iamginary = rc1.getImaginary() + rc2.getImaginary();
RectangularComplex resRec(real, iamginary);
PolarComplex resPol = toPolar(resRec);
return resPol;
}
inline PolarComplex operator+(PolarComplex pc, RectangularComplex rc) {
auto rc2 = toRectangular(pc);
const double real = rc.getReal() + rc2.getReal();
const double iamginary = rc.getImaginary() + rc2.getImaginary();
RectangularComplex resRec(real, iamginary);
PolarComplex resPol = toPolar(resRec);
return resPol;
}
};
| 37.875 | 89 | 0.671947 | nolasconapoleao |
5584b10f0ac21752110b8cf5c25a9075ec19cf44 | 23 | cpp | C++ | CudaTest/CudaTest.cpp | chenzhengxi/example | 07a8436e92ccab8e330d2a77e2cca23b8a540df3 | [
"MIT"
] | null | null | null | CudaTest/CudaTest.cpp | chenzhengxi/example | 07a8436e92ccab8e330d2a77e2cca23b8a540df3 | [
"MIT"
] | null | null | null | CudaTest/CudaTest.cpp | chenzhengxi/example | 07a8436e92ccab8e330d2a77e2cca23b8a540df3 | [
"MIT"
] | null | null | null | int CudaTest()
{
} | 5.75 | 14 | 0.478261 | chenzhengxi |
5587f0d801da097b18d89797e2ed364a87ec2c39 | 7,393 | cpp | C++ | ARM/ST/STM32L4xx/src/i2c_stm32l4xx.cpp | tmaltesen/IOsonata | 3ada9216305653670fccfca8fd53c6597ace8f12 | [
"MIT"
] | null | null | null | ARM/ST/STM32L4xx/src/i2c_stm32l4xx.cpp | tmaltesen/IOsonata | 3ada9216305653670fccfca8fd53c6597ace8f12 | [
"MIT"
] | null | null | null | ARM/ST/STM32L4xx/src/i2c_stm32l4xx.cpp | tmaltesen/IOsonata | 3ada9216305653670fccfca8fd53c6597ace8f12 | [
"MIT"
] | null | null | null | /**-------------------------------------------------------------------------
@file i2c_stm32l4xx.cpp
@brief I2C implementation on STM32L4xx series MCU
@author Hoang Nguyen Hoan
@date Sep. 5, 2019
@license
Copyright (c) 2019, I-SYST inc., all rights reserved
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies, and none of the
names : I-SYST or its contributors may be used to endorse or
promote products derived from this software without specific prior written
permission.
For info or contributing contact : hnhoan at i-syst dot com
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------------*/
#include "stm32l4xx.h"
#include "istddef.h"
#include "coredev/i2c.h"
#include "iopinctrl.h"
#include "system_core_clock.h"
#include "idelay.h"
#include "diskio_flash.h"
#define STM32L4XX_I2C_MAXDEV 3
#pragma pack(push, 4)
typedef struct {
int DevNo;
I2CDEV *pI2cDev;
I2C_TypeDef *pReg;
} STM32L4XX_I2CDEV;
#pragma pack(pop)
static STM32L4XX_I2CDEV s_STM32L4xxI2CDev[STM32L4XX_I2C_MAXDEV] = {
{
0, NULL, .pReg = I2C1
},
{
1, NULL, .pReg = I2C2
},
{
2, NULL, .pReg = I2C3
},
};
static int STM32L4xxI2CGetRate(DEVINTRF * const pDev)
{
int rate = 0;
return rate;
}
// Set data rate in bits/sec (Hz)
// return actual rate
static int STM32L4xxI2CSetRate(DEVINTRF * const pDev, int DataRate)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev->pDevData;
uint32_t pclk = SystemPeriphClockGet();
uint32_t div = (pclk + (DataRate >> 1)) / DataRate;
return DataRate;
}
void STM32L4xxI2CDisable(DEVINTRF * const pDev)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev->pDevData;
int32_t timout = 100000;
}
static void STM32L4xxI2CEnable(DEVINTRF * const pDev)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev->pDevData;
}
static void STM32L4xxI2CPowerOff(DEVINTRF * const pDev)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev->pDevData;
}
// Initial receive
static bool STM32L4xxI2CStartRx(DEVINTRF * const pDev, int DevCs)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev->pDevData;
return true;
}
// Receive Data only, no Start/Stop condition
static int STM32L4xxI2CRxDataDma(DEVINTRF * const pDev, uint8_t *pBuff, int BuffLen)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev-> pDevData;
int cnt = 0;
return cnt;
}
// Receive Data only, no Start/Stop condition
static int STM32L4xxI2CRxData(DEVINTRF * const pDev, uint8_t *pBuff, int BuffLen)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev-> pDevData;
int cnt = 0;
uint16_t d = 0;
return cnt;
}
// Stop receive
static void STM32L4xxI2CStopRx(DEVINTRF * const pDev)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev-> pDevData;
}
// Initiate transmit
static bool STM32L4xxI2CStartTx(DEVINTRF * const pDev, int DevCs)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev-> pDevData;
return true;
}
// Transmit Data only, no Start/Stop condition
static int STM32L4xxI2CTxDataDma(DEVINTRF * const pDev, uint8_t *pData, int DataLen)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev-> pDevData;
int cnt = 0;
return cnt;
}
// Send Data only, no Start/Stop condition
static int STM32L4xxI2CTxData(DEVINTRF *pDev, uint8_t *pData, int DataLen)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV*)pDev->pDevData;
int cnt = 0;
uint16_t d;
return cnt;
}
// Stop transmit
static void STM32L4xxI2CStopTx(DEVINTRF * const pDev)
{
STM32L4XX_I2CDEV *dev = (STM32L4XX_I2CDEV *)pDev-> pDevData;
}
void I2CIrqHandler(int DevNo)
{
STM32L4XX_I2CDEV *dev = &s_STM32L4xxI2CDev[DevNo];
}
bool I2CInit(I2CDEV * const pDev, const I2CCFG *pCfgData)
{
I2C_TypeDef *reg;
uint32_t cr1reg = 0;
uint32_t tmp = 0;
bool retval = false;
if (pDev == NULL || pCfgData == NULL)
{
return false;
}
if (pCfgData->DevNo >= STM32L4XX_I2C_MAXDEV)
{
return false;
}
pDev->Mode = pCfgData->Mode;
s_STM32L4xxI2CDev[pCfgData->DevNo].pI2cDev = pDev;
pDev->DevIntrf.pDevData = (void*)&s_STM32L4xxI2CDev[pCfgData->DevNo];
// Configure I/O pins
memcpy(pDev->Pins, pCfgData->Pins, sizeof(pDev->Pins));
IOPinCfg(pCfgData->Pins, I2C_MAX_NB_IOPIN);
for (int i = 0; i < I2C_MAX_NB_IOPIN; i++)
{
IOPinSetSpeed(pCfgData->Pins[i].PortNo, pCfgData->Pins[i].PinNo, IOPINSPEED_TURBO);
}
// Get the correct register map
reg = s_STM32L4xxI2CDev[pCfgData->DevNo].pReg;
// Note : this function call will modify CR1 register
STM32L4xxI2CSetRate(&pDev->DevIntrf, pCfgData->Rate);
pDev->DevIntrf.Type = DEVINTRF_TYPE_SPI;
pDev->DevIntrf.Disable = STM32L4xxI2CDisable;
pDev->DevIntrf.Enable = STM32L4xxI2CEnable;
pDev->DevIntrf.GetRate = STM32L4xxI2CGetRate;
pDev->DevIntrf.SetRate = STM32L4xxI2CSetRate;
pDev->DevIntrf.StartRx = STM32L4xxI2CStartRx;
pDev->DevIntrf.RxData = STM32L4xxI2CRxData;
pDev->DevIntrf.StopRx = STM32L4xxI2CStopRx;
pDev->DevIntrf.StartTx = STM32L4xxI2CStartTx;
pDev->DevIntrf.TxData = STM32L4xxI2CTxData;
pDev->DevIntrf.StopTx = STM32L4xxI2CStopTx;
pDev->DevIntrf.IntPrio = pCfgData->IntPrio;
pDev->DevIntrf.EvtCB = pCfgData->EvtCB;
pDev->DevIntrf.MaxRetry = pCfgData->MaxRetry;
pDev->DevIntrf.bDma = pCfgData->bDmaEn;
pDev->DevIntrf.PowerOff = STM32L4xxI2CPowerOff;
pDev->DevIntrf.EnCnt = 1;
atomic_flag_clear(&pDev->DevIntrf.bBusy);
if (pCfgData->bIntEn && pCfgData->Mode == I2CMODE_SLAVE)
{
switch (pCfgData->DevNo)
{
case 0:
NVIC_ClearPendingIRQ(I2C1_EV_IRQn);
NVIC_SetPriority(I2C1_EV_IRQn, pCfgData->IntPrio);
NVIC_EnableIRQ(I2C1_EV_IRQn);
break;
case 1:
NVIC_ClearPendingIRQ(I2C2_EV_IRQn);
NVIC_SetPriority(I2C2_EV_IRQn, pCfgData->IntPrio);
NVIC_EnableIRQ(I2C2_EV_IRQn);
break;
case 2:
NVIC_ClearPendingIRQ(I2C3_EV_IRQn);
NVIC_SetPriority(I2C3_EV_IRQn, pCfgData->IntPrio);
NVIC_EnableIRQ(I2C3_EV_IRQn);
break;
}
}
return true;
}
void QSPIIrqHandler()
{
}
extern "C" void I2C1_EV_IRQHandler(void)
{
NVIC_ClearPendingIRQ(I2C1_EV_IRQn);
}
extern "C" void I2C1_ER_IRQHandler(void)
{
NVIC_ClearPendingIRQ(I2C1_ER_IRQn);
}
extern "C" void I2C2_EV_IRQHandler(void)
{
NVIC_ClearPendingIRQ(I2C2_EV_IRQn);
}
extern "C" void I2C2_ER_IRQHandler(void)
{
NVIC_ClearPendingIRQ(I2C2_ER_IRQn);
}
extern "C" void I2C3_EV_IRQHandler()
{
NVIC_ClearPendingIRQ(I2C3_EV_IRQn);
}
extern "C" void I2C3_ER_IRQHandler()
{
NVIC_ClearPendingIRQ(I2C3_ER_IRQn);
}
| 24.976351 | 85 | 0.710943 | tmaltesen |
558848098a7f26a6f3528ea53ac0c3411668a351 | 4,584 | cpp | C++ | srcs/cgi/Cgi.cpp | NeuggWebserv/webserv | 0b90c362239761f561a0db8b03da4c4586a44197 | [
"MIT"
] | null | null | null | srcs/cgi/Cgi.cpp | NeuggWebserv/webserv | 0b90c362239761f561a0db8b03da4c4586a44197 | [
"MIT"
] | 6 | 2021-04-17T10:28:23.000Z | 2021-05-02T09:51:32.000Z | srcs/cgi/Cgi.cpp | NeuggWebserv/webserv | 0b90c362239761f561a0db8b03da4c4586a44197 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Cgi.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: youlee <youlee@student.42seoul.kr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/13 19:04:40 by youlee #+# #+# */
/* Updated: 2021/05/13 19:04:41 by youlee ### ########.fr */
/* */
/* ************************************************************************** */
#include "Cgi.hpp"
Cgi::Cgi(Request &request, ConfigRequest &config):body(request.get_body())
{
this->init_env(request, config);
}
Cgi::Cgi(Cgi const &src)
{
if (this != &src)
{
this->body = src.body;
this->env = src.env;
}
return ;
}
Cgi::~Cgi(void)
{
return ;
}
Cgi &Cgi::operator=(Cgi const &src)
{
if (this != &src)
{
this->body = src.body;
this->env = src.env;
}
return (*this);
}
void Cgi::init_env(Request &request, ConfigRequest &config)
{
std::map<std::string, std::string> headers = request.get_headers();
if (headers.find("Auth-Scheme") != headers.end() && headers["Auth-Scheme"] != "")
this->env["AUTH_TYPE"] = headers["Authorization"];
this->env["REDIRECT_STATUS"] = "200";
this->env["GATAWAY_INTERFACE"] = "CGI/1.1";
this->env["SCRIPT_NAME"] = config.get_path();
this->env["SCRIPT_FILENAME"] = config.get_path();
this->env["REQUEST_METHOD"] = request.get_method();
this->env["CONTENT_LENGTH"] = to_string(this->body.length());
this->env["CONTENT_TYPE"] = headers["Content-Type"];
this->env["PATH_INFO"] = request.get_path();
this->env["PATH_TRANSLATED"] = request.get_path();
this->env["QUERY_STRING"] = request.get_query();
this->env["REMOTEaddr"] = to_string(config.get_host_port().host);
this->env["REMOTE_IDENT"] = headers["Authorization"];
this->env["REMOTE_USER"] = headers["Authorization"];
this->env["REQUEST_URI"] = request.get_path() + request.get_query();
if (headers.find("Hostname") != headers.end())
this->env["SERVER_NAME"] = headers["Hostname"];
else
this->env["SERVER_NAME"] = this->env["REMOTEaddr"];
this->env["SERVER_PORT"] = to_string(config.get_host_port().port);
this->env["SERVER_PROTOCOL"] = "HTTP/1.1";
this->env["SERVER_SOFTWARE"] = "Weebserv/1.0";
this->env.insert(config.get_cgi_param().begin(), config.get_cgi_param().end());
}
char **Cgi::get_env_as_cstr_array() const
{
char **env = new char*[this->env.size() + 1];
int j = 0;
for (std::map<std::string, std::string>::const_iterator i = this->env.begin();i != this->env.end();i++)
{
std::string element = i->first + "=" + i->second;
env[j] = new char[element.size() + 1];
env[j] = strcpy(env[j], (const char*)element.c_str());
j++;
}
env[j] = NULL;
return (env);
}
std::string Cgi::execute_cgi(const std::string &script_name)
{
pid_t pid;
int save_stdin;
int save_stdout;
char **env;
std::string new_body;
try
{
env = this->get_env_as_cstr_array();
}
catch(const std::bad_alloc& e)
{
std::cerr << e.what() << std::endl;
}
save_stdin = dup(STDIN_FILENO);
save_stdout = dup(STDOUT_FILENO);
FILE *file_in = tmpfile();
FILE *file_out = tmpfile();
long fd_in = fileno(file_in);
long fd_out = fileno(file_out);
int ret = 1;
write(fd_in, body.c_str(), body.size());
lseek(fd_in, 0, SEEK_SET);
pid = fork();
if (pid == -1)
{
std::cerr << "Fork crashed." << std::endl;
return ("Status: 500\r\n\r\n");
}
else if (!pid)
{
char * const *nll = NULL;
dup2(fd_in, STDIN_FILENO);
dup2(fd_out, STDOUT_FILENO);
execve(script_name.c_str(), nll, env);
std::cerr<< "Execve crashed." << std::endl;
write(STDOUT_FILENO, "Status; 500\r\n\r\n", 15);
}
else
{
char buf[CGI_BUF_SIZE] = {0};
waitpid(-1, NULL, 0);
lseek(fd_out, 0, SEEK_SET);
ret = 1;
while (ret > 0)
{
memset(buf, 0, CGI_BUF_SIZE);
ret = read(fd_out, buf, CGI_BUF_SIZE - 1);
new_body += buf;
}
}
dup2(save_stdin,STDIN_FILENO);
dup2(save_stdout,STDOUT_FILENO);
fclose(file_in);
fclose(file_out);
close(fd_in);
close(fd_out);
close(save_stdout);
close(save_stdin);
for (size_t i = 0; env[i];i++)
delete[] env[i];
delete[] env;
if (!pid) exit(0);
return (new_body);
} | 27.95122 | 104 | 0.535558 | NeuggWebserv |
5589864eb0b9da27235090e3be5ead4587c55c20 | 1,330 | cpp | C++ | E11/E11B.cpp | tomhickey888/CS2014-CS1 | 61ad3a54e5dd4c591049fb0916d459f06beee578 | [
"MIT"
] | null | null | null | E11/E11B.cpp | tomhickey888/CS2014-CS1 | 61ad3a54e5dd4c591049fb0916d459f06beee578 | [
"MIT"
] | null | null | null | E11/E11B.cpp | tomhickey888/CS2014-CS1 | 61ad3a54e5dd4c591049fb0916d459f06beee578 | [
"MIT"
] | null | null | null | //Hickey, Thomas Matzen Fall 2013 Exercise 11 B
//Overview: Gets a file name from the user and reads from the file the number of numbers
// to be averaged and the numbers themselves, then displays the average. Stores
// the numbers in an array and then displays them in reverse order.
//Compiler Used: G++ with TextPad editor
//Status: Compiles and meets the requirements
//Help: Jackie -- Help with runtime error/max array values
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
const int MAX=10;
int i, N, num;
int array[MAX];
float total=0;
string fname;
ifstream inFile;
cout << "Please enter the name of the input file: ";
cin >> fname;
inFile.open(fname.c_str());
if(!inFile)
{
cout << endl << "Cannot find and open input file " << fname << "." << endl << endl;
exit(0);
}
inFile >> N;
while(N > 10 || N <= 0)
{
cout << endl << "Data Error. Cannot process a file with " << N << " numbers in it. " << endl << endl;
exit(0);
}
for(int i=0; i < N; i++)
{
inFile >> num;
array[i] = num;
total+=num;
}
cout << endl << "The average of your " << N << " numbers is " << total/N << "." << endl;
cout << endl << "The numbers in reverse order are: " << endl;
for (int j= N - 1; j>=0; j--)
cout << array[j] << ", ";
cout << endl << endl;
}
| 22.166667 | 102 | 0.621053 | tomhickey888 |
558a3d69356d7d3ef7643277e86e3a6b9d8b6655 | 1,746 | cpp | C++ | src/io/position_sensor.cpp | armeenm/terradecerpea | 7e64dc3b539061ad0a9e37ca5ec2e236376cfcc3 | [
"0BSD"
] | null | null | null | src/io/position_sensor.cpp | armeenm/terradecerpea | 7e64dc3b539061ad0a9e37ca5ec2e236376cfcc3 | [
"0BSD"
] | null | null | null | src/io/position_sensor.cpp | armeenm/terradecerpea | 7e64dc3b539061ad0a9e37ca5ec2e236376cfcc3 | [
"0BSD"
] | null | null | null | #include "io/position_sensor.h"
#include <ilanta/control/pose.hpp>
#include <spdlog/fmt/bundled/core.h>
#include <spdlog/spdlog.h>
#include <stdexcept>
#include <string>
constexpr int MAX_RESP_SIZE = 1000;
PositionSensor::PositionSensor(plhm::DevType dev_type)
: sensor_(plhm::DevHandle(nullptr, dev_type)) {
spdlog::info("Constructing PositionSensor of type {}", dev_type);
if (!sensor_.check_connection()) {
auto const err = fmt::format("Failed to create Polhemus sensor of type {}", dev_type);
spdlog::error(err);
throw std::runtime_error(err);
}
(void)sensor_.send_cmd("F0", MAX_RESP_SIZE);
(void)sensor_.send_cmd("U1", MAX_RESP_SIZE);
(void)sensor_.send_cmd("O*,2", MAX_RESP_SIZE);
}
auto PositionSensor::pose() const noexcept -> std::optional<ilanta::PoseTL<float>> {
// TODO: Make libpolhemus not throw here
//
try {
auto pose = ilanta::PoseTL<float>{};
auto constexpr delim = ',';
auto const resp_str = sensor_.send_cmd("p", MAX_RESP_SIZE);
auto const delim1 = std::find(std::begin(resp_str), std::end(resp_str), delim);
[[unlikely]] if (delim1 == std::end(resp_str)) {
spdlog::error("Pose data from sensor was invalid");
return std::nullopt;
}
auto const delim2 = std::find(delim1 + 1, std::end(resp_str), delim);
auto delim1_p = const_cast<char*>(&(*delim1));
auto delim2_p = const_cast<char*>(&(*delim2));
auto end_p = const_cast<char*>(&(*std::end(resp_str)));
pose.x(std::strtof(&(*std::begin(resp_str)), &delim1_p));
pose.y(std::strtof(delim1_p + 1, &delim2_p));
pose.z(std::strtof(delim2_p + 1, &end_p));
return pose;
} catch (std::exception const& e) {
spdlog::error(e.what());
return std::nullopt;
}
}
| 30.103448 | 90 | 0.662658 | armeenm |
55947a783c75b740e572a4d65c9e6e913d77f08f | 373 | hpp | C++ | internal/states/common/helper/helper.hpp | YarikRevich/SyE | 3f73350f7e8fd9975e747c9c49667bbee278b594 | [
"MIT"
] | null | null | null | internal/states/common/helper/helper.hpp | YarikRevich/SyE | 3f73350f7e8fd9975e747c9c49667bbee278b594 | [
"MIT"
] | null | null | null | internal/states/common/helper/helper.hpp | YarikRevich/SyE | 3f73350f7e8fd9975e747c9c49667bbee278b594 | [
"MIT"
] | null | null | null | #pragma once
#include <map>
#include <vector>
#include "./../../../bufs/bufs.hpp"
namespace CommonStateHelper
{
extern std::map<int, bool> key_handlers;
extern std::vector<int> key_exceptions;
bool isKeyException(int ch);
void setKeyHandled(int ch);
bool isKeyHandled(int ch);
void resetKeysHandled();
bool isCommonKeyHandler(int ch);
}; | 16.954545 | 44 | 0.678284 | YarikRevich |
55972b851352520c2b14283bdff07d19935cad7a | 12,562 | cpp | C++ | examples/bin_detector/odkex_bin_detector.cpp | HpLightcorner/OXYGEN-SDK | 4ede0ea07b513032605b32fc86539f081589e58c | [
"MIT"
] | 4 | 2019-12-20T18:21:03.000Z | 2020-09-08T05:16:53.000Z | examples/bin_detector/odkex_bin_detector.cpp | HpLightcorner/OXYGEN-SDK | 4ede0ea07b513032605b32fc86539f081589e58c | [
"MIT"
] | 13 | 2020-07-01T19:35:08.000Z | 2022-03-18T13:58:06.000Z | examples/bin_detector/odkex_bin_detector.cpp | HpLightcorner/OXYGEN-SDK | 4ede0ea07b513032605b32fc86539f081589e58c | [
"MIT"
] | 3 | 2020-07-28T06:50:56.000Z | 2022-02-24T10:32:52.000Z | // Copyright DEWETRON GmbH 2019
#include "odkfw_properties.h"
#include "odkfw_software_channel_plugin.h"
#include "odkapi_channel_dataformat_xml.h"
#include "odkapi_software_channel_xml.h"
#include "odkapi_utils.h"
#include <array>
#include <cmath>
#include <string.h>
//Parser should support an optional "DewetronPluginManifest" and only parse the OxygenPlugin child (if present).
static const char* PLUGIN_MANIFEST =
R"XML(<?xml version="1.0"?>
<OxygenPlugin name="ODK_BIN_DETECTOR" version="1.0" uuid="DCDF634A-377B-4E9F-89BD-09D54C9DFCD3">
<Info name="Example Plugin: Bin detector">
<Vendor name="DEWETRON GmbH"/>
<Description>SDK Example plugin that extracts specific elements from vector channels into scalar channels</Description>
</Info>
<Host minimum_version="3.7"/>
</OxygenPlugin>
)XML";
static const char* TRANSLATION_EN =
R"XML(<?xml version="1.0"?>
<TS version="2.1" language="en" sourcelanguage="en">
<context><name>ConfigKeys</name>
<message><source>ODK_BIN_DETECTOR/MyInputChannel</source><translation>Input Channel</translation></message>
<message><source>ODK_BIN_DETECTOR/EnableMin</source><translation>Enable Minimum</translation></message>
<message><source>ODK_BIN_DETECTOR/EnableMax</source><translation>Enable Maximum</translation></message>
</context>
</TS>
)XML";
static const char* KEY_INPUT_CHANNEL = "ODK_BIN_DETECTOR/MyInputChannel";
static const char* ENABLE_MIN_CHANNELS = "ODK_BIN_DETECTOR/EnableMin";
static const char* ENABLE_MAX_CHANNELS = "ODK_BIN_DETECTOR/EnableMax";
using namespace odk::framework;
class BinDetectorInstance : public SoftwareChannelInstance
{
public:
BinDetectorInstance()
: m_input_channel(new EditableChannelIDProperty())
, m_enable_min(new EditableStringProperty("On"))
, m_enable_max(new EditableStringProperty("On"))
{
m_enable_min->setArbitraryString(false);
m_enable_min->addOption("On");
m_enable_min->addOption("Off");
m_enable_max->setArbitraryString(false);
m_enable_max->addOption("On");
m_enable_max->addOption("Off");
}
static odk::RegisterSoftwareChannel getSoftwareChannelInfo()
{
odk::RegisterSoftwareChannel telegram;
telegram.m_display_name = "Example Plugin: Bin detector";
telegram.m_service_name = "DetectMinMaxBins";
telegram.m_display_group = "Basic Math";
telegram.m_description = "Detect min/max values and corresponding bins of a vector channel";
telegram.m_analysis_capable = true;
return telegram;
}
void updatePropertyTypes(const PluginChannelPtr& output_channel) override
{
ODK_UNUSED(output_channel);
}
void updateStaticPropertyConstraints(const PluginChannelPtr& channel) override
{
ODK_UNUSED(channel);
}
InitResult init(const InitParams& params) override
{
if (params.m_input_channels.size() >= 1)
{
m_input_channel->setValue(params.m_input_channels[0].m_channel_id);
}
InitResult r { true };
r.m_channel_list_action = InitResult::ChannelListAction::SHOW_DETAILS_OF_FIRST_CHANNEL;
return r;
}
void updateMyOutputChannels(InputChannelPtr input_channel)
{
//check min config item and create/remove min channels
if ((m_enable_min->getValue() == "On") && (!m_min_channels.m_value_channel))
{
m_min_channels.m_value_channel = addOutputChannel("min_value");
m_min_channels.m_bin_channel = addOutputChannel("min_bin");
}
else if ((m_enable_min->getValue() == "Off") && m_min_channels.m_value_channel)
{
removeOutputChannel(m_min_channels.m_value_channel);
removeOutputChannel(m_min_channels.m_bin_channel);
m_min_channels.m_value_channel.reset();
m_min_channels.m_bin_channel.reset();
}
//check max config item and create/remove max channels
if ((m_enable_max->getValue() == "On") && (!m_max_channels.m_value_channel))
{
m_max_channels.m_value_channel = addOutputChannel("max_value");
m_max_channels.m_bin_channel = addOutputChannel("max_bin");
}
else if ((m_enable_max->getValue() == "Off") && m_max_channels.m_value_channel)
{
removeOutputChannel(m_max_channels.m_value_channel);
removeOutputChannel(m_max_channels.m_bin_channel);
m_max_channels.m_value_channel.reset();
m_max_channels.m_bin_channel.reset();
}
//configure outputchannels if we have an inputchannel
if (input_channel)
{
const auto& input_range = input_channel->getRange();
const auto& unit = input_channel->getUnit();
//const auto& dimension = input_channel->getDataFormat().m_sample_dimension;
if (m_min_channels.m_value_channel)
{
m_min_channels.m_value_channel->setDefaultName(input_channel->getName() + "_min_Value")
.setSampleFormat(
odk::ChannelDataformat::SampleOccurrence::ASYNC,
odk::ChannelDataformat::SampleFormat::DOUBLE,
1)
.setDeletable(true)
.setRange(input_range)
.setUnit(unit)
;
}
if (m_min_channels.m_bin_channel)
{
m_min_channels.m_bin_channel->setDefaultName(input_channel->getName() + "_min_Bin")
.setSampleFormat(
odk::ChannelDataformat::SampleOccurrence::ASYNC,
odk::ChannelDataformat::SampleFormat::FLOAT,
1)
.setDeletable(true)
;
}
if (m_max_channels.m_value_channel)
{
m_max_channels.m_value_channel->setDefaultName(input_channel->getName() + "_max_Value")
.setSampleFormat(
odk::ChannelDataformat::SampleOccurrence::ASYNC,
odk::ChannelDataformat::SampleFormat::DOUBLE,
1)
.setDeletable(true)
.setRange(input_range)
.setUnit(unit)
;
}
if (m_max_channels.m_bin_channel)
{
m_max_channels.m_bin_channel->setDefaultName(input_channel->getName() + "_max_Bin")
.setSampleFormat(
odk::ChannelDataformat::SampleOccurrence::ASYNC,
odk::ChannelDataformat::SampleFormat::FLOAT,
1)
.setDeletable(true)
;
}
}
}
bool update() override
{
auto all_input_channels(getInputChannelProxies());
auto is_valid((all_input_channels.size() > 0));
auto an_input_channel = getInputChannelProxy(m_input_channel->getValue());
const auto dataformat = an_input_channel->getDataFormat();
//check for a valid input channel type
is_valid &= (dataformat.m_sample_value_type ==
odk::ChannelDataformat::SampleValueType::SAMPLE_VALUE_VECTOR);
//check for a valid sample size
is_valid &= dataformat.m_sample_dimension > 0;
if (!is_valid)
{
return is_valid;
}
m_dimension = dataformat.m_sample_dimension;
updateMyOutputChannels(an_input_channel);
return is_valid;
}
void updateInputChannelIDs(const std::map<uint64_t, uint64_t>& channel_mapping) override
{
ODK_UNUSED(channel_mapping);
//the channels have already been mapped by base-class
//remove all channel_ids that are invalid (not done by base-class)
}
void create(odk::IfHost *host) override
{
ODK_UNUSED(host);
//configure my group channel
//add properties for user interface
getRootChannel()->setDefaultName("Bin Detector Group")
.setDeletable(true)
.addProperty(KEY_INPUT_CHANNEL, m_input_channel)
.addProperty(ENABLE_MIN_CHANNELS, m_enable_min)
.addProperty(ENABLE_MAX_CHANNELS, m_enable_max);
}
bool configure(
const odk::UpdateChannelsTelegram& request,
std::map<uint32_t, uint32_t>& channel_id_map) override
{
//restore my output channels after loading configuration
configureFromTelegram(request, channel_id_map);
m_min_channels.m_value_channel = getOutputChannelByKey("min_value");
m_min_channels.m_bin_channel = getOutputChannelByKey("min_bin");
m_max_channels.m_value_channel = getOutputChannelByKey("max_value");
m_max_channels.m_bin_channel = getOutputChannelByKey("max_bin");
return true;
}
void initTimebases(odk::IfHost* host) override
{
const auto master_timestamp = getMasterTimestamp(host);
m_timebase_frequency = 0.0;
for(auto& input_channel : getInputChannelProxies())
{
const auto timebase = input_channel->getTimeBase();
m_timebase_frequency = std::max(m_timebase_frequency, timebase.m_frequency);
}
for(auto& output_channel : m_output_channels)
{
output_channel->setSimpleTimebase(m_timebase_frequency);
}
}
uint64_t getTickAtOrAfter(double time, double frequency)
{
if (time == 0.0)
{
return 0;
}
return static_cast<uint64_t>(std::nextafter(std::nextafter(time, 0.0) * frequency, std::numeric_limits<double>::lowest())) + 1;
}
void process(ProcessingContext& context, odk::IfHost *host) override
{
const auto channel_id = m_input_channel->getValue();
auto channel_iterator = context.m_channel_iterators[channel_id];
auto timebase = getInputChannelProxy(channel_id)->getTimeBase();
uint64_t start_sample = getTickAtOrAfter(context.m_window.first, m_timebase_frequency);
uint64_t end_sample = getTickAtOrAfter(context.m_window.second, m_timebase_frequency);
uint64_t sample_index = 0;
while ((start_sample + sample_index) < end_sample)
{
auto data = static_cast<const double*> (channel_iterator.data());
auto result = std::minmax_element(data, data+m_dimension);
if (m_min_channels.m_value_channel && (m_min_channels.m_value_channel->getUsedProperty()->getValue()))
{
addSample(host, m_min_channels.m_value_channel->getLocalId(), start_sample + sample_index, result.first, sizeof(double));
}
if (m_min_channels.m_bin_channel && (m_min_channels.m_bin_channel->getUsedProperty()->getValue()))
{
float offset = static_cast<float>(result.first - data);
addSample(host, m_min_channels.m_bin_channel->getLocalId(), start_sample + sample_index, &offset, sizeof(float));
}
if (m_max_channels.m_value_channel && (m_max_channels.m_value_channel->getUsedProperty()->getValue()))
{
addSample(host, m_max_channels.m_value_channel->getLocalId(), start_sample + sample_index, result.second, sizeof(double));
}
if (m_max_channels.m_value_channel && (m_max_channels.m_bin_channel->getUsedProperty()->getValue()))
{
float offset = static_cast<float>(result.second - data);
addSample(host, m_max_channels.m_bin_channel->getLocalId(), start_sample + sample_index, &offset, sizeof(float));
}
++channel_iterator;
++sample_index;
}
}
private:
std::shared_ptr<EditableChannelIDProperty> m_input_channel;
std::shared_ptr<EditableStringProperty> m_enable_min;
std::shared_ptr<EditableStringProperty> m_enable_max;
double m_timebase_frequency;
uint32_t m_dimension = 0;
struct OutputChannelStruct
{
PluginChannelPtr m_value_channel;
PluginChannelPtr m_bin_channel;
};
OutputChannelStruct m_min_channels;
OutputChannelStruct m_max_channels;
};
class MyDemuxVectorPlugin : public SoftwareChannelPlugin<BinDetectorInstance>
{
public:
void registerTranslations() final
{
addTranslation(TRANSLATION_EN);
}
};
OXY_REGISTER_PLUGIN1("ODK_BIN_DETECTOR", PLUGIN_MANIFEST, MyDemuxVectorPlugin);
| 37.610778 | 138 | 0.644643 | HpLightcorner |
5599b8826f8c180eff0bc3135e0bdb6a5df03d2f | 9,540 | cpp | C++ | modules/gapi/test/streaming/gapi_streaming_utils_test.cpp | nowireless/opencv | 1fcc4c74fefee4f845c0d57799163a1cbf36f654 | [
"Apache-2.0"
] | 56,632 | 2016-07-04T16:36:08.000Z | 2022-03-31T18:38:14.000Z | modules/gapi/test/streaming/gapi_streaming_utils_test.cpp | nowireless/opencv | 1fcc4c74fefee4f845c0d57799163a1cbf36f654 | [
"Apache-2.0"
] | 13,593 | 2016-07-04T13:59:03.000Z | 2022-03-31T21:04:51.000Z | modules/gapi/test/streaming/gapi_streaming_utils_test.cpp | nowireless/opencv | 1fcc4c74fefee4f845c0d57799163a1cbf36f654 | [
"Apache-2.0"
] | 54,986 | 2016-07-04T14:24:38.000Z | 2022-03-31T22:51:18.000Z | // This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2021 Intel Corporation
#include "../test_precomp.hpp"
#include "../common/gapi_streaming_tests_common.hpp"
#include <chrono>
#include <future>
#define private public
#include "streaming/onevpl/accelerators/utils/shared_lock.hpp"
#undef private
#include "streaming/onevpl/accelerators/utils/elastic_barrier.hpp"
namespace opencv_test
{
namespace
{
using cv::gapi::wip::onevpl::SharedLock;
struct TestBarrier : public cv::gapi::wip::onevpl::elastic_barrier<TestBarrier> {
void on_first_in_impl(size_t visitor_id) {
static std::atomic<int> thread_counter{};
thread_counter++;
EXPECT_EQ(thread_counter.load(), 1);
visitors_in.insert(visitor_id);
last_visitor_id = visitor_id;
thread_counter--;
EXPECT_EQ(thread_counter.load(), 0);
}
void on_last_out_impl(size_t visitor_id) {
static std::atomic<int> thread_counter{};
thread_counter++;
EXPECT_EQ(thread_counter.load(), 1);
visitors_out.insert(visitor_id);
last_visitor_id = visitor_id;
thread_counter--;
EXPECT_EQ(thread_counter.load(), 0);
}
size_t last_visitor_id = 0;
std::set<size_t> visitors_in;
std::set<size_t> visitors_out;
};
TEST(OneVPL_SharedLock, Create) {
SharedLock lock;
EXPECT_EQ(lock.shared_counter.load(), size_t{0});
}
TEST(OneVPL_SharedLock, Read_SingleThread)
{
SharedLock lock;
const size_t single_thread_read_count = 100;
for(size_t i = 0; i < single_thread_read_count; i++) {
lock.shared_lock();
EXPECT_FALSE(lock.owns());
}
EXPECT_EQ(lock.shared_counter.load(), single_thread_read_count);
for(size_t i = 0; i < single_thread_read_count; i++) {
lock.unlock_shared();
EXPECT_FALSE(lock.owns());
}
EXPECT_EQ(lock.shared_counter.load(), size_t{0});
}
TEST(OneVPL_SharedLock, TryLock_SingleThread)
{
SharedLock lock;
EXPECT_TRUE(lock.try_lock());
EXPECT_TRUE(lock.owns());
lock.unlock();
EXPECT_FALSE(lock.owns());
EXPECT_EQ(lock.shared_counter.load(), size_t{0});
}
TEST(OneVPL_SharedLock, Write_SingleThread)
{
SharedLock lock;
lock.lock();
EXPECT_TRUE(lock.owns());
lock.unlock();
EXPECT_FALSE(lock.owns());
EXPECT_EQ(lock.shared_counter.load(), size_t{0});
}
TEST(OneVPL_SharedLock, TryLockTryLock_SingleThread)
{
SharedLock lock;
lock.try_lock();
EXPECT_FALSE(lock.try_lock());
lock.unlock();
EXPECT_FALSE(lock.owns());
}
TEST(OneVPL_SharedLock, ReadTryLock_SingleThread)
{
SharedLock lock;
lock.shared_lock();
EXPECT_FALSE(lock.owns());
EXPECT_FALSE(lock.try_lock());
lock.unlock_shared();
EXPECT_TRUE(lock.try_lock());
EXPECT_TRUE(lock.owns());
lock.unlock();
}
TEST(OneVPL_SharedLock, WriteTryLock_SingleThread)
{
SharedLock lock;
lock.lock();
EXPECT_TRUE(lock.owns());
EXPECT_FALSE(lock.try_lock());
lock.unlock();
EXPECT_TRUE(lock.try_lock());
EXPECT_TRUE(lock.owns());
lock.unlock();
}
TEST(OneVPL_SharedLock, Write_MultiThread)
{
SharedLock lock;
std::promise<void> barrier;
std::shared_future<void> sync = barrier.get_future();
static const size_t inc_count = 10000000;
size_t shared_value = 0;
auto work = [&lock, &shared_value](size_t count) {
for (size_t i = 0; i < count; i ++) {
lock.lock();
shared_value ++;
lock.unlock();
}
};
std::thread worker_thread([&barrier, sync, work] () {
std::thread sub_worker([&barrier, work] () {
barrier.set_value();
work(inc_count);
});
sync.wait();
work(inc_count);
sub_worker.join();
});
sync.wait();
work(inc_count);
worker_thread.join();
EXPECT_EQ(shared_value, inc_count * 3);
}
TEST(OneVPL_SharedLock, ReadWrite_MultiThread)
{
SharedLock lock;
std::promise<void> barrier;
std::future<void> sync = barrier.get_future();
static const size_t inc_count = 10000000;
size_t shared_value = 0;
auto write_work = [&lock, &shared_value](size_t count) {
for (size_t i = 0; i < count; i ++) {
lock.lock();
shared_value ++;
lock.unlock();
}
};
auto read_work = [&lock, &shared_value](size_t count) {
auto old_shared_value = shared_value;
for (size_t i = 0; i < count; i ++) {
lock.shared_lock();
EXPECT_TRUE(shared_value >= old_shared_value);
old_shared_value = shared_value;
lock.unlock_shared();
}
};
std::thread writer_thread([&barrier, write_work] () {
barrier.set_value();
write_work(inc_count);
});
sync.wait();
read_work(inc_count);
writer_thread.join();
EXPECT_EQ(shared_value, inc_count);
}
TEST(OneVPL_ElasticBarrier, single_thread_visit)
{
TestBarrier barrier;
const size_t max_visit_count = 10000;
size_t visit_id = 0;
for (visit_id = 0; visit_id < max_visit_count; visit_id++) {
barrier.visit_in(visit_id);
EXPECT_EQ(barrier.visitors_in.size(), size_t{1});
}
EXPECT_EQ(barrier.last_visitor_id, size_t{0});
EXPECT_EQ(barrier.visitors_out.size(), size_t{0});
for (visit_id = 0; visit_id < max_visit_count; visit_id++) {
barrier.visit_out(visit_id);
EXPECT_EQ(barrier.visitors_in.size(), size_t{1});
}
EXPECT_EQ(barrier.last_visitor_id, visit_id - 1);
EXPECT_EQ(barrier.visitors_out.size(), size_t{1});
}
TEST(OneVPL_ElasticBarrier, multi_thread_visit)
{
TestBarrier tested_barrier;
static const size_t max_visit_count = 10000000;
std::atomic<size_t> visit_in_wait_counter{};
std::promise<void> start_sync_barrier;
std::shared_future<void> start_sync = start_sync_barrier.get_future();
std::promise<void> phase_sync_barrier;
std::shared_future<void> phase_sync = phase_sync_barrier.get_future();
auto visit_worker_job = [&tested_barrier,
&visit_in_wait_counter,
start_sync,
phase_sync] (size_t worker_id) {
start_sync.wait();
// first phase
const size_t begin_range = worker_id * max_visit_count;
const size_t end_range = (worker_id + 1) * max_visit_count;
for (size_t visit_id = begin_range; visit_id < end_range; visit_id++) {
tested_barrier.visit_in(visit_id);
}
// notify all worker first phase ready
visit_in_wait_counter.fetch_add(1);
// wait main second phase
phase_sync.wait();
// second phase
for (size_t visit_id = begin_range; visit_id < end_range; visit_id++) {
tested_barrier.visit_out(visit_id);
}
};
auto visit_main_job = [&tested_barrier,
&visit_in_wait_counter,
&phase_sync_barrier] (size_t total_workers_count,
size_t worker_id) {
const size_t begin_range = worker_id * max_visit_count;
const size_t end_range = (worker_id + 1) * max_visit_count;
for (size_t visit_id = begin_range; visit_id < end_range; visit_id++) {
tested_barrier.visit_in(visit_id);
}
// wait all workers first phase done
visit_in_wait_counter.fetch_add(1);
while (visit_in_wait_counter.load() != total_workers_count) {
std::this_thread::yield();
};
// TEST invariant: last_visitor_id MUST be one from any FIRST worker visitor_id
bool one_of_available_ids_matched = false;
for (size_t id = 0; id < total_workers_count; id ++) {
size_t expected_last_visitor_for_id = id * max_visit_count;
one_of_available_ids_matched |=
(tested_barrier.last_visitor_id == expected_last_visitor_for_id) ;
}
EXPECT_TRUE(one_of_available_ids_matched);
// unblock all workers to work out second phase
phase_sync_barrier.set_value();
// continue second phase
for (size_t visit_id = begin_range; visit_id < end_range; visit_id++) {
tested_barrier.visit_out(visit_id);
}
};
size_t max_worker_count = std::thread::hardware_concurrency();
if (max_worker_count < 2) {
max_worker_count = 2; // logical 2 threads required at least
}
std::vector<std::thread> workers;
workers.reserve(max_worker_count);
for (size_t worker_id = 1; worker_id < max_worker_count; worker_id++) {
workers.emplace_back(visit_worker_job, worker_id);
}
// let's go for first phase
start_sync_barrier.set_value();
// utilize main thread as well
visit_main_job(max_worker_count, 0);
// join all threads second phase
for (auto& w : workers) {
w.join();
}
// TEST invariant: last_visitor_id MUST be one from any LATTER worker visitor_id
bool one_of_available_ids_matched = false;
for (size_t id = 0; id < max_worker_count; id ++) {
one_of_available_ids_matched |=
(tested_barrier.last_visitor_id == ((id + 1) * max_visit_count - 1)) ;
}
EXPECT_TRUE(one_of_available_ids_matched);
}
}
} // opencv_test
| 27.335244 | 90 | 0.639203 | nowireless |
559b4005f0ef690b1c4d9f57ed4106a932c51a21 | 3,622 | cpp | C++ | depends/work/build/i686-w64-mingw32/qt/5.9.7-f2560c1efa6/qttools/src/designer/src/components/taskmenu/taskmenu_component.cpp | GrinCash/Grinc-core | 1377979453ba84082f70f9c128be38e57b65a909 | [
"MIT"
] | null | null | null | depends/work/build/i686-w64-mingw32/qt/5.9.7-f2560c1efa6/qttools/src/designer/src/components/taskmenu/taskmenu_component.cpp | GrinCash/Grinc-core | 1377979453ba84082f70f9c128be38e57b65a909 | [
"MIT"
] | null | null | null | depends/work/build/i686-w64-mingw32/qt/5.9.7-f2560c1efa6/qttools/src/designer/src/components/taskmenu/taskmenu_component.cpp | GrinCash/Grinc-core | 1377979453ba84082f70f9c128be38e57b65a909 | [
"MIT"
] | null | null | null | /****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "taskmenu_component.h"
#include "button_taskmenu.h"
#include "groupbox_taskmenu.h"
#include "label_taskmenu.h"
#include "lineedit_taskmenu.h"
#include "listwidget_taskmenu.h"
#include "treewidget_taskmenu.h"
#include "tablewidget_taskmenu.h"
#include "containerwidget_taskmenu.h"
#include "combobox_taskmenu.h"
#include "textedit_taskmenu.h"
#include "menutaskmenu.h"
#include "toolbar_taskmenu.h"
#include "layouttaskmenu.h"
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QExtensionManager>
QT_BEGIN_NAMESPACE
using namespace qdesigner_internal;
TaskMenuComponent::TaskMenuComponent(QDesignerFormEditorInterface *core, QObject *parent)
: QObject(parent),
m_core(core)
{
Q_ASSERT(m_core != 0);
QExtensionManager *mgr = core->extensionManager();
const QString taskMenuId = QStringLiteral("QDesignerInternalTaskMenuExtension");
ButtonTaskMenuFactory::registerExtension(mgr, taskMenuId);
CommandLinkButtonTaskMenuFactory::registerExtension(mgr, taskMenuId); // Order!
ButtonGroupTaskMenuFactory::registerExtension(mgr, taskMenuId);
GroupBoxTaskMenuFactory::registerExtension(mgr, taskMenuId);
LabelTaskMenuFactory::registerExtension(mgr, taskMenuId);
LineEditTaskMenuFactory::registerExtension(mgr, taskMenuId);
ListWidgetTaskMenuFactory::registerExtension(mgr, taskMenuId);
TreeWidgetTaskMenuFactory::registerExtension(mgr, taskMenuId);
TableWidgetTaskMenuFactory::registerExtension(mgr, taskMenuId);
TextEditTaskMenuFactory::registerExtension(mgr, taskMenuId);
PlainTextEditTaskMenuFactory::registerExtension(mgr, taskMenuId);
MenuTaskMenuFactory::registerExtension(mgr, taskMenuId);
MenuBarTaskMenuFactory::registerExtension(mgr, taskMenuId);
ToolBarTaskMenuFactory::registerExtension(mgr, taskMenuId);
StatusBarTaskMenuFactory::registerExtension(mgr, taskMenuId);
LayoutWidgetTaskMenuFactory::registerExtension(mgr, taskMenuId);
SpacerTaskMenuFactory::registerExtension(mgr, taskMenuId);
mgr->registerExtensions(new ContainerWidgetTaskMenuFactory(core, mgr), taskMenuId);
mgr->registerExtensions(new ComboBoxTaskMenuFactory(taskMenuId, mgr), taskMenuId);
}
TaskMenuComponent::~TaskMenuComponent()
{
}
QDesignerFormEditorInterface *TaskMenuComponent::core() const
{
return m_core;
}
QT_END_NAMESPACE
| 38.531915 | 89 | 0.754279 | GrinCash |
559c4e03cefccc68eb93a3968d0a50406130ec9f | 2,544 | cpp | C++ | src/bt-luaengine/app-src/render/SimpleSpriteRenderer.cpp | puretekniq/batterytech | cc831b2835b7bf4826948831f0274e3d80921339 | [
"MIT",
"BSD-3-Clause-Clear",
"Zlib",
"BSD-3-Clause"
] | 10 | 2015-04-07T22:23:31.000Z | 2016-03-06T11:48:32.000Z | src/bt-luaengine/app-src/render/SimpleSpriteRenderer.cpp | robdoesstuff/batterytech | cc831b2835b7bf4826948831f0274e3d80921339 | [
"MIT",
"BSD-3-Clause-Clear",
"Zlib",
"BSD-3-Clause"
] | 3 | 2015-05-17T10:45:48.000Z | 2016-07-29T18:34:53.000Z | src/bt-luaengine/app-src/render/SimpleSpriteRenderer.cpp | puretekniq/batterytech | cc831b2835b7bf4826948831f0274e3d80921339 | [
"MIT",
"BSD-3-Clause-Clear",
"Zlib",
"BSD-3-Clause"
] | 4 | 2015-05-03T03:00:48.000Z | 2016-03-03T12:49:01.000Z | /*
* BatteryTech
* Copyright (c) 2010 Battery Powered Games LLC.
*
* This code is a component of BatteryTech and is subject to the 'BatteryTech
* End User License Agreement'. Among other important provisions, this
* license prohibits the distribution of source code to anyone other than
* authorized parties. If you have any questions or would like an additional
* copy of the license, please contact: support@batterypoweredgames.com
*/
#include "SimpleSpriteRenderer.h"
#include "../GameConstants.h"
#include <stdio.h>
#include <string.h>
#include <batterytech/Logger.h>
#include <batterytech/util/esTransform.h>
#include <batterytech/render/GraphicsConfiguration.h>
#include <batterytech/render/RenderContext.h>
#include <batterytech/render/GLResourceManager.h>
#include "../World.h"
#include "../GameContext.h"
#include <batterytech/render/QuadRenderer.h>
SimpleSpriteRenderer::SimpleSpriteRenderer(GameContext *context) {
this->context = context;
}
SimpleSpriteRenderer::~SimpleSpriteRenderer() {
}
void SimpleSpriteRenderer::init(BOOL32 newContext) {
}
void SimpleSpriteRenderer::render(RenderItem *item) {
Texture *texture = NULL;
if (item->textureName[0]) {
texture = context->glResourceManager->getTexture(item->textureName);
if (!texture) {
char buf[1024];
sprintf(buf, "Texture not found %s", item->textureName);
logmsg(buf);
}
}
Matrix4f bbMat;
BOOL32 isBB = item->renderType == RenderItem::RENDERTYPE_BB;
Vector4f newUvs = item->uvs;
if (isBB) {
// calculate billboard matrix
Vector3f dir = context->world->camera->pos - item->pos;
dir.normalize();
Vector3f newY = context->world->camera->invRotMatrix * Vector3f(0,1,0);
Vector3f newX = context->world->camera->invRotMatrix * Vector3f(1,0,0);
bbMat.data[0] = newX.x;
bbMat.data[1] = newX.y;
bbMat.data[2] = newX.z;
bbMat.data[4] = newY.x;
bbMat.data[5] = newY.y;
bbMat.data[6] = newY.z;
bbMat.data[8] = dir.x;
bbMat.data[9] = dir.y;
bbMat.data[10] = dir.z;
// uvs will need flipping to avoid switching to LHS to flip Y
newUvs.y = newUvs.w;
newUvs.w = item->uvs.y;
}
context->quadRenderer->render(texture, item->pos, item->orientation.v.z, newUvs, Vector2f(item->scale.x, item->scale.y), item->colorFilter, item->flags & RENDERITEM_FLAG_IS_OPAQUE, isBB, bbMat);
}
void SimpleSpriteRenderer::startBatch() {
context->quadRenderer->startBatch();
}
void SimpleSpriteRenderer::endBatch() {
context->quadRenderer->endBatch();
}
| 33.038961 | 196 | 0.702044 | puretekniq |
559dca1edb60826065bdd054d771fac58ae39db4 | 10,655 | cpp | C++ | src/core/Identifier.cpp | grealish/opentxs | 614999063079f5843428abcaa62974f5f19f88a1 | [
"Apache-2.0"
] | 1 | 2015-11-05T12:09:37.000Z | 2015-11-05T12:09:37.000Z | src/core/Identifier.cpp | grealish/opentxs | 614999063079f5843428abcaa62974f5f19f88a1 | [
"Apache-2.0"
] | null | null | null | src/core/Identifier.cpp | grealish/opentxs | 614999063079f5843428abcaa62974f5f19f88a1 | [
"Apache-2.0"
] | null | null | null | /************************************************************
*
* OTIdentifier.cpp
*
*/
/************************************************************
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
* OPEN TRANSACTIONS
*
* Financial Cryptography and Digital Cash
* Library, Protocol, API, Server, CLI, GUI
*
* -- Anonymous Numbered Accounts.
* -- Untraceable Digital Cash.
* -- Triple-Signed Receipts.
* -- Cheques, Vouchers, Transfers, Inboxes.
* -- Basket Currencies, Markets, Payment Plans.
* -- Signed, XML, Ricardian-style Contracts.
* -- Scripted smart contracts.
*
* Copyright (C) 2010-2013 by "Fellow Traveler" (A pseudonym)
*
* EMAIL:
* FellowTraveler@rayservers.net
*
* BITCOIN: 1NtTPVVjDsUfDWybS4BwvHpG2pdS9RnYyQ
*
* KEY FINGERPRINT (PGP Key in license file):
* 9DD5 90EB 9292 4B48 0484 7910 0308 00ED F951 BB8E
*
* OFFICIAL PROJECT WIKI(s):
* https://github.com/FellowTraveler/Moneychanger
* https://github.com/FellowTraveler/Open-Transactions/wiki
*
* WEBSITE:
* http://www.OpenTransactions.org/
*
* Components and licensing:
* -- Moneychanger..A Java client GUI.....LICENSE:.....GPLv3
* -- otlib.........A class library.......LICENSE:...LAGPLv3
* -- otapi.........A client API..........LICENSE:...LAGPLv3
* -- opentxs/ot....Command-line client...LICENSE:...LAGPLv3
* -- otserver......Server Application....LICENSE:....AGPLv3
* Github.com/FellowTraveler/Open-Transactions/wiki/Components
*
* All of the above OT components were designed and written by
* Fellow Traveler, with the exception of Moneychanger, which
* was contracted out to Vicky C (bitcointrader4@gmail.com).
* The open-source community has since actively contributed.
*
* -----------------------------------------------------
*
* LICENSE:
* This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* ADDITIONAL PERMISSION under the GNU Affero GPL version 3
* section 7: (This paragraph applies only to the LAGPLv3
* components listed above.) If you modify this Program, or
* any covered work, by linking or combining it with other
* code, such other code is not for that reason alone subject
* to any of the requirements of the GNU Affero GPL version 3.
* (==> This means if you are only using the OT API, then you
* don't have to open-source your code--only your changes to
* Open-Transactions itself must be open source. Similar to
* LGPLv3, except it applies to software-as-a-service, not
* just to distributing binaries.)
*
* Extra WAIVER for OpenSSL, Lucre, and all other libraries
* used by Open Transactions: This program is released under
* the AGPL with the additional exemption that compiling,
* linking, and/or using OpenSSL is allowed. The same is true
* for any other open source libraries included in this
* project: complete waiver from the AGPL is hereby granted to
* compile, link, and/or use them with Open-Transactions,
* according to their own terms, as long as the rest of the
* Open-Transactions terms remain respected, with regard to
* the Open-Transactions code itself.
*
* Lucre License:
* This code is also "dual-license", meaning that Ben Lau-
* rie's license must also be included and respected, since
* the code for Lucre is also included with Open Transactions.
* See Open-Transactions/src/otlib/lucre/LUCRE_LICENSE.txt
* The Laurie requirements are light, but if there is any
* problem with his license, simply remove the Lucre code.
* Although there are no other blind token algorithms in Open
* Transactions (yet. credlib is coming), the other functions
* will continue to operate.
* See Lucre on Github: https://github.com/benlaurie/lucre
* -----------------------------------------------------
* You should have received a copy of the GNU Affero General
* Public License along with this program. If not, see:
* http://www.gnu.org/licenses/
*
* If you would like to use this software outside of the free
* software license, please contact FellowTraveler.
* (Unfortunately many will run anonymously and untraceably,
* so who could really stop them?)
*
* DISCLAIMER:
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Affero General Public License for
* more details.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQIcBAEBAgAGBQJRSsfJAAoJEAMIAO35UbuOQT8P/RJbka8etf7wbxdHQNAY+2cC
vDf8J3X8VI+pwMqv6wgTVy17venMZJa4I4ikXD/MRyWV1XbTG0mBXk/7AZk7Rexk
KTvL/U1kWiez6+8XXLye+k2JNM6v7eej8xMrqEcO0ZArh/DsLoIn1y8p8qjBI7+m
aE7lhstDiD0z8mwRRLKFLN2IH5rAFaZZUvj5ERJaoYUKdn4c+RcQVei2YOl4T0FU
LWND3YLoH8naqJXkaOKEN4UfJINCwxhe5Ke9wyfLWLUO7NamRkWD2T7CJ0xocnD1
sjAzlVGNgaFDRflfIF4QhBx1Ddl6wwhJfw+d08bjqblSq8aXDkmFA7HeunSFKkdn
oIEOEgyj+veuOMRJC5pnBJ9vV+7qRdDKQWaCKotynt4sWJDGQ9kWGWm74SsNaduN
TPMyr9kNmGsfR69Q2Zq/FLcLX/j8ESxU+HYUB4vaARw2xEOu2xwDDv6jt0j3Vqsg
x7rWv4S/Eh18FDNDkVRChiNoOIilLYLL6c38uMf1pnItBuxP3uhgY6COm59kVaRh
nyGTYCDYD2TK+fI9o89F1297uDCwEJ62U0Q7iTDp5QuXCoxkPfv8/kX6lS6T3y9G
M9mqIoLbIQ1EDntFv7/t6fUTS2+46uCrdZWbQ5RjYXdrzjij02nDmJAm2BngnZvd
kamH0Y/n11lCvo1oQxM+
=uSzz
-----END PGP SIGNATURE-----
**************************************************************/
#include <opentxs/core/stdafx.hpp>
#include <opentxs/core/Identifier.hpp>
#include <opentxs/core/Contract.hpp>
#include <opentxs/core/crypto/OTCachedKey.hpp>
#include <opentxs/core/crypto/OTCrypto.hpp>
#include <opentxs/core/Nym.hpp>
#include <opentxs/core/crypto/OTSymmetricKey.hpp>
#include <bitcoin-base58/hash.h>
#include <cstring>
#include <iostream>
namespace opentxs
{
Identifier::Identifier()
: OTData()
{
}
Identifier::Identifier(const Identifier& theID)
: OTData(theID)
{
}
Identifier::Identifier(const char* szStr)
: OTData()
{
OT_ASSERT(nullptr != szStr);
SetString(szStr);
}
Identifier::Identifier(const std::string& theStr)
: OTData()
{
OT_ASSERT(!theStr.empty());
SetString(theStr.c_str());
}
Identifier::Identifier(const String& theStr)
: OTData()
{
SetString(theStr);
}
Identifier::Identifier(const Contract& theContract)
: OTData() // Get the contract's ID into this identifier.
{
(const_cast<Contract&>(theContract)).GetIdentifier(*this);
}
Identifier::Identifier(const Nym& theNym)
: OTData() // Get the Nym's ID into this identifier.
{
(const_cast<Nym&>(theNym)).GetIdentifier(*this);
}
Identifier::Identifier(const OTSymmetricKey& theKey)
: OTData() // Get the Symmetric Key's ID into *this. (It's a hash of the
// encrypted form of the symmetric key.)
{
(const_cast<OTSymmetricKey&>(theKey)).GetIdentifier(*this);
}
Identifier::Identifier(const OTCachedKey& theKey)
: OTData() // Cached Key stores a symmetric key inside, so this actually
// captures the ID for that symmetrickey.
{
const bool bSuccess =
(const_cast<OTCachedKey&>(theKey)).GetIdentifier(*this);
OT_ASSERT(bSuccess); // should never fail. If it does, then we are calling
// this function at a time we shouldn't, when we aren't
// sure the master key has even been generated yet. (If
// this asserts, need to examine the line of code that
// tried to do this, and figure out where its logic
// went wrong, since it should have made sure this
// would not happen, before constructing like this.)
}
void Identifier::SetString(const char* szString)
{
OT_ASSERT(nullptr != szString);
const String theStr(szString);
SetString(theStr);
}
bool Identifier::operator==(const Identifier& s2) const
{
const String ots1(*this), ots2(s2);
return ots1.Compare(ots2);
}
bool Identifier::operator!=(const Identifier& s2) const
{
const String ots1(*this), ots2(s2);
return !(ots1.Compare(ots2));
}
bool Identifier::operator>(const Identifier& s2) const
{
const String ots1(*this), ots2(s2);
return ots1.operator>(ots2);
}
bool Identifier::operator<(const Identifier& s2) const
{
const String ots1(*this), ots2(s2);
return ots1.operator<(ots2);
}
bool Identifier::operator<=(const Identifier& s2) const
{
const String ots1(*this), ots2(s2);
return ots1.operator<=(ots2);
}
bool Identifier::operator>=(const Identifier& s2) const
{
const String ots1(*this), ots2(s2);
return ots1.operator>=(ots2);
}
Identifier::~Identifier()
{
}
// When calling SignContract or VerifySignature with "HASH256" as the hash type,
// the signature will use (sha256 . sha256) as a message digest.
// In this case, SignContractDefaultHash and VerifyContractDefaultHash are used,
// which resort to low level calls to accomplish non standard message digests.
// Otherwise, it will use whatever OpenSSL provides by that name (see
// GetOpenSSLDigestByName).
const String Identifier::DefaultHashAlgorithm("HASH256");
// This method implements the (ripemd160 . sha256) hash,
// so the result is 20 bytes long.
bool Identifier::CalculateDigest(const unsigned char* data, size_t len)
{
// The Hash160 function comes from the Bitcoin reference client, where
// it is implemented as RIPEMD160 ( SHA256 ( x ) ) => 20 byte hash
auto hash160 = Hash160(data, data + len);
SetSize(20);
memcpy(const_cast<void*>(GetPointer()), hash160, 20);
return true;
}
bool Identifier::CalculateDigest(const String& strInput)
{
return CalculateDigest(
reinterpret_cast<const unsigned char*>(strInput.Get()),
static_cast<size_t>(strInput.GetLength()));
}
bool Identifier::CalculateDigest(const OTData& dataInput)
{
auto dataPtr = static_cast<const unsigned char*>(dataInput.GetPointer());
return CalculateDigest(dataPtr, dataInput.GetSize());
}
// SET (binary id) FROM ENCODED STRING
//
void Identifier::SetString(const String& theStr)
{
OTCrypto::It()->SetIDFromEncoded(theStr, *this);
}
// This Identifier is stored in binary form.
// But what if you want a pretty string version of it?
// Just call this function.
//
void Identifier::GetString(String& theStr) const
{
OTCrypto::It()->EncodeID(*this, theStr); // *this input, theStr output.
}
} // namespace opentxs
| 34.370968 | 80 | 0.687565 | grealish |
559e6db528b6a5249ba3dfd042f1591dd2d781fe | 4,122 | cpp | C++ | pin-3.22-98547-g7a303a835-gcc-linux/source/tools/Debugger/set_xmm_scratches_before_breakpoint_and_set_xmm_reg.cpp | ArthasZhang007/15418FinalProject | a71f698ea48ebbc446111734c198f16a55633669 | [
"MIT"
] | null | null | null | pin-3.22-98547-g7a303a835-gcc-linux/source/tools/Debugger/set_xmm_scratches_before_breakpoint_and_set_xmm_reg.cpp | ArthasZhang007/15418FinalProject | a71f698ea48ebbc446111734c198f16a55633669 | [
"MIT"
] | null | null | null | pin-3.22-98547-g7a303a835-gcc-linux/source/tools/Debugger/set_xmm_scratches_before_breakpoint_and_set_xmm_reg.cpp | ArthasZhang007/15418FinalProject | a71f698ea48ebbc446111734c198f16a55633669 | [
"MIT"
] | null | null | null | /*
* Copyright (C) 2012-2021 Intel Corporation.
* SPDX-License-Identifier: MIT
*/
#include "pin.H"
#include <stdio.h>
KNOB< BOOL > KnobUseIargConstContext(KNOB_MODE_WRITEONCE, "pintool", "const_context", "0", "use IARG_CONST_CONTEXT");
KNOB< std::string > KnobOutputFileName(KNOB_MODE_WRITEONCE, "pintool", "output_filename",
"set_xmm_scratch_regs_before_breakpoint_tool_set_xmm_reg.out", "Name output file.");
FILE* fp;
bool instrumentedMovdqa = FALSE;
bool gotOurCommand = FALSE;
unsigned int xmmInitVals[64];
extern "C" int SetXmmScratchesFun(unsigned int* values);
// Insert a call to an analysis routine that sets the scratch xmm registers, the call is inserted just after the
// movdqa instruction of DoXmm (see xmm-asm-*.s)
static VOID InstrumentRoutine(RTN rtn, VOID*)
{
if (PIN_UndecorateSymbolName(RTN_Name(rtn), UNDECORATION_NAME_ONLY) == "DoXmm")
{
RTN_Open(rtn);
for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins))
{
if (INS_Opcode(ins) == XED_ICLASS_MOVDQA)
{
fprintf(fp, "instrumenting ins %p %s\n", (void*)INS_Address(ins), INS_Disassemble(ins).c_str());
instrumentedMovdqa = TRUE;
INS_InsertCall(ins, IPOINT_AFTER, (AFUNPTR)SetXmmScratchesFun, IARG_PTR, xmmInitVals, IARG_END);
fflush(fp);
}
}
RTN_Close(rtn);
}
}
static bool OnCommand(THREADID tid, CONTEXT* context, const std::string& cmd, std::string* reply, VOID*)
{
fprintf(fp, "OnCommand %s\n", cmd.c_str());
fflush(fp);
if (cmd == "set_xmm3")
{
gotOurCommand = true;
CHAR fpContextSpaceForFpConextFromPin[FPSTATE_SIZE];
FPSTATE* fpContextFromPin = reinterpret_cast< FPSTATE* >(fpContextSpaceForFpConextFromPin);
PIN_GetContextFPState(context, fpContextFromPin);
for (int j = 0; j < 16; j++)
{
fpContextFromPin->fxsave_legacy._xmms[3]._vec8[j] = 0x5a;
}
PIN_SetContextFPState(context, fpContextFromPin);
CHAR fpContextSpaceForFpConextFromPin1[FPSTATE_SIZE];
fpContextFromPin = reinterpret_cast< FPSTATE* >(fpContextSpaceForFpConextFromPin1);
PIN_GetContextFPState(context, fpContextFromPin);
for (int j = 0; j < 16; j++)
{
if (fpContextFromPin->fxsave_legacy._xmms[3]._vec8[j] != 0x5a)
{
fprintf(fp, "***Error tool did not properly set xmm3\n");
fflush(fp);
PIN_ExitProcess(1);
}
}
fprintf(fp, "tool properly set xmm3\n");
fflush(fp);
return true;
}
return false;
}
static void OnExit(INT32, VOID*)
{
if (!instrumentedMovdqa)
{
fprintf(fp, "***Error tool did not instrument the movdqa instruction of DoXmm\n");
fflush(fp);
PIN_ExitProcess(1);
}
else
{
fprintf(fp, "instrumented the movdqa instruction of DoXmm\n");
fflush(fp);
}
if (!gotOurCommand)
{
fprintf(fp, "***Error tool did NOT get the expected gdb command\n");
fflush(fp);
PIN_ExitProcess(1);
}
else
{
fprintf(fp, "tool got the expected gdb command\n");
fflush(fp);
}
}
// argc, argv are the entire command line, including pin -t <toolname> -- ...
int main(int argc, char* argv[])
{
// initialize memory area used to set values in ymm regs
for (int i = 0; i < 64; i++)
{
xmmInitVals[i] = 0xdeadbeef;
}
PIN_InitSymbols();
// Initialize pin
PIN_Init(argc, argv);
printf("filename %s\n", KnobOutputFileName.Value().c_str());
fp = fopen(KnobOutputFileName.Value().c_str(), "w");
// Register Instruction to be called to instrument the movdqa instruction of DoXmm
RTN_AddInstrumentFunction(InstrumentRoutine, 0);
//INS_AddInstrumentFunction(Instruction, 0);
PIN_AddDebugInterpreter(OnCommand, 0);
PIN_AddFiniFunction(OnExit, 0);
// Start the program, never returns
PIN_StartProgram();
return 0;
}
| 30.087591 | 123 | 0.624697 | ArthasZhang007 |