text string | size int64 | token_count int64 |
|---|---|---|
// You are given an array arr[] of N integers including 0. The task is to find the smallest
// positive number missing from the array.
// CONSTRAINS
// 1 <= N <= 10^6
// -10^6 <= Ai <= 10^6
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0; i<n; i++)
{
cin>>arr[i];
}
const int N = 1e6 + 2;
bool check[N];
for(int i=0; i<n; i++)
{
check[i]=false;
}
for(int i=0; i<n; i++)
{
if(arr[i] >= 0)
{
check[arr[i]] = true;
}
}
int ans = -1;
for(int i=1; i<N; i++)
{
if(!check[i])
{
ans = i;
break;
}
}
cout<<ans<<endl;
return 0;
} | 760 | 317 |
// X_Event.hpp
#ifndef X_EVENT_HPP
#define X_EVENT_HPP
#include "PX2EventSystem.hpp"
#include "PX2EventSpace.hpp"
#include "PX2Event.hpp"
namespace PX2
{
PX2_DECLARE_EVENT_BEGIN(X_EventSpace)
PX2_EVENT(Show_SplashOver)
PX2_EVENT(EnterMap)
PX2_DECLARE_EVENT_END(X_EventSpace)
struct MoveDistData
{
MoveDistData()
{
ID = 0;
Time = 0.0f;
Dist = 0.0f;
}
~MoveDistData()
{
}
int ID;
float Time;
float Dist;
};
}
#endif | 457 | 247 |
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include <runtime/eval/ast/new_object_expression.h>
#include <runtime/eval/ast/name.h>
#include <runtime/eval/runtime/eval_state.h>
#include <runtime/eval/ast/class_statement.h>
#include <runtime/eval/ast/method_statement.h>
namespace HPHP {
namespace Eval {
using namespace std;
///////////////////////////////////////////////////////////////////////////////
NewObjectExpression::NewObjectExpression(EXPRESSION_ARGS, NamePtr name,
const std::vector<ExpressionPtr> ¶ms)
: FunctionCallExpression(EXPRESSION_PASS, params), m_name(name) {}
Variant NewObjectExpression::eval(VariableEnvironment &env) const {
String name(m_name->get(env));
Object o(create_object_only(name));
SET_LINE;
const MethodStatement* ms = o.get()->getConstructorStatement();
if (ms) {
ms->invokeInstanceDirect(o, env, this);
return o;
}
// Handle builtins
MethodCallPackage mcp1;
mcp1.construct(o);
const CallInfo* ci = mcp1.ci;
ASSERT(ci);
unsigned int count = m_params.size();
// few args
if (count <= 6) {
CVarRef a0 = (count > 0) ? evalParam(env, ci, 0) : null;
CVarRef a1 = (count > 1) ? evalParam(env, ci, 1) : null;
CVarRef a2 = (count > 2) ? evalParam(env, ci, 2) : null;
CVarRef a3 = (count > 3) ? evalParam(env, ci, 3) : null;
CVarRef a4 = (count > 4) ? evalParam(env, ci, 4) : null;
CVarRef a5 = (count > 5) ? evalParam(env, ci, 5) : null;
(ci->getMethFewArgs())(mcp1, count, a0, a1, a2, a3, a4, a5);
return o;
}
if (RuntimeOption::UseArgArray) {
ArgArray *args = prepareArgArray(env, ci, count);
(ci->getMeth())(mcp1, args);
return o;
}
ArrayInit ai(count);
for (unsigned int i = 0; i < count; ++i) {
if (ci->mustBeRef(i)) {
ai.setRef(m_params[i]->refval(env));
} else if (ci->isRef(i)) {
ai.setRef(m_params[i]->refval(env, 0));
} else {
ai.set(m_params[i]->eval(env));
}
}
(ci->getMeth())(mcp1, Array(ai.create()));
return o;
}
void NewObjectExpression::dump(std::ostream &out) const {
out << "new ";
m_name->dump(out);
dumpParams(out);
}
///////////////////////////////////////////////////////////////////////////////
}
}
| 3,174 | 1,027 |
/*=========================================================================
*
* Copyright Insight Software Consortium
*
* 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.txt
*
* 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 itkStochasticFractalDimensionImageFilter_hxx
#define itkStochasticFractalDimensionImageFilter_hxx
#include "itkStochasticFractalDimensionImageFilter.h"
#include "itkNeighborhoodAlgorithm.h"
#include "itkProgressReporter.h"
#include <vector>
namespace itk
{
template< typename TInputImage, typename TMaskImage, typename TOutputImage >
StochasticFractalDimensionImageFilter< TInputImage, TMaskImage, TOutputImage >
::StochasticFractalDimensionImageFilter()
{
this->m_NeighborhoodRadius.Fill(2);
this->m_MaskImage = ITK_NULLPTR;
}
template< typename TInputImage, typename TMaskImage, typename TOutputImage >
StochasticFractalDimensionImageFilter< TInputImage, TMaskImage, TOutputImage >
::~StochasticFractalDimensionImageFilter()
{}
template< typename TInputImage, typename TMaskImage, typename TOutputImage >
void
StochasticFractalDimensionImageFilter< TInputImage, TMaskImage, TOutputImage >
::SetMaskImage(const MaskImageType *mask)
{
this->SetNthInput( 1, const_cast< MaskImageType * >( mask ) );
}
template< typename TInputImage, typename TMaskImage, typename TOutputImage >
const typename StochasticFractalDimensionImageFilter< TInputImage, TMaskImage, TOutputImage >::MaskImageType *
StochasticFractalDimensionImageFilter< TInputImage, TMaskImage, TOutputImage >
::GetMaskImage() const
{
const MaskImageType *maskImage =
dynamic_cast< const MaskImageType * >( this->ProcessObject::GetInput(1) );
return maskImage;
}
template< typename TInputImage, typename TMaskImage, typename TOutputImage >
void
StochasticFractalDimensionImageFilter< TInputImage, TMaskImage, TOutputImage >
::GenerateData()
{
this->AllocateOutputs();
typedef typename InputImageType::PixelType InputPixelType;
typedef typename OutputImageType::PixelType OutputPixelType;
typedef typename InputImageType::PointType PointType;
const InputImageType *inputImage = this->GetInput();
OutputImageType *outputImage = this->GetOutput();
typename InputImageType::RegionType region = inputImage->GetRequestedRegion();
ProgressReporter progress(this, 0, region.GetNumberOfPixels(), 100);
typedef typename NeighborhoodAlgorithm
::ImageBoundaryFacesCalculator< InputImageType > FaceCalculatorType;
FaceCalculatorType faceCalculator;
typename FaceCalculatorType::FaceListType faceList =
faceCalculator(inputImage, region, this->m_NeighborhoodRadius);
typename FaceCalculatorType::FaceListType::iterator fit;
typename InputImageType::SpacingType spacing = inputImage->GetSpacing();
RealType minSpacing = spacing[0];
for ( unsigned int d = 0; d < ImageDimension; d++ )
{
if ( spacing[d] < minSpacing )
{
minSpacing = spacing[d];
}
}
std::vector< RealType > distances;
std::vector< RealType > distancesFrequency;
std::vector< RealType > averageAbsoluteIntensityDifference;
for ( fit = faceList.begin(); fit != faceList.end(); ++fit )
{
ConstNeighborhoodIteratorType It(
this->m_NeighborhoodRadius, inputImage, *fit);
NeighborhoodIterator< OutputImageType > ItO(
this->m_NeighborhoodRadius, outputImage, *fit);
for ( It.GoToBegin(), ItO.GoToBegin(); !It.IsAtEnd(); ++It, ++ItO )
{
if ( this->m_MaskImage && !this->m_MaskImage->GetPixel( It.GetIndex() ) )
{
ItO.SetCenterPixel(NumericTraits< OutputPixelType >::ZeroValue());
progress.CompletedPixel();
continue;
}
distances.clear();
distancesFrequency.clear();
averageAbsoluteIntensityDifference.clear();
for ( unsigned int i = 0; i < It.GetNeighborhood().Size(); i++ )
{
bool IsInBounds1;
InputPixelType pixel1 = It.GetPixel(i, IsInBounds1);
if ( !IsInBounds1 )
{
continue;
}
if ( !this->m_MaskImage || this->m_MaskImage->GetPixel( It.GetIndex(i) ) )
{
PointType point1;
inputImage->TransformIndexToPhysicalPoint(It.GetIndex(i), point1);
for ( unsigned int j = 0; j < It.GetNeighborhood().Size(); j++ )
{
if ( i == j )
{
continue;
}
bool IsInBounds2;
InputPixelType pixel2 = It.GetPixel(j, IsInBounds2);
if ( !IsInBounds2 )
{
continue;
}
if ( !this->m_MaskImage || this->m_MaskImage->GetPixel( It.GetIndex(j) ) )
{
PointType point2;
inputImage->TransformIndexToPhysicalPoint(It.GetIndex(j), point2);
const RealType distance = point1.SquaredEuclideanDistanceTo(point2);
bool distanceFound = false;
for ( unsigned int k = 0; k < distances.size(); k++ )
{
if ( itk::Math::abs(distances[k] - distance) < 0.5 * minSpacing )
{
distancesFrequency[k]++;
averageAbsoluteIntensityDifference[k] += itk::Math::abs(pixel1 - pixel2);
distanceFound = true;
break;
}
}
if ( !distanceFound )
{
distances.push_back(distance);
distancesFrequency.push_back(1);
averageAbsoluteIntensityDifference.push_back( itk::Math::abs(pixel1 - pixel2) );
}
}
}
}
}
RealType sumY = 0.0;
RealType sumX = 0.0;
RealType sumXY = 0.0;
RealType sumXX = 0.0;
for ( unsigned int k = 0; k < distances.size(); k++ )
{
if ( distancesFrequency[k] == 0 )
{
continue;
}
averageAbsoluteIntensityDifference[k] /= static_cast< RealType >( distancesFrequency[k] );
averageAbsoluteIntensityDifference[k] = std::log(averageAbsoluteIntensityDifference[k]);
const RealType distance = std::log( std::sqrt(distances[k]) );
sumY += averageAbsoluteIntensityDifference[k];
sumX += distance;
sumXX += ( distance * distance );
sumXY += ( averageAbsoluteIntensityDifference[k] * distance );
}
const RealType N = static_cast< RealType >( distances.size() );
const RealType slope = ( N * sumXY - sumX * sumY ) / ( N * sumXX - sumX * sumX );
ItO.SetCenterPixel( static_cast< OutputPixelType >( 3.0 - slope ) );
progress.CompletedPixel();
}
}
}
template< typename TInputImage, typename TMaskImage, typename TOutputImage >
void
StochasticFractalDimensionImageFilter< TInputImage, TMaskImage, TOutputImage >
::PrintSelf(std::ostream & os, Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Neighborhood radius: " << this->m_NeighborhoodRadius << std::endl;
}
} // end namespace itk
#endif
| 7,850 | 2,425 |
// Note: this file tests schema registration for AuxData. It is
// purposely built as a separate test program so that we can keep the
// type map unlocked. This means, one can write tests that register
// schema, but one should *not* write tests that actually involve
// constructing GTIRB IR.
// Note also: Because schema registration is global, keeping this file
// to a single unit test explicitly guarantees ordering in the state
// of the registration.
#include "AuxDataContainerSchema.hpp"
#include "PrepDeathTest.hpp"
#include <gtirb/AuxDataContainer.hpp>
#include <gtest/gtest.h>
using namespace gtirb;
using namespace schema;
#ifndef NDEBUG
TEST(Unit_AuxDataContainerDeathTest, SchemaRegistration) {
AuxDataContainer::registerAuxDataType<RegisteredType>();
// Able to re-register the same schema with no error.
AuxDataContainer::registerAuxDataType<RegisteredType>();
// Assertion if registering a second schema w/ duplicate name but
// incompatibable type.
{
[[maybe_unused]] PrepDeathTest PDT;
EXPECT_DEATH(AuxDataContainer::registerAuxDataType<DuplicateNameType>(),
"Different types registered for the same AuxData name.");
}
}
#endif
| 1,192 | 348 |
//@HEADER
// ************************************************************************
//
// HPCCG: Simple Conjugate Gradient Benchmark Code
// Copyright (2006) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ************************************************************************
//@HEADER
/////////////////////////////////////////////////////////////////////////
// Function to return time in seconds.
// If compiled with no flags, return CPU time (user and system).
// If compiled with -DWALL, returns elapsed time.
/////////////////////////////////////////////////////////////////////////
#ifdef USING_MPI
#include <mpi.h> // If this routine is compiled with -DUSING_MPI
// then include mpi.h
double mytimer(void)
{
return(MPI_Wtime());
}
#elif defined(UseClock)
#include <time.hpp>
double mytimer(void)
{
clock_t t1;
static clock_t t0=0;
static double CPS = CLOCKS_PER_SEC;
double d;
if (t0 == 0) t0 = clock();
t1 = clock() - t0;
d = t1 / CPS;
return(d);
}
#elif defined(WALL)
#include <cstdlib>
#include <sys/time.h>
#include <sys/resource.h>
double mytimer(void)
{
struct timeval tp;
static long start=0, startu;
if (!start)
{
gettimeofday(&tp, NULL);
start = tp.tv_sec;
startu = tp.tv_usec;
return(0.0);
}
gettimeofday(&tp, NULL);
return( ((double) (tp.tv_sec - start)) + (tp.tv_usec-startu)/1000000.0 );
}
#elif defined(UseTimes)
#include <cstdlib>
#include <sys/times.h>
#include <unistd.h>
double mytimer(void)
{
struct tms ts;
static double ClockTick=0.0;
if (ClockTick == 0.0) ClockTick = (double) sysconf(_SC_CLK_TCK);
times(&ts);
return( (double) ts.tms_utime / ClockTick );
}
#else
#include <cstdlib>
#include <sys/time.h>
#include <sys/resource.h>
double mytimer(void)
{
struct rusage ruse;
getrusage(RUSAGE_SELF, &ruse);
return( (double)(ruse.ru_utime.tv_sec+ruse.ru_utime.tv_usec / 1000000.0) );
}
#endif
| 2,916 | 1,018 |
/*
Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
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.
*/
// ROCM_TARGET=gfx900 hipcc --genco memcpyInt.device.cpp -o memcpyInt.hsaco
// hipcc copy_coherency.cpp -I ~/X/HIP/tests/src/ ~/X/HIP/tests/src/test_common.cpp
// TODO - add code object support here.
/* HIT_START
* BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS --std=c++11
* TEST: %t
* HIT_END
*/
// Test cache management (fences) and synchronization between kernel and copy commands.
// Exhaustively tests 3 command types (copy, kernel, module kernel),
// many sync types (see SyncType), followed by another command, across a sweep
// of data sizes designed to stress various levels of the memory hierarchy.
#include "hip/hip_runtime.h"
#include "test_common.h"
// TODO - turn this back on when test infra can copy the module files to use as test inputs.
#define SKIP_MODULE_KERNEL 1
class MemcpyFunction {
public:
MemcpyFunction(const char* fileName, const char* functionName) {
load(fileName, functionName);
};
void load(const char* fileName, const char* functionName);
void launch(int* dst, const int* src, size_t numElements, hipStream_t s);
private:
hipFunction_t _function;
hipModule_t _module;
};
void MemcpyFunction::load(const char* fileName, const char* functionName) {
#if SKIP_MODULE_KERNEL != 1
HIPCHECK(hipModuleLoad(&_module, fileName));
HIPCHECK(hipModuleGetFunction(&_function, _module, functionName));
#endif
};
void MemcpyFunction::launch(int* dst, const int* src, size_t numElements, hipStream_t s) {
struct {
int* _dst;
const int* _src;
size_t _numElements;
} args;
args._dst = dst;
args._src = src;
args._numElements = numElements;
size_t size = sizeof(args);
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
HIP_LAUNCH_PARAM_END};
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, numElements);
HIPCHECK(hipModuleLaunchKernel(_function, blocks, 1, 1, threadsPerBlock, 1, 1,
0 /*dynamicShared*/, s, NULL, (void**)&config));
};
bool g_warnOnFail = true;
// int g_elementSizes[] = {1, 16, 1024, 524288, 16*1000*1000}; // TODO
int g_elementSizes[] = {128 * 1000, 256 * 1000, 16 * 1000 * 1000};
MemcpyFunction g_moduleMemcpy("memcpyInt.hsaco", "memcpyIntKernel");
// Set value of array to specified 32-bit integer:
__global__ void memsetIntKernel(int* ptr, const int val, size_t numElements) {
int gid = (blockIdx.x * blockDim.x + threadIdx.x);
int stride = blockDim.x * gridDim.x;
for (size_t i = gid; i < numElements; i += stride) {
ptr[i] = val;
}
};
__global__ void memcpyIntKernel(int* dst, const int* src, size_t numElements) {
int gid = (blockIdx.x * blockDim.x + threadIdx.x);
int stride = blockDim.x * gridDim.x;
for (size_t i = gid; i < numElements; i += stride) {
dst[i] = src[i];
}
};
// CHeck arrays in reverse order, to more easily detect cases where
// the copy is "partially" done.
void checkReverse(const int* ptr, int numElements, int expected) {
int mismatchCnt = 0;
for (int i = numElements - 1; i >= 0; i--) {
if (ptr[i] != expected) {
fprintf(stderr, "%s**error: i=%d, ptr[i] == (%x) , does not equal expected (%x)\n%s",
KRED, i, ptr[i], expected, KNRM);
if (!g_warnOnFail) {
assert(ptr[i] == expected);
}
if (++mismatchCnt >= 10) {
break;
}
}
}
fprintf(stderr, "test: OK\n");
}
#define ENUM_CASE_STR(x) \
case x: \
return #x
enum CmdType { COPY, KERNEL, MODULE_KERNEL, MAX_CmdType };
const char* CmdTypeStr(CmdType c) {
switch (c) {
ENUM_CASE_STR(COPY);
ENUM_CASE_STR(KERNEL);
ENUM_CASE_STR(MODULE_KERNEL);
default:
return "UNKNOWN";
};
}
enum SyncType {
NONE,
EVENT_QUERY,
EVENT_SYNC,
STREAM_WAIT_EVENT,
STREAM_QUERY,
STREAM_SYNC,
DEVICE_SYNC,
MAX_SyncType
};
const char* SyncTypeStr(SyncType s) {
switch (s) {
ENUM_CASE_STR(NONE);
ENUM_CASE_STR(EVENT_QUERY);
ENUM_CASE_STR(EVENT_SYNC);
ENUM_CASE_STR(STREAM_WAIT_EVENT);
ENUM_CASE_STR(STREAM_QUERY);
ENUM_CASE_STR(STREAM_SYNC);
ENUM_CASE_STR(DEVICE_SYNC);
default:
return "UNKNOWN";
};
};
void runCmd(CmdType cmd, int* dst, const int* src, hipStream_t s, size_t numElements) {
switch (cmd) {
case COPY:
HIPCHECK(
hipMemcpyAsync(dst, src, numElements * sizeof(int), hipMemcpyDeviceToDevice, s));
break;
case KERNEL: {
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, numElements);
hipLaunchKernelGGL(memcpyIntKernel, dim3(blocks), dim3(threadsPerBlock), 0, s, dst, src,
numElements);
} break;
case MODULE_KERNEL:
g_moduleMemcpy.launch(dst, src, numElements, s);
break;
default:
failed("unknown cmd=%d type", cmd);
};
}
void resetInputs(int* Ad, int* Bd, int* Cd, int* Ch, size_t numElements, int expected) {
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, numElements);
hipLaunchKernelGGL(memsetIntKernel, dim3(blocks), dim3(threadsPerBlock), 0, hipStream_t(0), Ad,
expected, numElements);
hipLaunchKernelGGL(memsetIntKernel, dim3(blocks), dim3(threadsPerBlock), 0, hipStream_t(0), Bd,
0xDEADBEEF,
numElements); // poison with bad value to ensure is overwritten correctly
hipLaunchKernelGGL(memsetIntKernel, dim3(blocks), dim3(threadsPerBlock), 0, hipStream_t(0), Bd,
0xF000BA55,
numElements); // poison with bad value to ensure is overwritten correctly
memset(Ch, 13,
numElements * sizeof(int)); // poison with bad value to ensure is overwritten correctly
HIPCHECK(hipDeviceSynchronize());
}
// Intended to test proper synchronization and cache flushing between CMDA and CMDB.
// CMD are of type CmdType. All command copy memory, using either hipMemcpyAsync or kernel
// implementations. CmdA copies from Ad to Bd, Some form of synchronization is applied. Then cmdB
// copies from Bd to Cd.
//
// Cd is then copied to host Ch using a memory copy.
//
// Correct result at the end is that Ch contains the contents originally in Ad (integer 0x42)
void runTestImpl(CmdType cmdAType, SyncType syncType, CmdType cmdBType, hipStream_t stream1,
hipStream_t stream2, int numElements, int* Ad, int* Bd, int* Cd, int* Ch,
int expected) {
hipEvent_t e;
HIPCHECK(hipEventCreateWithFlags(&e, 0));
resetInputs(Ad, Bd, Cd, Ch, numElements, expected);
const size_t sizeElements = numElements * sizeof(int);
fprintf(stderr, "test: runTest with %zu bytes (%6.2f MB) cmdA=%s; sync=%s; cmdB=%s\n",
sizeElements, (double)(sizeElements / 1024.0), CmdTypeStr(cmdAType),
SyncTypeStr(syncType), CmdTypeStr(cmdBType));
if (SKIP_MODULE_KERNEL && ((cmdAType == MODULE_KERNEL) || (cmdBType == MODULE_KERNEL))) {
fprintf(stderr, "warn: skipping since test infra does not yet support modules\n");
return;
}
// Step A:
runCmd(cmdAType, Bd, Ad, stream1, numElements);
// Sync in-between?
switch (syncType) {
case NONE:
break;
case EVENT_QUERY: {
hipError_t st = hipErrorNotReady;
HIPCHECK(hipEventRecord(e, stream1));
do {
st = hipEventQuery(e);
} while (st == hipErrorNotReady);
HIPCHECK(st);
} break;
case EVENT_SYNC:
HIPCHECK(hipEventRecord(e, stream1));
HIPCHECK(hipEventSynchronize(e));
break;
case STREAM_WAIT_EVENT:
HIPCHECK(hipEventRecord(e, stream1));
HIPCHECK(hipStreamWaitEvent(stream2, e, 0));
break;
case STREAM_QUERY: {
hipError_t st = hipErrorNotReady;
do {
st = hipStreamQuery(stream1);
} while (st == hipErrorNotReady);
HIPCHECK(st);
} break;
case STREAM_SYNC:
HIPCHECK(hipStreamSynchronize(stream1));
break;
case DEVICE_SYNC:
HIPCHECK(hipDeviceSynchronize());
break;
default:
fprintf(stderr, "warning: unknown sync type=%s", SyncTypeStr(syncType));
return; // FIXME, this doesn't clean up
// failed("unknown sync type=%s", SyncTypeStr(syncType));
};
runCmd(cmdBType, Cd, Bd, stream2, numElements);
// Copy back to host, use async copy to avoid any extra synchronization that might mask issues.
HIPCHECK(hipMemcpyAsync(Ch, Cd, sizeElements, hipMemcpyDeviceToHost, stream2));
HIPCHECK(hipStreamSynchronize(stream2));
checkReverse(Ch, numElements, expected);
HIPCHECK(hipEventDestroy(e));
};
void testWrapper(size_t numElements) {
const size_t sizeElements = numElements * sizeof(int);
const int expected = 0x42;
int *Ad, *Bd, *Cd, *Ch;
HIPCHECK(hipMalloc(&Ad, sizeElements));
HIPCHECK(hipMalloc(&Bd, sizeElements));
HIPCHECK(hipMalloc(&Cd, sizeElements));
HIPCHECK(hipHostMalloc(&Ch, sizeElements)); // Ch is the end array
hipStream_t stream1, stream2;
HIPCHECK(hipStreamCreate(&stream1));
HIPCHECK(hipStreamCreate(&stream2));
HIPCHECK(hipDeviceSynchronize());
fprintf(stderr, "test: init complete, start running tests\n");
runTestImpl(COPY, EVENT_SYNC, KERNEL, stream1, stream2, numElements, Ad, Bd, Cd, Ch, expected);
for (int cmdA = 0; cmdA < MAX_CmdType; cmdA++) {
for (int cmdB = 0; cmdB < MAX_CmdType; cmdB++) {
for (int syncMode = 0; syncMode < MAX_SyncType; syncMode++) {
switch (syncMode) {
// case NONE::
case EVENT_QUERY:
case EVENT_SYNC:
case STREAM_WAIT_EVENT:
// case STREAM_QUERY:
case STREAM_SYNC:
case DEVICE_SYNC:
runTestImpl(CmdType(cmdA), SyncType(syncMode), CmdType(cmdB), stream1,
stream2, numElements, Ad, Bd, Cd, Ch, expected);
break;
default:
break;
}
}
}
}
#if 0
runTestImpl(COPY, STREAM_SYNC, MODULE_KERNEL, stream1, stream2, numElements, Ad, Bd, Cd, Ch, expected);
runTestImpl(COPY, STREAM_SYNC, KERNEL, stream1, stream2, numElements, Ad, Bd, Cd, Ch, expected);
runTestImpl(COPY, STREAM_WAIT_EVENT, MODULE_KERNEL, stream1, stream2, numElements, Ad, Bd, Cd, Ch, expected);
runTestImpl(COPY, STREAM_WAIT_EVENT, KERNEL, stream1, stream2, numElements, Ad, Bd, Cd, Ch, expected);
#endif
HIPCHECK(hipFree(Ad));
HIPCHECK(hipFree(Bd));
HIPCHECK(hipFree(Cd));
HIPCHECK(hipHostFree(Ch));
HIPCHECK(hipStreamDestroy(stream1));
HIPCHECK(hipStreamDestroy(stream2));
}
int main(int argc, char* argv[]) {
for (int index = 0; index < sizeof(g_elementSizes) / sizeof(int); index++) {
size_t numElements = g_elementSizes[index];
testWrapper(numElements);
}
passed();
}
// TODO
// - test environment variables
| 12,829 | 4,370 |
#include"Global.h"
void charMgr_beginCharacterSelection(clientGamemain_t *cgm)
{
pyMarshalString_t pms;
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addUnicode(&pms, (sint8*)"Name"); // familyName // this should be null if hasCharacters is 0
pym_addInt(&pms, 0); // hasCharacters
pym_addInt(&pms, cgm->userID); // userId
//pym_addInt(&pms, 5); // enabledRaceList
pym_tuple_begin(&pms);
pym_addInt(&pms, 1); // human
pym_addInt(&pms, 2); // forean_hybrid
pym_addInt(&pms, 3); // brann_hybrid
pym_addInt(&pms, 4); // thrax_hybrid
pym_tuple_end(&pms);
pym_addInt(&pms, 1); // bCanSkipBootcamp
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 5, BeginCharacterSelection, pym_getData(&pms), pym_getLen(&pms));
}
void charMgr_sendCharacterCreateSuccess(clientGamemain_t *cgm, sint8* familyName, sint32 slotNum)
{
pyMarshalString_t pms;
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addInt(&pms, slotNum); // slotNum
pym_addUnicode(&pms, familyName); // familyName
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 5, CharacterCreateSuccess, pym_getData(&pms), pym_getLen(&pms)); // 426 = CharacterCreateSuccess
}
void charMgr_sendCharacterCreateFailed(clientGamemain_t *cgm, sint32 errorCode)
{
pyMarshalString_t pms;
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addInt(&pms, errorCode); // errorCode
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 5, UserCreationFailed, pym_getData(&pms), pym_getLen(&pms));
}
void charMgr_sendCharacterDeleteSuccess(clientGamemain_t *cgm)
{
pyMarshalString_t pms;
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addInt(&pms, 1); // hasCharacters
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 5, CharacterDeleteSuccess, pym_getData(&pms), pym_getLen(&pms));
}
void charMgr_sendGeneratedCharacterName(clientGamemain_t *cgm, bool isMale)
{
pym_init(&cgm->pyms);
pym_tuple_begin(&cgm->pyms);
if( isMale )
pym_addUnicode(&cgm->pyms, (sint8*)"Richard");
else
pym_addUnicode(&cgm->pyms, (sint8*)"Rachel");
pym_tuple_end(&cgm->pyms);
netMgr_pythonAddMethodCallRaw(cgm, 5, GeneratedCharacterName, pym_getData(&cgm->pyms), pym_getLen(&cgm->pyms));
}
void charMgr_sendGeneratedFamilyName(clientGamemain_t *cgm)
{
pym_init(&cgm->pyms);
pym_tuple_begin(&cgm->pyms);
pym_addUnicode(&cgm->pyms, (sint8*)"Garriott");
pym_tuple_end(&cgm->pyms);
netMgr_pythonAddMethodCallRaw(cgm, 5, 456, pym_getData(&cgm->pyms), pym_getLen(&cgm->pyms));
}
// podIdx --> 0 to 15
void _charMgr_sendUpdateEmptyPod(clientGamemain_t *cgm, sint32 podIdx)
{
pyMarshalString_t pms;
pym_init(&pms);
pym_tuple_begin(&pms);
pym_dict_begin(&pms);
//SlotId
pym_dict_addKey(&pms, (sint8*)"SlotId");
pym_addInt(&pms, podIdx);
//IsSelected
pym_dict_addKey(&pms, (sint8*)"IsSelected");
if( podIdx == 1 )
pym_addInt(&pms, 1);
else
pym_addInt(&pms, 0);
//BodyData
pym_dict_addKey(&pms, (sint8*)"BodyData");
pym_addNoneStruct(&pms);
pym_dict_addKey(&pms, (sint8*)"AppearanceData");
pym_tuple_begin(&pms);
pym_tuple_end(&pms);
//CharacterData
pym_dict_addKey(&pms, (sint8*)"CharacterData");
pym_addNoneStruct(&pms);
//UserName
pym_dict_addKey(&pms, (sint8*)"UserName");
pym_addNoneStruct(&pms);
//GameContextId
pym_dict_addKey(&pms, (sint8*)"GameContextId");
pym_addNoneStruct(&pms);
//LoginData
pym_dict_addKey(&pms, (sint8*)"LoginData");
pym_addNoneStruct(&pms);
//ClanData
pym_dict_addKey(&pms, (sint8*)"ClanData");
pym_addNoneStruct(&pms);
pym_dict_end(&pms);
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, entityID_charPodFirst+podIdx-1, CharacterInfo, pym_getData(&pms), pym_getLen(&pms));
}
void charMgr_createSelectionPodEntitys(clientGamemain_t *cgm)
{
pyMarshalString_t pms;
for(sint32 i=0; i<16; i++)
{
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addInt(&pms, entityID_charPodFirst+i); // entityID
pym_addInt(&pms, 3543); // classID
pym_addNoneStruct(&pms); // entityData (dunno)
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 5, CreatePhysicalEntity, pym_getData(&pms), pym_getLen(&pms));
}
}
// slotId: 1-16
void charMgr_sendCharacterInfo(clientGamemain_t *cgm, sint32 slotId, di_characterPreview_t *charInfo)
{
if( charInfo == NULL )
{
_charMgr_sendUpdateEmptyPod(cgm, slotId);
return;
}
pyMarshalString_t pms;
pym_init(&pms);
pym_tuple_begin(&pms);
pym_dict_begin(&pms);
//SlotId
pym_dict_addKey(&pms, (sint8*)"SlotId");
pym_addInt(&pms, slotId);
//IsSelected
pym_dict_addKey(&pms, (sint8*)"IsSelected");
if( slotId == 0 )
pym_addInt(&pms, 1);
else
pym_addInt(&pms, 0);
//BodyData
pym_dict_addKey(&pms, (sint8*)"BodyData");
pym_tuple_begin(&pms);
pym_addInt(&pms, charInfo->genderIsMale?692:691); // 0 - genderClassId (human: m692,f691 )
pym_addInt(&pms, 1); // 1 - scale, actually is a float!
pym_tuple_end(&pms);
//CharacterData
pym_dict_addKey(&pms, (sint8*)"CharacterData");
pym_tuple_begin(&pms);
pym_addUnicode(&pms, charInfo->unicodeName); // 0 charname
pym_addInt(&pms, 1); // 1 Pos
pym_addInt(&pms, charInfo->experience); // 2 XPPtrs
pym_addInt(&pms, charInfo->level); // 3 XPLvl
pym_addInt(&pms, charInfo->body); // 4 Body
pym_addInt(&pms, charInfo->mind); // 5 Mind
pym_addInt(&pms, charInfo->spirit); // 6 Spirit
pym_addInt(&pms, charInfo->classID); // 7 Class
pym_addInt(&pms, charInfo->clonecredits); // 8 CloneCredits
pym_addInt(&pms, charInfo->raceID); // 9 RaceID
pym_tuple_end(&pms);
//AppearanceData
pym_dict_addKey(&pms, (sint8*)"AppearanceData");
pym_dict_begin(&pms);
for(sint32 i=0; i<SWAPSET_SIZE; i++)
{
if( charInfo->appearanceData[i].classId )
{
pym_addInt(&pms, i+1); // index(equipmentSlotId)
pym_tuple_begin(&pms);
pym_addInt(&pms, charInfo->appearanceData[i].classId); // classId
pym_tuple_begin(&pms);
uint32 hueR = (charInfo->appearanceData[i].hue>>0)&0xFF;
uint32 hueG = (charInfo->appearanceData[i].hue>>8)&0xFF;
uint32 hueB = (charInfo->appearanceData[i].hue>>16)&0xFF;
uint32 hueA = (charInfo->appearanceData[i].hue>>24)&0xFF;
pym_addInt(&pms, (sint32)hueR);
pym_addInt(&pms, (sint32)hueG);
pym_addInt(&pms, (sint32)hueB);
pym_addInt(&pms, (sint32)hueA);
pym_tuple_end(&pms);
pym_tuple_end(&pms);
}
}
pym_dict_end(&pms);
//UserName
pym_dict_addKey(&pms, (sint8*)"UserName");
pym_addUnicode(&pms, charInfo->unicodeFamily);
//GameContextId
pym_dict_addKey(&pms, (sint8*)"GameContextId");
pym_addInt(&pms, charInfo->currentContextId); // see gamecontextlanguage.txt
//LoginData
pym_dict_addKey(&pms, (sint8*)"LoginData");
pym_tuple_begin(&pms);
pym_addInt(&pms, charInfo->numLogins); // 0 numLogins
pym_addInt(&pms, charInfo->totalTimePlayed); // 1 totalTimePlayed
pym_addInt(&pms, charInfo->timeSinceLastPlayed); // 2 timeSinceLastPlayed
pym_tuple_end(&pms);
//ClanData
pym_dict_addKey(&pms, (sint8*)"ClanData");
pym_tuple_begin(&pms);
pym_addInt(&pms, 0); // 0 clanID (0 marks no-clan)
pym_addUnicode(&pms, ""); // 1 clanName
pym_tuple_end(&pms);
pym_dict_end(&pms);
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, entityID_charPodFirst+slotId-1, CharacterInfo, pym_getData(&pms), pym_getLen(&pms));
}
sint32 charMgr_recv_requestCharacterName(clientGamemain_t *cgm, uint8 *pyString, sint32 pyStringLen)
{
pym_init(&cgm->pyums, pyString, pyStringLen);
if( pym_unpackTuple_begin(&cgm->pyums) == false )
return 0;
uint32 gender = pym_unpackInt(&cgm->pyums); // gender (0 - male, 1 - female)
uint32 langID = pym_unpackInt(&cgm->pyums); // Language ID "always 1"
charMgr_sendGeneratedCharacterName(cgm, gender==0);
return 1;
}
sint32 charMgr_recv_requestFamilyName(clientGamemain_t *cgm, uint8 *pyString, sint32 pyStringLen)
{
pym_init(&cgm->pyums, pyString, pyStringLen);
if( pym_unpackTuple_begin(&cgm->pyums) == false )
return 0;
uint32 langID = pym_unpackInt(&cgm->pyums); // Language ID "always 1"
charMgr_sendGeneratedFamilyName(cgm);
return 1;
}
void _cb_charMgr_recv_requestCreateCharacterInSlot(void *param, di_characterLayout_t *characterData)
{
clientGamemain_t *cgm = (clientGamemain_t*)param;
if( characterData->error )
{
if( characterData->error_nameAlreadyInUse )
charMgr_sendCharacterCreateFailed(cgm, 7); // name in use
free(characterData);
return;
}
charMgr_sendCharacterCreateSuccess(cgm, characterData->unicodeFamily, characterData->slotIndex);
charMgr_updateCharacterSelection(cgm);
free(characterData);
}
sint32 charMgr_recv_requestCreateCharacterInSlot(clientGamemain_t *cgm, uint8 *pyString, sint32 pyStringLen)
{
di_characterLayout_t *characterData = (di_characterLayout_t*)malloc(sizeof(di_characterLayout_t));
RtlZeroMemory((void*)characterData, sizeof(di_characterLayout_t));
pym_init(&cgm->pyums, pyString, pyStringLen);
if( pym_unpackTuple_begin(&cgm->pyums) == false )
return 0;
uint32 slotNum = pym_unpackInt(&cgm->pyums);
characterData->slotIndex = slotNum;
//sint8 familyName[128];
//sint8 firstName[128];
characterData->unicodeFamily[0] = '\0';
characterData->unicodeName[0] = '\0';
pym_unpackUnicode(&cgm->pyums, characterData->unicodeFamily, CHARACTER_FIRSTNAMELIMIT);
pym_unpackUnicode(&cgm->pyums, characterData->unicodeName, CHARACTER_FIRSTNAMELIMIT);
sint8 gender = pym_unpackInt(&cgm->pyums); // 0 --> male, 1 --> female
float scale = pym_unpackFloat(&cgm->pyums);
if( pym_unpackDict_begin(&cgm->pyums) == false )
return 0;
characterData->genderIsMale = gender == 0;
// scale is still todo
sint32 aCount = pym_getContainerSize(&cgm->pyums);
for(sint32 i=0; i<aCount; i++)
{
sint32 key = pym_unpackInt(&cgm->pyums);
if( pym_unpackTuple_begin(&cgm->pyums) == false )
return 0;
sint32 templateId = pym_unpackInt(&cgm->pyums);
sint32 classId = gameData_getStarterItemTemplateClassId(templateId);
if( classId == 0 )
return 0; // unknown starter item
sint32 equipmentSlotId = gameData_getEquipmentClassIdSlot(classId);
if( equipmentSlotId == 0 )
return 0; // unknown starter item class id
if( key != equipmentSlotId )
return 0; // client has unsychrounous data
if( pym_unpackTuple_begin(&cgm->pyums) == false )
return 0;
sint32 cLen = pym_getContainerSize(&cgm->pyums);
if( cLen != 4 ) // no 4 subelements
return 0;
sint32 hue1 = pym_unpackLongLong(&cgm->pyums); // R
sint32 hue2 = pym_unpackLongLong(&cgm->pyums); // G
sint32 hue3 = pym_unpackLongLong(&cgm->pyums); // B
sint32 hue4 = pym_unpackLongLong(&cgm->pyums); // A
uint32 hueRGBA = (hue1) | (hue2<<8) | (hue3<<16) | (hue4<<24);
characterData->appearanceData[equipmentSlotId-1].classId = classId;
characterData->appearanceData[equipmentSlotId-1].hue = hueRGBA;
}
// Default armor
characterData->appearanceData[0].classId = 10908; // helm
characterData->appearanceData[0].hue = 0xFF808080;
characterData->appearanceData[1].classId = 7054; // boots
characterData->appearanceData[1].hue = 0xFF808080;
characterData->appearanceData[2].classId = 10909; // gloves
characterData->appearanceData[2].hue = 0xFF808080;
characterData->appearanceData[14].classId = 7052; // torso
characterData->appearanceData[14].hue = 0xFF808080;
characterData->appearanceData[15].classId = 7053; // legs
characterData->appearanceData[15].hue = 0xFF808080;
// Default armor end
sint32 raceId = pym_unpackInt(&cgm->pyums);
if( raceId < 1 || raceId > 4 )
return 0; // invalid race
// setup other characterData
characterData->userID = cgm->userID;
characterData->raceID = raceId;
characterData->classId = 1; // recruit
// setup starting location
characterData->currentContextId = 1220 ; // wilderness (alia das)
characterData->posX = 894.9f;
characterData->posY = 307.9f;
characterData->posZ = 347.1f;
// check name for valid letters
bool validName = true;
sint32 nameLength = strlen((char*)characterData->unicodeName);
for(sint32 i=0; i<127; i++)
{
sint8 c = characterData->unicodeName[i];
if( !c )
break;
if( c >= 'a' && c <= 'z' )
continue;
if( c >= 'A' && c <= 'Z' )
continue;
if( c >= '0' && c <= '9' )
continue;
if( c == '_' || c == ' ' )
continue;
// passed through all, invalid character
validName = false;
break;
}
if( nameLength < 3 )
{
charMgr_sendCharacterCreateFailed(cgm, 2);
return 1;
}
if( nameLength > 20 )
{
charMgr_sendCharacterCreateFailed(cgm, 3);
return 1;
}
if( validName == false )
{
charMgr_sendCharacterCreateFailed(cgm, 4);
return 1;
}
// queue job for character creation
DataInterface_Character_createCharacter(characterData, _cb_charMgr_recv_requestCreateCharacterInSlot, cgm);
return 1;
}
void _cb_charMgr_recv_requestDeleteCharacterInSlot(void *param, diJob_deleteCharacter_t *jobData)
{
clientGamemain_t *cgm = (clientGamemain_t*)param;
charMgr_sendCharacterDeleteSuccess(cgm);
if( jobData->error == false )
if( jobData->slotId >= 1 && jobData->slotId <= 16 )
_charMgr_sendUpdateEmptyPod(cgm, jobData->slotId);
}
sint32 charMgr_recv_requestDeleteCharacterInSlot(clientGamemain_t *cgm, uint8 *pyString, sint32 pyStringLen)
{
pym_init(&cgm->pyums, pyString, pyStringLen);
if( pym_unpackTuple_begin(&cgm->pyums) == false )
return 0;
uint32 slotId = pym_unpackInt(&cgm->pyums); // slotIndex
DataInterface_Character_deleteCharacter(cgm->userID, slotId, _cb_charMgr_recv_requestDeleteCharacterInSlot, cgm);
return 1;
}
void _cb_charMgr_initCharacterSelection(void *param, diJob_getCharacterPreviewInfo_t *jobData)
{
for(sint32 i=0; i<16; i++)
charMgr_sendCharacterInfo((clientGamemain_t*)param, i+1, jobData->outPreviewData[i]);
}
void charMgr_initCharacterSelection(clientGamemain_t *cgm)
{
charMgr_beginCharacterSelection(cgm);
charMgr_createSelectionPodEntitys(cgm);
// request character info
DataInterface_Character_getCharacterPreviewInfo(cgm->userID, -1, _cb_charMgr_initCharacterSelection, cgm);
}
void charMgr_updateCharacterSelection(clientGamemain_t *cgm)
{
// request character info
DataInterface_Character_getCharacterPreviewInfo(cgm->userID, -1, _cb_charMgr_initCharacterSelection, cgm);
}
/*selects the current character*/
void _cb_charMgr_recv_requestSwitchToCharacterInSlot(void *param, diJob_getCharacterPreviewInfo_t *jobData)
{
clientGamemain_t *cgm = (clientGamemain_t*)param;
sint32 slotIndex = jobData->slotIndex;
if( slotIndex < 1 || slotIndex > 16 )
return;
// check if character was found
di_characterPreview_t *characterData;
characterData = jobData->outPreviewData[slotIndex-1];
if( !characterData )
return;
cgm->mapLoadSlotId = slotIndex;
pyMarshalString_t pms;
// Test: send GM enabled
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addBool(&pms, true);
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 5, 366, pym_getData(&pms), pym_getLen(&pms));
// send PreWonkavate (clientMethod.134)
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addInt(&pms, 0); // wonkType - actually not used by the game
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 5, 134, pym_getData(&pms), pym_getLen(&pms));
// send Wonkavate (inputstateRouter.242)
pym_init(&pms);
pym_tuple_begin(&pms);
pym_addInt(&pms, characterData->currentContextId); // gameContextId (alias mapId)
cgm->mapLoadContextId = characterData->currentContextId;
pym_addInt(&pms, 0); // instanceId ( not important for now )
// find map version
sint32 mapVersion = 0;
for(sint32 i=0; i<mapInfoCount; i++)
{
if( mapInfoArray[i].contextId == characterData->currentContextId )
{
mapVersion = mapInfoArray[i].version;
break;
}
}
pym_addInt(&pms, mapVersion); // templateVersion ( from the map file? )
pym_tuple_begin(&pms); // startPosition
pym_addInt(&pms, characterData->posX); // x (todo: send as float)
pym_addInt(&pms, characterData->posY); // y (todo: send as float)
pym_addInt(&pms, characterData->posZ); // z (todo: send as float)
pym_tuple_end(&pms);
pym_addInt(&pms, 0); // startRotation (todo, read from db and send as float)
pym_tuple_end(&pms);
netMgr_pythonAddMethodCallRaw(cgm, 6, Wonkavate, pym_getData(&pms), pym_getLen(&pms));
// early pass the client to the mapChannel ( since it must load character )
cgm->State = GAMEMAIN_STATE_RELIEVED; // the gameMain thread will pass the client to the mapChannel
return;
}
sint32 charMgr_recv_requestSwitchToCharacterInSlot(clientGamemain_t *cgm, uint8 *pyString, sint32 pyStringLen)
{
pym_init(&cgm->pyums, pyString, pyStringLen);
if( pym_unpackTuple_begin(&cgm->pyums) == false )
return 0;
uint32 slotId = pym_unpackInt(&cgm->pyums); // slotIndex
//bool canSkipBootcamp = pym_readBool(&cgm->pymus); --> bool: 02(true false?)
// request character info
DataInterface_Character_getCharacterPreviewInfo(cgm->userID, slotId, _cb_charMgr_recv_requestSwitchToCharacterInSlot, cgm);
return true;
}
| 16,683 | 7,455 |
#include <bits/stdc++.h>
using namespace std;
int main(){
freopen("Puzzle_Input.txt", "r", stdin);
string s;
vector <int> input;
input.push_back(0);
while(cin >> s) input.push_back(stoi(s));
long long answer = 1;
sort(input.begin(), input.end());
for(int i = 0; i < input.size(); i++){
int dif = 1, ip = i;
while(dif == 1 && ip < input.size()){
dif = input[ip+1] - input[ip];
ip++;
} ip--;
if(ip != i && ip - i < 4) answer *= pow(2, ip - i - 1);
else if(ip - i == 4) answer *= 7;
i = ip;
}
cout << answer;
}
//Answer = 3947645370368 | 646 | 259 |
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "pch.h"
#include "Terminal.hpp"
using namespace Microsoft::Terminal::Core;
using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::VirtualTerminal;
// Print puts the text in the buffer and moves the cursor
bool Terminal::PrintString(std::wstring_view stringView)
{
_WriteBuffer(stringView);
return true;
}
bool Terminal::ExecuteChar(wchar_t wch)
{
std::wstring_view view{&wch, 1};
_WriteBuffer(view);
return true;
}
bool Terminal::SetTextToDefaults(bool foreground, bool background)
{
TextAttribute attrs = _buffer->GetCurrentAttributes();
if (foreground)
{
attrs.SetDefaultForeground();
}
if (background)
{
attrs.SetDefaultBackground();
}
_buffer->SetCurrentAttributes(attrs);
return true;
}
bool Terminal::SetTextForegroundIndex(BYTE colorIndex)
{
TextAttribute attrs = _buffer->GetCurrentAttributes();
attrs.SetIndexedAttributes({ colorIndex }, {});
_buffer->SetCurrentAttributes(attrs);
return true;
}
bool Terminal::SetTextBackgroundIndex(BYTE colorIndex)
{
TextAttribute attrs = _buffer->GetCurrentAttributes();
attrs.SetIndexedAttributes({}, { colorIndex });
_buffer->SetCurrentAttributes(attrs);
return true;
}
bool Terminal::SetTextRgbColor(COLORREF color, bool foreground)
{
TextAttribute attrs = _buffer->GetCurrentAttributes();
attrs.SetColor(color, foreground);
_buffer->SetCurrentAttributes(attrs);
return true;
}
bool Terminal::BoldText(bool boldOn)
{
TextAttribute attrs = _buffer->GetCurrentAttributes();
if (boldOn)
{
attrs.Embolden();
}
else
{
attrs.Debolden();
}
_buffer->SetCurrentAttributes(attrs);
return true;
}
bool Terminal::UnderlineText(bool underlineOn)
{
TextAttribute attrs = _buffer->GetCurrentAttributes();
WORD metaAttrs = attrs.GetMetaAttributes();
WI_UpdateFlag(metaAttrs, COMMON_LVB_UNDERSCORE, underlineOn);
attrs.SetMetaAttributes(metaAttrs);
_buffer->SetCurrentAttributes(attrs);
return true;
}
bool Terminal::ReverseText(bool reversed)
{
TextAttribute attrs = _buffer->GetCurrentAttributes();
WORD metaAttrs = attrs.GetMetaAttributes();
WI_UpdateFlag(metaAttrs, COMMON_LVB_REVERSE_VIDEO, reversed);
attrs.SetMetaAttributes(metaAttrs);
_buffer->SetCurrentAttributes(attrs);
return true;
}
bool Terminal::SetCursorPosition(short x, short y)
{
const auto viewport = _GetMutableViewport();
const auto viewOrigin = viewport.Origin();
const short absoluteX = viewOrigin.X + x;
const short absoluteY = viewOrigin.Y + y;
COORD newPos{absoluteX, absoluteY};
viewport.Clamp(newPos);
_buffer->GetCursor().SetPosition(newPos);
return true;
}
COORD Terminal::GetCursorPosition()
{
const auto absoluteCursorPos = _buffer->GetCursor().GetPosition();
const auto viewport = _GetMutableViewport();
const auto viewOrigin = viewport.Origin();
const short relativeX = absoluteCursorPos.X - viewOrigin.X;
const short relativeY = absoluteCursorPos.Y - viewOrigin.Y;
COORD newPos{ relativeX, relativeY };
// TODO assert that the coord is > (0, 0) && <(view.W, view.H)
return newPos;
}
bool Terminal::EraseCharacters(const unsigned int numChars)
{
const auto absoluteCursorPos = _buffer->GetCursor().GetPosition();
const auto viewport = _GetMutableViewport();
const short distanceToRight = viewport.RightExclusive() - absoluteCursorPos.X;
const short fillLimit = std::min(static_cast<short>(numChars), distanceToRight);
auto eraseIter = OutputCellIterator(L' ', _buffer->GetCurrentAttributes(), fillLimit);
_buffer->Write(eraseIter, absoluteCursorPos);
return true;
}
bool Terminal::SetWindowTitle(std::wstring_view title)
{
_title = title;
if (_pfnTitleChanged)
{
_pfnTitleChanged(title);
}
return true;
}
// Method Description:
// - Updates the value in the colortable at index tableIndex to the new color
// dwColor. dwColor is a COLORREF, format 0x00BBGGRR.
// Arguments:
// - tableIndex: the index of the color table to update.
// - dwColor: the new COLORREF to use as that color table value.
// Return Value:
// - true iff we successfully updated the color table entry.
bool Terminal::SetColorTableEntry(const size_t tableIndex, const COLORREF dwColor)
{
if (tableIndex > _colorTable.size())
{
return false;
}
_colorTable.at(tableIndex) = dwColor;
// Repaint everything - the colors might have changed
_buffer->GetRenderTarget().TriggerRedrawAll();
return true;
}
// Method Description:
// - Sets the cursor style to the given style.
// Arguments:
// - cursorStyle: the style to be set for the cursor
// Return Value:
// - true iff we successfully set the cursor style
bool Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle)
{
CursorType finalCursorType;
bool fShouldBlink;
switch (cursorStyle)
{
case DispatchTypes::CursorStyle::BlinkingBlockDefault:
[[fallthrough]];
case DispatchTypes::CursorStyle::BlinkingBlock:
finalCursorType = CursorType::FullBox;
fShouldBlink = true;
break;
case DispatchTypes::CursorStyle::SteadyBlock:
finalCursorType = CursorType::FullBox;
fShouldBlink = false;
break;
case DispatchTypes::CursorStyle::BlinkingUnderline:
finalCursorType = CursorType::Underscore;
fShouldBlink = true;
break;
case DispatchTypes::CursorStyle::SteadyUnderline:
finalCursorType = CursorType::Underscore;
fShouldBlink = false;
break;
case DispatchTypes::CursorStyle::BlinkingBar:
finalCursorType = CursorType::VerticalBar;
fShouldBlink = true;
break;
case DispatchTypes::CursorStyle::SteadyBar:
finalCursorType = CursorType::VerticalBar;
fShouldBlink = false;
break;
default:
finalCursorType = CursorType::Legacy;
fShouldBlink = false;
}
_buffer->GetCursor().SetType(finalCursorType);
_buffer->GetCursor().SetBlinkingAllowed(fShouldBlink);
return true;
}
// Method Description:
// - Updates the default foreground color from a COLORREF, format 0x00BBGGRR.
// Arguments:
// - dwColor: the new COLORREF to use as the default foreground color
// Return Value:
// - true
bool Terminal::SetDefaultForeground(const COLORREF dwColor)
{
_defaultFg = dwColor;
// Repaint everything - the colors might have changed
_buffer->GetRenderTarget().TriggerRedrawAll();
return true;
}
// Method Description:
// - Updates the default background color from a COLORREF, format 0x00BBGGRR.
// Arguments:
// - dwColor: the new COLORREF to use as the default background color
// Return Value:
// - true
bool Terminal::SetDefaultBackground(const COLORREF dwColor)
{
_defaultBg = dwColor;
_pfnBackgroundColorChanged(dwColor);
// Repaint everything - the colors might have changed
_buffer->GetRenderTarget().TriggerRedrawAll();
return true;
}
| 7,403 | 2,212 |
/* Copyright (c) 2008-2014, Avian Contributors
Permission to use, copy, modify, and/or 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.
There is NO WARRANTY for this software. See license.txt for
details. */
#include "avian/target.h"
#include "codegen/compiler/context.h"
#include "codegen/compiler/value.h"
#include "codegen/compiler/site.h"
#include "codegen/compiler/resource.h"
#include "codegen/compiler/frame.h"
#include "codegen/compiler/promise.h"
namespace avian {
namespace codegen {
namespace compiler {
int intersectFrameIndexes(int a, int b)
{
if (a == NoFrameIndex or b == NoFrameIndex)
return NoFrameIndex;
if (a == AnyFrameIndex)
return b;
if (b == AnyFrameIndex)
return a;
if (a == b)
return a;
return NoFrameIndex;
}
SiteMask SiteMask::intersectionWith(const SiteMask& b)
{
return SiteMask(typeMask & b.typeMask,
registerMask & b.registerMask,
intersectFrameIndexes(frameIndex, b.frameIndex));
}
SiteIterator::SiteIterator(Context* c,
Value* v,
bool includeBuddies,
bool includeNextWord)
: c(c),
originalValue(v),
currentValue(v),
includeBuddies(includeBuddies),
includeNextWord(includeNextWord),
pass(0),
next_(findNext(&(v->sites))),
previous(0)
{
}
Site** SiteIterator::findNext(Site** p)
{
while (true) {
if (*p) {
if (pass == 0 or (*p)->registerSize(c) > c->targetInfo.pointerSize) {
return p;
} else {
p = &((*p)->next);
}
} else {
if (includeBuddies) {
Value* v = currentValue->buddy;
if (v != originalValue) {
currentValue = v;
p = &(v->sites);
continue;
}
}
if (includeNextWord and pass == 0) {
Value* v = originalValue->nextWord;
if (v != originalValue) {
pass = 1;
originalValue = v;
currentValue = v;
p = &(v->sites);
continue;
}
}
return 0;
}
}
}
bool SiteIterator::hasMore()
{
if (previous) {
next_ = findNext(&((*previous)->next));
previous = 0;
}
return next_ != 0;
}
Site* SiteIterator::next()
{
previous = next_;
return *previous;
}
void SiteIterator::remove(Context* c)
{
(*previous)->release(c, originalValue);
*previous = (*previous)->next;
next_ = findNext(previous);
previous = 0;
}
unsigned Site::registerSize(Context* c)
{
return c->targetInfo.pointerSize;
}
Site* constantSite(Context* c, Promise* value)
{
return new (c->zone) ConstantSite(value);
}
Site* constantSite(Context* c, int64_t value)
{
return constantSite(c, resolvedPromise(c, value));
}
class AddressSite : public Site {
public:
AddressSite(Promise* address) : address(address)
{
}
virtual unsigned toString(Context*, char* buffer, unsigned bufferSize)
{
if (address->resolved()) {
return vm::snprintf(
buffer, bufferSize, "address %" LLD, address->value());
} else {
return vm::snprintf(buffer, bufferSize, "address unresolved");
}
}
virtual unsigned copyCost(Context*, Site* s)
{
return (s == this ? 0 : AddressCopyCost);
}
virtual bool match(Context*, const SiteMask& mask)
{
return mask.typeMask & lir::Operand::AddressMask;
}
virtual bool loneMatch(Context*, const SiteMask&)
{
return false;
}
virtual bool matchNextWord(Context* c, Site*, unsigned)
{
abort(c);
}
virtual lir::Operand::Type type(Context*)
{
return lir::Operand::Type::Address;
}
virtual void asAssemblerOperand(Context* c UNUSED,
Site* high UNUSED,
lir::Operand* result)
{
assertT(c, high == this);
new (result) lir::Address(address);
}
virtual Site* copy(Context* c)
{
return addressSite(c, address);
}
virtual Site* copyLow(Context* c)
{
abort(c);
}
virtual Site* copyHigh(Context* c)
{
abort(c);
}
virtual Site* makeNextWord(Context* c, unsigned)
{
abort(c);
}
virtual SiteMask mask(Context*)
{
return SiteMask(lir::Operand::AddressMask, 0, NoFrameIndex);
}
virtual SiteMask nextWordMask(Context* c, unsigned)
{
abort(c);
}
Promise* address;
};
Site* addressSite(Context* c, Promise* address)
{
return new (c->zone) AddressSite(address);
}
RegisterSite::RegisterSite(RegisterMask mask, Register number)
: mask_(mask), number(number)
{
}
unsigned RegisterSite::toString(Context*, char* buffer, unsigned bufferSize)
{
if (number != NoRegister) {
return vm::snprintf(buffer, bufferSize, "%p register %d", this, number);
} else {
return vm::snprintf(
buffer, bufferSize, "%p register unacquired (mask %d)", this, mask_);
}
}
unsigned RegisterSite::copyCost(Context* c, Site* s)
{
assertT(c, number != NoRegister);
if (s and (this == s
or (s->type(c) == lir::Operand::Type::RegisterPair
and (static_cast<RegisterSite*>(s)->mask_.contains(number))))) {
return 0;
} else {
return RegisterCopyCost;
}
}
bool RegisterSite::match(Context* c UNUSED, const SiteMask& mask)
{
assertT(c, number != NoRegister);
if ((mask.typeMask & lir::Operand::RegisterPairMask)) {
return mask.registerMask.contains(number);
} else {
return false;
}
}
bool RegisterSite::loneMatch(Context* c UNUSED, const SiteMask& mask)
{
assertT(c, number != NoRegister);
if ((mask.typeMask & lir::Operand::RegisterPairMask)) {
return mask.registerMask.containsExactly(number);
} else {
return false;
}
}
bool RegisterSite::matchNextWord(Context* c, Site* s, unsigned)
{
assertT(c, number != NoRegister);
if (s->type(c) != lir::Operand::Type::RegisterPair) {
return false;
}
RegisterSite* rs = static_cast<RegisterSite*>(s);
unsigned size = rs->registerSize(c);
if (size > c->targetInfo.pointerSize) {
assertT(c, number != NoRegister);
return number == rs->number;
} else {
RegisterMask mask = c->regFile->generalRegisters;
return mask.contains(number) and mask.contains(rs->number);
}
}
void RegisterSite::acquire(Context* c, Value* v)
{
Target target;
if (number != NoRegister) {
target = Target(number, 0);
} else {
target = pickRegisterTarget(c, v, mask_);
expect(c, target.cost < Target::Impossible);
}
RegisterResource* resource = c->registerResources + target.index;
compiler::acquire(c, resource, v, this);
number = Register(target.index);
}
void RegisterSite::release(Context* c, Value* v)
{
assertT(c, number != NoRegister);
compiler::release(c, c->registerResources + number.index(), v, this);
}
void RegisterSite::freeze(Context* c, Value* v)
{
assertT(c, number != NoRegister);
c->registerResources[number.index()].freeze(c, v);
}
void RegisterSite::thaw(Context* c, Value* v)
{
assertT(c, number != NoRegister);
c->registerResources[number.index()].thaw(c, v);
}
bool RegisterSite::frozen(Context* c UNUSED)
{
assertT(c, number != NoRegister);
return c->registerResources[number.index()].freezeCount != 0;
}
lir::Operand::Type RegisterSite::type(Context*)
{
return lir::Operand::Type::RegisterPair;
}
void RegisterSite::asAssemblerOperand(Context* c UNUSED,
Site* high,
lir::Operand* result)
{
assertT(c, number != NoRegister);
Register highNumber;
if (high != this) {
highNumber = static_cast<RegisterSite*>(high)->number;
assertT(c, highNumber != NoRegister);
} else {
highNumber = NoRegister;
}
new (result) lir::RegisterPair(number, highNumber);
}
Site* RegisterSite::copy(Context* c)
{
RegisterMask mask;
if (number != NoRegister) {
mask = RegisterMask(number);
} else {
mask = mask_;
}
return freeRegisterSite(c, mask);
}
Site* RegisterSite::copyLow(Context* c)
{
abort(c);
}
Site* RegisterSite::copyHigh(Context* c)
{
abort(c);
}
Site* RegisterSite::makeNextWord(Context* c, unsigned)
{
assertT(c, number != NoRegister);
assertT(c, c->regFile->generalRegisters.contains(number));
return freeRegisterSite(c, c->regFile->generalRegisters);
}
SiteMask RegisterSite::mask(Context* c UNUSED)
{
return SiteMask(lir::Operand::RegisterPairMask, mask_, NoFrameIndex);
}
SiteMask RegisterSite::nextWordMask(Context* c, unsigned)
{
assertT(c, number != NoRegister);
if (registerSize(c) > c->targetInfo.pointerSize) {
return SiteMask(lir::Operand::RegisterPairMask, number, NoFrameIndex);
} else {
return SiteMask(lir::Operand::RegisterPairMask,
c->regFile->generalRegisters,
NoFrameIndex);
}
}
unsigned RegisterSite::registerSize(Context* c)
{
assertT(c, number != NoRegister);
if (c->regFile->floatRegisters.contains(number)) {
return c->arch->floatRegisterSize();
} else {
return c->targetInfo.pointerSize;
}
}
RegisterMask RegisterSite::registerMask(Context* c UNUSED)
{
assertT(c, number != NoRegister);
return RegisterMask(number);
}
Site* registerSite(Context* c, Register number)
{
assertT(c, number != NoRegister);
assertT(c,
(c->regFile->generalRegisters
| c->regFile->floatRegisters).contains(number));
return new (c->zone) RegisterSite(RegisterMask(number), number);
}
Site* freeRegisterSite(Context* c, RegisterMask mask)
{
return new (c->zone) RegisterSite(mask, NoRegister);
}
MemorySite::MemorySite(Register base, int offset, Register index, unsigned scale)
: acquired(false), base(base), offset(offset), index(index), scale(scale)
{
}
unsigned MemorySite::toString(Context*, char* buffer, unsigned bufferSize)
{
if (acquired) {
return vm::snprintf(
buffer, bufferSize, "memory %d 0x%x %d %d", base, offset, index, scale);
} else {
return vm::snprintf(buffer, bufferSize, "memory unacquired");
}
}
unsigned MemorySite::copyCost(Context* c, Site* s)
{
assertT(c, acquired);
if (s and (this == s or (s->type(c) == lir::Operand::Type::Memory
and static_cast<MemorySite*>(s)->base == base
and static_cast<MemorySite*>(s)->offset == offset
and static_cast<MemorySite*>(s)->index == index
and static_cast<MemorySite*>(s)->scale == scale))) {
return 0;
} else {
return MemoryCopyCost;
}
}
bool MemorySite::conflicts(const SiteMask& mask)
{
return (mask.typeMask & lir::Operand::RegisterPairMask) != 0
and (!mask.registerMask.contains(base)
or (index != NoRegister
and !mask.registerMask.contains(index)));
}
bool MemorySite::match(Context* c, const SiteMask& mask)
{
assertT(c, acquired);
if (mask.typeMask & lir::Operand::MemoryMask) {
if (mask.frameIndex >= 0) {
if (base == c->arch->stack()) {
assertT(c, index == NoRegister);
return static_cast<int>(frameIndexToOffset(c, mask.frameIndex))
== offset;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
}
bool MemorySite::loneMatch(Context* c, const SiteMask& mask)
{
assertT(c, acquired);
if (mask.typeMask & lir::Operand::MemoryMask) {
if (base == c->arch->stack()) {
assertT(c, index == NoRegister);
if (mask.frameIndex == AnyFrameIndex) {
return false;
} else {
return true;
}
}
}
return false;
}
bool MemorySite::matchNextWord(Context* c, Site* s, unsigned index)
{
if (s->type(c) == lir::Operand::Type::Memory) {
MemorySite* ms = static_cast<MemorySite*>(s);
return ms->base == this->base
and ((index == 1
and ms->offset
== static_cast<int>(this->offset
+ c->targetInfo.pointerSize))
or (index == 0
and this->offset
== static_cast<int>(ms->offset
+ c->targetInfo.pointerSize)))
and ms->index == this->index and ms->scale == this->scale;
} else {
return false;
}
}
void MemorySite::acquire(Context* c, Value* v)
{
c->registerResources[base.index()].increment(c);
if (index != NoRegister) {
c->registerResources[index.index()].increment(c);
}
if (base == c->arch->stack()) {
assertT(c, index == NoRegister);
assertT(c, not c->frameResources[offsetToFrameIndex(c, offset)].reserved);
compiler::acquire(
c, c->frameResources + offsetToFrameIndex(c, offset), v, this);
}
acquired = true;
}
void MemorySite::release(Context* c, Value* v)
{
if (base == c->arch->stack()) {
assertT(c, index == NoRegister);
assertT(c, not c->frameResources[offsetToFrameIndex(c, offset)].reserved);
compiler::release(
c, c->frameResources + offsetToFrameIndex(c, offset), v, this);
}
c->registerResources[base.index()].decrement(c);
if (index != NoRegister) {
c->registerResources[index.index()].decrement(c);
}
acquired = false;
}
void MemorySite::freeze(Context* c, Value* v)
{
if (base == c->arch->stack()) {
c->frameResources[offsetToFrameIndex(c, offset)].freeze(c, v);
} else {
c->registerResources[base.index()].increment(c);
if (index != NoRegister) {
c->registerResources[index.index()].increment(c);
}
}
}
void MemorySite::thaw(Context* c, Value* v)
{
if (base == c->arch->stack()) {
c->frameResources[offsetToFrameIndex(c, offset)].thaw(c, v);
} else {
c->registerResources[base.index()].decrement(c);
if (index != NoRegister) {
c->registerResources[index.index()].decrement(c);
}
}
}
bool MemorySite::frozen(Context* c)
{
return base == c->arch->stack()
and c->frameResources[offsetToFrameIndex(c, offset)].freezeCount != 0;
}
lir::Operand::Type MemorySite::type(Context*)
{
return lir::Operand::Type::Memory;
}
void MemorySite::asAssemblerOperand(Context* c UNUSED,
Site* high UNUSED,
lir::Operand* result)
{
// todo: endianness?
assertT(c,
high == this
or (static_cast<MemorySite*>(high)->base == base
and static_cast<MemorySite*>(high)->offset
== static_cast<int>(offset + c->targetInfo.pointerSize)
and static_cast<MemorySite*>(high)->index == index
and static_cast<MemorySite*>(high)->scale == scale));
assertT(c, acquired);
new (result) lir::Memory(base, offset, index, scale);
}
Site* MemorySite::copy(Context* c)
{
return memorySite(c, base, offset, index, scale);
}
Site* MemorySite::copyHalf(Context* c, bool add)
{
if (add) {
return memorySite(
c, base, offset + c->targetInfo.pointerSize, index, scale);
} else {
return copy(c);
}
}
Site* MemorySite::copyLow(Context* c)
{
return copyHalf(c, c->arch->bigEndian());
}
Site* MemorySite::copyHigh(Context* c)
{
return copyHalf(c, not c->arch->bigEndian());
}
Site* MemorySite::makeNextWord(Context* c, unsigned index)
{
return memorySite(c,
base,
offset + ((index == 1) xor c->arch->bigEndian()
? c->targetInfo.pointerSize
: -c->targetInfo.pointerSize),
this->index,
scale);
}
SiteMask MemorySite::mask(Context* c)
{
return SiteMask(lir::Operand::MemoryMask,
0,
(base == c->arch->stack())
? static_cast<int>(offsetToFrameIndex(c, offset))
: NoFrameIndex);
}
SiteMask MemorySite::nextWordMask(Context* c, unsigned index)
{
int frameIndex;
if (base == c->arch->stack()) {
assertT(c, this->index == NoRegister);
frameIndex = static_cast<int>(offsetToFrameIndex(c, offset))
+ ((index == 1) xor c->arch->bigEndian() ? 1 : -1);
} else {
frameIndex = NoFrameIndex;
}
return SiteMask(lir::Operand::MemoryMask, 0, frameIndex);
}
bool MemorySite::isVolatile(Context* c)
{
return base != c->arch->stack();
}
MemorySite* memorySite(Context* c,
Register base,
int offset,
Register index,
unsigned scale)
{
return new (c->zone) MemorySite(base, offset, index, scale);
}
MemorySite* frameSite(Context* c, int frameIndex)
{
assertT(c, frameIndex >= 0);
return memorySite(c,
c->arch->stack(),
frameIndexToOffset(c, frameIndex),
NoRegister,
0);
}
} // namespace compiler
} // namespace codegen
} // namespace avian
| 16,989 | 5,504 |
#include "circle.hpp"
#include <cmath>
#include "color.hpp"
#include "mat2.hpp"
#include "vec2.hpp"
#include "window.hpp"
#define Pi 3.1415926
Circle::Circle() :
center_{ 0.0,0.0 },
radius_{ 1.0 },
color_{ 0,0,0 }
{}
Circle::Circle(Vec2 const& center, float const& radius) :
center_{ center },
radius_{ radius }
{}
Circle::Circle(Vec2 const& center, float const& radius, Color const& color) :
center_{ center },
radius_{ radius },
color_{ color }
{}
float Circle::diameter()const
{
float diameter = (radius_ * 2);
return diameter;
}
float Circle::circumrefrence() const
{
return Pi * radius() * 2;
}
Vec2 Circle::center() const //getter Function
{
return center_;
}
float Circle::radius() const //getter Function
{
return radius_;
}
void Circle::center(Vec2 const& center) //setter Function
{
center_ = center;
}
void Circle::radius(float radius) //setter Function
{
radius_ = radius;
}
void Circle::drawCircle(Window const& win)
{
win.draw_point(center_.x, center_.y, 0.0f, 0.0f, 0.0f);
for (int i = 1; i <= 360; i++) {
float M_PI = std::acos(-1.0);
Vec2 start = ((make_rotation_mat2(2 * i * M_PI / 360)) * Vec2(radius_, 0.0f) + center_);
Vec2 end = ((make_rotation_mat2(2 * M_PI * (i + 1) / 360)) * Vec2(radius_, 0.0f) + center_);
win.draw_line(start.x, start.y, end.x, end.y, 0.0f, 0.0f, 0.0f);
}
return;
}
void Circle::drawCircle(Window const& win, Color const& color) {
win.draw_point(center_.x, center_.y, color.r, color.g, color.b);
for (int i = 1; i <= 360; i++) {
float M_PI = std::acos(-1.0);
Vec2 start = ((make_rotation_mat2(2 * i * M_PI / 360)) * Vec2(radius_, 0.0f) + center_);
Vec2 end = ((make_rotation_mat2(2 * M_PI * (i + 1) / 360)) * Vec2(radius_, 0.0f) + center_);
win.draw_line(start.x, start.y, end.x, end.y, color.r, color.g, color.b);
}
return;
} | 1,832 | 799 |
#include "ModeDebugPluginWidget.h"
#include "ui_ModeDebugPluginWidget.h"
ModeDebugPluginWidget::ModeDebugPluginWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ModeDebugPluginWidget)
{
ui->setupUi(this);
}
ModeDebugPluginWidget::~ModeDebugPluginWidget()
{
delete ui;
}
Ui::ModeDebugPluginWidget *ModeDebugPluginWidget::getUi()
{
return ui;
}
| 370 | 127 |
#include "qrecthf.h"
QRectHF::QRectHF()
{
}
QRectHF::QRectHF(QPoint topleft, QPoint bottomright) : QRect(topleft,bottomright)
{
m_topHF = hfloat(topleft.y());
m_leftHF = hfloat(topleft.x());
m_bottomHF = hfloat(bottomright.y());
m_rightHF = hfloat(bottomright.x());
}
QRectHF::QRectHF(QRectHF& val) : QRect(val)
{
m_topHF = val.topHF();
m_bottomHF = val.bottomHF();
m_rightHF = val.rightHF();
m_leftHF = val.leftHF();
}
hfloat QRectHF::topHF(void)
{
return m_topHF;
}
hfloat QRectHF::bottomHF(void)
{
return m_bottomHF;
}
hfloat QRectHF::rightHF(void)
{
return m_rightHF;
}
hfloat QRectHF::leftHF(void)
{
return m_leftHF;
}
| 679 | 326 |
/*
** Copyright (c) 2018 Valve Corporation
** Copyright (c) 2018-2021 LunarG, Inc.
**
** 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 "application/xlib_context.h"
#include "application/application.h"
#include "application/xlib_window.h"
#include "util/logging.h"
#include <cstdlib>
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(application)
static int ErrorHandler(Display* display, XErrorEvent* error_event)
{
GFXRECON_LOG_ERROR("Xlib error: %d", error_event->error_code);
return 0;
}
XlibContext::XlibContext(Application* application) : WsiContext(application)
{
if (!xlib_loader_.Initialize())
{
GFXRECON_LOG_DEBUG("Failed to initialize xlib loader");
return;
}
const auto xlib = xlib_loader_.GetFunctionTable();
xlib.SetErrorHandler(ErrorHandler);
display_ = xlib.OpenDisplay(nullptr);
if (!display_)
{
GFXRECON_LOG_DEBUG("Failed to open xlib display");
return;
}
window_factory_ = std::make_unique<XlibWindowFactory>(this);
}
XlibContext::~XlibContext()
{
if (display_ != nullptr)
{
const auto xlib = xlib_loader_.GetFunctionTable();
xlib.CloseDisplay(display_);
}
}
// A reference-counting interface to to XOpenDisplay/XCloseDisplay which shares
// a single display connection among multiple windows, and closes it when the
// last window is destroyed. This is a workaround for an issue with the NVIDIA
// driver which registers a callback for XCloseDisplay that needs to happen
// before the ICD is unloaded at vkDestroyInstance time.
// https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/1894
Display* XlibContext::OpenDisplay()
{
if (display_ == nullptr)
{
auto xlib = xlib_loader_.GetFunctionTable();
display_ = xlib.OpenDisplay(nullptr);
}
++display_open_count_;
return display_;
}
void XlibContext::CloseDisplay(Display* display)
{
assert(display == display_);
if ((--display_open_count_ == 0) && (display_ != nullptr))
{
auto xlib = xlib_loader_.GetFunctionTable();
xlib.CloseDisplay(display_);
display_ = nullptr;
}
}
bool XlibContext::RegisterXlibWindow(XlibWindow* window)
{
return WsiContext::RegisterWindow(window);
}
bool XlibContext::UnregisterXlibWindow(XlibWindow* window)
{
return WsiContext::UnregisterWindow(window);
}
void XlibContext::ProcessEvents(bool wait_for_input)
{
assert(application_);
const auto xlib = xlib_loader_.GetFunctionTable();
while (application_->IsRunning() && (wait_for_input || (xlib.Pending(display_) > 0)))
{
wait_for_input = false;
XEvent event;
xlib.NextEvent(display_, &event);
switch (event.type)
{
case KeyRelease:
switch (event.xkey.keycode)
{
case 0x9: // Escape
application_->StopRunning();
break;
case 0x21: // p
case 0x41: // Space
application_->SetPaused(!application_->GetPaused());
break;
default:
break;
}
break;
case KeyPress:
switch (event.xkey.keycode)
{
// Using XCB_KEY_PRESS for repeat when key is held down.
case 0x72: // Right arrow
case 0x39: // n
if (application_->GetPaused())
{
application_->PlaySingleFrame();
}
break;
default:
break;
}
break;
}
}
}
GFXRECON_END_NAMESPACE(application)
GFXRECON_END_NAMESPACE(gfxrecon)
| 4,929 | 1,492 |
/**
* @file print_as_ascii.cpp
* A simple command line program that prints a binary file (as created from
* a BinaryFileWriter) as a sequence of ascii 0s and 1s.
*/
#include <iostream>
#include <string>
#include <vector>
#include "binary_file_reader.h"
void print_usage(const std::string& name)
{
std::cout
<< "Usage: " << name << " filename"
<< "\n\tPrints filename (a binary file) to standard out as a sequence"
" of ASCII 0s and 1s." << std::endl;
}
void print_as_ascii(const std::string& filename)
{
binary_file_reader file(filename);
while (file.has_bits())
std::cout << file.next_bit();
std::cout << std::endl;
}
int main(int argc, char** argv)
{
std::vector<std::string> args(argv, argv + argc);
if (args.size() < 2)
{
print_usage(args[0]);
return 1;
}
print_as_ascii(args[1]);
return 0;
}
| 897 | 317 |
/**
* @file hmm_train.cpp
* @author Chase Geigle
*/
#include <iostream>
#include "cpptoml.h"
#include "meta/hashing/probe_map.h"
#include "meta/io/filesystem.h"
#include "meta/io/gzstream.h"
#include "meta/logging/logger.h"
#include "meta/sequence/hmm/discrete_observations.h"
#include "meta/sequence/hmm/hmm.h"
#include "meta/sequence/io/ptb_parser.h"
#include "meta/util/progress.h"
using namespace meta;
std::string two_digit(uint8_t num)
{
std::stringstream ss;
ss << std::setw(2) << std::setfill('0') << static_cast<int>(num);
return ss.str();
}
/**
* Required config parameters:
* ~~~toml
* prefix = "global-data-prefix"
*
* [hmm]
* prefix = "path-to-model"
* treebank = "penn-treebank" # relative to data prefix
* corpus = "wsj"
* section-size = 99
* train-sections = [0, 18]
* dev-sections = [19, 21]
* test-sections = [22, 24]
* ~~~
*
* Optional config parameters: none
*/
int main(int argc, char** argv)
{
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " config.toml" << std::endl;
return 1;
}
logging::set_cerr_logging();
auto config = cpptoml::parse_file(argv[1]);
auto prefix = config->get_as<std::string>("prefix");
if (!prefix)
{
LOG(fatal) << "Global configuration must have a prefix key" << ENDLG;
return 1;
}
auto seq_grp = config->get_table("hmm");
if (!seq_grp)
{
LOG(fatal) << "Configuration must contain a [hmm] group" << ENDLG;
return 1;
}
auto seq_prefix = seq_grp->get_as<std::string>("prefix");
if (!seq_prefix)
{
LOG(fatal) << "[hmm] group must contain a prefix to store model files"
<< ENDLG;
return 1;
}
auto treebank = seq_grp->get_as<std::string>("treebank");
if (!treebank)
{
LOG(fatal) << "[hmm] group must contain a treebank path" << ENDLG;
return 1;
}
auto corpus = seq_grp->get_as<std::string>("corpus");
if (!corpus)
{
LOG(fatal) << "[hmm] group must contain a corpus" << ENDLG;
return 1;
}
auto train_sections = seq_grp->get_array("train-sections");
if (!train_sections)
{
LOG(fatal) << "[hmm] group must contain train-sections" << ENDLG;
return 1;
}
auto section_size = seq_grp->get_as<int64_t>("section-size");
if (!section_size)
{
LOG(fatal) << "[hmm] group must contain section-size" << ENDLG;
return 1;
}
std::string path
= *prefix + "/" + *treebank + "/treebank-2/tagged/" + *corpus;
hashing::probe_map<std::string, term_id> vocab;
std::vector<std::vector<term_id>> training;
{
auto begin = train_sections->at(0)->as<int64_t>()->get();
auto end = train_sections->at(1)->as<int64_t>()->get();
printing::progress progress(
" > Reading training data: ",
static_cast<uint64_t>((end - begin + 1) * *section_size));
for (auto i = static_cast<uint8_t>(begin); i <= end; ++i)
{
auto folder = two_digit(i);
for (uint8_t j = 0; j <= *section_size; ++j)
{
progress(static_cast<uint64_t>(i - begin) * 99 + j);
auto file = *corpus + "_" + folder + two_digit(j) + ".pos";
auto filename = path + "/" + folder + "/" + file;
auto sequences = sequence::extract_sequences(filename);
for (auto& seq : sequences)
{
std::vector<term_id> instance;
instance.reserve(seq.size());
for (const auto& obs : seq)
{
auto it = vocab.find(obs.symbol());
if (it == vocab.end())
it = vocab.insert(obs.symbol(),
term_id{vocab.size()});
instance.push_back(it->value());
}
training.emplace_back(std::move(instance));
}
}
}
}
using namespace sequence;
using namespace hmm;
std::mt19937 rng{47};
discrete_observations<> obs_dist{
30, vocab.size(), rng, stats::dirichlet<term_id>{1e-6, vocab.size()}};
parallel::thread_pool pool;
hidden_markov_model<discrete_observations<>> hmm{
30, rng, std::move(obs_dist), stats::dirichlet<state_id>{1e-6, 30}};
decltype(hmm)::training_options options;
options.delta = 1e-5;
options.max_iters = 50;
hmm.fit(training, pool, options);
filesystem::make_directories(*seq_prefix);
{
io::gzofstream file{*seq_prefix + "/model.gz"};
hmm.save(file);
}
return 0;
}
| 4,747 | 1,655 |
/* /////////////////////////////////////////////////////////////////////////
* File: impl.util.windows.cpp
*
* Purpose: Windows utility functions for the recls API.
*
* Created: 17th August 2003
* Updated: 10th January 2017
*
* Home: http://recls.org/
*
* Copyright (c) 2003-2017, Matthew Wilson and Synesis Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name(s) of Matthew Wilson and Synesis Software nor the
* names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////
* includes
*/
#include <recls/recls.h>
#include <recls/assert.h>
#include "impl.root.h"
#include "impl.types.hpp"
#include "impl.util.h"
#include "impl.cover.h"
#include "impl.trace.h"
#include <ctype.h>
/* /////////////////////////////////////////////////////////////////////////
* namespace
*/
#if !defined(RECLS_NO_NAMESPACE)
namespace recls
{
namespace impl
{
#endif /* !RECLS_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
RECLS_LINKAGE_C recls_char_t const* recls_find_directory_0_(recls_char_t const* path)
{
RECLS_COVER_MARK_LINE();
if(':' == path[1])
{
RECLS_COVER_MARK_LINE();
// It's a drive-prefixed absolute path, so ...
#if RECLS_TRACE_LEVEL > 0
if(!isalpha(path[0]))
{
RECLS_COVER_MARK_LINE();
recls_trace_printf_("recls_find_directory_0_() given an invalid path: %s", path);
}
#endif /* RECLS_TRACE_LEVEL > 0 */
// ... we just skip the drive
return &path[2];
}
else if('\\' == path[0] &&
'\\' == path[1])
{
RECLS_COVER_MARK_LINE();
// It's a UNC absolute path, so we have to find the share name (with a '\')
// and then the next slash or backslash
recls_char_t const* share = types::traits_type::str_chr(path + 2, '\\');
if(NULL == share)
{
RECLS_COVER_MARK_LINE();
goto bad_path_given;
}
else
{
RECLS_COVER_MARK_LINE();
recls_char_t const* slash = types::traits_type::str_chr(share + 1, '\\');
recls_char_t const* slash_a = types::traits_type::str_chr(share + 1, '/');
if( NULL == slash ||
( NULL != slash_a &&
slash_a < slash))
{
RECLS_COVER_MARK_LINE();
slash = slash_a;
}
if(NULL == slash)
{
RECLS_COVER_MARK_LINE();
goto bad_path_given;
}
else
{
RECLS_COVER_MARK_LINE();
return slash;
}
}
}
else
{
RECLS_ASSERT(2 < types::traits_type::str_len(path));
RECLS_COVER_MARK_LINE();
return path;
}
bad_path_given:
// Can't really do _anything_ sensible here, so we just return the
// end of the string.
#if RECLS_TRACE_LEVEL > 0
recls_trace_printf_("recls_find_directory_0_() given an invalid path: %s", path);
#endif /* RECLS_TRACE_LEVEL > 0 */
return path + types::traits_type::str_len(path);
}
RECLS_LINKAGE_C size_t recls_get_home_(recls_char_t* buff, size_t cchBuff)
{
RECLS_COVER_MARK_LINE();
recls_char_t homeDrive[1 + _MAX_DRIVE];
recls_char_t homeDir[1 + _MAX_DIR];
const size_t cchHomeDrive = types::traits_type::get_environment_variable( RECLS_LITERAL("HOMEDRIVE")
, &homeDrive[0]
, RECLS_NUM_ELEMENTS(homeDrive));
size_t cchHomeDir = types::traits_type::get_environment_variable( RECLS_LITERAL("HOMEPATH")
, &homeDir[0]
, RECLS_NUM_ELEMENTS(homeDir));
if( 0 == cchHomeDrive ||
RECLS_NUM_ELEMENTS(homeDrive) == cchHomeDrive)
{
RECLS_COVER_MARK_LINE();
return 0;
}
if( 0 == cchHomeDir ||
RECLS_NUM_ELEMENTS(homeDir) == cchHomeDir)
{
RECLS_COVER_MARK_LINE();
return 0;
}
if(!types::traits_type::has_dir_end(homeDir))
{
RECLS_COVER_MARK_LINE();
types::traits_type::ensure_dir_end(&homeDir[0] + cchHomeDir - 1);
++cchHomeDir;
}
if(NULL == buff)
{
RECLS_COVER_MARK_LINE();
return cchHomeDrive + cchHomeDir;
}
else
{
RECLS_COVER_MARK_LINE();
if(cchBuff <= cchHomeDrive)
{
RECLS_COVER_MARK_LINE();
recls_strncpy_(buff, cchBuff, homeDrive, cchHomeDrive);
return cchHomeDrive;
}
else if(cchBuff <= cchHomeDrive + cchHomeDir)
{
RECLS_COVER_MARK_LINE();
recls_strncpy_(buff, cchBuff, homeDrive, cchHomeDrive);
recls_strncpy_(buff + cchHomeDrive, cchBuff - cchHomeDrive, homeDir, cchHomeDir);
return cchBuff;
}
else
{
RECLS_COVER_MARK_LINE();
recls_strncpy_(buff, cchBuff, homeDrive, cchHomeDrive);
recls_strncpy_(buff + cchHomeDrive, cchBuff - cchHomeDrive, homeDir, cchHomeDir);
RECLS_ASSERT('\0' == buff[cchHomeDrive + cchHomeDir]);
return cchHomeDrive + cchHomeDir;
}
}
}
/* /////////////////////////////////////////////////////////////////////////
* namespace
*/
#if !defined(RECLS_NO_NAMESPACE)
} /* namespace impl */
} /* namespace recls */
#endif /* !RECLS_NO_NAMESPACE */
/* ///////////////////////////// end of file //////////////////////////// */
| 7,307 | 2,502 |
//
// Created by 1124a on 2021/10/27.
//
#include <Algorithm/DataStructure/GridCluster.hpp>
#include <Utils/Logger.hpp>
SESAME::GridCluster::GridCluster()
{
}
SESAME::GridCluster::GridCluster( int label)
{
this->clusterLabel = label;
}
//TODO: if Using this function, be careful when grids are not NULL
SESAME::GridCluster::GridCluster(HashGrids hashMap, int label)
{
HashGrids::iterator iterW;
for (iterW = hashMap.begin(); iterW != hashMap.end(); iterW++)
{
DensityGrid grid = iterW->first;
bool inside = iterW->second;
this->grids.insert(std::make_pair(grid, inside));
}
this->clusterLabel = label;
}
/**
* @param grid the density grid to add to the cluster
*/
void SESAME::GridCluster::addGrid(DensityGrid grid)
{
bool inside = isInside(grid);
if(this->grids.find(grid)!=this->grids.end())
this->grids.find(grid)->second=inside;
else
this->grids.insert(std::make_pair(grid,inside));
HashGrids::iterator iterW;
//Iterate on grids and judge whether they are inside grids or not
for (iterW = this->grids.begin(); iterW != this->grids.end(); iterW++)
{
bool inside2U = iterW->second;
if(!inside2U)
{
DensityGrid dg2U = iterW->first;
iterW->second=isInside(dg2U);
}
}
}
/**
* @param dg the density grid to remove from the cluster
*/
void SESAME::GridCluster::removeGrid(DensityGrid grid)
{
this->grids.erase(grid);
}
/**
* @param gridClus the GridCluster to be absorbed into this cluster
*/
void SESAME::GridCluster::absorbCluster(GridCluster gridCluster)
{
bool inside;
SESAME::HashGrids newCluster;
SESAME_INFO("Absorb cluster "<< gridCluster.clusterLabel <<" into cluster "<<this->clusterLabel<<".");
// Add each density grid from gridCluster into this->grids
auto grid=gridCluster.grids.begin();
while ( grid != gridCluster.grids.end())
{
//TODO whether they have same grids?
this->grids.insert(std::make_pair(grid->first, false));
grid++;
}
SESAME_INFO("...density grids added");
//Determine which density grids in this.grids are 'inside' and which are 'outside'
auto thisGrid=this->grids.begin();
while( thisGrid != this->grids.end())
{
inside = isInside(thisGrid->first);
if(newCluster.find(thisGrid->first)!= newCluster.end())
{
newCluster.find(thisGrid->first)->second=inside;
}
else
{
newCluster.insert(std::make_pair(thisGrid->first, inside));
}
thisGrid++;
}
this->grids = newCluster;
SESAME_INFO("...inside/outside determined");
}
/**
* Inside Grids are defined in Definition 3.5 of Chen and Tu 2007 as:
* Consider a grid group G and a grid g ∈ G, suppose g =(j1, ··· ,jd), if g has
* neighboring grids in every dimension i =1, ·· · ,d, then g is an inside grid
* in G.Otherwise g is an outside grid in G.
*
* @param grid the density grid to label as being inside or out
* @return TRUE if g is an inside grid, FALSE otherwise
*/
bool SESAME::GridCluster::isInside(DensityGrid grid)
{
std::vector<DensityGrid> neighbour= grid.getNeighbours();
for(auto gridNeighbourhood : neighbour)
{
if(this->grids.find(gridNeighbourhood)==this->grids.end())
{
return false;
}
}
return true;
}
/**
* Inside Grids are defined in Definition 3.5 of Chen and Tu 2007 as:
* Consider a grid group G and a grid g ∈ G, suppose g =(j1, ··· ,jd), if g has
* neighboring grids in every dimension i =1, ·· · ,d, then g is an inside grid
* in G. Otherwise g is an outside grid in G.
*
* @param grid the density grid being labelled as inside or outside
* @param other the density grid being proposed for addition
* @return TRUE if g would be an inside grid, FALSE otherwise
*/
bool SESAME::GridCluster::isInside(DensityGrid grid, DensityGrid other)
{
std::vector<DensityGrid> neighbour= grid.getNeighbours();
for(auto gridNeighbourhood : neighbour)
{
if(this->grids.find(gridNeighbourhood)!=this->grids.end()&&gridNeighbourhood == other)
{
return false;
}
}
return true;
}
/**
* Tests a grid cluster for connectedness according to Definition 3.4, Grid Group, from
* Chen and Tu 2007.
*
* Selects one density grid in the grid cluster as a starting point and iterates repeatedly
* through its neighbours until no more density grids in the grid cluster can be visited.
*
* @return TRUE if the cluster represent one single grid group; FALSE otherwise.
*/
bool SESAME::GridCluster::isConnected()
{
//TODO A little confused about here
if (!this->grids.empty())
{
DensityGrid grid = this->grids.begin()->first;
if(this->visited.find(grid)!=this->visited.end())
this->visited.find(grid)->second=this->grids.begin()->second;
else
this->visited.insert(std::make_pair(grid,this->grids.begin()->second));
bool changesMade;
do{
changesMade = false;
auto visIter= this->visited.begin();
HashGrids toAdd;
while(visIter!= this->visited.end() && toAdd.empty())
{
DensityGrid dg2V = visIter->first;
std::vector<DensityGrid> neighbour= dg2V.getNeighbours();
for(auto dg2VNeighbourhood : neighbour)
{
if(this->grids.find(dg2VNeighbourhood)!=this->grids.end()
&& this->visited.find(dg2VNeighbourhood)==this->visited.end())
toAdd.insert(std::make_pair(dg2VNeighbourhood, this->grids.find(dg2VNeighbourhood)->second));
}
visIter++;
}
if(!toAdd.empty())
{
HashGrids::iterator gridToAdd;
for (gridToAdd = toAdd.begin(); gridToAdd != toAdd.end(); gridToAdd++)
{
if(this->visited.find(gridToAdd->first)!=this->visited.end())
this->visited.find(gridToAdd->first)->second=gridToAdd->second;
else
this->visited.insert(std::make_pair(gridToAdd->first,gridToAdd->second));
}
changesMade = true;
}
}while(changesMade);
}
if (this->visited.size() == this->grids.size())
{
//SESAME_INFO("The cluster is still connected. "<<this->visited.size()+" of "<<this->grids.size()<<" reached.");
return true;
}
else
{
//SESAME_INFO("The cluster is no longer connected. "<<this.visited.size()<<" of "+this.grids.size()+" reached.");
return false;
}
}
/**
* Iterates through the DensityGrids in the cluster and calculates the inclusion probability for each.
*
* @return 1.0 if instance matches any of the density grids; 0.0 otherwise.
*/
double SESAME::GridCluster::getInclusionProb(Point point) {
HashGrids::iterator iterW;
//Iterate on grids and judge whether they are inside grids or not
for (iterW = this->grids.begin(); iterW != this->grids.end(); iterW++)
{
DensityGrid grid = iterW->first;
if(grid.getInclusionProbability(point) == 1.0)
return 1.0;
}
return 0.0;
}
bool SESAME::GridCluster::operator==(GridCluster& other)const {
bool equal = false;
if( clusterLabel == other.clusterLabel && grids.size()==other.grids.size()
&& visited.size()==other.visited.size())
equal = true;
return equal;
} | 7,185 | 2,453 |
#include <iostream>
using namespace std;
int main()
{
int N;
cout<<"Enter the range";
cin>>N;
double sum=0.0;
for(int i=1;i<=N;i++)
{
sum+=((double)1/(i*i));
}
cout<<sum;
return 0;
}
| 235 | 100 |
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <dlfcn.h>
#include <stdio.h>
void usage() {
printf("[USAGE] skia_launcher program_name [options]\n");
printf(" program_name: the skia program you want to launch (e.g. tests, bench)\n");
printf(" options: options specific to the program you are launching\n");
}
bool file_exists(const char* fileName) {
FILE* file = fopen(fileName, "r");
if (file) {
fclose(file);
return true;
}
return false;
}
int launch_app(int (*app_main)(int, const char**), int argc,
const char** argv) {
return (*app_main)(argc, argv);
}
void* load_library(const char* appLocation, const char* libraryName)
{
// attempt to lookup the location of the shared libraries
char libraryLocation[100];
sprintf(libraryLocation, "%s/lib%s.so", appLocation, libraryName);
if (!file_exists(libraryLocation)) {
printf("ERROR: Unable to find the '%s' library in the Skia App.\n", libraryName);
printf("ERROR: Did you provide the correct program_name?\n");
usage();
return NULL;
}
// load the appropriate library
void* appLibrary = dlopen(libraryLocation, RTLD_LOCAL | RTLD_LAZY);
if (!appLibrary) {
printf("ERROR: Unable to open the shared library.\n");
printf("ERROR: %s", dlerror());
return NULL;
}
return appLibrary;
}
int main(int argc, const char** argv) {
// check that the program name was specified
if (argc < 2) {
printf("ERROR: No program_name was specified\n");
usage();
return -1;
}
// attempt to lookup the location of the skia app
const char* appLocation = "/data/local/tmp";
if (!file_exists(appLocation)) {
printf("ERROR: Unable to find /data/local/tmp on the device.\n");
return -1;
}
void* skiaLibrary;
#if defined(SKIA_DLL)
// load the local skia shared library
skiaLibrary = load_library(appLocation, "skia_android");
if (NULL == skiaLibrary)
{
return -1;
}
#endif
// load the appropriate library
void* appLibrary = load_library(appLocation, argv[1]);
if (NULL == appLibrary) {
return -1;
}
#if !defined(SKIA_DLL)
skiaLibrary = appLibrary;
#endif
// find the address of the main function
int (*app_main)(int, const char**);
*(void **) (&app_main) = dlsym(appLibrary, "main");
if (!app_main) {
printf("ERROR: Unable to load the main function of the selected program.\n");
printf("ERROR: %s\n", dlerror());
return -1;
}
// find the address of the SkPrintToConsole function
void (*app_SkDebugToStdOut)(bool);
*(void **) (&app_SkDebugToStdOut) = dlsym(skiaLibrary, "AndroidSkDebugToStdOut");
if (app_SkDebugToStdOut) {
(*app_SkDebugToStdOut)(true);
} else {
printf("WARNING: Unable to redirect output to the console.\n");
printf("WARNING: %s\n", dlerror());
}
// pass all additional arguments to the main function
return launch_app(app_main, argc - 1, ++argv);
}
| 3,192 | 1,028 |
#include "SH_BulletController.h"
#include "SH_World.h"
#include "SH_BaseBullet.h"
#include "SH_PlayerBullet.h"
#include "SH_EnemyBullet.h"
#include "SH_EnumBullet.h"
SH_BulletController::SH_BulletController()
{
}
void SH_BulletController::Initialize(SH_World* world)
{
mWorld = world;
}
SH_BaseBullet* SH_BulletController::CreateBullet(SH_EnumBullet bulletType, float x, float y) {
SH_BaseBullet* result = nullptr;
std::string imagePath = "";
switch (bulletType)
{
case SH_EnumBullet::Player:
result = new SH_PlayerBullet();
imagePath = "Content/Sprites/spBullet.png";
break;
case SH_EnumBullet::Enemy:
result = new SH_EnemyBullet();
imagePath = "Content/Sprites/spBullet.png";
break;
}
if (result != nullptr) {
result->Initialize(mWorld, x, y, imagePath);
// agregar la bala al vector
mBullets.push_back(result);
}
return result;
}
void SH_BulletController::Update(float dt)
{
for (std::vector<SH_BaseBullet*>::iterator it = mBullets.begin(); it != mBullets.end();)
{
if (!(*it)->IsWaitingForDelete)
{
(*it)->Update(dt);
it++;
}
else
{
delete (*it);
it = mBullets.erase(it);
}
}
}
void SH_BulletController::Draw(float dt)
{
for (std::vector<SH_BaseBullet*>::iterator it = mBullets.begin(); it != mBullets.end();)
{
if (!(*it)->IsWaitingForDelete)
{
(*it)->Draw(dt);
}
it++;
}
}
| 1,361 | 608 |
#include <catch.hpp>
#include <skizzay/fsm/ancestors.h>
#include <skizzay/fsm/guarded_action_transition.h>
using namespace skizzay::fsm;
namespace {
struct timer_expired {};
struct green {};
struct red {
bool should_transition_result = true;
bool should_transition(timer_expired const &) const noexcept {
return should_transition_result;
}
};
} // namespace
SCENARIO("actionable and guarded transition", "[unit][transition]") {
GIVEN("an actionable, guarded transition type from red to green") {
bool triggered = false;
auto action = [&triggered](timer_expired const &) noexcept {
triggered = true;
};
using target_type =
guarded_action_transition<red, green, timer_expired,
decltype(&red::should_transition),
decltype(action)>;
using fake_machine = details_::dummy_machine<states_list<red, green>,
events_list<timer_expired>,
std::tuple<target_type>>;
target_type target{&red::should_transition, action};
THEN("it models a transition") {
REQUIRE(is_transition<target_type>::value);
REQUIRE(concepts::transition<target_type>);
AND_THEN("it does also model an actionable transtion") {
REQUIRE(is_actionable_transition<target_type>::value);
REQUIRE(concepts::actionable_transition<target_type>);
}
}
WHEN("a timer expired event is queried for acceptance which is set to "
"pass") {
timer_expired const event;
bool const actual = target.accepts(red{true}, fake_machine{}, event);
THEN("the transition accepts the event") { REQUIRE(actual); }
AND_WHEN("triggered") {
target.on_triggered(timer_expired{});
THEN("the callback was fired") { REQUIRE(triggered); }
}
}
WHEN("a timer expired event is queried for acceptance which is set to "
"fail") {
bool const actual =
target.accepts(red{false}, fake_machine{}, timer_expired{});
THEN("the transition rejects the event") { REQUIRE_FALSE(actual); }
THEN("the callback was not fired") { REQUIRE_FALSE(triggered); }
}
}
} | 2,247 | 665 |
#include "AI.h"
#include <cmath>
#include <queue>
#include <unordered_map>
#include <algorithm>
//heuristic function to judge board states
double evaluate(int totalLinesSent, int linesCleared, TetrisBoard board) {
//stack height, flatness, holes
double LINESSENT_Weight = 2;
double LINESCLEARED_Weight = 2;
double HOLETYPE1_Weight = -0.5; // an empty cell where there is a filled cell somewhere above the cell
// double HOLETYPE2_Weight = -1; //an empty cell where there is a filled cell in the column to the left at or above the cell
// double HOLETYPE3_Weight = -1; //an empty cell where there is a filled cell in the column to the right at or above the cell
double BUMPINESS_Weight = -0.3; //summed up differences between adjacent column heights
double WELL_Weight = -0.5; // ab empty cell where both cells to the left and right (including wall) are filled
double STACKHEIGHT_ExponentWeight = 2; // weight exponentially, so height^(weight). aggregate height of columns
double STACKHEIGHT_MultipleWeight = -0.04; //multiplied value to the exponential weight
//i guess we just iterate over every value in each row bitboard? idk how to do more efficiently
int holeType1 = 0;
int well = 0;
// int holeType2 = 0;
// int holeType3 = 0;
double bumpiness = 0;
double stackHeight = 0;
double heightTotal = 0;
//finding highest block in each column to calculate bumbpiness and stackheight, also used after to find holes
int highestHeightPerX[10];
for (int column = 0; column < board.getColumns(); column++) {
bool highestYFound = false;
for (int y = board.getRows() - 1; y >= 0; y--) {
if (board.get(column, y)) {
// cout << "ACTUALLY GETS HERE" << endl;
// cout << "x, y: " << column << ", " << y << endl;
//found
highestHeightPerX[column] = y + 1;
heightTotal+= y + 1;
highestYFound = true;
break;
}
}
//only reaches here if not found
if (!highestYFound) {
highestHeightPerX[column] = 0;
}
//no need to add height, would just be +0
}
//calculate average height (stack height)
stackHeight = heightTotal / (double)board.getColumns();
//CALCULATE HOLES AND WELLS
// for (int column = 0; column < board.getColumns(); column++) {
// for (int row = highestHeightPerX[column] - 1; row >= 0; row--) {
// //calculate hole type 1. start at cell right below highest one
// if (!board.get(column, row)) {
// holeType1++;
// }
// }
// }
for (int column = 0; column < board.getColumns(); column++) {
//CALCULATE BUMPINESS. compare height of each column to the one to the right. dont do for last column
if (column != board.getColumns() - 1) {
bumpiness += abs(highestHeightPerX[column + 1] - highestHeightPerX[column]);
}
//start at the height to calculate wells next to it
if (highestHeightPerX[column] > 0) {
for (int row = highestHeightPerX[column] - 1; row >= 0; row--) {
//calculate hole type 1. start at cell right below highest one, nope start as highest
if (!board.get(column, row)) {
holeType1++;
}
else {
//check for wells on the right side, then a separate check for the first column
//check if the cell to the right is unfilled
//first check if it's a wall
if (column != board.getColumns() - 1) {
if (!board.get(column + 1, row)) {
if (column + 1 == board.getColumns() - 1) {
well ++;
}
else if (board.get(column+2, row)) {
well++;
}
}
}
//separate check for first column
if (column == 1) {
if (!board.get(0, row)) {
well++;
}
}
}
}
}
}
double score = 0;
score += (double)totalLinesSent * LINESSENT_Weight;
score += (double)linesCleared * LINESCLEARED_Weight;
score += (double)holeType1 * HOLETYPE1_Weight;
score += (double)well * WELL_Weight;
// score += (double)holeType2 * HOLETYPE2_Weight;
// score += (double)holeType3 * HOLETYPE3_Weight;
score += bumpiness * BUMPINESS_Weight;
score += pow(stackHeight, STACKHEIGHT_ExponentWeight) * STACKHEIGHT_MultipleWeight;
return score;
}
TetrisBoard updateBoardAfterMove(Move move, TetrisBoard board, pair<int, int>* lines) {
//move later to centralized constants page (cant figure it out, keeps saying multiple definition)
int SZJLTOIArray [7][4][4][2] = {{{{-1, 0}, {0, 0}, {0, 1}, {1, 1}},
{{0, 1}, {0, 0}, {1, 0}, {1, -1}},
{{-1, -1}, {0, -1}, {0, 0}, {1, 0}},
{{-1, 1}, {-1, 0}, {0, 0}, {0, -1}}},
{{{-1, 1}, {0, 1}, {0, 0}, {1, 0}},
{{0, -1}, {0, 0}, {1, 0}, {1, 1}},
{{-1, 0}, {0, 0}, {0, -1}, {1, -1}},
{{-1, -1}, {-1, 0}, {0, 0}, {0, 1}}},
{{{-1, 1}, {-1, 0}, {0, 0}, {1, 0}},
{{1, 1}, {0, 1}, {0, 0}, {0, -1}},
{{-1, 0}, {0, 0}, {1, 0}, {1, -1}},
{{0, 1}, {0, 0}, {0, -1}, {-1, -1}}},
{{{-1, 0}, {0, 0}, {1, 0}, {1, 1}},
{{0, 1}, {0, 0}, {0, -1}, {1, -1}},
{{-1, -1}, {-1, 0}, {0, 0}, {1, 0}},
{{-1, 1}, {0, 1}, {0, 0}, {0, -1}}},
{{{-1, 0}, {0, 0}, {0, 1}, {1, 0}},
{{0, 1}, {0, 0}, {1, 0}, {0, -1}},
{{-1, 0}, {0, 0}, {0, -1}, {1, 0}},
{{0, -1}, {0, 0}, {-1, 0}, {0, 1}}},
{{{0, 1}, {0, 0}, {1, 0}, {1, 1}},
{{0, 0}, {0, -1}, {1, -1}, {1, 0}},
{{-1, 0}, {-1, -1}, {0, -1}, {0, 0}},
{{-1, 1}, {-1, 0}, {0, 0}, {0, 1}}},
{{{-1, 0}, {0, 0}, {1, 0}, {2, 0}},
{{0, 1}, {0, 0}, {0, -1}, {0, -2}},
{{-2, 0}, {-1, 0}, {0, 0}, {1, 0}},
{{0, 2}, {0, 1}, {0, 0}, {0, -1}}}};
int JLSTZOffsetTable [4][5][2] = {{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}},
{{ 0, 0}, { 1, 0}, { 1,-1}, { 0, 2}, { 1, 2}},
{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}},
{{ 0, 0}, {-1, 0}, {-1,-1}, { 0, 2}, {-1, 2}}};
int IOffsetTable [4][5][2] = {{{ 0, 0}, {-1, 0}, { 2, 0}, {-1, 0}, { 2, 0}},
{{-1, 0}, { 0, 0}, { 0, 0}, { 0, 1}, { 0,-2}},
{{-1, 1}, { 1, 1}, {-2, 1}, {1, 0}, {-2, 0}},
{{ 0, 1}, { 0, 1}, { 0, 1}, { 0,-1}, { 0, 2}}};
int OOffsetTable [4][2] = {{0, 0},
{0, -1},
{-1, -1},
{-1, 0}};
TetrisBoard newBoard = board;
//store all relevant y values for checking for clears. since only small amount use vector instead of set
//maybe use set for the ordering so can have consistent offsets when clearing multiple lines. order it from high to low
vector<int> yValues;
for (int blockPart; blockPart < 4; blockPart++) {
int globalX = move.getX() + SZJLTOIArray[move.getPiece()][move.getR()][blockPart][0];
int globalY = move.getY() + SZJLTOIArray[move.getPiece()][move.getR()][blockPart][1];
newBoard.set(globalX, globalY, true);
if (!count(yValues.begin(), yValues.end(), globalY)) {
yValues.push_back(globalY);
}
}
//sort yvalues from most to least so clearing them in that order has no problems
sort(yValues.begin(), yValues.end(), greater<int>());
//need to go through and clear line(s), calculate amount sent and lines cleared. back to back as well, b2b will add later
//there must be a more efficient method than going one by one and seeing if entire row is selected, need to see later
//TAKE INTO ACCOUNT SHIFTING INDEXES
int numberOfLinesCleared = 0;
for (int yIndex = 0; yIndex < yValues.size(); yIndex++) {
int yValue = yValues[yIndex];
bool clearRow = true;
for (int x = 0; x < newBoard.getColumns(); x++) {
if (!newBoard.get(x, yValue)) {
clearRow = false;
break;
}
}
if (clearRow) {
numberOfLinesCleared++;
//clear the line
newBoard.clearRow(yValue);
}
}
//calculate amount sent
int amountSentThisRound = 0;
if (move.getTspin()) {
amountSentThisRound = numberOfLinesCleared * 2;
}
else {
if (numberOfLinesCleared == 4) {
amountSentThisRound = 4;
}
else if (numberOfLinesCleared == 3) {
amountSentThisRound = 2;
}
else if (numberOfLinesCleared == 2) {
amountSentThisRound = 1;
}
}
int totalAmountSent = (*lines).second + amountSentThisRound;
//add on b2b later and combos
// int numberOfLinesCleared = 0;
// int amountSent = 0;
//update
(*lines).first = numberOfLinesCleared;
(*lines).second = totalAmountSent;
return newBoard;
}
struct MoveWithBoardAfter {
Move move;
TetrisBoard board;
int originalMoveIndex;
int totalSends;
bool operator <(const MoveWithBoardAfter& rhs) const {
//i dont think this matters so just making this arbitrary
return originalMoveIndex < rhs.originalMoveIndex;
}
};
struct OriginalMoveIndexAndTotalSends {
int originalMoveIndex;
int totalSends;
};
AI::AI(TetrisBoard board, int levels, int optionsToExplorePerLevel) {
m_rootBoard = board;
m_levels = levels;
m_optionsToExplorePerLevel = optionsToExplorePerLevel;
}
//no hold taken into account right now
pair<Move, TetrisBoard> AI::GreedyBFS(int piece, int x, int y, int r, int* queue, int* sends) {
//go through each possible move and select
//the few highest eval, continue for next move from those, etc.
//Pick move that gets the best eval board at end.
//in each pair, int is the eval result of the move
priority_queue<pair<int, MoveWithBoardAfter>> moves;
SRSPathfinder pathfinder(piece, x, y, r, m_rootBoard);
vector<Move> rootMoves = pathfinder.findPossiblePlacementsWithPaths();
//this tetris board is of before doing the move
vector<tuple<Move, TetrisBoard, OriginalMoveIndexAndTotalSends>> potentialMoves;
for (int i = 0; i < rootMoves.size(); i++) {
OriginalMoveIndexAndTotalSends originalAndSends;
originalAndSends.originalMoveIndex = i;
originalAndSends.totalSends = 0;
potentialMoves.push_back(tuple<Move, TetrisBoard, OriginalMoveIndexAndTotalSends>(rootMoves[i], m_rootBoard, originalAndSends));
}
// cout << "BFS 1" << endl;
// for (int i = 0; i < potentialMoves.size(); i++) {
// //this part just takes all potential moves and the boards after and evaluates them.
// pair<int, int> linesClearedSent;
// TetrisBoard newBoard = updateBoardAfterMove(get<0>(potentialMoves[i]), get<1>(potentialMoves[i]), &linesClearedSent);
// int eval = evaluate(linesClearedSent.first, linesClearedSent.second, newBoard);
// MoveWithBoardAfter item;
// item.move = get<0>(potentialMoves[i]);
// item.board = newBoard;
// item.originalMoveIndex = get<2>(potentialMoves[i]);
// moves.push(pair<int, MoveWithBoardAfter>(eval, item));
// }
// potentialMoves.clear();
// cout << "MARKER 1" << endl;
//this is real janky. the loop should be rearranged or something
for (int level = 0; level < m_levels; level++) {
// cout << "BFS 1.25: level: " << level << endl;
for (int i = 0; i < potentialMoves.size(); i++) {
//this part just takes all potential moves and the boards after and evaluates them.
pair<int, int> linesClearedSent;
linesClearedSent.second = get<2>(potentialMoves[i]).totalSends;
TetrisBoard newBoard = updateBoardAfterMove(get<0>(potentialMoves[i]), get<1>(potentialMoves[i]), &linesClearedSent);
// cout << "TOTAL LINES SENT: " << linesClearedSent.second << endl;
// cout << "TOTAL LINES CLEARED: " << linesClearedSent.first << endl;
int eval = evaluate(linesClearedSent.first, linesClearedSent.second, newBoard);
MoveWithBoardAfter item;
item.move = get<0>(potentialMoves[i]);
item.board = newBoard;
item.originalMoveIndex = get<2>(potentialMoves[i]).originalMoveIndex;
item.totalSends = linesClearedSent.second;
moves.push(pair<int, MoveWithBoardAfter>(eval, item));
// cout << "SIZE OF MOVES PQ IN LOOP: " << i << " " << moves.size() << endl;
}
potentialMoves.clear();
// cout << "MARKER 2.1" << endl;
// cout << "SIZE OF MOVES PQ: " << moves.size() << endl;
// cout << "MOVES SIZE: " << moves.size() << endl;
for (int i = 0; i < m_optionsToExplorePerLevel; i++) {
// cout << "HI0.5" << endl;
MoveWithBoardAfter item = moves.top().second;
SRSPathfinder piecePathfinder(queue[level], 4, 19, 0,
item.board);
vector<Move> piecePotentialMoves = piecePathfinder.findPossiblePlacementsWithPaths();
// cout << piecePotentialMoves.size() << endl;
// cout << "HI" << endl;
for (int piecePotentialMove = 0; piecePotentialMove < piecePotentialMoves.size(); piecePotentialMove++) {
OriginalMoveIndexAndTotalSends originalAndSends;
originalAndSends.originalMoveIndex = item.originalMoveIndex;
originalAndSends.totalSends = item.totalSends;
// cout << "HI1.5 " << i << endl;
potentialMoves.push_back(tuple<Move, TetrisBoard, OriginalMoveIndexAndTotalSends>(piecePotentialMoves[piecePotentialMove], item.board, originalAndSends));
// cout << "HI1.6" << endl;
}
// cout << "HI2" << endl;
// cout << moves.size() << endl;
moves.pop();
}
// cout << "MARKER 2.5" << endl;
//if last level, do one final round of evaluation and then pick one and push it to potential moves
if (level == m_levels - 1) {
// cout << "BFS 1.5" << endl;
// cout << "MARKER 3" << endl;
for (int i = 0; i < potentialMoves.size(); i++) {
//this part just takes all potential moves and the boards after and evaluates them.
pair<int, int> linesClearedSent;
linesClearedSent.second = get<2>(potentialMoves[i]).totalSends;
TetrisBoard newBoard = updateBoardAfterMove(get<0>(potentialMoves[i]), get<1>(potentialMoves[i]), &linesClearedSent);
int eval = evaluate(linesClearedSent.first, linesClearedSent.second, newBoard);
MoveWithBoardAfter item;
item.move = get<0>(potentialMoves[i]);
item.board = newBoard;
item.originalMoveIndex = get<2>(potentialMoves[i]).originalMoveIndex;
item.totalSends = linesClearedSent.second;
moves.push(pair<int, MoveWithBoardAfter>(eval, item));
}
potentialMoves.clear();
MoveWithBoardAfter item = moves.top().second;
OriginalMoveIndexAndTotalSends originalAndSends;
originalAndSends.originalMoveIndex = item.originalMoveIndex;
originalAndSends.totalSends = item.totalSends;
potentialMoves.push_back(tuple<Move, TetrisBoard, OriginalMoveIndexAndTotalSends>(item.move, item.board, originalAndSends));
TetrisBoard finalBoard = item.board;
// finalBoard.printBoard();
moves.pop();
}
//empty priority queue
moves = priority_queue<pair<int, MoveWithBoardAfter>>();
}
// cout << "BFS 2" << endl;
// cout << "MARKER 4" << endl;
//recalculate board after the move. could be more efficient, already done earlier
Move finalMove = rootMoves[get<2>(potentialMoves.front()).originalMoveIndex];
Move final5thLevelMove = get<0>(potentialMoves.front());
// final5thLevelMove.printMove();
// finalMove.printMove();
// m_rootBoard.printBoard();
// cout << "FINAL SENDS: " << get<2>(potentialMoves.front()).totalSends << endl;
pair<int, int> linesClearedSent;
TetrisBoard newBoard = updateBoardAfterMove(finalMove, m_rootBoard, &linesClearedSent);
*sends = linesClearedSent.second;
// cout << "TESTING" << endl;
// vector<int> newVector;
// pair<int, int> lines;
// Move newMove(9, 3, 3, 0, 4, newVector, true);
// TetrisBoard testBoard = updateBoardAfterMove(newMove, m_rootBoard, &lines);
// testBoard.printBoard();
// cout << "GEST HERE 1" << endl;
// cout << "BFS 3" << endl;
return pair<Move, TetrisBoard>(finalMove, newBoard);
}
| 18,144 | 6,038 |
/* ========================================================================= */
/* === AMD_dump ============================================================ */
/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
/* Debugging routines for AMD. Not used if NDEBUG_AMD is not defined at compile-
* time (the default). See comments in amd_internal.h on how to enable
* debugging. Not user-callable.
*/
#include "StdAfx.h"
#ifndef NDEBUG_AMD
/* This global variable is present only when debugging */
GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */
/* ========================================================================= */
/* === AMD_debug_init ====================================================== */
/* ========================================================================= */
/* Sets the debug print level, by reading the file debug.amd (if it exists) */
GLOBAL void AMD_debug_init ( char *s )
{
FILE *f ;
f = ElFopen ("debug.amd", "r") ;
if (f == (FILE *) NULL)
{
AMD_debug = -999 ;
}
else
{
fscanf (f, ID, &AMD_debug) ;
ElFclose (f) ;
}
if (AMD_debug >= 0)
{
printf ("%s: AMD_debug_init, D= " ID"\n", s, AMD_debug) ;
}
}
/* ========================================================================= */
/* === AMD_dump ============================================================ */
/* ========================================================================= */
/* Dump AMD's data structure, except for the hash buckets. This routine
* cannot be called when the hash buckets are non-empty.
*/
GLOBAL void AMD_dump (
Int n, /* A is n-by-n */
Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */
Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1]
* holds the matrix on input */
Int Len [ ], /* len [0..n-1]: length for row i */
Int iwlen, /* length of iw */
Int pfree, /* iw [pfree ... iwlen-1] is empty on input */
Int Nv [ ], /* nv [0..n-1] */
Int Next [ ], /* next [0..n-1] */
Int Last [ ], /* last [0..n-1] */
Int Head [ ], /* head [0..n-1] */
Int Elen [ ], /* size n */
Int Degree [ ], /* size n */
Int W [ ], /* size n */
Int nel
)
{
Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ;
if (AMD_debug < 0) return ;
ASSERT (pfree <= iwlen) ;
AMD_DEBUG3 (("\nAMD dump, pfree: " ID"\n", pfree)) ;
for (i = 0 ; i < n ; i++)
{
pe = Pe [i] ;
elen = Elen [i] ;
nv = Nv [i] ;
len = Len [i] ;
w = W [i] ;
if (elen >= EMPTY)
{
if (nv == 0)
{
AMD_DEBUG3 (("\nI " ID": nonprincipal: ", i)) ;
ASSERT (elen == EMPTY) ;
if (pe == EMPTY)
{
AMD_DEBUG3 ((" dense node\n")) ;
ASSERT (w == 1) ;
}
else
{
ASSERT (pe < EMPTY) ;
AMD_DEBUG3 ((" i " ID" -> parent " ID"\n", i, FLIP (Pe[i])));
}
}
else
{
AMD_DEBUG3 (("\nI " ID": active principal supervariable:\n",i));
AMD_DEBUG3 ((" nv(i): " ID" Flag: %d\n", nv, (nv < 0))) ;
ASSERT (elen >= 0) ;
ASSERT (nv > 0 && pe >= 0) ;
p = pe ;
AMD_DEBUG3 ((" e/s: ")) ;
if (elen == 0) AMD_DEBUG3 ((" : ")) ;
ASSERT (pe + len <= pfree) ;
for (k = 0 ; k < len ; k++)
{
j = Iw [p] ;
AMD_DEBUG3 ((" " ID"", j)) ;
ASSERT (j >= 0 && j < n) ;
if (k == elen-1) AMD_DEBUG3 ((" : ")) ;
p++ ;
}
AMD_DEBUG3 (("\n")) ;
}
}
else
{
e = i ;
if (w == 0)
{
AMD_DEBUG3 (("\nE " ID": absorbed element: w " ID"\n", e, w)) ;
ASSERT (nv > 0 && pe < 0) ;
AMD_DEBUG3 ((" e " ID" -> parent " ID"\n", e, FLIP (Pe [e]))) ;
}
else
{
AMD_DEBUG3 (("\nE " ID": unabsorbed element: w " ID"\n", e, w)) ;
ASSERT (nv > 0 && pe >= 0) ;
p = pe ;
AMD_DEBUG3 ((" : ")) ;
ASSERT (pe + len <= pfree) ;
for (k = 0 ; k < len ; k++)
{
j = Iw [p] ;
AMD_DEBUG3 ((" " ID"", j)) ;
ASSERT (j >= 0 && j < n) ;
p++ ;
}
AMD_DEBUG3 (("\n")) ;
}
}
}
/* this routine cannot be called when the hash buckets are non-empty */
AMD_DEBUG3 (("\nDegree lists:\n")) ;
if (nel >= 0)
{
cnt = 0 ;
for (deg = 0 ; deg < n ; deg++)
{
if (Head [deg] == EMPTY) continue ;
ilast = EMPTY ;
AMD_DEBUG3 ((ID": \n", deg)) ;
for (i = Head [deg] ; i != EMPTY ; i = Next [i])
{
AMD_DEBUG3 ((" " ID" : next " ID" last " ID" deg " ID"\n",
i, Next [i], Last [i], Degree [i])) ;
ASSERT (i >= 0 && i < n && ilast == Last [i] &&
deg == Degree [i]) ;
cnt += Nv [i] ;
ilast = i ;
}
AMD_DEBUG3 (("\n")) ;
}
ASSERT (cnt == n - nel) ;
}
}
#endif
| 5,181 | 2,042 |
#include<iostream>
#include<mutex>
#include<thread>
#include<vector>
using namespace std;
mutex g_mutex;
int g_count = 0;
void Counter()
{
g_mutex.lock();
int i = ++g_count;
cout << "cout: " << i << endl;
g_mutex.unlock();
}
int main()
{
const size_t SIZE = 4;
// Create a group of counter threads.
vector<thread> v;
v.reserve(SIZE);
for (size_t i = 0; i < SIZE; ++i)
{
v.emplace_back(&Counter);
}
//Wait for all the threads to finish.
for(thread& t:v)
t.join();
return 0;
} | 560 | 226 |
#include <iostream>
#include <variant>
template <class F1, class F2>
struct overload : F1, F2
{
overload(F1 const& f1, F2 const& f2) : F1{f1}, F2{f2}
{
std::cout << "overload::overload\n";
}
~overload()
{
std::cout << "overload::~overload\n";
}
using F1::operator();
using F2::operator();
};
int main( int argc, char **argv )
{
{
std::variant<std::string, int> var;
var = 1;
std::visit(
overload(
[](int){std::cout << "int!\n";},
[](std::string const&){std::cout << "string!\n";}
),
var
);
}
return 0;
}
| 660 | 248 |
#include "player.h"
bool ePlayer::Move()
{
eMoveType var = ConsoleMove();
if (CanMove(var))
{
Move(var);
return true;
}
return false;
}
void ePlayer::Move(eMoveType type)
{
switch (type)
{
case eMoveType::DOWN: x++; break;
case eMoveType::UP: x--; break;
case eMoveType::LEFT: y--; break;
case eMoveType::RIGHT: y++; break;
}
eFieldType field = map_->Get(x, y);
switch (field)
{
case eFieldType::WELL : hp++ ;
break;
}
map_->Set(x, y, eFieldType::EMPTY);
}
bool ePlayer::CanMove(eMoveType type) const
{
int xNew = x;
int yNew = y;
switch (type)
{
case eMoveType::DOWN: xNew++; break;
case eMoveType::UP: xNew--; break;
case eMoveType::LEFT: yNew--; break;
case eMoveType::RIGHT: yNew++; break;
}
if (!IsCoordinatesOnBoard(xNew, yNew))
{
return false;
}
eFieldType field = map_->Get(xNew,yNew);
switch (field)
{
case eFieldType::TREE: return false;
}
return true;
}
string ePlayer::Dump() const
{
stringstream ss;
ss << "player " << eUnit::Dump();
return ss.str();
}
| 1,035 | 470 |
#include <SFML/Graphics/RenderWindow.hpp>
#include "starfield_handler.h"
StarfieldHandler::StarfieldHandler(int xResolution, int yResolution)
{
srand(time(NULL));
nType = rand() % 6;
//nType = 0;
if(nType < 2)
starfield_a = new StarfieldA(xResolution, yResolution);
else
starfield_b = new StarfieldB(xResolution, yResolution, nType - 2);
}
void StarfieldHandler::update()
{
// Starfield is still updated even if drawing has been disabled
if(nType < 2)
starfield_a->update();
else
starfield_b->update();
}
void StarfieldHandler::draw(sf::RenderWindow &window, bool enabled)
{
if(enabled)
{
if(nType < 2)
starfield_a->draw(window);
else
starfield_b->draw(window);
}
}
| 793 | 274 |
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*
* Read from the class/offset table that resides within a debugged process.
*/
#include "strike.h"
#include "util.h"
#include "get-table-info.h"
#include <dump-tables.h>
#include "process-info.h"
#ifdef _DEBUG
#define DOUT OutputDebugStringW
#else
static void _ods (const wchar_t* s)
{
}
#define DOUT _ods
#endif
const ULONG_PTR InvalidOffset = static_cast<ULONG_PTR>(-1);
static HANDLE g_CurrentProcess = INVALID_HANDLE_VALUE;
static ClassDumpTable g_ClassTable;
static BOOL g_fClassTableInit = FALSE;
/**
* Initialize g_ClassTable to point to the class dump table in the debuggee
* process.
*/
bool InitializeOffsetTable ()
{
if (g_fClassTableInit)
return (true);
// We use the process handle to determine if we're debugging the same
// process. It's conceivable that the same debugger session will debug
// multiple programs, so the process may change, requiring everything to be
// re-loaded.
ULONG64 ProcHandle;
HANDLE hProcess;
HRESULT hr = E_FAIL;
if (SUCCEEDED(hr = g_ExtSystem->GetCurrentProcessHandle (&ProcHandle)))
{
// we cache the ClassDumpTable info, so we should only update it if the
// process changes.
hProcess = (HANDLE) ProcHandle;
if (g_CurrentProcess == hProcess)
return (true);
}
else
{
DOUT (L"Unable to get the current process.");
return (false);
}
// Module names don't include file name extensions.
ULONG64 BaseOfDll;
if (FAILED(hr = g_ExtSymbols->GetModuleByModuleName (
"mscorwks", 0, NULL, &BaseOfDll)))
{
DOUT (L"unable to get base of mscorwks.dll; trying mscorsvr.dll");
if (FAILED(hr = g_ExtSymbols->GetModuleByModuleName (
"mscorsvr", 0, NULL, &BaseOfDll)))
{
DOUT (L"unable to get base of mscorsvr.dll; stopping.");
return (false);
}
}
int tableName = 80;
ULONG_PTR TableAddress = NULL;
if (!GetExportByName ((ULONG_PTR) BaseOfDll,
reinterpret_cast<const char*>(tableName), &TableAddress))
{
DOUT (L"unable to find class dump table");
return (false);
}
ULONG bytesRead;
if (!SafeReadMemory (TableAddress, &g_ClassTable,
sizeof(g_ClassTable), &bytesRead))
{
DOUT (L"Lunable to read class dump table");
return (false);
}
// Is the version what we're expecting? If it isn't, we don't know what the
// correct indexes are.
if (g_ClassTable.version != 1)
return (false);
// At this point, everything has been initialized properly. Cache the
// process handle so we don't repeat all this.
g_CurrentProcess = hProcess;
g_fClassTableInit = TRUE;
return (true);
}
/**
* Return pointer to initialized class dump table.
*/
ClassDumpTable *GetClassDumpTable()
{
if (InitializeOffsetTable())
return &g_ClassTable;
return (NULL);
}
/**
* Return the memory location of the beginning of the ClassDumpInfo for the
* requested class.
*/
static ULONG_PTR GetClassInfo (size_t klass)
{
// is the requested class correct?
if (klass == (size_t)-1)
return (InvalidOffset);
// make sure our data is current.
if (!InitializeOffsetTable ())
return (InvalidOffset);
if (klass >= g_ClassTable.nentries)
return (InvalidOffset);
// g_ClassTable.classes is a continuous array of pointers to ClassDumpInfo
// objects. We need the address of the correct object.
ULONG BR; // bytes read
ULONG_PTR Class;
if (!SafeReadMemory (
reinterpret_cast<ULONG_PTR>(g_ClassTable.classes) + // base of array
(klass*sizeof(ClassDumpInfo*)), // memory offset into array
&Class,
sizeof(Class), &BR))
return (InvalidOffset);
return (Class);
}
ULONG_PTR GetMemberInformation (size_t klass, size_t member)
{
const ULONG_PTR error = InvalidOffset;
// get the location of the class in memory
ULONG_PTR pcdi;
if ((pcdi = GetClassInfo(klass)) == InvalidOffset)
return (error);
ULONG BR; // bytes read
ClassDumpInfo cdi;
if (!SafeReadMemory (pcdi, &cdi, sizeof(cdi), &BR))
return (error);
// get the member
if (member == (size_t)-1)
return (error);
if (member >= cdi.nmembers)
return (error);
ULONG_PTR size;
if (!SafeReadMemory (
reinterpret_cast<ULONG_PTR>(cdi.memberOffsets) + // base of offset array
(member*sizeof(ULONG_PTR)), // member index
&size,
sizeof(size),
&BR))
return (error);
return (size);
}
SIZE_T GetClassSize (size_t klass)
{
// reminder: in C++, all classes must be at least 1 byte in size
// (this is to prevent two variables from having the same memory address)
// Thus, 0 is an invalid class size value.
const SIZE_T error = 0;
// get the location of the class in memory
ULONG_PTR pcdi;
if ((pcdi = GetClassInfo(klass)) == InvalidOffset)
return (error);
// read in the class information.
ULONG BR; // bytes read
ClassDumpInfo cdi;
if (!SafeReadMemory (pcdi, &cdi, sizeof(cdi), &BR))
return (error);
return (cdi.classSize);
}
ULONG_PTR GetEEJitManager ()
{
if (InitializeOffsetTable())
return (g_ClassTable.pEEJitManagerVtable);
return (0);
}
ULONG_PTR GetEconoJitManager ()
{
if (InitializeOffsetTable())
return (g_ClassTable.pEconoJitManagerVtable);
return (0);
}
ULONG_PTR GetMNativeJitManager ()
{
if (InitializeOffsetTable())
return (g_ClassTable.pMNativeJitManagerVtable);
return (0);
}
| 6,267 | 2,005 |
// Copyright (c) 2018, Smart Projects Holdings Ltd
// All rights reserved.
// See LICENSE file for license details.
#include <UnitTest++.h>
#include <ugcs/vsm/actions.h>
using namespace ugcs::vsm;
Geodetic_tuple geo_pos(1,2,3);
Wgs84_position position(geo_pos);
TEST(convertions_from_base_class_wait)
{
Action::Ptr action = Wait_action::Create(42);
CHECK(Action::Type::WAIT == action->Get_type());
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK_EQUAL(42, wa->wait_time);
Landing_action::Ptr la = action->Get_action<Action::Type::LANDING>();
CHECK(!la);
}
TEST(convertions_from_base_class_landing)
{
Action::Ptr action = Landing_action::Create(position, 10, 13.5, 0.42, 2);
CHECK(Action::Type::LANDING == action->Get_type());
Landing_action::Ptr la = action->Get_action<Action::Type::LANDING>();
CHECK_EQUAL(10, la->heading);
CHECK_EQUAL(13.5, la->elevation);
CHECK_EQUAL(0.42, la->descend_rate);
CHECK_EQUAL(2, la->acceptance_radius);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_move)
{
Action::Ptr action = Move_action::Create(position, 1, 2, 3, 4, 5);
CHECK(Action::Type::MOVE == action->Get_type());
Move_action::Ptr ma = action->Get_action<Action::Type::MOVE>();
CHECK_EQUAL(1, ma->wait_time);
CHECK_EQUAL(2, ma->acceptance_radius);
CHECK_EQUAL(3, ma->loiter_orbit);
CHECK_EQUAL(4, ma->heading);
CHECK_EQUAL(5, ma->elevation);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_payload_steering)
{
Action::Ptr action = Payload_steering_action::Create();
CHECK(Action::Type::PAYLOAD_STEERING == action->Get_type());
Payload_steering_action::Ptr pa = action->Get_action<Action::Type::PAYLOAD_STEERING>();
CHECK(pa);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_takeoff)
{
Action::Ptr action = Takeoff_action::Create(position, 42, 13.5, 0.12, 2);
CHECK(Action::Type::TAKEOFF == action->Get_type());
Takeoff_action::Ptr ta = action->Get_action<Action::Type::TAKEOFF>();
CHECK_EQUAL(42, ta->heading);
CHECK_EQUAL(13.5, ta->elevation);
CHECK_EQUAL(0.12, ta->climb_rate);
CHECK_EQUAL(2, ta->acceptance_radius);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_change_speed)
{
Action::Ptr action = Change_speed_action::Create(42, 0);
CHECK(Action::Type::CHANGE_SPEED == action->Get_type());
Change_speed_action::Ptr ca = action->Get_action<Action::Type::CHANGE_SPEED>();
CHECK_EQUAL(42, ca->speed);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_set_home)
{
Action::Ptr action = Set_home_action::Create(true, position, 13.5);
CHECK(Action::Type::SET_HOME == action->Get_type());
Set_home_action::Ptr sa = action->Get_action<Action::Type::SET_HOME>();
CHECK_EQUAL(true, sa->use_current_position);
CHECK_EQUAL(13.5, sa->elevation);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_poi)
{
Action::Ptr action = Poi_action::Create(position, true);
CHECK(Action::Type::POI == action->Get_type());
Poi_action::Ptr pa = action->Get_action<Action::Type::POI>();
CHECK(pa->active);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_heading)
{
Action::Ptr action = Heading_action::Create(M_PI);
CHECK(Action::Type::HEADING == action->Get_type());
Heading_action::Ptr ha = action->Get_action<Action::Type::HEADING>();
CHECK_EQUAL(M_PI, ha->heading);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_camera_control)
{
Action::Ptr action = Camera_control_action::Create(0, 0, 0, 42);
CHECK(Action::Type::CAMERA_CONTROL == action->Get_type());
Camera_control_action::Ptr cc = action->Get_action<Action::Type::CAMERA_CONTROL>();
CHECK_EQUAL(42, cc->zoom);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_camera_trigger)
{
Action::Ptr action = Camera_trigger_action::Create(
proto::CAMERA_MISSION_TRIGGER_STATE_OFF, std::chrono::seconds(1));
CHECK(Action::Type::CAMERA_TRIGGER == action->Get_type());
Camera_trigger_action::Ptr ct = action->Get_action<Action::Type::CAMERA_TRIGGER>();
CHECK_EQUAL(proto::CAMERA_MISSION_TRIGGER_STATE_OFF, ct->state);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_task_attributes)
{
using Emerg = Task_attributes_action::Emergency_action;
Action::Ptr action = Task_attributes_action::Create(
42, Emerg::GO_HOME, Emerg::LAND, Emerg::WAIT);
CHECK(Action::Type::TASK_ATTRIBUTES == action->Get_type());
Task_attributes_action::Ptr ta = action->Get_action<Action::Type::TASK_ATTRIBUTES>();
CHECK_EQUAL(42, ta->safe_altitude);
CHECK_EQUAL(Emerg::GO_HOME, ta->rc_loss);
CHECK_EQUAL(Emerg::LAND, ta->gnss_loss);
CHECK_EQUAL(Emerg::WAIT, ta->low_battery);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
TEST(convertions_from_base_class_panorama)
{
Action::Ptr action = Panorama_action::Create(
proto::PANORAMA_MODE_PHOTO,
M_PI,
M_PI / 10,
std::chrono::milliseconds(500),
M_PI / 10);
CHECK(Action::Type::PANORAMA == action->Get_type());
Panorama_action::Ptr pa = action->Get_action<Action::Type::PANORAMA>();
CHECK_EQUAL(proto::PANORAMA_MODE_PHOTO, pa->trigger_state);
CHECK(std::chrono::milliseconds(500) == pa->delay);
Wait_action::Ptr wa = action->Get_action<Action::Type::WAIT>();
CHECK(!wa);
}
const double tol = 0.000001;
template<class Pld_mission_item_ex>
void Fill_mavlink_position(Pld_mission_item_ex& item)
{
item->x = 89.999; /* lat grad */
item->y = 179.999; /* lon grad */
item->z = 42; /* alt m */
}
#define CHECK_GEO_POSITION(geo_pos) \
CHECK_CLOSE(1, geo_pos.latitude, tol); \
CHECK_CLOSE(2, geo_pos.longitude, tol); \
CHECK_EQUAL(3, geo_pos.altitude);
#define STRINGIFY_(x_) #x_
#define STRINGIFY(x_) STRINGIFY_(x_)
TEST(construct_move)
{
#define P(n,v) p.emplace(n, Property::Create(n, v, proto::FIELD_SEMANTIC_NUMERIC));
Property_list p;
P("latitude", 1)
P("longitude", 2)
P("altitude_amsl", 3)
P("acceptance_radius", 3)
P("heading", 1)
P("loiter_radius", 5)
P("wait_time", 1)
P("ground_elevation", 1.5)
P("turn_type", 1)
Move_action ma(p);
CHECK_GEO_POSITION(ma.position.Get_geodetic());
CHECK_CLOSE(1, ma.wait_time, tol);
CHECK_EQUAL(3, ma.acceptance_radius);
CHECK_EQUAL(5, ma.loiter_orbit);
CHECK_CLOSE(1, ma.heading, tol);
CHECK_CLOSE(1.5, ma.elevation, tol);
}
| 7,148 | 2,765 |
/*
* jmemdos.c
*
* Copyright (C) 1992-1994, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file provides an MS-DOS-compatible implementation of the system-
* dependent portion of the JPEG memory manager. Temporary data can be
* stored in extended or expanded memory as well as in regular DOS files.
*
* If you use this file, you must be sure that NEED_FAR_POINTERS is defined
* if you compile in a small-data memory model; it should NOT be defined if
* you use a large-data memory model. This file is not recommended if you
* are using a flat-memory-space 386 environment such as DJGCC or Watcom C.
* Also, this code will NOT work if struct fields are aligned on greater than
* 2-byte boundaries.
*
* Based on code contributed by Ge' Weijers.
*/
/*
* If you have both extended and expanded memory, you may want to change the
* order in which they are tried in jopen_backing_store. On a 286 machine
* expanded memory is usually faster, since extended memory access involves
* an expensive protected-mode-and-back switch. On 386 and better, extended
* memory is usually faster. As distributed, the code tries extended memory
* first (what? not everyone has a 386? :-).
*
* You can disable use of extended/expanded memory entirely by altering these
* definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0).
*/
#ifndef XMS_SUPPORTED
#define XMS_SUPPORTED 1
#endif
#ifndef EMS_SUPPORTED
#define EMS_SUPPORTED 1
#endif
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jmemsys.h" /* import the system-dependent declarations */
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare these */
extern void * malloc JPP((size_t size));
extern void free JPP((void *ptr));
extern char * getenv JPP((const char * name));
#endif
#ifdef NEED_FAR_POINTERS
#ifdef __TURBOC__
/* These definitions work for Borland C (Turbo C) */
#include <alloc.h> /* need farmalloc(), farfree() */
#define far_malloc(x) farmalloc(x)
#define far_free(x) farfree(x)
#else
/* These definitions work for Microsoft C and compatible compilers */
#include <malloc.h> /* need _fmalloc(), _ffree() */
#define far_malloc(x) _fmalloc(x)
#define far_free(x) _ffree(x)
#endif
#else /* not NEED_FAR_POINTERS */
#define far_malloc(x) malloc(x)
#define far_free(x) free(x)
#endif /* NEED_FAR_POINTERS */
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
#define READ_BINARY "r"
#else
#define READ_BINARY "rb"
#endif
#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */
MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */
#endif
/*
* Declarations for assembly-language support routines (see jmemdosa.asm).
*
* The functions are declared "far" as are all pointer arguments;
* this ensures the assembly source code will work regardless of the
* compiler memory model. We assume "short" is 16 bits, "long" is 32.
*/
typedef void far * XMSDRIVER; /* actually a pointer to code */
typedef struct { /* registers for calling XMS driver */
unsigned short ax, dx, bx;
void far * ds_si;
} XMScontext;
typedef struct { /* registers for calling EMS driver */
unsigned short ax, dx, bx;
void far * ds_si;
} EMScontext;
EXTERN short far jdos_open JPP((short far * handle, char far * filename));
EXTERN short far jdos_close JPP((short handle));
EXTERN short far jdos_seek JPP((short handle, long offset));
EXTERN short far jdos_read JPP((short handle, void far * buffer,
unsigned short count));
EXTERN short far jdos_write JPP((short handle, void far * buffer,
unsigned short count));
EXTERN void far jxms_getdriver JPP((XMSDRIVER far *));
EXTERN void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *));
EXTERN short far jems_available JPP((void));
EXTERN void far jems_calldriver JPP((EMScontext far *));
/*
* Selection of a file name for a temporary file.
* This is highly system-dependent, and you may want to customize it.
*/
static int next_file_num; /* to distinguish among several temp files */
LOCAL void
select_file_name (char * fname)
{
const char * env;
char * ptr;
FILE * tfile;
/* Keep generating file names till we find one that's not in use */
for (;;) {
/* Get temp directory name from environment TMP or TEMP variable;
* if none, use "."
*/
if ((env = (const char *) getenv("TMP")) == NULL)
if ((env = (const char *) getenv("TEMP")) == NULL)
env = ".";
if (*env == '\0') /* null string means "." */
env = ".";
ptr = fname; /* copy name to fname */
while (*env != '\0')
*ptr++ = *env++;
if (ptr[-1] != '\\' && ptr[-1] != '/')
*ptr++ = '\\'; /* append backslash if not in env variable */
/* Append a suitable file name */
next_file_num++; /* advance counter */
wsprintf(ptr, "JPG%03d.TMP", next_file_num);
/* Probe to see if file name is already in use */
#ifdef DEAD_CODE
if ((tfile = fopen(fname, READ_BINARY)) == NULL)
break;
fclose(tfile); /* oops, it's there; close tfile & try again */
#endif
}
}
/*
* Near-memory allocation and freeing are controlled by the regular library
* routines malloc() and free().
*/
// Removed to eliminate Compiler Warnings. TML 6/8/98
/*
GLOBAL void *
jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
{
return (void *) malloc(sizeofobject);
}
GLOBAL void
jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
{
free(object);
}
//
// "Large" objects are allocated in far memory, if possible
//
GLOBAL void FAR *
jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
{
return (void FAR *) far_malloc(sizeofobject);
}
GLOBAL void
jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
{
far_free(object);
}
*/
//
// This routine computes the total memory space available for allocation.
// It's impossible to do this in a portable way; our current solution is
// to make the user tell us (with a default value set at compile time).
// if you can actually get the available space, it's a good idea to subtract
// slop factor of 5% or so.
//
#ifndef DEFAULT_MAX_MEM // so can override from makefile
#define DEFAULT_MAX_MEM 300000L // for total usage about 450K
#endif
// Removed to eliminate Compiler Warnings. TML 6/8/98
/*
GLOBAL long
jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
long max_bytes_needed, long already_allocated)
{
return cinfo->mem->max_memory_to_use - already_allocated;
}
*/
//
// Backing store (temporary file) management.
// Backing store objects are only used when the value returned by
// jpeg_mem_available is less than the total space needed. You can dispense
// with these routines if you have plenty of virtual memory; see jmemnobs.c.
//
//
// For MS-DOS we support three types of backing storage:
// 1. Conventional DOS files. We access these by direct DOS calls rather
// than via the stdio package. This provides a bit better performance,
// but the real reason is that the buffers to be read or written are FAR.
// The stdio library for small-data memory models can't cope with that.
// 2. Extended memory, accessed per the XMS V2.0 specification.
// 3. Expanded memory, accessed per the LIM/EMS 4.0 specification.
// You'll need copies of those specs to make sense of the related code.
// The specs are available by Internet FTP from the SIMTEL archives
// (oak.oakland.edu and its various mirror sites). See files
// pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip.
//
//
// Access methods for a DOS file.
//
METHODDEF void
read_file_store (j_common_ptr cinfo, backing_store_ptr info,
void FAR * buffer_address,
long file_offset, long byte_count)
{
if (jdos_seek(info->handle.file_handle, file_offset))
ERREXIT(cinfo, JERR_TFILE_SEEK);
/* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */
if (byte_count > 65535L) /* safety check */
ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
if (jdos_read(info->handle.file_handle, buffer_address,
(unsigned short) byte_count))
ERREXIT(cinfo, JERR_TFILE_READ);
}
METHODDEF void
write_file_store (j_common_ptr cinfo, backing_store_ptr info,
void FAR * buffer_address,
long file_offset, long byte_count)
{
if (jdos_seek(info->handle.file_handle, file_offset))
ERREXIT(cinfo, JERR_TFILE_SEEK);
/* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */
if (byte_count > 65535L) /* safety check */
ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
if (jdos_write(info->handle.file_handle, buffer_address,
(unsigned short) byte_count))
ERREXIT(cinfo, JERR_TFILE_WRITE);
}
METHODDEF void
close_file_store (j_common_ptr cinfo, backing_store_ptr info)
{
jdos_close(info->handle.file_handle); /* close the file */
remove(info->temp_name); /* delete the file */
/* If your system doesn't have remove(), try unlink() instead.
* remove() is the ANSI-standard name for this function, but
* unlink() was more common in pre-ANSI systems.
*/
TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name);
}
// Removed to eliminate Compiler Warnings. TML 6/8/98
/*
LOCAL boolean
open_file_store (j_common_ptr cinfo, backing_store_ptr info,
long total_bytes_needed)
{
short handle;
select_file_name(info->temp_name);
if (jdos_open((short far *) & handle, (char far *) info->temp_name)) {
// might as well exit since jpeg_open_backing_store will fail anyway
ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);
return FALSE;
}
info->handle.file_handle = handle;
info->read_backing_store = read_file_store;
info->write_backing_store = write_file_store;
info->close_backing_store = close_file_store;
TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);
return TRUE; // succeeded
}
*/
//
// Access methods for extended memory.
//
#if XMS_SUPPORTED
static XMSDRIVER xms_driver; /* saved address of XMS driver */
typedef union { /* either long offset or real-mode pointer */
long offset;
void far * ptr;
} XMSPTR;
typedef struct { /* XMS move specification structure */
long length;
XMSH src_handle;
XMSPTR src;
XMSH dst_handle;
XMSPTR dst;
} XMSspec;
#define ODD(X) (((X) & 1L) != 0)
METHODDEF void
read_xms_store (j_common_ptr cinfo, backing_store_ptr info,
void FAR * buffer_address,
long file_offset, long byte_count)
{
XMScontext ctx;
XMSspec spec;
char endbuffer[2];
/* The XMS driver can't cope with an odd length, so handle the last byte
* specially if byte_count is odd. We don't expect this to be common.
*/
spec.length = byte_count & (~ 1L);
spec.src_handle = info->handle.xms_handle;
spec.src.offset = file_offset;
spec.dst_handle = 0;
spec.dst.ptr = buffer_address;
ctx.ds_si = (void far *) & spec;
ctx.ax = 0x0b00; /* EMB move */
jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
if (ctx.ax != 1)
ERREXIT(cinfo, JERR_XMS_READ);
if (ODD(byte_count)) {
read_xms_store(cinfo, info, (void FAR *) endbuffer,
file_offset + byte_count - 1L, 2L);
((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0];
}
}
METHODDEF void
write_xms_store (j_common_ptr cinfo, backing_store_ptr info,
void FAR * buffer_address,
long file_offset, long byte_count)
{
XMScontext ctx;
XMSspec spec;
char endbuffer[2];
/* The XMS driver can't cope with an odd length, so handle the last byte
* specially if byte_count is odd. We don't expect this to be common.
*/
spec.length = byte_count & (~ 1L);
spec.src_handle = 0;
spec.src.ptr = buffer_address;
spec.dst_handle = info->handle.xms_handle;
spec.dst.offset = file_offset;
ctx.ds_si = (void far *) & spec;
ctx.ax = 0x0b00; /* EMB move */
jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
if (ctx.ax != 1)
ERREXIT(cinfo, JERR_XMS_WRITE);
if (ODD(byte_count)) {
read_xms_store(cinfo, info, (void FAR *) endbuffer,
file_offset + byte_count - 1L, 2L);
endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L];
write_xms_store(cinfo, info, (void FAR *) endbuffer,
file_offset + byte_count - 1L, 2L);
}
}
METHODDEF void
close_xms_store (j_common_ptr cinfo, backing_store_ptr info)
{
XMScontext ctx;
ctx.dx = info->handle.xms_handle;
ctx.ax = 0x0a00;
jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle);
/* we ignore any error return from the driver */
}
LOCAL boolean
open_xms_store (j_common_ptr cinfo, backing_store_ptr info,
long total_bytes_needed)
{
XMScontext ctx;
/* Get address of XMS driver */
jxms_getdriver((XMSDRIVER far *) & xms_driver);
if (xms_driver == NULL)
return FALSE; /* no driver to be had */
/* Get version number, must be >= 2.00 */
ctx.ax = 0x0000;
jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
if (ctx.ax < (unsigned short) 0x0200)
return FALSE;
/* Try to get space (expressed in kilobytes) */
ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10);
ctx.ax = 0x0900;
jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
if (ctx.ax != 1)
return FALSE;
/* Succeeded, save the handle and away we go */
info->handle.xms_handle = ctx.dx;
info->read_backing_store = read_xms_store;
info->write_backing_store = write_xms_store;
info->close_backing_store = close_xms_store;
TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx);
return TRUE; // succeeded
}
#endif /* XMS_SUPPORTED */
/*
* Access methods for expanded memory.
*/
#if EMS_SUPPORTED
/* The EMS move specification structure requires word and long fields aligned
* at odd byte boundaries. Some compilers will align struct fields at even
* byte boundaries. While it's usually possible to force byte alignment,
* that causes an overall performance penalty and may pose problems in merging
* JPEG into a larger application. Instead we accept some rather dirty code
* here. Note this code would fail if the hardware did not allow odd-byte
* word & long accesses, but all 80x86 CPUs do.
*/
typedef void far * EMSPTR;
typedef union { /* EMS move specification structure */
long length; /* It's easy to access first 4 bytes */
char bytes[18]; /* Misaligned fields in here! */
} EMSspec;
/* Macros for accessing misaligned fields */
#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset])))
#define SRC_TYPE(spec) FIELD_AT(spec,4,char)
#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH)
#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short)
#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short)
#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR)
#define DST_TYPE(spec) FIELD_AT(spec,11,char)
#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH)
#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short)
#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short)
#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR)
#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */
#define HIBYTE(W) (((W) >> 8) & 0xFF)
#define LOBYTE(W) ((W) & 0xFF)
METHODDEF void
read_ems_store (j_common_ptr cinfo, backing_store_ptr info,
void FAR * buffer_address,
long file_offset, long byte_count)
{
EMScontext ctx;
EMSspec spec;
spec.length = byte_count;
SRC_TYPE(spec) = 1;
SRC_HANDLE(spec) = info->handle.ems_handle;
SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE);
SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);
DST_TYPE(spec) = 0;
DST_HANDLE(spec) = 0;
DST_PTR(spec) = buffer_address;
ctx.ds_si = (void far *) & spec;
ctx.ax = 0x5700; /* move memory region */
jems_calldriver((EMScontext far *) & ctx);
if (HIBYTE(ctx.ax) != 0)
ERREXIT(cinfo, JERR_EMS_READ);
}
METHODDEF void
write_ems_store (j_common_ptr cinfo, backing_store_ptr info,
void FAR * buffer_address,
long file_offset, long byte_count)
{
EMScontext ctx;
EMSspec spec;
spec.length = byte_count;
SRC_TYPE(spec) = 0;
SRC_HANDLE(spec) = 0;
SRC_PTR(spec) = buffer_address;
DST_TYPE(spec) = 1;
DST_HANDLE(spec) = info->handle.ems_handle;
DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE);
DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);
ctx.ds_si = (void far *) & spec;
ctx.ax = 0x5700; /* move memory region */
jems_calldriver((EMScontext far *) & ctx);
if (HIBYTE(ctx.ax) != 0)
ERREXIT(cinfo, JERR_EMS_WRITE);
}
METHODDEF void
close_ems_store (j_common_ptr cinfo, backing_store_ptr info)
{
EMScontext ctx;
ctx.ax = 0x4500;
ctx.dx = info->handle.ems_handle;
jems_calldriver((EMScontext far *) & ctx);
TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle);
/* we ignore any error return from the driver */
}
LOCAL boolean
open_ems_store (j_common_ptr cinfo, backing_store_ptr info,
long total_bytes_needed)
{
EMScontext ctx;
/* Is EMS driver there? */
if (! jems_available())
return FALSE;
/* Get status, make sure EMS is OK */
ctx.ax = 0x4000;
jems_calldriver((EMScontext far *) & ctx);
if (HIBYTE(ctx.ax) != 0)
return FALSE;
/* Get version, must be >= 4.0 */
ctx.ax = 0x4600;
jems_calldriver((EMScontext far *) & ctx);
if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40)
return FALSE;
/* Try to allocate requested space */
ctx.ax = 0x4300;
ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE);
jems_calldriver((EMScontext far *) & ctx);
if (HIBYTE(ctx.ax) != 0)
return FALSE;
/* Succeeded, save the handle and away we go */
info->handle.ems_handle = ctx.dx;
info->read_backing_store = read_ems_store;
info->write_backing_store = write_ems_store;
info->close_backing_store = close_ems_store;
TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx);
return TRUE; /* succeeded */
}
#endif /* EMS_SUPPORTED */
//
// Initial opening of a backing-store object.
//
GLOBAL void
jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
long total_bytes_needed)
{
// Try extended memory, then expanded memory, then regular file.
#if XMS_SUPPORTED
if (open_xms_store(cinfo, info, total_bytes_needed))
return;
#endif
#if EMS_SUPPORTED
if (open_ems_store(cinfo, info, total_bytes_needed))
return;
#endif
if (open_file_store(cinfo, info, total_bytes_needed))
return;
ERREXITS(cinfo, JERR_TFILE_CREATE, "");
}
/*
* These routines take care of any system-dependent initialization and
* cleanup required.
*/
// Removed to eliminate Compiler Warnings. TML 6/8/98
/*
GLOBAL long
jpeg_mem_init (j_common_ptr cinfo)
{
next_file_num = 0; // initialize temp file name generator
return DEFAULT_MAX_MEM; // default for max_memory_to_use
}
GLOBAL void
jpeg_mem_term (j_common_ptr cinfo)
{
// Microsoft C, at least in v6.00A, will not successfully reclaim freed
// blocks of size > 32Kbytes unless we give it a kick in the rear, like so:
//
#ifdef NEED_FHEAPMIN
_fheapmin();
#endif
}
*/
| 19,961 | 7,122 |
#ifndef DI_SYSTEMS_VR_CAMERA_FRAME_TYPE_HPP_
#define DI_SYSTEMS_VR_CAMERA_FRAME_TYPE_HPP_
#include <openvr.h>
namespace di
{
enum class camera_frame_type
{
distorted = vr::VRTrackedCameraFrameType_Distorted ,
undistorted = vr::VRTrackedCameraFrameType_Undistorted ,
maximum_undistorted = vr::VRTrackedCameraFrameType_MaximumUndistorted
};
}
#endif | 388 | 155 |
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._ResetSeatedZeroPose
#include "OVR/OpenVR/IVRSystem__ResetSeatedZeroPose.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ResetSeatedZeroPose.Invoke
void OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ResetSeatedZeroPose.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ResetSeatedZeroPose.EndInvoke
void OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ResetSeatedZeroPose*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSeatedZeroPoseToStandingAbsoluteTrackingPose
#include "OVR/OpenVR/IVRSystem__GetSeatedZeroPoseToStandingAbsoluteTrackingPose.hpp"
// Including type: OVR.OpenVR.HmdMatrix34_t
#include "OVR/OpenVR/HmdMatrix34_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSeatedZeroPoseToStandingAbsoluteTrackingPose.Invoke
::OVR::OpenVR::HmdMatrix34_t OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HmdMatrix34_t, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSeatedZeroPoseToStandingAbsoluteTrackingPose.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSeatedZeroPoseToStandingAbsoluteTrackingPose.EndInvoke
::OVR::OpenVR::HmdMatrix34_t OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetSeatedZeroPoseToStandingAbsoluteTrackingPose*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HmdMatrix34_t, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetRawZeroPoseToStandingAbsoluteTrackingPose
#include "OVR/OpenVR/IVRSystem__GetRawZeroPoseToStandingAbsoluteTrackingPose.hpp"
// Including type: OVR.OpenVR.HmdMatrix34_t
#include "OVR/OpenVR/HmdMatrix34_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetRawZeroPoseToStandingAbsoluteTrackingPose.Invoke
::OVR::OpenVR::HmdMatrix34_t OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HmdMatrix34_t, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetRawZeroPoseToStandingAbsoluteTrackingPose.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetRawZeroPoseToStandingAbsoluteTrackingPose.EndInvoke
::OVR::OpenVR::HmdMatrix34_t OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetRawZeroPoseToStandingAbsoluteTrackingPose*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HmdMatrix34_t, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSortedTrackedDeviceIndicesOfClass
#include "OVR/OpenVR/IVRSystem__GetSortedTrackedDeviceIndicesOfClass.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceClass
#include "OVR/OpenVR/ETrackedDeviceClass.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSortedTrackedDeviceIndicesOfClass.Invoke
uint OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass::Invoke(::OVR::OpenVR::ETrackedDeviceClass eTrackedDeviceClass, ByRef<::ArrayW<uint>> punTrackedDeviceIndexArray, uint unTrackedDeviceIndexArrayCount, uint unRelativeToTrackedDeviceIndex) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, eTrackedDeviceClass, byref(punTrackedDeviceIndexArray), unTrackedDeviceIndexArrayCount, unRelativeToTrackedDeviceIndex);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSortedTrackedDeviceIndicesOfClass.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass::BeginInvoke(::OVR::OpenVR::ETrackedDeviceClass eTrackedDeviceClass, ByRef<::ArrayW<uint>> punTrackedDeviceIndexArray, uint unTrackedDeviceIndexArrayCount, uint unRelativeToTrackedDeviceIndex, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eTrackedDeviceClass, byref(punTrackedDeviceIndexArray), unTrackedDeviceIndexArrayCount, unRelativeToTrackedDeviceIndex, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetSortedTrackedDeviceIndicesOfClass.EndInvoke
uint OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetSortedTrackedDeviceIndicesOfClass*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceActivityLevel
#include "OVR/OpenVR/IVRSystem__GetTrackedDeviceActivityLevel.hpp"
// Including type: OVR.OpenVR.EDeviceActivityLevel
#include "OVR/OpenVR/EDeviceActivityLevel.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceActivityLevel.Invoke
::OVR::OpenVR::EDeviceActivityLevel OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel::Invoke(uint unDeviceId) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EDeviceActivityLevel, false>(this, ___internal__method, unDeviceId);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceActivityLevel.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel::BeginInvoke(uint unDeviceId, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceId, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceActivityLevel.EndInvoke
::OVR::OpenVR::EDeviceActivityLevel OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceActivityLevel*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EDeviceActivityLevel, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._ApplyTransform
#include "OVR/OpenVR/IVRSystem__ApplyTransform.hpp"
// Including type: OVR.OpenVR.TrackedDevicePose_t
#include "OVR/OpenVR/TrackedDevicePose_t.hpp"
// Including type: OVR.OpenVR.HmdMatrix34_t
#include "OVR/OpenVR/HmdMatrix34_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ApplyTransform.Invoke
void OVR::OpenVR::IVRSystem::_ApplyTransform::Invoke(ByRef<::OVR::OpenVR::TrackedDevicePose_t> pOutputPose, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ByRef<::OVR::OpenVR::HmdMatrix34_t> pTransform) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ApplyTransform::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ApplyTransform*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pOutputPose), byref(pTrackedDevicePose), byref(pTransform));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ApplyTransform.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_ApplyTransform::BeginInvoke(ByRef<::OVR::OpenVR::TrackedDevicePose_t> pOutputPose, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ByRef<::OVR::OpenVR::HmdMatrix34_t> pTransform, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ApplyTransform::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ApplyTransform*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pOutputPose), byref(pTrackedDevicePose), byref(pTransform), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ApplyTransform.EndInvoke
void OVR::OpenVR::IVRSystem::_ApplyTransform::EndInvoke(ByRef<::OVR::OpenVR::TrackedDevicePose_t> pOutputPose, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ByRef<::OVR::OpenVR::HmdMatrix34_t> pTransform, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ApplyTransform::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ApplyTransform*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pOutputPose), byref(pTrackedDevicePose), byref(pTransform), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceIndexForControllerRole
#include "OVR/OpenVR/IVRSystem__GetTrackedDeviceIndexForControllerRole.hpp"
// Including type: OVR.OpenVR.ETrackedControllerRole
#include "OVR/OpenVR/ETrackedControllerRole.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceIndexForControllerRole.Invoke
uint OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole::Invoke(::OVR::OpenVR::ETrackedControllerRole unDeviceType) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, unDeviceType);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceIndexForControllerRole.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole::BeginInvoke(::OVR::OpenVR::ETrackedControllerRole unDeviceType, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceType, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceIndexForControllerRole.EndInvoke
uint OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceIndexForControllerRole*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerRoleForTrackedDeviceIndex
#include "OVR/OpenVR/IVRSystem__GetControllerRoleForTrackedDeviceIndex.hpp"
// Including type: OVR.OpenVR.ETrackedControllerRole
#include "OVR/OpenVR/ETrackedControllerRole.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerRoleForTrackedDeviceIndex.Invoke
::OVR::OpenVR::ETrackedControllerRole OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex::Invoke(uint unDeviceIndex) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::ETrackedControllerRole, false>(this, ___internal__method, unDeviceIndex);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerRoleForTrackedDeviceIndex.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex::BeginInvoke(uint unDeviceIndex, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerRoleForTrackedDeviceIndex.EndInvoke
::OVR::OpenVR::ETrackedControllerRole OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerRoleForTrackedDeviceIndex*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::ETrackedControllerRole, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceClass
#include "OVR/OpenVR/IVRSystem__GetTrackedDeviceClass.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceClass
#include "OVR/OpenVR/ETrackedDeviceClass.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceClass.Invoke
::OVR::OpenVR::ETrackedDeviceClass OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass::Invoke(uint unDeviceIndex) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::ETrackedDeviceClass, false>(this, ___internal__method, unDeviceIndex);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceClass.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass::BeginInvoke(uint unDeviceIndex, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetTrackedDeviceClass.EndInvoke
::OVR::OpenVR::ETrackedDeviceClass OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetTrackedDeviceClass*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::ETrackedDeviceClass, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsTrackedDeviceConnected
#include "OVR/OpenVR/IVRSystem__IsTrackedDeviceConnected.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsTrackedDeviceConnected.Invoke
bool OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected::Invoke(uint unDeviceIndex) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, unDeviceIndex);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsTrackedDeviceConnected.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected::BeginInvoke(uint unDeviceIndex, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsTrackedDeviceConnected.EndInvoke
bool OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsTrackedDeviceConnected*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetBoolTrackedDeviceProperty
#include "OVR/OpenVR/IVRSystem__GetBoolTrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceProperty
#include "OVR/OpenVR/ETrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetBoolTrackedDeviceProperty.Invoke
bool OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty::Invoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetBoolTrackedDeviceProperty.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty::BeginInvoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetBoolTrackedDeviceProperty.EndInvoke
bool OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty::EndInvoke(ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetBoolTrackedDeviceProperty*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetFloatTrackedDeviceProperty
#include "OVR/OpenVR/IVRSystem__GetFloatTrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceProperty
#include "OVR/OpenVR/ETrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetFloatTrackedDeviceProperty.Invoke
float OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty::Invoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty*), 12));
return ::il2cpp_utils::RunMethodRethrow<float, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetFloatTrackedDeviceProperty.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty::BeginInvoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetFloatTrackedDeviceProperty.EndInvoke
float OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty::EndInvoke(ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetFloatTrackedDeviceProperty*), 14));
return ::il2cpp_utils::RunMethodRethrow<float, false>(this, ___internal__method, byref(pError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetInt32TrackedDeviceProperty
#include "OVR/OpenVR/IVRSystem__GetInt32TrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceProperty
#include "OVR/OpenVR/ETrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetInt32TrackedDeviceProperty.Invoke
int OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty::Invoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty*), 12));
return ::il2cpp_utils::RunMethodRethrow<int, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetInt32TrackedDeviceProperty.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty::BeginInvoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetInt32TrackedDeviceProperty.EndInvoke
int OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty::EndInvoke(ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetInt32TrackedDeviceProperty*), 14));
return ::il2cpp_utils::RunMethodRethrow<int, false>(this, ___internal__method, byref(pError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetUint64TrackedDeviceProperty
#include "OVR/OpenVR/IVRSystem__GetUint64TrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceProperty
#include "OVR/OpenVR/ETrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetUint64TrackedDeviceProperty.Invoke
uint64_t OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty::Invoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint64_t, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetUint64TrackedDeviceProperty.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty::BeginInvoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetUint64TrackedDeviceProperty.EndInvoke
uint64_t OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty::EndInvoke(ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetUint64TrackedDeviceProperty*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint64_t, false>(this, ___internal__method, byref(pError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetMatrix34TrackedDeviceProperty
#include "OVR/OpenVR/IVRSystem__GetMatrix34TrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.HmdMatrix34_t
#include "OVR/OpenVR/HmdMatrix34_t.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceProperty
#include "OVR/OpenVR/ETrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetMatrix34TrackedDeviceProperty.Invoke
::OVR::OpenVR::HmdMatrix34_t OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty::Invoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HmdMatrix34_t, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetMatrix34TrackedDeviceProperty.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty::BeginInvoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, prop, byref(pError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetMatrix34TrackedDeviceProperty.EndInvoke
::OVR::OpenVR::HmdMatrix34_t OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty::EndInvoke(ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetMatrix34TrackedDeviceProperty*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HmdMatrix34_t, false>(this, ___internal__method, byref(pError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetArrayTrackedDeviceProperty
#include "OVR/OpenVR/IVRSystem__GetArrayTrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceProperty
#include "OVR/OpenVR/ETrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetArrayTrackedDeviceProperty.Invoke
uint OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty::Invoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, uint propType, ::System::IntPtr pBuffer, uint unBufferSize, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, unDeviceIndex, prop, propType, pBuffer, unBufferSize, byref(pError));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetArrayTrackedDeviceProperty.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty::BeginInvoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, uint propType, ::System::IntPtr pBuffer, uint unBufferSize, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, prop, propType, pBuffer, unBufferSize, byref(pError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetArrayTrackedDeviceProperty.EndInvoke
uint OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty::EndInvoke(ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetArrayTrackedDeviceProperty*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, byref(pError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetStringTrackedDeviceProperty
#include "OVR/OpenVR/IVRSystem__GetStringTrackedDeviceProperty.hpp"
// Including type: OVR.OpenVR.ETrackedDeviceProperty
#include "OVR/OpenVR/ETrackedDeviceProperty.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetStringTrackedDeviceProperty.Invoke
uint OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty::Invoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ::System::Text::StringBuilder* pchValue, uint unBufferSize, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, unDeviceIndex, prop, pchValue, unBufferSize, byref(pError));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetStringTrackedDeviceProperty.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty::BeginInvoke(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ::System::Text::StringBuilder* pchValue, uint unBufferSize, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, prop, pchValue, unBufferSize, byref(pError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetStringTrackedDeviceProperty.EndInvoke
uint OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty::EndInvoke(ByRef<::OVR::OpenVR::ETrackedPropertyError> pError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetStringTrackedDeviceProperty*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, byref(pError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetPropErrorNameFromEnum
#include "OVR/OpenVR/IVRSystem__GetPropErrorNameFromEnum.hpp"
// Including type: OVR.OpenVR.ETrackedPropertyError
#include "OVR/OpenVR/ETrackedPropertyError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetPropErrorNameFromEnum.Invoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum::Invoke(::OVR::OpenVR::ETrackedPropertyError error) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum*), 12));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, error);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetPropErrorNameFromEnum.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum::BeginInvoke(::OVR::OpenVR::ETrackedPropertyError error, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, error, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetPropErrorNameFromEnum.EndInvoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetPropErrorNameFromEnum*), 14));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEvent
#include "OVR/OpenVR/IVRSystem__PollNextEvent.hpp"
// Including type: OVR.OpenVR.VREvent_t
#include "OVR/OpenVR/VREvent_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEvent.Invoke
bool OVR::OpenVR::IVRSystem::_PollNextEvent::Invoke(ByRef<::OVR::OpenVR::VREvent_t> pEvent, uint uncbVREvent) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PollNextEvent::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PollNextEvent*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pEvent), uncbVREvent);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEvent.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_PollNextEvent::BeginInvoke(ByRef<::OVR::OpenVR::VREvent_t> pEvent, uint uncbVREvent, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PollNextEvent::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PollNextEvent*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pEvent), uncbVREvent, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEvent.EndInvoke
bool OVR::OpenVR::IVRSystem::_PollNextEvent::EndInvoke(ByRef<::OVR::OpenVR::VREvent_t> pEvent, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PollNextEvent::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PollNextEvent*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pEvent), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEventWithPose
#include "OVR/OpenVR/IVRSystem__PollNextEventWithPose.hpp"
// Including type: OVR.OpenVR.ETrackingUniverseOrigin
#include "OVR/OpenVR/ETrackingUniverseOrigin.hpp"
// Including type: OVR.OpenVR.VREvent_t
#include "OVR/OpenVR/VREvent_t.hpp"
// Including type: OVR.OpenVR.TrackedDevicePose_t
#include "OVR/OpenVR/TrackedDevicePose_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEventWithPose.Invoke
bool OVR::OpenVR::IVRSystem::_PollNextEventWithPose::Invoke(::OVR::OpenVR::ETrackingUniverseOrigin eOrigin, ByRef<::OVR::OpenVR::VREvent_t> pEvent, uint uncbVREvent, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PollNextEventWithPose::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PollNextEventWithPose*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, eOrigin, byref(pEvent), uncbVREvent, byref(pTrackedDevicePose));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEventWithPose.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_PollNextEventWithPose::BeginInvoke(::OVR::OpenVR::ETrackingUniverseOrigin eOrigin, ByRef<::OVR::OpenVR::VREvent_t> pEvent, uint uncbVREvent, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PollNextEventWithPose::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PollNextEventWithPose*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eOrigin, byref(pEvent), uncbVREvent, byref(pTrackedDevicePose), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PollNextEventWithPose.EndInvoke
bool OVR::OpenVR::IVRSystem::_PollNextEventWithPose::EndInvoke(ByRef<::OVR::OpenVR::VREvent_t> pEvent, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PollNextEventWithPose::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PollNextEventWithPose*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pEvent), byref(pTrackedDevicePose), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetEventTypeNameFromEnum
#include "OVR/OpenVR/IVRSystem__GetEventTypeNameFromEnum.hpp"
// Including type: OVR.OpenVR.EVREventType
#include "OVR/OpenVR/EVREventType.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetEventTypeNameFromEnum.Invoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum::Invoke(::OVR::OpenVR::EVREventType eType) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum*), 12));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, eType);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetEventTypeNameFromEnum.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum::BeginInvoke(::OVR::OpenVR::EVREventType eType, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eType, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetEventTypeNameFromEnum.EndInvoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetEventTypeNameFromEnum*), 14));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetHiddenAreaMesh
#include "OVR/OpenVR/IVRSystem__GetHiddenAreaMesh.hpp"
// Including type: OVR.OpenVR.HiddenAreaMesh_t
#include "OVR/OpenVR/HiddenAreaMesh_t.hpp"
// Including type: OVR.OpenVR.EVREye
#include "OVR/OpenVR/EVREye.hpp"
// Including type: OVR.OpenVR.EHiddenAreaMeshType
#include "OVR/OpenVR/EHiddenAreaMeshType.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetHiddenAreaMesh.Invoke
::OVR::OpenVR::HiddenAreaMesh_t OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh::Invoke(::OVR::OpenVR::EVREye eEye, ::OVR::OpenVR::EHiddenAreaMeshType type) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HiddenAreaMesh_t, false>(this, ___internal__method, eEye, type);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetHiddenAreaMesh.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh::BeginInvoke(::OVR::OpenVR::EVREye eEye, ::OVR::OpenVR::EHiddenAreaMeshType type, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eEye, type, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetHiddenAreaMesh.EndInvoke
::OVR::OpenVR::HiddenAreaMesh_t OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetHiddenAreaMesh*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::HiddenAreaMesh_t, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerState
#include "OVR/OpenVR/IVRSystem__GetControllerState.hpp"
// Including type: OVR.OpenVR.VRControllerState_t
#include "OVR/OpenVR/VRControllerState_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerState.Invoke
bool OVR::OpenVR::IVRSystem::_GetControllerState::Invoke(uint unControllerDeviceIndex, ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, uint unControllerStateSize) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerState::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerState*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, unControllerDeviceIndex, byref(pControllerState), unControllerStateSize);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerState.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetControllerState::BeginInvoke(uint unControllerDeviceIndex, ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, uint unControllerStateSize, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerState::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerState*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unControllerDeviceIndex, byref(pControllerState), unControllerStateSize, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerState.EndInvoke
bool OVR::OpenVR::IVRSystem::_GetControllerState::EndInvoke(ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerState::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerState*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pControllerState), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerStateWithPose
#include "OVR/OpenVR/IVRSystem__GetControllerStateWithPose.hpp"
// Including type: OVR.OpenVR.ETrackingUniverseOrigin
#include "OVR/OpenVR/ETrackingUniverseOrigin.hpp"
// Including type: OVR.OpenVR.VRControllerState_t
#include "OVR/OpenVR/VRControllerState_t.hpp"
// Including type: OVR.OpenVR.TrackedDevicePose_t
#include "OVR/OpenVR/TrackedDevicePose_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerStateWithPose.Invoke
bool OVR::OpenVR::IVRSystem::_GetControllerStateWithPose::Invoke(::OVR::OpenVR::ETrackingUniverseOrigin eOrigin, uint unControllerDeviceIndex, ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, uint unControllerStateSize, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerStateWithPose::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerStateWithPose*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, eOrigin, unControllerDeviceIndex, byref(pControllerState), unControllerStateSize, byref(pTrackedDevicePose));
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerStateWithPose.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetControllerStateWithPose::BeginInvoke(::OVR::OpenVR::ETrackingUniverseOrigin eOrigin, uint unControllerDeviceIndex, ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, uint unControllerStateSize, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerStateWithPose::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerStateWithPose*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eOrigin, unControllerDeviceIndex, byref(pControllerState), unControllerStateSize, byref(pTrackedDevicePose), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerStateWithPose.EndInvoke
bool OVR::OpenVR::IVRSystem::_GetControllerStateWithPose::EndInvoke(ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerStateWithPose::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerStateWithPose*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pControllerState), byref(pTrackedDevicePose), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._TriggerHapticPulse
#include "OVR/OpenVR/IVRSystem__TriggerHapticPulse.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._TriggerHapticPulse.Invoke
void OVR::OpenVR::IVRSystem::_TriggerHapticPulse::Invoke(uint unControllerDeviceIndex, uint unAxisId, uint16_t usDurationMicroSec) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_TriggerHapticPulse::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_TriggerHapticPulse*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, unControllerDeviceIndex, unAxisId, usDurationMicroSec);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._TriggerHapticPulse.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_TriggerHapticPulse::BeginInvoke(uint unControllerDeviceIndex, uint unAxisId, uint16_t usDurationMicroSec, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_TriggerHapticPulse::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_TriggerHapticPulse*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unControllerDeviceIndex, unAxisId, usDurationMicroSec, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._TriggerHapticPulse.EndInvoke
void OVR::OpenVR::IVRSystem::_TriggerHapticPulse::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_TriggerHapticPulse::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_TriggerHapticPulse*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetButtonIdNameFromEnum
#include "OVR/OpenVR/IVRSystem__GetButtonIdNameFromEnum.hpp"
// Including type: OVR.OpenVR.EVRButtonId
#include "OVR/OpenVR/EVRButtonId.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetButtonIdNameFromEnum.Invoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum::Invoke(::OVR::OpenVR::EVRButtonId eButtonId) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum*), 12));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, eButtonId);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetButtonIdNameFromEnum.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum::BeginInvoke(::OVR::OpenVR::EVRButtonId eButtonId, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eButtonId, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetButtonIdNameFromEnum.EndInvoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetButtonIdNameFromEnum*), 14));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerAxisTypeNameFromEnum
#include "OVR/OpenVR/IVRSystem__GetControllerAxisTypeNameFromEnum.hpp"
// Including type: OVR.OpenVR.EVRControllerAxisType
#include "OVR/OpenVR/EVRControllerAxisType.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerAxisTypeNameFromEnum.Invoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum::Invoke(::OVR::OpenVR::EVRControllerAxisType eAxisType) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum*), 12));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, eAxisType);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerAxisTypeNameFromEnum.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum::BeginInvoke(::OVR::OpenVR::EVRControllerAxisType eAxisType, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eAxisType, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._GetControllerAxisTypeNameFromEnum.EndInvoke
::System::IntPtr OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_GetControllerAxisTypeNameFromEnum*), 14));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsInputAvailable
#include "OVR/OpenVR/IVRSystem__IsInputAvailable.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsInputAvailable.Invoke
bool OVR::OpenVR::IVRSystem::_IsInputAvailable::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsInputAvailable::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsInputAvailable*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsInputAvailable.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_IsInputAvailable::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsInputAvailable::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsInputAvailable*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsInputAvailable.EndInvoke
bool OVR::OpenVR::IVRSystem::_IsInputAvailable::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsInputAvailable::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsInputAvailable*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsSteamVRDrawingControllers
#include "OVR/OpenVR/IVRSystem__IsSteamVRDrawingControllers.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsSteamVRDrawingControllers.Invoke
bool OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsSteamVRDrawingControllers.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._IsSteamVRDrawingControllers.EndInvoke
bool OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_IsSteamVRDrawingControllers*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationPause
#include "OVR/OpenVR/IVRSystem__ShouldApplicationPause.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationPause.Invoke
bool OVR::OpenVR::IVRSystem::_ShouldApplicationPause::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ShouldApplicationPause::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ShouldApplicationPause*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationPause.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_ShouldApplicationPause::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ShouldApplicationPause::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ShouldApplicationPause*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationPause.EndInvoke
bool OVR::OpenVR::IVRSystem::_ShouldApplicationPause::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ShouldApplicationPause::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ShouldApplicationPause*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationReduceRenderingWork
#include "OVR/OpenVR/IVRSystem__ShouldApplicationReduceRenderingWork.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationReduceRenderingWork.Invoke
bool OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationReduceRenderingWork.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._ShouldApplicationReduceRenderingWork.EndInvoke
bool OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_ShouldApplicationReduceRenderingWork*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._DriverDebugRequest
#include "OVR/OpenVR/IVRSystem__DriverDebugRequest.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._DriverDebugRequest.Invoke
uint OVR::OpenVR::IVRSystem::_DriverDebugRequest::Invoke(uint unDeviceIndex, ::StringW pchRequest, ::System::Text::StringBuilder* pchResponseBuffer, uint unResponseBufferSize) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_DriverDebugRequest::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_DriverDebugRequest*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, unDeviceIndex, pchRequest, pchResponseBuffer, unResponseBufferSize);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._DriverDebugRequest.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_DriverDebugRequest::BeginInvoke(uint unDeviceIndex, ::StringW pchRequest, ::System::Text::StringBuilder* pchResponseBuffer, uint unResponseBufferSize, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_DriverDebugRequest::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_DriverDebugRequest*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, pchRequest, pchResponseBuffer, unResponseBufferSize, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._DriverDebugRequest.EndInvoke
uint OVR::OpenVR::IVRSystem::_DriverDebugRequest::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_DriverDebugRequest::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_DriverDebugRequest*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._PerformFirmwareUpdate
#include "OVR/OpenVR/IVRSystem__PerformFirmwareUpdate.hpp"
// Including type: OVR.OpenVR.EVRFirmwareError
#include "OVR/OpenVR/EVRFirmwareError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PerformFirmwareUpdate.Invoke
::OVR::OpenVR::EVRFirmwareError OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate::Invoke(uint unDeviceIndex) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRFirmwareError, false>(this, ___internal__method, unDeviceIndex);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PerformFirmwareUpdate.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate::BeginInvoke(uint unDeviceIndex, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unDeviceIndex, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._PerformFirmwareUpdate.EndInvoke
::OVR::OpenVR::EVRFirmwareError OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_PerformFirmwareUpdate*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRFirmwareError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_Exiting
#include "OVR/OpenVR/IVRSystem__AcknowledgeQuit_Exiting.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_Exiting.Invoke
void OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_Exiting.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_Exiting.EndInvoke
void OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_Exiting*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_UserPrompt
#include "OVR/OpenVR/IVRSystem__AcknowledgeQuit_UserPrompt.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_UserPrompt.Invoke
void OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_UserPrompt.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRSystem/OVR.OpenVR._AcknowledgeQuit_UserPrompt.EndInvoke
void OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRSystem::_AcknowledgeQuit_UserPrompt*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetWindowBounds
#include "OVR/OpenVR/IVRExtendedDisplay__GetWindowBounds.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetWindowBounds.Invoke
void OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds::Invoke(ByRef<int> pnX, ByRef<int> pnY, ByRef<uint> pnWidth, ByRef<uint> pnHeight) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight));
}
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetWindowBounds.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds::BeginInvoke(ByRef<int> pnX, ByRef<int> pnY, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetWindowBounds.EndInvoke
void OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds::EndInvoke(ByRef<int> pnX, ByRef<int> pnY, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetWindowBounds*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetEyeOutputViewport
#include "OVR/OpenVR/IVRExtendedDisplay__GetEyeOutputViewport.hpp"
// Including type: OVR.OpenVR.EVREye
#include "OVR/OpenVR/EVREye.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetEyeOutputViewport.Invoke
void OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport::Invoke(::OVR::OpenVR::EVREye eEye, ByRef<uint> pnX, ByRef<uint> pnY, ByRef<uint> pnWidth, ByRef<uint> pnHeight) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, eEye, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight));
}
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetEyeOutputViewport.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport::BeginInvoke(::OVR::OpenVR::EVREye eEye, ByRef<uint> pnX, ByRef<uint> pnY, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eEye, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetEyeOutputViewport.EndInvoke
void OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport::EndInvoke(ByRef<uint> pnX, ByRef<uint> pnY, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetEyeOutputViewport*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetDXGIOutputInfo
#include "OVR/OpenVR/IVRExtendedDisplay__GetDXGIOutputInfo.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetDXGIOutputInfo.Invoke
void OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo::Invoke(ByRef<int> pnAdapterIndex, ByRef<int> pnAdapterOutputIndex) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pnAdapterIndex), byref(pnAdapterOutputIndex));
}
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetDXGIOutputInfo.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo::BeginInvoke(ByRef<int> pnAdapterIndex, ByRef<int> pnAdapterOutputIndex, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pnAdapterIndex), byref(pnAdapterOutputIndex), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRExtendedDisplay/OVR.OpenVR._GetDXGIOutputInfo.EndInvoke
void OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo::EndInvoke(ByRef<int> pnAdapterIndex, ByRef<int> pnAdapterOutputIndex, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRExtendedDisplay::_GetDXGIOutputInfo*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pnAdapterIndex), byref(pnAdapterOutputIndex), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraErrorNameFromEnum
#include "OVR/OpenVR/IVRTrackedCamera__GetCameraErrorNameFromEnum.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraErrorNameFromEnum.Invoke
::System::IntPtr OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum::Invoke(::OVR::OpenVR::EVRTrackedCameraError eCameraError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum*), 12));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, eCameraError);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraErrorNameFromEnum.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum::BeginInvoke(::OVR::OpenVR::EVRTrackedCameraError eCameraError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, eCameraError, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraErrorNameFromEnum.EndInvoke
::System::IntPtr OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraErrorNameFromEnum*), 14));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._HasCamera
#include "OVR/OpenVR/IVRTrackedCamera__HasCamera.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._HasCamera.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_HasCamera::Invoke(uint nDeviceIndex, ByRef<bool> pHasCamera) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_HasCamera::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_HasCamera*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, nDeviceIndex, byref(pHasCamera));
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._HasCamera.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_HasCamera::BeginInvoke(uint nDeviceIndex, ByRef<bool> pHasCamera, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_HasCamera::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_HasCamera*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, nDeviceIndex, byref(pHasCamera), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._HasCamera.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_HasCamera::EndInvoke(ByRef<bool> pHasCamera, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_HasCamera::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_HasCamera*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pHasCamera), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraFrameSize
#include "OVR/OpenVR/IVRTrackedCamera__GetCameraFrameSize.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraFrameType
#include "OVR/OpenVR/EVRTrackedCameraFrameType.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraFrameSize.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize::Invoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ByRef<uint> pnFrameBufferSize) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, nDeviceIndex, eFrameType, byref(pnWidth), byref(pnHeight), byref(pnFrameBufferSize));
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraFrameSize.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize::BeginInvoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ByRef<uint> pnFrameBufferSize, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, nDeviceIndex, eFrameType, byref(pnWidth), byref(pnHeight), byref(pnFrameBufferSize), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraFrameSize.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize::EndInvoke(ByRef<uint> pnWidth, ByRef<uint> pnHeight, ByRef<uint> pnFrameBufferSize, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraFrameSize*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pnWidth), byref(pnHeight), byref(pnFrameBufferSize), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraIntrinsics
#include "OVR/OpenVR/IVRTrackedCamera__GetCameraIntrinsics.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraFrameType
#include "OVR/OpenVR/EVRTrackedCameraFrameType.hpp"
// Including type: OVR.OpenVR.HmdVector2_t
#include "OVR/OpenVR/HmdVector2_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraIntrinsics.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics::Invoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<::OVR::OpenVR::HmdVector2_t> pFocalLength, ByRef<::OVR::OpenVR::HmdVector2_t> pCenter) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, nDeviceIndex, eFrameType, byref(pFocalLength), byref(pCenter));
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraIntrinsics.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics::BeginInvoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<::OVR::OpenVR::HmdVector2_t> pFocalLength, ByRef<::OVR::OpenVR::HmdVector2_t> pCenter, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, nDeviceIndex, eFrameType, byref(pFocalLength), byref(pCenter), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraIntrinsics.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics::EndInvoke(ByRef<::OVR::OpenVR::HmdVector2_t> pFocalLength, ByRef<::OVR::OpenVR::HmdVector2_t> pCenter, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraIntrinsics*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pFocalLength), byref(pCenter), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraProjection
#include "OVR/OpenVR/IVRTrackedCamera__GetCameraProjection.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraFrameType
#include "OVR/OpenVR/EVRTrackedCameraFrameType.hpp"
// Including type: OVR.OpenVR.HmdMatrix44_t
#include "OVR/OpenVR/HmdMatrix44_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraProjection.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection::Invoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, ByRef<::OVR::OpenVR::HmdMatrix44_t> pProjection) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, nDeviceIndex, eFrameType, flZNear, flZFar, byref(pProjection));
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraProjection.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection::BeginInvoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, ByRef<::OVR::OpenVR::HmdMatrix44_t> pProjection, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, nDeviceIndex, eFrameType, flZNear, flZFar, byref(pProjection), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetCameraProjection.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection::EndInvoke(ByRef<::OVR::OpenVR::HmdMatrix44_t> pProjection, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetCameraProjection*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pProjection), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._AcquireVideoStreamingService
#include "OVR/OpenVR/IVRTrackedCamera__AcquireVideoStreamingService.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._AcquireVideoStreamingService.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService::Invoke(uint nDeviceIndex, ByRef<uint64_t> pHandle) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, nDeviceIndex, byref(pHandle));
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._AcquireVideoStreamingService.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService::BeginInvoke(uint nDeviceIndex, ByRef<uint64_t> pHandle, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, nDeviceIndex, byref(pHandle), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._AcquireVideoStreamingService.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService::EndInvoke(ByRef<uint64_t> pHandle, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_AcquireVideoStreamingService*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pHandle), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamingService
#include "OVR/OpenVR/IVRTrackedCamera__ReleaseVideoStreamingService.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamingService.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService::Invoke(uint64_t hTrackedCamera) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, hTrackedCamera);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamingService.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService::BeginInvoke(uint64_t hTrackedCamera, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, hTrackedCamera, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamingService.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamingService*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamFrameBuffer
#include "OVR/OpenVR/IVRTrackedCamera__GetVideoStreamFrameBuffer.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraFrameType
#include "OVR/OpenVR/EVRTrackedCameraFrameType.hpp"
// Including type: OVR.OpenVR.CameraVideoStreamFrameHeader_t
#include "OVR/OpenVR/CameraVideoStreamFrameHeader_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamFrameBuffer.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer::Invoke(uint64_t hTrackedCamera, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ::System::IntPtr pFrameBuffer, uint nFrameBufferSize, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, uint nFrameHeaderSize) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, hTrackedCamera, eFrameType, pFrameBuffer, nFrameBufferSize, byref(pFrameHeader), nFrameHeaderSize);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamFrameBuffer.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer::BeginInvoke(uint64_t hTrackedCamera, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ::System::IntPtr pFrameBuffer, uint nFrameBufferSize, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, uint nFrameHeaderSize, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, hTrackedCamera, eFrameType, pFrameBuffer, nFrameBufferSize, byref(pFrameHeader), nFrameHeaderSize, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamFrameBuffer.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer::EndInvoke(ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamFrameBuffer*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pFrameHeader), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureSize
#include "OVR/OpenVR/IVRTrackedCamera__GetVideoStreamTextureSize.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraFrameType
#include "OVR/OpenVR/EVRTrackedCameraFrameType.hpp"
// Including type: OVR.OpenVR.VRTextureBounds_t
#include "OVR/OpenVR/VRTextureBounds_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureSize.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize::Invoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<::OVR::OpenVR::VRTextureBounds_t> pTextureBounds, ByRef<uint> pnWidth, ByRef<uint> pnHeight) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, nDeviceIndex, eFrameType, byref(pTextureBounds), byref(pnWidth), byref(pnHeight));
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureSize.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize::BeginInvoke(uint nDeviceIndex, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<::OVR::OpenVR::VRTextureBounds_t> pTextureBounds, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, nDeviceIndex, eFrameType, byref(pTextureBounds), byref(pnWidth), byref(pnHeight), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureSize.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize::EndInvoke(ByRef<::OVR::OpenVR::VRTextureBounds_t> pTextureBounds, ByRef<uint> pnWidth, ByRef<uint> pnHeight, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureSize*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pTextureBounds), byref(pnWidth), byref(pnHeight), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureD3D11
#include "OVR/OpenVR/IVRTrackedCamera__GetVideoStreamTextureD3D11.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraFrameType
#include "OVR/OpenVR/EVRTrackedCameraFrameType.hpp"
// Including type: OVR.OpenVR.CameraVideoStreamFrameHeader_t
#include "OVR/OpenVR/CameraVideoStreamFrameHeader_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureD3D11.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11::Invoke(uint64_t hTrackedCamera, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ::System::IntPtr pD3D11DeviceOrResource, ByRef<::System::IntPtr> ppD3D11ShaderResourceView, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, uint nFrameHeaderSize) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, hTrackedCamera, eFrameType, pD3D11DeviceOrResource, byref(ppD3D11ShaderResourceView), byref(pFrameHeader), nFrameHeaderSize);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureD3D11.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11::BeginInvoke(uint64_t hTrackedCamera, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ::System::IntPtr pD3D11DeviceOrResource, ByRef<::System::IntPtr> ppD3D11ShaderResourceView, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, uint nFrameHeaderSize, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, hTrackedCamera, eFrameType, pD3D11DeviceOrResource, byref(ppD3D11ShaderResourceView), byref(pFrameHeader), nFrameHeaderSize, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureD3D11.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11::EndInvoke(ByRef<::System::IntPtr> ppD3D11ShaderResourceView, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureD3D11*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(ppD3D11ShaderResourceView), byref(pFrameHeader), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureGL
#include "OVR/OpenVR/IVRTrackedCamera__GetVideoStreamTextureGL.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraFrameType
#include "OVR/OpenVR/EVRTrackedCameraFrameType.hpp"
// Including type: OVR.OpenVR.CameraVideoStreamFrameHeader_t
#include "OVR/OpenVR/CameraVideoStreamFrameHeader_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureGL.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL::Invoke(uint64_t hTrackedCamera, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<uint> pglTextureId, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, uint nFrameHeaderSize) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, hTrackedCamera, eFrameType, byref(pglTextureId), byref(pFrameHeader), nFrameHeaderSize);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureGL.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL::BeginInvoke(uint64_t hTrackedCamera, ::OVR::OpenVR::EVRTrackedCameraFrameType eFrameType, ByRef<uint> pglTextureId, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, uint nFrameHeaderSize, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, hTrackedCamera, eFrameType, byref(pglTextureId), byref(pFrameHeader), nFrameHeaderSize, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._GetVideoStreamTextureGL.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL::EndInvoke(ByRef<uint> pglTextureId, ByRef<::OVR::OpenVR::CameraVideoStreamFrameHeader_t> pFrameHeader, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_GetVideoStreamTextureGL*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, byref(pglTextureId), byref(pFrameHeader), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamTextureGL
#include "OVR/OpenVR/IVRTrackedCamera__ReleaseVideoStreamTextureGL.hpp"
// Including type: OVR.OpenVR.EVRTrackedCameraError
#include "OVR/OpenVR/EVRTrackedCameraError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamTextureGL.Invoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL::Invoke(uint64_t hTrackedCamera, uint glTextureId) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, hTrackedCamera, glTextureId);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamTextureGL.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL::BeginInvoke(uint64_t hTrackedCamera, uint glTextureId, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, hTrackedCamera, glTextureId, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRTrackedCamera/OVR.OpenVR._ReleaseVideoStreamTextureGL.EndInvoke
::OVR::OpenVR::EVRTrackedCameraError OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRTrackedCamera::_ReleaseVideoStreamTextureGL*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRTrackedCameraError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._AddApplicationManifest
#include "OVR/OpenVR/IVRApplications__AddApplicationManifest.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._AddApplicationManifest.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_AddApplicationManifest::Invoke(::StringW pchApplicationManifestFullPath, bool bTemporary) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_AddApplicationManifest::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_AddApplicationManifest*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchApplicationManifestFullPath, bTemporary);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._AddApplicationManifest.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_AddApplicationManifest::BeginInvoke(::StringW pchApplicationManifestFullPath, bool bTemporary, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_AddApplicationManifest::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_AddApplicationManifest*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchApplicationManifestFullPath, bTemporary, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._AddApplicationManifest.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_AddApplicationManifest::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_AddApplicationManifest::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_AddApplicationManifest*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._RemoveApplicationManifest
#include "OVR/OpenVR/IVRApplications__RemoveApplicationManifest.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._RemoveApplicationManifest.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_RemoveApplicationManifest::Invoke(::StringW pchApplicationManifestFullPath) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_RemoveApplicationManifest::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_RemoveApplicationManifest*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchApplicationManifestFullPath);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._RemoveApplicationManifest.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_RemoveApplicationManifest::BeginInvoke(::StringW pchApplicationManifestFullPath, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_RemoveApplicationManifest::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_RemoveApplicationManifest*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchApplicationManifestFullPath, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._RemoveApplicationManifest.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_RemoveApplicationManifest::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_RemoveApplicationManifest::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_RemoveApplicationManifest*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsApplicationInstalled
#include "OVR/OpenVR/IVRApplications__IsApplicationInstalled.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsApplicationInstalled.Invoke
bool OVR::OpenVR::IVRApplications::_IsApplicationInstalled::Invoke(::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IsApplicationInstalled::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IsApplicationInstalled*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsApplicationInstalled.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_IsApplicationInstalled::BeginInvoke(::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IsApplicationInstalled::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IsApplicationInstalled*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsApplicationInstalled.EndInvoke
bool OVR::OpenVR::IVRApplications::_IsApplicationInstalled::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IsApplicationInstalled::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IsApplicationInstalled*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationCount
#include "OVR/OpenVR/IVRApplications__GetApplicationCount.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationCount.Invoke
uint OVR::OpenVR::IVRApplications::_GetApplicationCount::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationCount::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationCount*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationCount.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationCount::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationCount::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationCount*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationCount.EndInvoke
uint OVR::OpenVR::IVRApplications::_GetApplicationCount::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationCount::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationCount*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByIndex
#include "OVR/OpenVR/IVRApplications__GetApplicationKeyByIndex.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByIndex.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex::Invoke(uint unApplicationIndex, ::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, unApplicationIndex, pchAppKeyBuffer, unAppKeyBufferLen);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByIndex.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex::BeginInvoke(uint unApplicationIndex, ::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unApplicationIndex, pchAppKeyBuffer, unAppKeyBufferLen, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByIndex.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationKeyByIndex*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByProcessId
#include "OVR/OpenVR/IVRApplications__GetApplicationKeyByProcessId.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByProcessId.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId::Invoke(uint unProcessId, ::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, unProcessId, pchAppKeyBuffer, unAppKeyBufferLen);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByProcessId.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId::BeginInvoke(uint unProcessId, ::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unProcessId, pchAppKeyBuffer, unAppKeyBufferLen, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationKeyByProcessId.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationKeyByProcessId*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplication
#include "OVR/OpenVR/IVRApplications__LaunchApplication.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplication.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchApplication::Invoke(::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchApplication::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchApplication*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplication.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_LaunchApplication::BeginInvoke(::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchApplication::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchApplication*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplication.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchApplication::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchApplication::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchApplication*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchTemplateApplication
#include "OVR/OpenVR/IVRApplications__LaunchTemplateApplication.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchTemplateApplication.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchTemplateApplication::Invoke(::StringW pchTemplateAppKey, ::StringW pchNewAppKey, ByRef<::ArrayW<::OVR::OpenVR::AppOverrideKeys_t>> pKeys, uint unKeys) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchTemplateApplication::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchTemplateApplication*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchTemplateAppKey, pchNewAppKey, byref(pKeys), unKeys);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchTemplateApplication.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_LaunchTemplateApplication::BeginInvoke(::StringW pchTemplateAppKey, ::StringW pchNewAppKey, ByRef<::ArrayW<::OVR::OpenVR::AppOverrideKeys_t>> pKeys, uint unKeys, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchTemplateApplication::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchTemplateApplication*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchTemplateAppKey, pchNewAppKey, byref(pKeys), unKeys, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchTemplateApplication.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchTemplateApplication::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchTemplateApplication::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchTemplateApplication*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplicationFromMimeType
#include "OVR/OpenVR/IVRApplications__LaunchApplicationFromMimeType.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplicationFromMimeType.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType::Invoke(::StringW pchMimeType, ::StringW pchArgs) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchMimeType, pchArgs);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplicationFromMimeType.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType::BeginInvoke(::StringW pchMimeType, ::StringW pchArgs, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchMimeType, pchArgs, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchApplicationFromMimeType.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchApplicationFromMimeType*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchDashboardOverlay
#include "OVR/OpenVR/IVRApplications__LaunchDashboardOverlay.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchDashboardOverlay.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay::Invoke(::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchDashboardOverlay.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay::BeginInvoke(::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchDashboardOverlay.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchDashboardOverlay*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._CancelApplicationLaunch
#include "OVR/OpenVR/IVRApplications__CancelApplicationLaunch.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._CancelApplicationLaunch.Invoke
bool OVR::OpenVR::IVRApplications::_CancelApplicationLaunch::Invoke(::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_CancelApplicationLaunch::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_CancelApplicationLaunch*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._CancelApplicationLaunch.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_CancelApplicationLaunch::BeginInvoke(::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_CancelApplicationLaunch::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_CancelApplicationLaunch*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._CancelApplicationLaunch.EndInvoke
bool OVR::OpenVR::IVRApplications::_CancelApplicationLaunch::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_CancelApplicationLaunch::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_CancelApplicationLaunch*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._IdentifyApplication
#include "OVR/OpenVR/IVRApplications__IdentifyApplication.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IdentifyApplication.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_IdentifyApplication::Invoke(uint unProcessId, ::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IdentifyApplication::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IdentifyApplication*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, unProcessId, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IdentifyApplication.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_IdentifyApplication::BeginInvoke(uint unProcessId, ::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IdentifyApplication::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IdentifyApplication*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unProcessId, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IdentifyApplication.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_IdentifyApplication::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IdentifyApplication::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IdentifyApplication*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationProcessId
#include "OVR/OpenVR/IVRApplications__GetApplicationProcessId.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationProcessId.Invoke
uint OVR::OpenVR::IVRApplications::_GetApplicationProcessId::Invoke(::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationProcessId::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationProcessId*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationProcessId.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationProcessId::BeginInvoke(::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationProcessId::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationProcessId*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationProcessId.EndInvoke
uint OVR::OpenVR::IVRApplications::_GetApplicationProcessId::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationProcessId::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationProcessId*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsErrorNameFromEnum
#include "OVR/OpenVR/IVRApplications__GetApplicationsErrorNameFromEnum.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsErrorNameFromEnum.Invoke
::System::IntPtr OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum::Invoke(::OVR::OpenVR::EVRApplicationError error) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum*), 12));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, error);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsErrorNameFromEnum.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum::BeginInvoke(::OVR::OpenVR::EVRApplicationError error, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, error, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsErrorNameFromEnum.EndInvoke
::System::IntPtr OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsErrorNameFromEnum*), 14));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyString
#include "OVR/OpenVR/IVRApplications__GetApplicationPropertyString.hpp"
// Including type: OVR.OpenVR.EVRApplicationProperty
#include "OVR/OpenVR/EVRApplicationProperty.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyString.Invoke
uint OVR::OpenVR::IVRApplications::_GetApplicationPropertyString::Invoke(::StringW pchAppKey, ::OVR::OpenVR::EVRApplicationProperty eProperty, ::System::Text::StringBuilder* pchPropertyValueBuffer, uint unPropertyValueBufferLen, ByRef<::OVR::OpenVR::EVRApplicationError> peError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyString::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyString*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, pchAppKey, eProperty, pchPropertyValueBuffer, unPropertyValueBufferLen, byref(peError));
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyString.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationPropertyString::BeginInvoke(::StringW pchAppKey, ::OVR::OpenVR::EVRApplicationProperty eProperty, ::System::Text::StringBuilder* pchPropertyValueBuffer, uint unPropertyValueBufferLen, ByRef<::OVR::OpenVR::EVRApplicationError> peError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyString::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyString*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, eProperty, pchPropertyValueBuffer, unPropertyValueBufferLen, byref(peError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyString.EndInvoke
uint OVR::OpenVR::IVRApplications::_GetApplicationPropertyString::EndInvoke(ByRef<::OVR::OpenVR::EVRApplicationError> peError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyString::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyString*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, byref(peError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyBool
#include "OVR/OpenVR/IVRApplications__GetApplicationPropertyBool.hpp"
// Including type: OVR.OpenVR.EVRApplicationProperty
#include "OVR/OpenVR/EVRApplicationProperty.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyBool.Invoke
bool OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool::Invoke(::StringW pchAppKey, ::OVR::OpenVR::EVRApplicationProperty eProperty, ByRef<::OVR::OpenVR::EVRApplicationError> peError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, pchAppKey, eProperty, byref(peError));
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyBool.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool::BeginInvoke(::StringW pchAppKey, ::OVR::OpenVR::EVRApplicationProperty eProperty, ByRef<::OVR::OpenVR::EVRApplicationError> peError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, eProperty, byref(peError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyBool.EndInvoke
bool OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool::EndInvoke(ByRef<::OVR::OpenVR::EVRApplicationError> peError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyBool*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(peError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyUint64
#include "OVR/OpenVR/IVRApplications__GetApplicationPropertyUint64.hpp"
// Including type: OVR.OpenVR.EVRApplicationProperty
#include "OVR/OpenVR/EVRApplicationProperty.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyUint64.Invoke
uint64_t OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64::Invoke(::StringW pchAppKey, ::OVR::OpenVR::EVRApplicationProperty eProperty, ByRef<::OVR::OpenVR::EVRApplicationError> peError) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint64_t, false>(this, ___internal__method, pchAppKey, eProperty, byref(peError));
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyUint64.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64::BeginInvoke(::StringW pchAppKey, ::OVR::OpenVR::EVRApplicationProperty eProperty, ByRef<::OVR::OpenVR::EVRApplicationError> peError, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, eProperty, byref(peError), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationPropertyUint64.EndInvoke
uint64_t OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64::EndInvoke(ByRef<::OVR::OpenVR::EVRApplicationError> peError, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationPropertyUint64*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint64_t, false>(this, ___internal__method, byref(peError), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetApplicationAutoLaunch
#include "OVR/OpenVR/IVRApplications__SetApplicationAutoLaunch.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetApplicationAutoLaunch.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch::Invoke(::StringW pchAppKey, bool bAutoLaunch) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchAppKey, bAutoLaunch);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetApplicationAutoLaunch.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch::BeginInvoke(::StringW pchAppKey, bool bAutoLaunch, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, bAutoLaunch, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetApplicationAutoLaunch.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_SetApplicationAutoLaunch*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationAutoLaunch
#include "OVR/OpenVR/IVRApplications__GetApplicationAutoLaunch.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationAutoLaunch.Invoke
bool OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch::Invoke(::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationAutoLaunch.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch::BeginInvoke(::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationAutoLaunch.EndInvoke
bool OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationAutoLaunch*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetDefaultApplicationForMimeType
#include "OVR/OpenVR/IVRApplications__SetDefaultApplicationForMimeType.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetDefaultApplicationForMimeType.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType::Invoke(::StringW pchAppKey, ::StringW pchMimeType) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchAppKey, pchMimeType);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetDefaultApplicationForMimeType.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType::BeginInvoke(::StringW pchAppKey, ::StringW pchMimeType, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, pchMimeType, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._SetDefaultApplicationForMimeType.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_SetDefaultApplicationForMimeType*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetDefaultApplicationForMimeType
#include "OVR/OpenVR/IVRApplications__GetDefaultApplicationForMimeType.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetDefaultApplicationForMimeType.Invoke
bool OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType::Invoke(::StringW pchMimeType, ::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, pchMimeType, pchAppKeyBuffer, unAppKeyBufferLen);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetDefaultApplicationForMimeType.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType::BeginInvoke(::StringW pchMimeType, ::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchMimeType, pchAppKeyBuffer, unAppKeyBufferLen, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetDefaultApplicationForMimeType.EndInvoke
bool OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetDefaultApplicationForMimeType*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationSupportedMimeTypes
#include "OVR/OpenVR/IVRApplications__GetApplicationSupportedMimeTypes.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationSupportedMimeTypes.Invoke
bool OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes::Invoke(::StringW pchAppKey, ::System::Text::StringBuilder* pchMimeTypesBuffer, uint unMimeTypesBuffer) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, pchAppKey, pchMimeTypesBuffer, unMimeTypesBuffer);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationSupportedMimeTypes.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes::BeginInvoke(::StringW pchAppKey, ::System::Text::StringBuilder* pchMimeTypesBuffer, uint unMimeTypesBuffer, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, pchMimeTypesBuffer, unMimeTypesBuffer, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationSupportedMimeTypes.EndInvoke
bool OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationSupportedMimeTypes*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsThatSupportMimeType
#include "OVR/OpenVR/IVRApplications__GetApplicationsThatSupportMimeType.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsThatSupportMimeType.Invoke
uint OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType::Invoke(::StringW pchMimeType, ::System::Text::StringBuilder* pchAppKeysThatSupportBuffer, uint unAppKeysThatSupportBuffer) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, pchMimeType, pchAppKeysThatSupportBuffer, unAppKeysThatSupportBuffer);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsThatSupportMimeType.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType::BeginInvoke(::StringW pchMimeType, ::System::Text::StringBuilder* pchAppKeysThatSupportBuffer, uint unAppKeysThatSupportBuffer, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchMimeType, pchAppKeysThatSupportBuffer, unAppKeysThatSupportBuffer, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsThatSupportMimeType.EndInvoke
uint OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsThatSupportMimeType*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationLaunchArguments
#include "OVR/OpenVR/IVRApplications__GetApplicationLaunchArguments.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationLaunchArguments.Invoke
uint OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments::Invoke(uint unHandle, ::System::Text::StringBuilder* pchArgs, uint unArgs) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, unHandle, pchArgs, unArgs);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationLaunchArguments.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments::BeginInvoke(uint unHandle, ::System::Text::StringBuilder* pchArgs, uint unArgs, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, unHandle, pchArgs, unArgs, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationLaunchArguments.EndInvoke
uint OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationLaunchArguments*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetStartingApplication
#include "OVR/OpenVR/IVRApplications__GetStartingApplication.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.Text.StringBuilder
#include "System/Text/StringBuilder.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetStartingApplication.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_GetStartingApplication::Invoke(::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetStartingApplication::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetStartingApplication*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchAppKeyBuffer, unAppKeyBufferLen);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetStartingApplication.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetStartingApplication::BeginInvoke(::System::Text::StringBuilder* pchAppKeyBuffer, uint unAppKeyBufferLen, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetStartingApplication::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetStartingApplication*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKeyBuffer, unAppKeyBufferLen, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetStartingApplication.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_GetStartingApplication::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetStartingApplication::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetStartingApplication*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetTransitionState
#include "OVR/OpenVR/IVRApplications__GetTransitionState.hpp"
// Including type: OVR.OpenVR.EVRApplicationTransitionState
#include "OVR/OpenVR/EVRApplicationTransitionState.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetTransitionState.Invoke
::OVR::OpenVR::EVRApplicationTransitionState OVR::OpenVR::IVRApplications::_GetTransitionState::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetTransitionState::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetTransitionState*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationTransitionState, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetTransitionState.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetTransitionState::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetTransitionState::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetTransitionState*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetTransitionState.EndInvoke
::OVR::OpenVR::EVRApplicationTransitionState OVR::OpenVR::IVRApplications::_GetTransitionState::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetTransitionState::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetTransitionState*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationTransitionState, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._PerformApplicationPrelaunchCheck
#include "OVR/OpenVR/IVRApplications__PerformApplicationPrelaunchCheck.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._PerformApplicationPrelaunchCheck.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck::Invoke(::StringW pchAppKey) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchAppKey);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._PerformApplicationPrelaunchCheck.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck::BeginInvoke(::StringW pchAppKey, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchAppKey, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._PerformApplicationPrelaunchCheck.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_PerformApplicationPrelaunchCheck*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsTransitionStateNameFromEnum
#include "OVR/OpenVR/IVRApplications__GetApplicationsTransitionStateNameFromEnum.hpp"
// Including type: OVR.OpenVR.EVRApplicationTransitionState
#include "OVR/OpenVR/EVRApplicationTransitionState.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsTransitionStateNameFromEnum.Invoke
::System::IntPtr OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum::Invoke(::OVR::OpenVR::EVRApplicationTransitionState state) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum*), 12));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, state);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsTransitionStateNameFromEnum.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum::BeginInvoke(::OVR::OpenVR::EVRApplicationTransitionState state, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, state, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetApplicationsTransitionStateNameFromEnum.EndInvoke
::System::IntPtr OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetApplicationsTransitionStateNameFromEnum*), 14));
return ::il2cpp_utils::RunMethodRethrow<::System::IntPtr, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsQuitUserPromptRequested
#include "OVR/OpenVR/IVRApplications__IsQuitUserPromptRequested.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsQuitUserPromptRequested.Invoke
bool OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsQuitUserPromptRequested.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._IsQuitUserPromptRequested.EndInvoke
bool OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_IsQuitUserPromptRequested*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchInternalProcess
#include "OVR/OpenVR/IVRApplications__LaunchInternalProcess.hpp"
// Including type: OVR.OpenVR.EVRApplicationError
#include "OVR/OpenVR/EVRApplicationError.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchInternalProcess.Invoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchInternalProcess::Invoke(::StringW pchBinaryPath, ::StringW pchArguments, ::StringW pchWorkingDirectory) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchInternalProcess::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchInternalProcess*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, pchBinaryPath, pchArguments, pchWorkingDirectory);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchInternalProcess.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_LaunchInternalProcess::BeginInvoke(::StringW pchBinaryPath, ::StringW pchArguments, ::StringW pchWorkingDirectory, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchInternalProcess::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchInternalProcess*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, pchBinaryPath, pchArguments, pchWorkingDirectory, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._LaunchInternalProcess.EndInvoke
::OVR::OpenVR::EVRApplicationError OVR::OpenVR::IVRApplications::_LaunchInternalProcess::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_LaunchInternalProcess::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_LaunchInternalProcess*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::EVRApplicationError, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetCurrentSceneProcessId
#include "OVR/OpenVR/IVRApplications__GetCurrentSceneProcessId.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetCurrentSceneProcessId.Invoke
uint OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId*), 12));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetCurrentSceneProcessId.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRApplications/OVR.OpenVR._GetCurrentSceneProcessId.EndInvoke
uint OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRApplications::_GetCurrentSceneProcessId*), 14));
return ::il2cpp_utils::RunMethodRethrow<uint, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetCalibrationState
#include "OVR/OpenVR/IVRChaperone__GetCalibrationState.hpp"
// Including type: OVR.OpenVR.ChaperoneCalibrationState
#include "OVR/OpenVR/ChaperoneCalibrationState.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetCalibrationState.Invoke
::OVR::OpenVR::ChaperoneCalibrationState OVR::OpenVR::IVRChaperone::_GetCalibrationState::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetCalibrationState::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetCalibrationState*), 12));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::ChaperoneCalibrationState, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetCalibrationState.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_GetCalibrationState::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetCalibrationState::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetCalibrationState*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetCalibrationState.EndInvoke
::OVR::OpenVR::ChaperoneCalibrationState OVR::OpenVR::IVRChaperone::_GetCalibrationState::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetCalibrationState::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetCalibrationState*), 14));
return ::il2cpp_utils::RunMethodRethrow<::OVR::OpenVR::ChaperoneCalibrationState, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaSize
#include "OVR/OpenVR/IVRChaperone__GetPlayAreaSize.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaSize.Invoke
bool OVR::OpenVR::IVRChaperone::_GetPlayAreaSize::Invoke(ByRef<float> pSizeX, ByRef<float> pSizeZ) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetPlayAreaSize::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetPlayAreaSize*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pSizeX), byref(pSizeZ));
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaSize.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_GetPlayAreaSize::BeginInvoke(ByRef<float> pSizeX, ByRef<float> pSizeZ, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetPlayAreaSize::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetPlayAreaSize*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pSizeX), byref(pSizeZ), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaSize.EndInvoke
bool OVR::OpenVR::IVRChaperone::_GetPlayAreaSize::EndInvoke(ByRef<float> pSizeX, ByRef<float> pSizeZ, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetPlayAreaSize::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetPlayAreaSize*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pSizeX), byref(pSizeZ), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaRect
#include "OVR/OpenVR/IVRChaperone__GetPlayAreaRect.hpp"
// Including type: OVR.OpenVR.HmdQuad_t
#include "OVR/OpenVR/HmdQuad_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaRect.Invoke
bool OVR::OpenVR::IVRChaperone::_GetPlayAreaRect::Invoke(ByRef<::OVR::OpenVR::HmdQuad_t> rect) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetPlayAreaRect::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetPlayAreaRect*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(rect));
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaRect.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_GetPlayAreaRect::BeginInvoke(ByRef<::OVR::OpenVR::HmdQuad_t> rect, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetPlayAreaRect::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetPlayAreaRect*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(rect), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetPlayAreaRect.EndInvoke
bool OVR::OpenVR::IVRChaperone::_GetPlayAreaRect::EndInvoke(ByRef<::OVR::OpenVR::HmdQuad_t> rect, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetPlayAreaRect::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetPlayAreaRect*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(rect), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ReloadInfo
#include "OVR/OpenVR/IVRChaperone__ReloadInfo.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ReloadInfo.Invoke
void OVR::OpenVR::IVRChaperone::_ReloadInfo::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_ReloadInfo::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_ReloadInfo*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ReloadInfo.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_ReloadInfo::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_ReloadInfo::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_ReloadInfo*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ReloadInfo.EndInvoke
void OVR::OpenVR::IVRChaperone::_ReloadInfo::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_ReloadInfo::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_ReloadInfo*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._SetSceneColor
#include "OVR/OpenVR/IVRChaperone__SetSceneColor.hpp"
// Including type: OVR.OpenVR.HmdColor_t
#include "OVR/OpenVR/HmdColor_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._SetSceneColor.Invoke
void OVR::OpenVR::IVRChaperone::_SetSceneColor::Invoke(::OVR::OpenVR::HmdColor_t color) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_SetSceneColor::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_SetSceneColor*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, color);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._SetSceneColor.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_SetSceneColor::BeginInvoke(::OVR::OpenVR::HmdColor_t color, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_SetSceneColor::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_SetSceneColor*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, color, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._SetSceneColor.EndInvoke
void OVR::OpenVR::IVRChaperone::_SetSceneColor::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_SetSceneColor::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_SetSceneColor*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetBoundsColor
#include "OVR/OpenVR/IVRChaperone__GetBoundsColor.hpp"
// Including type: OVR.OpenVR.HmdColor_t
#include "OVR/OpenVR/HmdColor_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetBoundsColor.Invoke
void OVR::OpenVR::IVRChaperone::_GetBoundsColor::Invoke(ByRef<::OVR::OpenVR::HmdColor_t> pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, ByRef<::OVR::OpenVR::HmdColor_t> pOutputCameraColor) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetBoundsColor::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetBoundsColor*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pOutputColorArray), nNumOutputColors, flCollisionBoundsFadeDistance, byref(pOutputCameraColor));
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetBoundsColor.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_GetBoundsColor::BeginInvoke(ByRef<::OVR::OpenVR::HmdColor_t> pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, ByRef<::OVR::OpenVR::HmdColor_t> pOutputCameraColor, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetBoundsColor::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetBoundsColor*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pOutputColorArray), nNumOutputColors, flCollisionBoundsFadeDistance, byref(pOutputCameraColor), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._GetBoundsColor.EndInvoke
void OVR::OpenVR::IVRChaperone::_GetBoundsColor::EndInvoke(ByRef<::OVR::OpenVR::HmdColor_t> pOutputColorArray, ByRef<::OVR::OpenVR::HmdColor_t> pOutputCameraColor, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_GetBoundsColor::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_GetBoundsColor*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, byref(pOutputColorArray), byref(pOutputCameraColor), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._AreBoundsVisible
#include "OVR/OpenVR/IVRChaperone__AreBoundsVisible.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._AreBoundsVisible.Invoke
bool OVR::OpenVR::IVRChaperone::_AreBoundsVisible::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_AreBoundsVisible::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_AreBoundsVisible*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._AreBoundsVisible.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_AreBoundsVisible::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_AreBoundsVisible::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_AreBoundsVisible*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._AreBoundsVisible.EndInvoke
bool OVR::OpenVR::IVRChaperone::_AreBoundsVisible::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_AreBoundsVisible::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_AreBoundsVisible*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ForceBoundsVisible
#include "OVR/OpenVR/IVRChaperone__ForceBoundsVisible.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ForceBoundsVisible.Invoke
void OVR::OpenVR::IVRChaperone::_ForceBoundsVisible::Invoke(bool bForce) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_ForceBoundsVisible::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_ForceBoundsVisible*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, bForce);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ForceBoundsVisible.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperone::_ForceBoundsVisible::BeginInvoke(bool bForce, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_ForceBoundsVisible::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_ForceBoundsVisible*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, bForce, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperone/OVR.OpenVR._ForceBoundsVisible.EndInvoke
void OVR::OpenVR::IVRChaperone::_ForceBoundsVisible::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperone::_ForceBoundsVisible::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperone::_ForceBoundsVisible*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._CommitWorkingCopy
#include "OVR/OpenVR/IVRChaperoneSetup__CommitWorkingCopy.hpp"
// Including type: OVR.OpenVR.EChaperoneConfigFile
#include "OVR/OpenVR/EChaperoneConfigFile.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._CommitWorkingCopy.Invoke
bool OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy::Invoke(::OVR::OpenVR::EChaperoneConfigFile configFile) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, configFile);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._CommitWorkingCopy.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy::BeginInvoke(::OVR::OpenVR::EChaperoneConfigFile configFile, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, configFile, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._CommitWorkingCopy.EndInvoke
bool OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_CommitWorkingCopy*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._RevertWorkingCopy
#include "OVR/OpenVR/IVRChaperoneSetup__RevertWorkingCopy.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._RevertWorkingCopy.Invoke
void OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy::Invoke() {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy*), 12));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._RevertWorkingCopy.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy::BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._RevertWorkingCopy.EndInvoke
void OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy::EndInvoke(::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_RevertWorkingCopy*), 14));
::il2cpp_utils::RunMethodRethrow<void, false>(this, ___internal__method, result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaSize
#include "OVR/OpenVR/IVRChaperoneSetup__GetWorkingPlayAreaSize.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaSize.Invoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize::Invoke(ByRef<float> pSizeX, ByRef<float> pSizeZ) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pSizeX), byref(pSizeZ));
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaSize.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize::BeginInvoke(ByRef<float> pSizeX, ByRef<float> pSizeZ, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pSizeX), byref(pSizeZ), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaSize.EndInvoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize::EndInvoke(ByRef<float> pSizeX, ByRef<float> pSizeZ, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaSize*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pSizeX), byref(pSizeZ), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaRect
#include "OVR/OpenVR/IVRChaperoneSetup__GetWorkingPlayAreaRect.hpp"
// Including type: OVR.OpenVR.HmdQuad_t
#include "OVR/OpenVR/HmdQuad_t.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaRect.Invoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect::Invoke(ByRef<::OVR::OpenVR::HmdQuad_t> rect) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(rect));
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaRect.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect::BeginInvoke(ByRef<::OVR::OpenVR::HmdQuad_t> rect, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(rect), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingPlayAreaRect.EndInvoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect::EndInvoke(ByRef<::OVR::OpenVR::HmdQuad_t> rect, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingPlayAreaRect*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(rect), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingCollisionBoundsInfo
#include "OVR/OpenVR/IVRChaperoneSetup__GetWorkingCollisionBoundsInfo.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingCollisionBoundsInfo.Invoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo::Invoke(ByRef<::ArrayW<::OVR::OpenVR::HmdQuad_t>> pQuadsBuffer, ByRef<uint> punQuadsCount) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pQuadsBuffer), byref(punQuadsCount));
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingCollisionBoundsInfo.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo::BeginInvoke(ByRef<::ArrayW<::OVR::OpenVR::HmdQuad_t>> pQuadsBuffer, ByRef<uint> punQuadsCount, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pQuadsBuffer), byref(punQuadsCount), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetWorkingCollisionBoundsInfo.EndInvoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo::EndInvoke(ByRef<uint> punQuadsCount, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetWorkingCollisionBoundsInfo*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(punQuadsCount), result);
}
// Autogenerated from CppSourceCreator
// Created by Sc2ad
// =========================================================================
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
// Including type: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetLiveCollisionBoundsInfo
#include "OVR/OpenVR/IVRChaperoneSetup__GetLiveCollisionBoundsInfo.hpp"
// Including type: System.IAsyncResult
#include "System/IAsyncResult.hpp"
// Including type: System.AsyncCallback
#include "System/AsyncCallback.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetLiveCollisionBoundsInfo.Invoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo::Invoke(ByRef<::ArrayW<::OVR::OpenVR::HmdQuad_t>> pQuadsBuffer, ByRef<uint> punQuadsCount) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo::Invoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo*), 12));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(pQuadsBuffer), byref(punQuadsCount));
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetLiveCollisionBoundsInfo.BeginInvoke
::System::IAsyncResult* OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo::BeginInvoke(ByRef<::ArrayW<::OVR::OpenVR::HmdQuad_t>> pQuadsBuffer, ByRef<uint> punQuadsCount, ::System::AsyncCallback* callback, ::Il2CppObject* object) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo::BeginInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo*), 13));
return ::il2cpp_utils::RunMethodRethrow<::System::IAsyncResult*, false>(this, ___internal__method, byref(pQuadsBuffer), byref(punQuadsCount), callback, object);
}
// Autogenerated method: OVR.OpenVR.IVRChaperoneSetup/OVR.OpenVR._GetLiveCollisionBoundsInfo.EndInvoke
bool OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo::EndInvoke(ByRef<uint> punQuadsCount, ::System::IAsyncResult* result) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo::EndInvoke");
auto* ___internal__method = THROW_UNLESS(::il2cpp_utils::ResolveVtableSlot(this, classof(::OVR::OpenVR::IVRChaperoneSetup::_GetLiveCollisionBoundsInfo*), 14));
return ::il2cpp_utils::RunMethodRethrow<bool, false>(this, ___internal__method, byref(punQuadsCount), result);
}
| 266,481 | 94,175 |
double power(double x, int n)
{
double result = 1;
for (int i = 0; i < n; i++) {
result *= x;
}
return result;
} | 136 | 54 |
// Generated by Haxe 4.2.1+bf9ff69
#include <hxcpp.h>
#ifndef INCLUDED_flixel_input_actions_ResetPolicy
#include <flixel/input/actions/ResetPolicy.h>
#endif
namespace flixel{
namespace input{
namespace actions{
::flixel::input::actions::ResetPolicy ResetPolicy_obj::ALL_SETS;
::flixel::input::actions::ResetPolicy ResetPolicy_obj::DEFAULT_SET_ONLY;
::flixel::input::actions::ResetPolicy ResetPolicy_obj::NONE;
bool ResetPolicy_obj::__GetStatic(const ::String &inName, ::Dynamic &outValue, ::hx::PropertyAccess inCallProp)
{
if (inName==HX_("ALL_SETS",cf,1d,70,2b)) { outValue = ResetPolicy_obj::ALL_SETS; return true; }
if (inName==HX_("DEFAULT_SET_ONLY",27,e9,a0,b6)) { outValue = ResetPolicy_obj::DEFAULT_SET_ONLY; return true; }
if (inName==HX_("NONE",b8,da,ca,33)) { outValue = ResetPolicy_obj::NONE; return true; }
return super::__GetStatic(inName, outValue, inCallProp);
}
HX_DEFINE_CREATE_ENUM(ResetPolicy_obj)
int ResetPolicy_obj::__FindIndex(::String inName)
{
if (inName==HX_("ALL_SETS",cf,1d,70,2b)) return 1;
if (inName==HX_("DEFAULT_SET_ONLY",27,e9,a0,b6)) return 2;
if (inName==HX_("NONE",b8,da,ca,33)) return 0;
return super::__FindIndex(inName);
}
int ResetPolicy_obj::__FindArgCount(::String inName)
{
if (inName==HX_("ALL_SETS",cf,1d,70,2b)) return 0;
if (inName==HX_("DEFAULT_SET_ONLY",27,e9,a0,b6)) return 0;
if (inName==HX_("NONE",b8,da,ca,33)) return 0;
return super::__FindArgCount(inName);
}
::hx::Val ResetPolicy_obj::__Field(const ::String &inName,::hx::PropertyAccess inCallProp)
{
if (inName==HX_("ALL_SETS",cf,1d,70,2b)) return ALL_SETS;
if (inName==HX_("DEFAULT_SET_ONLY",27,e9,a0,b6)) return DEFAULT_SET_ONLY;
if (inName==HX_("NONE",b8,da,ca,33)) return NONE;
return super::__Field(inName,inCallProp);
}
static ::String ResetPolicy_obj_sStaticFields[] = {
HX_("NONE",b8,da,ca,33),
HX_("ALL_SETS",cf,1d,70,2b),
HX_("DEFAULT_SET_ONLY",27,e9,a0,b6),
::String(null())
};
::hx::Class ResetPolicy_obj::__mClass;
Dynamic __Create_ResetPolicy_obj() { return new ResetPolicy_obj; }
void ResetPolicy_obj::__register()
{
::hx::Static(__mClass) = ::hx::_hx_RegisterClass(HX_("flixel.input.actions.ResetPolicy",1a,a2,1d,33), ::hx::TCanCast< ResetPolicy_obj >,ResetPolicy_obj_sStaticFields,0,
&__Create_ResetPolicy_obj, &__Create,
&super::__SGetClass(), &CreateResetPolicy_obj, 0
#ifdef HXCPP_VISIT_ALLOCS
, 0
#endif
#ifdef HXCPP_SCRIPTABLE
, 0
#endif
);
__mClass->mGetStaticField = &ResetPolicy_obj::__GetStatic;
}
void ResetPolicy_obj::__boot()
{
ALL_SETS = ::hx::CreateConstEnum< ResetPolicy_obj >(HX_("ALL_SETS",cf,1d,70,2b),1);
DEFAULT_SET_ONLY = ::hx::CreateConstEnum< ResetPolicy_obj >(HX_("DEFAULT_SET_ONLY",27,e9,a0,b6),2);
NONE = ::hx::CreateConstEnum< ResetPolicy_obj >(HX_("NONE",b8,da,ca,33),0);
}
} // end namespace flixel
} // end namespace input
} // end namespace actions
| 2,854 | 1,272 |
// Time Complexity: O((m - n * k) * n * k) ~ O(m * n * k), where m is string length, n is dict size, k is word length
// Space Complexity: O( n * k)
class Solution {
public:
vector<int> findSubstring(string s, vector<string> &dict) {
const size_t wordLength = dict.front().length();
const size_t catLength = wordLength * dict.size();
vector<int> result;
if(s.length() < catLength) return result;
unordered_map<string, int> wordCount;
for(auto const & word : dict) ++wordCount[word];
for(auto i = begin(s); i <= prev(end(s), catLength); ++i) {
unordered_map<string, int> unused(wordCount);
for(auto j = i; j != next(i, catLength); j += wordLength) {
auto pos = unused.find(string(j, next(j, wordLength)));
if(pos == unused.end()) break;
if(--pos->second == 0) unused.erase(pos);
}
if(unused.size() == 0) result.push_back(distance(begin(s), i));
}
return result;
}
};
| 1,127 | 346 |
#include "mesh_generation/hexcore.h"
#include "core/math/aabb.h"
#include "core/container/tvector.h"
#include "mesh_generation/point_octotree.h"
#include <set>
struct HexcoreCell {
u64 morton;
uint depth; //todo could compute this implicitly, but probably more error prone
bool front;
union {
HexcoreCell* parent;
HexcoreCell* next_free;
};
HexcoreCell* children;
};
const uint CHUNK_SIZE = mb(50);
HexcoreCell* alloc_8_hexcore_cell(HexcoreCell** pool) {
if (!*pool) {
*pool = (HexcoreCell*)calloc(1,CHUNK_SIZE);
uint n = CHUNK_SIZE / (8 * sizeof(HexcoreCell));
for (uint i = 0; i < n - 1; i++) {
(*pool)[i * 8].next_free = *pool + (i + 1) * 8;
}
(*pool)[(n - 1) * 8].next_free = nullptr;
}
HexcoreCell* current = *pool;
*pool = current->next_free;
return current;
}
void hexcore_to_mesh(CFDVolume& volume, HexcoreCell* root, const AABB& aabb) {
struct Data {
AABB aabb;
HexcoreCell* cells;
};
tvector<Data> stack;
stack.append({ aabb, root->children });
while (stack.length > 0) {
Data data = stack.pop();
AABB child_aabbs[8];
subdivide_aabb(data.aabb, child_aabbs);
for (uint i = 0; i < 8; i++) {
if (!data.cells[i].children) {
if (!data.cells[i].front) continue;
uint subdivision = 1;
vec3 dx = child_aabbs[i].size() / subdivision;
for (uint x = 0; x < subdivision; x++) {
for (uint y = 0; y < subdivision; y++) {
for (uint z = 0; z < subdivision; z++) {
AABB aabb;
aabb.min = child_aabbs[i].min + vec3(x, y, z) * dx;
aabb.max = aabb.min + dx;
glm::vec3 points[8];
aabb.to_verts(points);
CFDCell cell{ CFDCell::HEXAHEDRON };
for (uint j = 0; j < 8; j++) {
cell.vertices[j] = { (int)volume.vertices.length };
volume.vertices.append({ points[j] });
}
volume.cells.append(cell);
}
}
}
}
else {
stack.append({ child_aabbs[i], data.cells[i].children });
}
}
}
}
#define MORTON_MASK(depth, i) ((u64)(i) << (depth-1)*3)
#define MORTON_AXIS(depth, k) ((u64)(1) << ((depth-1)*3+k))
// Assumes little endian
void printBits(size_t const size, void const* const ptr)
{
unsigned char* b = (unsigned char*)ptr;
unsigned char byte;
int i, j;
for (i = size - 1; i >= 0; i--) {
for (j = 7; j >= 0; j--) {
byte = (b[i] >> j) & 1;
printf("%u", byte);
}
}
puts("");
}
void build_hexcore(HexcoreCell** pool, HexcoreCell* root, PointOctotree& octo) {
struct Data {
HexcoreCell* parent;
HexcoreCell* cells;
PointOctotree::Payload* payload;
};
root->children = alloc_8_hexcore_cell(pool);
tvector<Data> stack;
stack.append({ root, root->children, octo.root.p });
while (stack.length > 0) {
Data data = stack.pop();
HexcoreCell* cells = data.cells;
u64 morton = data.parent->morton;
uint depth = data.parent->depth + 1;
for (uint i = 0; i < 8; i++) {
auto& subdivision = data.payload->children[i];
u64 child_morton = morton | MORTON_MASK(depth, i);
cells[i].morton = child_morton;
cells[i].parent = data.parent;
cells[i].depth = depth;
if (subdivision.count <= PointOctotree::MAX_PER_CELL) {
cells[i].children = nullptr;
cells[i].front = subdivision.count > 0;
}
else {
cells[i].children = alloc_8_hexcore_cell(pool);
stack.append({ cells + i, cells[i].children, subdivision.p });
}
}
}
}
struct HexRefinementQueue {
vector<HexcoreCell*> refine;
std::set<u64> morton_codes;
};
u64 neighbor_code(u64 morton, uint depth, uint k, uint* f) {
u64 mask = MORTON_AXIS(depth, k);
bool b = morton & mask;
u64 neighbor = morton ^ mask;
for (uint i = depth - 1; i > 0; i--) {
u64 mask = MORTON_AXIS(i, k);
neighbor ^= mask;
if (b != bool(morton & mask)) {
*f = i;
return neighbor;
}
}
return UINT64_MAX;
}
HexcoreCell* find_cell(HexcoreCell* start, u64 neighbor, uint max_depth, uint f) {
if (neighbor == UINT64_MAX) return nullptr;
HexcoreCell* current = start;
while (current && current->depth >= f) { //(current->morton & morton) != current->morton ) {
current = current->parent;
}
if (!current) return nullptr;
while (current->children && current->depth < max_depth) {
uint index = (neighbor >> 3 * current->depth) & (1 << 3) - 1;
current = current->children + index;
}
if (current->children) return nullptr;
return current;
}
void refine_children_if_needed(HexRefinementQueue& queue, HexcoreCell* children, uint n) {
for (uint i = 0; i < n; i++) {
HexcoreCell& cell = children[i];
if (!cell.front) continue;
uint depth = cell.depth;
u64 morton = cell.morton;
for (uint k = 0; k < 3; k++) {
uint f;
u64 neighbor = neighbor_code(morton, depth, k, &f);
HexcoreCell* neighbor_cell = find_cell(cell.parent, neighbor, depth, f);
if (!neighbor_cell) continue;
if (neighbor_cell->front) continue;
if (queue.morton_codes.find(neighbor_cell->morton) != queue.morton_codes.end()) continue;
//neighbor_cell->depth >= depth - 1 ||
queue.refine.append(neighbor_cell);
queue.morton_codes.insert(neighbor_cell->morton);
}
}
}
void balance_hexcore(HexcoreCell* root, HexcoreCell** pool) {
struct Data {
HexcoreCell* cells;
};
HexRefinementQueue queue;
tvector<Data> stack;
uint target_subdivision = 4;
uint count = 0;
while (count++ < 0) {
stack.append({ root->children });
while (stack.length > 0) {
Data data = stack.pop();
for (uint i = 0; i < 8; i++) {
HexcoreCell& cell = data.cells[i];
if (cell.children) {
stack.append({ cell.children });
continue;
}
refine_children_if_needed(queue, &cell, 1);
}
}
if (queue.refine.length == 0) break;
while (queue.refine.length > 0) {
HexcoreCell* cell = queue.refine.pop();
cell->children = alloc_8_hexcore_cell(pool);
uint depth = cell->depth + 1;
for (uint i = 0; i < 8; i++) {
cell->children[i].parent = cell;
cell->children[i].depth = depth;
cell->children[i].morton = cell->morton | MORTON_MASK(depth, i);
cell->children[i].children = 0;
cell->children[i].front = true;
if (depth < target_subdivision) {
//queue.refine.append(cell->children + i);
}
}
}
queue.refine.clear();
queue.morton_codes.clear();
}
}
void hexcore(PointOctotree& octo, CFDVolume& volume, CFDDebugRenderer& debug) {
HexcoreCell* pool = nullptr;
HexcoreCell root = {};
build_hexcore(&pool, &root, octo);
balance_hexcore(&root, &pool);
hexcore_to_mesh(volume, &root, octo.root.aabb);
} | 7,867 | 2,661 |
// Copyright 2019 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 "services/device/public/cpp/hid/fake_hid_manager.h"
#include <memory>
#include <utility>
#include "base/guid.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/device/public/cpp/hid/hid_blocklist.h"
namespace device {
FakeHidConnection::FakeHidConnection(
mojom::HidDeviceInfoPtr device,
mojo::PendingReceiver<mojom::HidConnection> receiver,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
mojo::PendingRemote<mojom::HidConnectionWatcher> watcher)
: receiver_(this, std::move(receiver)),
device_(std::move(device)),
watcher_(std::move(watcher)) {
receiver_.set_disconnect_handler(base::BindOnce(
[](FakeHidConnection* self) { delete self; }, base::Unretained(this)));
if (watcher_) {
watcher_.set_disconnect_handler(base::BindOnce(
[](FakeHidConnection* self) { delete self; }, base::Unretained(this)));
}
if (connection_client)
client_.Bind(std::move(connection_client));
}
FakeHidConnection::~FakeHidConnection() = default;
// mojom::HidConnection implementation:
void FakeHidConnection::Read(ReadCallback callback) {
const char kResult[] = "This is a HID input report.";
uint8_t report_id = device_->has_report_id ? 1 : 0;
std::vector<uint8_t> buffer(kResult, kResult + sizeof(kResult) - 1);
std::move(callback).Run(true, report_id, buffer);
}
void FakeHidConnection::Write(uint8_t report_id,
const std::vector<uint8_t>& buffer,
WriteCallback callback) {
const char kExpected[] = "o-report"; // 8 bytes
if (buffer.size() != sizeof(kExpected) - 1) {
std::move(callback).Run(false);
return;
}
int expected_report_id = device_->has_report_id ? 1 : 0;
if (report_id != expected_report_id) {
std::move(callback).Run(false);
return;
}
if (memcmp(buffer.data(), kExpected, sizeof(kExpected) - 1) != 0) {
std::move(callback).Run(false);
return;
}
std::move(callback).Run(true);
}
void FakeHidConnection::GetFeatureReport(uint8_t report_id,
GetFeatureReportCallback callback) {
uint8_t expected_report_id = device_->has_report_id ? 1 : 0;
if (report_id != expected_report_id) {
std::move(callback).Run(false, base::nullopt);
return;
}
const char kResult[] = "This is a HID feature report.";
std::vector<uint8_t> buffer;
if (device_->has_report_id)
buffer.push_back(report_id);
buffer.insert(buffer.end(), kResult, kResult + sizeof(kResult) - 1);
std::move(callback).Run(true, buffer);
}
void FakeHidConnection::SendFeatureReport(uint8_t report_id,
const std::vector<uint8_t>& buffer,
SendFeatureReportCallback callback) {
const char kExpected[] = "The app is setting this HID feature report.";
if (buffer.size() != sizeof(kExpected) - 1) {
std::move(callback).Run(false);
return;
}
int expected_report_id = device_->has_report_id ? 1 : 0;
if (report_id != expected_report_id) {
std::move(callback).Run(false);
return;
}
if (memcmp(buffer.data(), kExpected, sizeof(kExpected) - 1) != 0) {
std::move(callback).Run(false);
return;
}
std::move(callback).Run(true);
}
// Implementation of FakeHidManager.
FakeHidManager::FakeHidManager() = default;
FakeHidManager::~FakeHidManager() = default;
void FakeHidManager::Bind(mojo::PendingReceiver<mojom::HidManager> receiver) {
receivers_.Add(this, std::move(receiver));
}
// mojom::HidManager implementation:
void FakeHidManager::AddReceiver(
mojo::PendingReceiver<mojom::HidManager> receiver) {
Bind(std::move(receiver));
}
void FakeHidManager::GetDevicesAndSetClient(
mojo::PendingAssociatedRemote<mojom::HidManagerClient> client,
GetDevicesCallback callback) {
GetDevices(std::move(callback));
if (!client.is_valid())
return;
clients_.Add(std::move(client));
}
void FakeHidManager::GetDevices(GetDevicesCallback callback) {
std::vector<mojom::HidDeviceInfoPtr> device_list;
for (auto& map_entry : devices_)
device_list.push_back(map_entry.second->Clone());
std::move(callback).Run(std::move(device_list));
}
void FakeHidManager::Connect(
const std::string& device_guid,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
mojo::PendingRemote<mojom::HidConnectionWatcher> watcher,
bool allow_protected_reports,
ConnectCallback callback) {
if (!base::Contains(devices_, device_guid)) {
std::move(callback).Run(mojo::NullRemote());
return;
}
mojo::PendingRemote<mojom::HidConnection> connection;
// FakeHidConnection is self-owned.
new FakeHidConnection(devices_[device_guid]->Clone(),
connection.InitWithNewPipeAndPassReceiver(),
std::move(connection_client), std::move(watcher));
std::move(callback).Run(std::move(connection));
}
mojom::HidDeviceInfoPtr FakeHidManager::CreateAndAddDevice(
const std::string& physical_device_id,
uint16_t vendor_id,
uint16_t product_id,
const std::string& product_name,
const std::string& serial_number,
mojom::HidBusType bus_type) {
return CreateAndAddDeviceWithTopLevelUsage(
physical_device_id, vendor_id, product_id, product_name, serial_number,
bus_type, /*usage_page=*/0xff00,
/*usage=*/0x0001);
}
mojom::HidDeviceInfoPtr FakeHidManager::CreateAndAddDeviceWithTopLevelUsage(
const std::string& physical_device_id,
uint16_t vendor_id,
uint16_t product_id,
const std::string& product_name,
const std::string& serial_number,
mojom::HidBusType bus_type,
uint16_t usage_page,
uint16_t usage) {
auto collection = mojom::HidCollectionInfo::New();
collection->usage = mojom::HidUsageAndPage::New(usage, usage_page);
collection->collection_type = mojom::kHIDCollectionTypeApplication;
collection->input_reports.push_back(mojom::HidReportDescription::New());
auto device = mojom::HidDeviceInfo::New();
device->guid = base::GenerateGUID();
device->physical_device_id = physical_device_id;
device->vendor_id = vendor_id;
device->product_id = product_id;
device->product_name = product_name;
device->serial_number = serial_number;
device->bus_type = bus_type;
device->collections.push_back(std::move(collection));
device->protected_input_report_ids =
HidBlocklist::Get().GetProtectedReportIds(HidBlocklist::kReportTypeInput,
vendor_id, product_id,
device->collections);
device->protected_output_report_ids =
HidBlocklist::Get().GetProtectedReportIds(HidBlocklist::kReportTypeOutput,
vendor_id, product_id,
device->collections);
device->protected_feature_report_ids =
HidBlocklist::Get().GetProtectedReportIds(
HidBlocklist::kReportTypeFeature, vendor_id, product_id,
device->collections);
AddDevice(device.Clone());
return device;
}
void FakeHidManager::AddDevice(mojom::HidDeviceInfoPtr device) {
std::string guid = device->guid;
DCHECK(!base::Contains(devices_, guid));
devices_[guid] = std::move(device);
const mojom::HidDeviceInfoPtr& device_info = devices_[guid];
for (auto& client : clients_)
client->DeviceAdded(device_info->Clone());
}
void FakeHidManager::RemoveDevice(const std::string& guid) {
if (base::Contains(devices_, guid)) {
const mojom::HidDeviceInfoPtr& device_info = devices_[guid];
for (auto& client : clients_)
client->DeviceRemoved(device_info->Clone());
devices_.erase(guid);
}
}
void FakeHidManager::ChangeDevice(mojom::HidDeviceInfoPtr device) {
DCHECK(base::Contains(devices_, device->guid));
mojom::HidDeviceInfoPtr& device_info = devices_[device->guid];
device_info = std::move(device);
for (auto& client : clients_)
client->DeviceChanged(device_info->Clone());
}
void FakeHidManager::SimulateConnectionError() {
clients_.Clear();
receivers_.Clear();
}
} // namespace device
| 8,384 | 2,801 |
/**
* @file AffichageReseau.hpp
* @brief Déclaration de la classe AffichageReseau.
*
* @author Johann RAMANANDRAISIORY
* @date 2021
**/
#ifndef AFFICHAGERESEAU_H
#define AFFICHAGERESEAU_H
#include "Contexte.hpp"
#include <QApplication>
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>
#include <QtCharts>
using namespace QtCharts;
class AffichageReseau : public QHBoxLayout
{
Q_OBJECT
private:
// Attributs
AffichageReseau();
QPushButton* m_Image;
QChartView* m_Vue;
QChart* m_Graphique;
std::vector<QLineSeries*> m_Lignes;
QHBoxLayout* m_Layout;
public:
// Singleton
static AffichageReseau& GetInstance() {
static AffichageReseau singleton;
return singleton;
}
// Méthodes de copie
AffichageReseau(AffichageReseau&) = delete;
void operator=(AffichageReseau&) = delete;
// Destructeur
~AffichageReseau();
// Methodes
void configSimple();
void configMaison();
void configPme();
void configEntreprise();
void initialiserGraphe();
void rafraichirGraphe();
void sauvegarderGraphe(const QString& nomFichier);
private slots :
// Méthode Slots
void informationsReseau();
};
#endif // AFFICHAGERESEAU_H
| 1,413 | 481 |
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <memory>
#include <string>
#include <vector>
#include "base/bind.h"
#include "base/callback.h"
#include "base/check.h"
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/hash/sha1.h"
#include "base/memory/scoped_refptr.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ash/certificate_provider/certificate_provider.h"
#include "chrome/browser/ash/certificate_provider/certificate_provider_service.h"
#include "chrome/browser/ash/certificate_provider/certificate_provider_service_factory.h"
#include "chrome/browser/ash/certificate_provider/test_certificate_provider_extension.h"
#include "chrome/browser/chromeos/ui/request_pin_view.h"
#include "chrome/browser/extensions/api/certificate_provider/certificate_provider_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "crypto/rsa_private_key.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/test_background_page_first_load_observer.h"
#include "net/cert/x509_certificate.h"
#include "net/http/http_status_code.h"
#include "net/ssl/client_cert_identity.h"
#include "net/ssl/ssl_config.h"
#include "net/ssl/ssl_server_config.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/boringssl/src/include/openssl/base.h"
#include "third_party/boringssl/src/include/openssl/digest.h"
#include "third_party/boringssl/src/include/openssl/evp.h"
#include "third_party/boringssl/src/include/openssl/mem.h"
#include "third_party/boringssl/src/include/openssl/pool.h"
#include "third_party/boringssl/src/include/openssl/rsa.h"
#include "third_party/boringssl/src/include/openssl/ssl.h"
#include "ui/gfx/color_palette.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
using testing::Return;
using testing::_;
namespace {
void StoreDigest(std::vector<uint8_t>* digest,
base::OnceClosure callback,
base::Value value) {
ASSERT_TRUE(value.is_blob()) << "Unexpected value in StoreDigest";
digest->assign(value.GetBlob().begin(), value.GetBlob().end());
std::move(callback).Run();
}
bool RsaSignRawData(uint16_t openssl_signature_algorithm,
const std::vector<uint8_t>& input,
crypto::RSAPrivateKey* key,
std::vector<uint8_t>* signature) {
const EVP_MD* const digest_algorithm =
SSL_get_signature_algorithm_digest(openssl_signature_algorithm);
bssl::ScopedEVP_MD_CTX ctx;
EVP_PKEY_CTX* pkey_ctx = nullptr;
if (!EVP_DigestSignInit(ctx.get(), &pkey_ctx, digest_algorithm,
/*ENGINE* e=*/nullptr, key->key()))
return false;
if (SSL_is_signature_algorithm_rsa_pss(openssl_signature_algorithm)) {
// For RSA-PSS, configure the special padding and set the salt length to be
// equal to the hash size.
if (!EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) ||
!EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, /*salt_len=*/-1)) {
return false;
}
}
size_t sig_len = 0;
// Determine the signature length for the buffer.
if (!EVP_DigestSign(ctx.get(), /*out_sig=*/nullptr, &sig_len, input.data(),
input.size()))
return false;
signature->resize(sig_len);
return EVP_DigestSign(ctx.get(), signature->data(), &sig_len, input.data(),
input.size()) != 0;
}
bool RsaSignPrehashed(uint16_t openssl_signature_algorithm,
const std::vector<uint8_t>& digest,
crypto::RSAPrivateKey* key,
std::vector<uint8_t>* signature) {
// RSA-PSS is not supported for prehashed data.
EXPECT_FALSE(SSL_is_signature_algorithm_rsa_pss(openssl_signature_algorithm));
RSA* rsa_key = EVP_PKEY_get0_RSA(key->key());
if (!rsa_key)
return false;
const int digest_algorithm_nid = EVP_MD_type(
SSL_get_signature_algorithm_digest(openssl_signature_algorithm));
unsigned len = 0;
signature->resize(RSA_size(rsa_key));
if (!RSA_sign(digest_algorithm_nid, digest.data(), digest.size(),
signature->data(), &len, rsa_key)) {
signature->clear();
return false;
}
signature->resize(len);
return true;
}
// Create a string that if evaluated in JavaScript returns a Uint8Array with
// |bytes| as content.
std::string JsUint8Array(const std::vector<uint8_t>& bytes) {
std::string res = "new Uint8Array([";
for (const uint8_t byte : bytes) {
res += base::NumberToString(byte);
res += ", ";
}
res += "])";
return res;
}
std::string GetPageTextContent(content::WebContents* web_contents) {
std::string text_content;
EXPECT_TRUE(content::ExecuteScriptAndExtractString(
web_contents->GetMainFrame(),
"domAutomationController.send(document.body.textContent);",
&text_content));
return text_content;
}
std::string GetCertFingerprint1(const net::X509Certificate& cert) {
unsigned char hash[base::kSHA1Length];
base::SHA1HashBytes(CRYPTO_BUFFER_data(cert.cert_buffer()),
CRYPTO_BUFFER_len(cert.cert_buffer()), hash);
return base::ToLowerASCII(base::HexEncode(hash, base::kSHA1Length));
}
class CertificateProviderApiTest : public extensions::ExtensionApiTest {
public:
CertificateProviderApiTest() {}
void SetUpInProcessBrowserTestFixture() override {
ON_CALL(provider_, IsInitializationComplete(_)).WillByDefault(Return(true));
ON_CALL(provider_, IsFirstPolicyLoadComplete(_))
.WillByDefault(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
extensions::ExtensionApiTest::SetUpInProcessBrowserTestFixture();
}
void SetUpOnMainThread() override {
extensions::ExtensionApiTest::SetUpOnMainThread();
// Set up the AutoSelectCertificateForUrls policy to avoid the client
// certificate selection dialog.
const std::string autoselect_pattern = R"({"pattern": "*", "filter": {}})";
base::Value autoselect_policy(base::Value::Type::LIST);
autoselect_policy.Append(autoselect_pattern);
policy_map_.Set(policy::key::kAutoSelectCertificateForUrls,
policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
policy::POLICY_SOURCE_CLOUD, std::move(autoselect_policy),
nullptr);
provider_.UpdateChromePolicy(policy_map_);
content::RunAllPendingInMessageLoop();
cert_provider_service_ =
chromeos::CertificateProviderServiceFactory::GetForBrowserContext(
profile());
}
// Starts an HTTPS test server that requests a client certificate.
bool StartHttpsServer(uint16_t ssl_protocol_version) {
net::SSLServerConfig ssl_server_config;
ssl_server_config.client_cert_type =
net::SSLServerConfig::REQUIRE_CLIENT_CERT;
ssl_server_config.version_max = ssl_protocol_version;
https_server_ = std::make_unique<net::EmbeddedTestServer>(
net::EmbeddedTestServer::TYPE_HTTPS);
https_server_->SetSSLConfig(net::EmbeddedTestServer::CERT_OK,
ssl_server_config);
https_server_->RegisterRequestHandler(
base::BindRepeating(&CertificateProviderApiTest::OnHttpsServerRequested,
base::Unretained(this)));
return https_server_->Start();
}
void CheckCertificateProvidedByExtension(
const net::X509Certificate& certificate,
const extensions::Extension& extension) {
bool is_currently_provided = false;
std::string provider_extension_id;
cert_provider_service_->LookUpCertificate(
certificate, &is_currently_provided, &provider_extension_id);
EXPECT_TRUE(is_currently_provided);
EXPECT_EQ(provider_extension_id, extension.id());
}
void CheckCertificateAbsent(const net::X509Certificate& certificate) {
bool is_currently_provided = true;
std::string provider_extension_id;
cert_provider_service_->LookUpCertificate(
certificate, &is_currently_provided, &provider_extension_id);
EXPECT_FALSE(is_currently_provided);
}
std::vector<scoped_refptr<net::X509Certificate>>
GetAllProvidedCertificates() {
base::RunLoop run_loop;
std::unique_ptr<chromeos::CertificateProvider> cert_provider =
cert_provider_service_->CreateCertificateProvider();
std::vector<scoped_refptr<net::X509Certificate>> all_provided_certificates;
auto callback = base::BindLambdaForTesting(
[&](net::ClientCertIdentityList cert_identity_list) {
for (const auto& cert_identity : cert_identity_list)
all_provided_certificates.push_back(cert_identity->certificate());
});
cert_provider->GetCertificates(callback.Then(run_loop.QuitClosure()));
run_loop.Run();
return all_provided_certificates;
}
GURL GetHttpsClientCertUrl() const {
return https_server_->GetURL(kClientCertUrl);
}
protected:
testing::NiceMock<policy::MockConfigurationPolicyProvider> provider_;
chromeos::CertificateProviderService* cert_provider_service_ = nullptr;
policy::PolicyMap policy_map_;
private:
const char* const kClientCertUrl = "/client-cert";
std::unique_ptr<net::test_server::HttpResponse> OnHttpsServerRequested(
const net::test_server::HttpRequest& request) const {
if (request.relative_url != kClientCertUrl)
return nullptr;
auto response = std::make_unique<net::test_server::BasicHttpResponse>();
if (!request.ssl_info || !request.ssl_info->cert) {
response->set_code(net::HTTP_FORBIDDEN);
return response;
}
response->set_content("got client cert with fingerprint: " +
GetCertFingerprint1(*request.ssl_info->cert));
response->set_content_type("text/plain");
return response;
}
std::unique_ptr<net::EmbeddedTestServer> https_server_;
};
// Tests the API with a test extension in place. Tests can cause the extension
// to trigger API calls.
class CertificateProviderApiMockedExtensionTest
: public CertificateProviderApiTest {
public:
void SetUpOnMainThread() override {
CertificateProviderApiTest::SetUpOnMainThread();
extension_path_ = test_data_dir_.AppendASCII("certificate_provider");
extension_ = LoadExtension(extension_path_);
ui_test_utils::NavigateToURL(browser(),
extension_->GetResourceURL("basic.html"));
extension_contents_ = browser()->tab_strip_model()->GetActiveWebContents();
std::string raw_certificate = GetCertificateData();
std::vector<uint8_t> certificate_bytes(raw_certificate.begin(),
raw_certificate.end());
ExecuteJavascript("initialize(" + JsUint8Array(certificate_bytes) + ");");
}
content::RenderFrameHost* GetExtensionMainFrame() const {
return extension_contents_->GetMainFrame();
}
void ExecuteJavascript(const std::string& function) const {
ASSERT_TRUE(content::ExecuteScript(GetExtensionMainFrame(), function));
}
// Calls |function| in the extension. |function| needs to return a bool. If
// that happens at the end of a callback, this will wait for the callback to
// complete.
void ExecuteJavascriptAndWaitForCallback(const std::string& function) const {
bool success = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(GetExtensionMainFrame(),
function, &success));
ASSERT_TRUE(success);
}
const extensions::Extension* extension() const { return extension_; }
std::string GetKeyPk8() const {
std::string key_pk8;
base::ScopedAllowBlockingForTesting allow_io;
EXPECT_TRUE(base::ReadFileToString(
extension_path_.AppendASCII("l1_leaf.pk8"), &key_pk8));
return key_pk8;
}
// Returns the certificate stored in
// chrome/test/data/extensions/api_test/certificate_provider
scoped_refptr<net::X509Certificate> GetCertificate() const {
std::string raw_certificate = GetCertificateData();
return net::X509Certificate::CreateFromBytes(raw_certificate.data(),
raw_certificate.size());
}
// Tests the api by navigating to a webpage that requests to perform a
// signature operation with the available certificate.
// This signs the request using the algorithm specified by
// `openssl_signature_algorithm`, with additionally hashing it if
// `is_raw_data` is true, and replies to the page.
void TestNavigationToCertificateRequestingWebPage(
const std::string& expected_request_signature_algorithm,
uint16_t openssl_signature_algorithm,
bool is_raw_data) {
content::TestNavigationObserver navigation_observer(
nullptr /* no WebContents */);
navigation_observer.StartWatchingNewWebContents();
ExtensionTestMessageListener sign_digest_listener(
"signature request received", /*will_reply=*/false);
// Navigate to a page which triggers a sign request. Navigation is blocked
// by completion of this request, so we don't wait for navigation to finish.
ui_test_utils::NavigateToURLWithDisposition(
browser(), GetHttpsClientCertUrl(),
WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_NONE);
content::WebContents* const https_contents =
browser()->tab_strip_model()->GetActiveWebContents();
// Wait for the extension to receive the sign request.
ASSERT_TRUE(sign_digest_listener.WaitUntilSatisfied());
// Check that the certificate is available.
scoped_refptr<net::X509Certificate> certificate = GetCertificate();
CheckCertificateProvidedByExtension(*certificate, *extension());
// Fetch the data from the sign request.
const std::string request_algorithm =
ExecuteScriptAndGetValue(GetExtensionMainFrame(),
"signatureRequestAlgorithm;")
.GetString();
EXPECT_EQ(expected_request_signature_algorithm, request_algorithm);
std::vector<uint8_t> request_data;
{
base::RunLoop run_loop;
GetExtensionMainFrame()->ExecuteJavaScriptForTests(
base::ASCIIToUTF16("signatureRequestData;"),
base::BindOnce(&StoreDigest, &request_data, run_loop.QuitClosure()));
run_loop.Run();
}
// Load the private key.
std::string key_pk8 = GetKeyPk8();
std::unique_ptr<crypto::RSAPrivateKey> key(
crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(
base::as_bytes(base::make_span(key_pk8))));
ASSERT_TRUE(key);
// Sign using the private key.
std::vector<uint8_t> signature;
if (is_raw_data) {
EXPECT_TRUE(RsaSignRawData(openssl_signature_algorithm, request_data,
key.get(), &signature));
} else {
EXPECT_TRUE(RsaSignPrehashed(openssl_signature_algorithm, request_data,
key.get(), &signature));
}
// Inject the signature back to the extension and let it reply.
ExecuteJavascript("replyWithSignature(" + JsUint8Array(signature) + ");");
// Wait for the https navigation to finish.
navigation_observer.Wait();
// Check whether the server acknowledged that a client certificate was
// presented.
const std::string client_cert_fingerprint =
GetCertFingerprint1(*certificate);
EXPECT_EQ(GetPageTextContent(https_contents),
"got client cert with fingerprint: " + client_cert_fingerprint);
}
private:
std::string GetCertificateData() const {
const base::FilePath certificate_path =
test_data_dir_.AppendASCII("certificate_provider")
.AppendASCII("l1_leaf.der");
std::string certificate_data;
base::ScopedAllowBlockingForTesting allow_io;
EXPECT_TRUE(base::ReadFileToString(certificate_path, &certificate_data));
return certificate_data;
}
content::WebContents* extension_contents_ = nullptr;
const extensions::Extension* extension_ = nullptr;
base::FilePath extension_path_;
};
class CertificateProviderRequestPinTest : public CertificateProviderApiTest {
protected:
static constexpr int kFakeSignRequestId = 123;
static constexpr int kWrongPinAttemptsLimit = 3;
static constexpr const char* kCorrectPin = "1234";
static constexpr const char* kWrongPin = "567";
void SetUpOnMainThread() override {
CertificateProviderApiTest::SetUpOnMainThread();
command_request_listener_ = std::make_unique<ExtensionTestMessageListener>(
"GetCommand", /*will_reply=*/true);
LoadRequestPinExtension();
}
void TearDownOnMainThread() override {
if (command_request_listener_->was_satisfied()) {
// Avoid destroying a non-replied extension function without.
command_request_listener_->Reply(/*message=*/std::string());
}
command_request_listener_.reset();
CertificateProviderApiTest::TearDownOnMainThread();
}
std::string pin_request_extension_id() const { return extension_->id(); }
void AddFakeSignRequest(int sign_request_id) {
cert_provider_service_->pin_dialog_manager()->AddSignRequestId(
extension_->id(), sign_request_id, {});
}
void NavigateTo(const std::string& test_page_file_name) {
ui_test_utils::NavigateToURL(
browser(), extension_->GetResourceURL(test_page_file_name));
}
chromeos::RequestPinView* GetActivePinDialogView() {
return cert_provider_service_->pin_dialog_manager()
->default_dialog_host_for_testing()
->active_view_for_testing();
}
views::Widget* GetActivePinDialogWindow() {
return cert_provider_service_->pin_dialog_manager()
->default_dialog_host_for_testing()
->active_window_for_testing();
}
// Enters the code in the ShowPinDialog window and pushes the OK event.
void EnterCode(const std::string& code) {
GetActivePinDialogView()->textfield_for_testing()->SetText(
base::ASCIIToUTF16(code));
GetActivePinDialogView()->Accept();
base::RunLoop().RunUntilIdle();
}
// Enters the valid code for extensions from local example folders, in the
// ShowPinDialog window and waits for the window to close. The extension code
// is expected to send "Success" message after the validation and request to
// stopPinRequest is done.
void EnterCorrectPinAndWaitForMessage() {
ExtensionTestMessageListener listener("Success", false);
EnterCode(kCorrectPin);
ASSERT_TRUE(listener.WaitUntilSatisfied());
}
// Enters an invalid code for extensions from local example folders, in the
// ShowPinDialog window and waits for the window to update with the error. The
// extension code is expected to send "Invalid PIN" message after the
// validation and the new requestPin (with the error) is done.
void EnterWrongPinAndWaitForMessage() {
ExtensionTestMessageListener listener("Invalid PIN", false);
EnterCode(kWrongPin);
ASSERT_TRUE(listener.WaitUntilSatisfied());
// Check that we have an error message displayed.
EXPECT_EQ(
gfx::kGoogleRed600,
GetActivePinDialogView()->error_label_for_testing()->GetEnabledColor());
}
bool SendCommand(const std::string& command) {
if (!command_request_listener_->WaitUntilSatisfied())
return false;
command_request_listener_->Reply(command);
command_request_listener_->Reset();
return true;
}
bool SendCommandAndWaitForMessage(const std::string& command,
const std::string& expected_message) {
ExtensionTestMessageListener listener(expected_message,
/*will_reply=*/false);
if (!SendCommand(command))
return false;
return listener.WaitUntilSatisfied();
}
private:
void LoadRequestPinExtension() {
const base::FilePath extension_path =
test_data_dir_.AppendASCII("certificate_provider/request_pin");
extension_ = LoadExtension(extension_path);
}
const extensions::Extension* extension_ = nullptr;
std::unique_ptr<ExtensionTestMessageListener> command_request_listener_;
};
} // namespace
// Tests an extension that only provides certificates in response to the
// onCertificatesUpdateRequested event.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
ResponsiveExtension) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("registerAsCertificateProvider();");
ExecuteJavascript("registerForSignatureRequests();");
TestNavigationToCertificateRequestingWebPage(
"RSASSA_PKCS1_v1_5_SHA1", SSL_SIGN_RSA_PKCS1_SHA1, /*is_raw_data=*/true);
}
// Tests an extension that only provides certificates in response to the
// legacy onCertificatesRequested event.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
LegacyResponsiveExtension) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
TestNavigationToCertificateRequestingWebPage("SHA1", SSL_SIGN_RSA_PKCS1_SHA1,
/*is_raw_data=*/false);
}
// Tests that signing a request twice in response to the legacy
// onSignDigestRequested event will fail.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
LegacyExtensionSigningTwice) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
// This causes a signature request that will be replied to.
TestNavigationToCertificateRequestingWebPage("SHA1", SSL_SIGN_RSA_PKCS1_SHA1,
/*is_raw_data=*/false);
// Replying to the signature request a second time must fail.
bool success = true;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
GetExtensionMainFrame(), "replyWithSignatureSecondTime();", &success));
ASSERT_FALSE(success);
}
// Tests an extension that provides certificates both proactively with
// setCertificates() and in response to onCertificatesUpdateRequested.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
ProactiveAndResponsiveExtension) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("registerAsCertificateProvider();");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
scoped_refptr<net::X509Certificate> certificate = GetCertificate();
CheckCertificateProvidedByExtension(*certificate, *extension());
TestNavigationToCertificateRequestingWebPage(
"RSASSA_PKCS1_v1_5_SHA1", SSL_SIGN_RSA_PKCS1_SHA1, /*is_raw_data=*/true);
// Remove the certificate.
ExecuteJavascriptAndWaitForCallback("unsetCertificates();");
CheckCertificateAbsent(*certificate);
}
// Tests an extension that provides certificates both proactively with
// setCertificates() and in response to the legacy onCertificatesRequested.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
ProactiveAndLegacyResponsiveExtension) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
scoped_refptr<net::X509Certificate> certificate = GetCertificate();
CheckCertificateProvidedByExtension(*certificate, *extension());
TestNavigationToCertificateRequestingWebPage("SHA1", SSL_SIGN_RSA_PKCS1_SHA1,
/*is_raw_data=*/false);
// Remove the certificate.
ExecuteJavascriptAndWaitForCallback("unsetCertificates();");
CheckCertificateAbsent(*certificate);
}
// Tests an extension that provides certificates both proactively with
// setCertificates() and in response to both events:
// onCertificatesUpdateRequested and legacy onCertificatesRequested. Verify that
// the non-legacy signature event is used.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
ProactiveAndRedundantLegacyResponsiveExtension) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("registerAsCertificateProvider();");
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascript("registerForLegacySignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
scoped_refptr<net::X509Certificate> certificate = GetCertificate();
CheckCertificateProvidedByExtension(*certificate, *extension());
TestNavigationToCertificateRequestingWebPage(
"RSASSA_PKCS1_v1_5_SHA1", SSL_SIGN_RSA_PKCS1_SHA1, /*is_raw_data=*/true);
// Remove the certificate.
ExecuteJavascriptAndWaitForCallback("unsetCertificates();");
CheckCertificateAbsent(*certificate);
}
// Tests an extension that only provides certificates proactively via
// setCertificates().
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
ProactiveExtension) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
scoped_refptr<net::X509Certificate> certificate = GetCertificate();
CheckCertificateProvidedByExtension(*certificate, *extension());
EXPECT_EQ(GetAllProvidedCertificates().size(), 1U);
TestNavigationToCertificateRequestingWebPage(
"RSASSA_PKCS1_v1_5_SHA1", SSL_SIGN_RSA_PKCS1_SHA1, /*is_raw_data=*/true);
// Remove the certificate.
ExecuteJavascriptAndWaitForCallback("unsetCertificates();");
CheckCertificateAbsent(*certificate);
EXPECT_TRUE(GetAllProvidedCertificates().empty());
}
// Tests that all of invalid certificates are rejected.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
OnlyInvalidCertificates) {
ExecuteJavascriptAndWaitForCallback("setInvalidCertificates();");
EXPECT_TRUE(GetAllProvidedCertificates().empty());
}
// Tests the RSA MD5/SHA-1 signature algorithm. Note that TLS 1.1 is used in
// order to make this algorithm employed.
// TODO(cthomp): The SSLVersionMin policy will be removed in M-91, making these
// algorithms unsupported.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest, RsaMd5Sha1) {
// This test requires the SSLVersionMin policy is set to allow TLS 1.0.
base::Value ssl_policy("tls1"); // TLS 1.0
policy_map_.Set(policy::key::kSSLVersionMin, policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_CLOUD,
std::move(ssl_policy), nullptr);
EXPECT_NO_FATAL_FAILURE(provider_.UpdateChromePolicy(policy_map_));
// Wait for the updated SSL configuration to be sent to the network service,
// to avoid a race.
g_browser_process->system_network_context_manager()
->FlushSSLConfigManagerForTesting();
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_1));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PKCS1_v1_5_MD5_SHA1'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PKCS1_v1_5_MD5_SHA1",
SSL_SIGN_RSA_PKCS1_MD5_SHA1,
/*is_raw_data=*/true);
}
// Tests the RSA MD5/SHA-1 signature algorithm using the legacy version of the
// API. Note that TLS 1.1 is used in order to make this algorithm employed.
// TODO(cthomp): The SSLVersionMin policy will be removed in M-91, making these
// algorithms unsupported.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
LegacyRsaMd5Sha1) {
// This test requires the SSLVersionMin policy is set to allow TLS 1.0.
base::Value ssl_policy("tls1"); // TLS 1.0
policy_map_.Set(policy::key::kSSLVersionMin, policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_CLOUD,
std::move(ssl_policy), nullptr);
EXPECT_NO_FATAL_FAILURE(provider_.UpdateChromePolicy(policy_map_));
// Wait for the updated SSL configuration to be sent to the network service,
// to avoid a race.
g_browser_process->system_network_context_manager()
->FlushSSLConfigManagerForTesting();
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_1));
ExecuteJavascript("supportedLegacyHashes = ['MD5_SHA1'];");
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
TestNavigationToCertificateRequestingWebPage("MD5_SHA1",
SSL_SIGN_RSA_PKCS1_MD5_SHA1,
/*is_raw_data=*/false);
}
// Tests the RSA SHA-1 signature algorithm.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest, RsaSha1) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PKCS1_v1_5_SHA1'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PKCS1_v1_5_SHA1",
SSL_SIGN_RSA_PKCS1_SHA1,
/*is_raw_data=*/true);
}
// Tests the RSA SHA-1 signature algorithm using the legacy version of the API.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
LegacyRsaSha1) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedLegacyHashes = ['SHA1'];");
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
TestNavigationToCertificateRequestingWebPage("SHA1", SSL_SIGN_RSA_PKCS1_SHA1,
/*is_raw_data=*/false);
}
// Tests the RSA SHA-256 signature algorithm.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest, RsaSha256) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PKCS1_v1_5_SHA256'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PKCS1_v1_5_SHA256",
SSL_SIGN_RSA_PKCS1_SHA256,
/*is_raw_data=*/true);
}
// Tests the RSA SHA-256 signature algorithm using the legacy version of the
// API.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
LegacyRsaSha256) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedLegacyHashes = ['SHA256'];");
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
TestNavigationToCertificateRequestingWebPage("SHA256",
SSL_SIGN_RSA_PKCS1_SHA256,
/*is_raw_data=*/false);
}
// Tests the RSA SHA-384 signature algorithm.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest, RsaSha384) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PKCS1_v1_5_SHA384'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PKCS1_v1_5_SHA384",
SSL_SIGN_RSA_PKCS1_SHA384,
/*is_raw_data=*/true);
}
// Tests the RSA SHA-384 signature algorithm using the legacy version of the
// API.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
LegacyRsaSha384) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedLegacyHashes = ['SHA384'];");
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
TestNavigationToCertificateRequestingWebPage("SHA384",
SSL_SIGN_RSA_PKCS1_SHA384,
/*is_raw_data=*/false);
}
// Tests the RSA SHA-512 signature algorithm.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest, RsaSha512) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PKCS1_v1_5_SHA512'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PKCS1_v1_5_SHA512",
SSL_SIGN_RSA_PKCS1_SHA512,
/*is_raw_data=*/true);
}
// Tests the RSA SHA-512 signature algorithm using the legacy version of the
// API.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
LegacyRsaSha512) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript("supportedLegacyHashes = ['SHA512'];");
ExecuteJavascript("registerAsLegacyCertificateProvider();");
ExecuteJavascript("registerForLegacySignatureRequests();");
TestNavigationToCertificateRequestingWebPage("SHA512",
SSL_SIGN_RSA_PKCS1_SHA512,
/*is_raw_data=*/false);
}
// Tests that the RSA SHA-512 signature algorithm is still used when there are
// other, less strong, algorithms specified after it.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
RsaSha512AndOthers) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
ExecuteJavascript(
"supportedAlgorithms = ['RSASSA_PKCS1_v1_5_SHA512', "
"'RSASSA_PKCS1_v1_5_SHA1', 'RSASSA_PKCS1_v1_5_MD5_SHA1'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PKCS1_v1_5_SHA512",
SSL_SIGN_RSA_PKCS1_SHA512,
/*is_raw_data=*/true);
}
// Tests that the RSA MD5/SHA-1 signature algorithm is used in case of TLS 1.1,
// even when there are other algorithms specified (which are stronger but aren't
// supported on TLS 1.1).
// TODO(cthomp): The SSLVersionMin policy will be removed in M-91, making these
// algorithms unsupported.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
RsaMd5Sha1AndOthers) {
// This test requires the SSLVersionMin policy is set to allow TLS 1.0.
base::Value ssl_policy("tls1"); // TLS 1.0
policy_map_.Set(policy::key::kSSLVersionMin, policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_CLOUD,
std::move(ssl_policy), nullptr);
EXPECT_NO_FATAL_FAILURE(provider_.UpdateChromePolicy(policy_map_));
// Wait for the updated SSL configuration to be sent to the network service,
// to avoid a race.
g_browser_process->system_network_context_manager()
->FlushSSLConfigManagerForTesting();
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_1));
ExecuteJavascript(
"supportedAlgorithms = ['RSASSA_PKCS1_v1_5_SHA512', "
"'RSASSA_PKCS1_v1_5_SHA1', 'RSASSA_PKCS1_v1_5_MD5_SHA1'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PKCS1_v1_5_MD5_SHA1",
SSL_SIGN_RSA_PKCS1_MD5_SHA1,
/*is_raw_data=*/true);
}
// Tests the RSA-PSS SHA-256 signature algorithm.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
RsaPssSha256) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_3));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PSS_SHA256'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PSS_SHA256",
SSL_SIGN_RSA_PSS_RSAE_SHA256,
/*is_raw_data=*/true);
}
// Tests the RSA-PSS SHA-384 signature algorithm.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
RsaPssSha384) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_3));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PSS_SHA384'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PSS_SHA384",
SSL_SIGN_RSA_PSS_RSAE_SHA384,
/*is_raw_data=*/true);
}
// Tests the RSA-PSS SHA-512 signature algorithm.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiMockedExtensionTest,
RsaPssSha512) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_3));
ExecuteJavascript("supportedAlgorithms = ['RSASSA_PSS_SHA512'];");
ExecuteJavascript("registerForSignatureRequests();");
ExecuteJavascriptAndWaitForCallback("setCertificates();");
TestNavigationToCertificateRequestingWebPage("RSASSA_PSS_SHA512",
SSL_SIGN_RSA_PSS_RSAE_SHA512,
/*is_raw_data=*/true);
}
// Test that the certificateProvider events are delivered correctly in the
// scenario when the event listener is in a lazy background page that gets idle.
IN_PROC_BROWSER_TEST_F(CertificateProviderApiTest, LazyBackgroundPage) {
ASSERT_TRUE(StartHttpsServer(net::SSL_PROTOCOL_VERSION_TLS1_2));
// Make extension background pages idle immediately.
extensions::ProcessManager::SetEventPageIdleTimeForTesting(1);
extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1);
// Load the test extension.
TestCertificateProviderExtension test_certificate_provider_extension(
profile());
extensions::TestBackgroundPageFirstLoadObserver
test_background_page_first_load_observer(
profile(), TestCertificateProviderExtension::extension_id());
const extensions::Extension* const extension =
LoadExtension(base::PathService::CheckedGet(chrome::DIR_TEST_DATA)
.AppendASCII("extensions")
.AppendASCII("test_certificate_provider")
.AppendASCII("extension"));
ASSERT_TRUE(extension);
EXPECT_EQ(extension->id(), TestCertificateProviderExtension::extension_id());
test_background_page_first_load_observer.Wait();
// Navigate to the page that requests the client authentication. Use the
// incognito profile in order to force re-authentication in the later request
// made by the test.
const std::string client_cert_fingerprint =
GetCertFingerprint1(*TestCertificateProviderExtension::GetCertificate());
Browser* const incognito_browser = CreateIncognitoBrowser(profile());
ASSERT_TRUE(incognito_browser);
ui_test_utils::NavigateToURLWithDisposition(
incognito_browser, GetHttpsClientCertUrl(),
WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP);
EXPECT_EQ(test_certificate_provider_extension.certificate_request_count(), 1);
EXPECT_EQ(GetPageTextContent(
incognito_browser->tab_strip_model()->GetActiveWebContents()),
"got client cert with fingerprint: " + client_cert_fingerprint);
CheckCertificateProvidedByExtension(
*TestCertificateProviderExtension::GetCertificate(), *extension);
// Let the extension's background page become idle.
WaitForExtensionIdle(extension->id());
// Navigate again to the page with the client authentication. The extension
// gets awakened and handles the request.
ui_test_utils::NavigateToURLWithDisposition(
browser(), GetHttpsClientCertUrl(),
WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP);
EXPECT_EQ(test_certificate_provider_extension.certificate_request_count(), 2);
EXPECT_EQ(
GetPageTextContent(browser()->tab_strip_model()->GetActiveWebContents()),
"got client cert with fingerprint: " + client_cert_fingerprint);
}
// User enters the correct PIN.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, ShowPinDialogAccept) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("basic.html");
// Enter the valid PIN.
EnterCorrectPinAndWaitForMessage();
// The view should be set to nullptr when the window is closed.
EXPECT_FALSE(GetActivePinDialogView());
}
// User closes the dialog kMaxClosedDialogsPerMinute times, and the extension
// should be blocked from showing it again.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, ShowPinDialogClose) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("basic.html");
for (int i = 0;
i < extensions::api::certificate_provider::kMaxClosedDialogsPerMinute;
i++) {
ExtensionTestMessageListener listener("User closed the dialog", false);
GetActivePinDialogWindow()->Close();
ASSERT_TRUE(listener.WaitUntilSatisfied());
}
ExtensionTestMessageListener close_listener("User closed the dialog", true);
GetActivePinDialogWindow()->Close();
ASSERT_TRUE(close_listener.WaitUntilSatisfied());
close_listener.Reply("GetLastError");
ExtensionTestMessageListener last_error_listener(
"This request exceeds the MAX_PIN_DIALOGS_CLOSED_PER_MINUTE quota.",
false);
ASSERT_TRUE(last_error_listener.WaitUntilSatisfied());
EXPECT_FALSE(GetActivePinDialogView());
}
// User enters a wrong PIN first and a correct PIN on the second try.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
ShowPinDialogWrongPin) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("basic.html");
EnterWrongPinAndWaitForMessage();
// The window should be active.
EXPECT_TRUE(GetActivePinDialogWindow()->IsVisible());
EXPECT_TRUE(GetActivePinDialogView());
// Enter the valid PIN.
EnterCorrectPinAndWaitForMessage();
// The view should be set to nullptr when the window is closed.
EXPECT_FALSE(GetActivePinDialogView());
}
// User enters wrong PIN three times.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
ShowPinDialogWrongPinThreeTimes) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("basic.html");
for (int i = 0; i < kWrongPinAttemptsLimit; i++)
EnterWrongPinAndWaitForMessage();
// The textfield has to be disabled, as extension does not allow input now.
EXPECT_FALSE(GetActivePinDialogView()->textfield_for_testing()->GetEnabled());
// Close the dialog.
ExtensionTestMessageListener listener("No attempt left", false);
GetActivePinDialogWindow()->Close();
ASSERT_TRUE(listener.WaitUntilSatisfied());
EXPECT_FALSE(GetActivePinDialogView());
}
// User closes the dialog while the extension is processing the request.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
ShowPinDialogCloseWhileProcessing) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage("Request", "request1:begun"));
ExtensionTestMessageListener listener(
base::StringPrintf("request1:success:%s", kWrongPin), false);
EnterCode(kWrongPin);
EXPECT_TRUE(listener.WaitUntilSatisfied());
GetActivePinDialogWindow()->Close();
base::RunLoop().RunUntilIdle();
// The view should be set to nullptr when the window is closed.
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension closes the dialog kMaxClosedDialogsPerMinute times after the user
// inputs some value, and it should be blocked from showing it again.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
RepeatedProgrammaticCloseAfterInput) {
NavigateTo("operated.html");
for (int i = 0;
i <
extensions::api::certificate_provider::kMaxClosedDialogsPerMinute + 1;
i++) {
AddFakeSignRequest(kFakeSignRequestId);
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Request", base::StringPrintf("request%d:begun", i + 1)));
EnterCode(kCorrectPin);
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Stop", base::StringPrintf("stop%d:success", i + 1)));
EXPECT_FALSE(GetActivePinDialogView());
}
AddFakeSignRequest(kFakeSignRequestId);
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Request",
base::StringPrintf(
"request%d:error:This request exceeds the "
"MAX_PIN_DIALOGS_CLOSED_PER_MINUTE quota.",
extensions::api::certificate_provider::kMaxClosedDialogsPerMinute +
2)));
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension erroneously attempts to close the PIN dialog twice.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, DoubleClose) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommand("Request"));
EXPECT_TRUE(SendCommandAndWaitForMessage("Stop", "stop1:success"));
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Stop", "stop2:error:No active dialog from extension."));
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension closes the dialog kMaxClosedDialogsPerMinute times before the user
// inputs anything, and it should be blocked from showing it again.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
RepeatedProgrammaticCloseBeforeInput) {
NavigateTo("operated.html");
for (int i = 0;
i <
extensions::api::certificate_provider::kMaxClosedDialogsPerMinute + 1;
i++) {
AddFakeSignRequest(kFakeSignRequestId);
EXPECT_TRUE(SendCommand("Request"));
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Stop", base::StringPrintf("stop%d:success", i + 1)));
EXPECT_FALSE(GetActivePinDialogView());
}
AddFakeSignRequest(kFakeSignRequestId);
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Request",
base::StringPrintf(
"request%d:error:This request exceeds the "
"MAX_PIN_DIALOGS_CLOSED_PER_MINUTE quota.",
extensions::api::certificate_provider::kMaxClosedDialogsPerMinute +
2)));
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension erroneously attempts to stop the PIN request with an error before
// the user provided any input.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
StopWithErrorBeforeInput) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommand("Request"));
EXPECT_TRUE(SendCommandAndWaitForMessage(
"StopWithUnknownError", "stop1:error:No user input received"));
EXPECT_TRUE(GetActivePinDialogView()->textfield_for_testing()->GetEnabled());
}
// Extension erroneously uses an invalid sign request ID.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, InvalidRequestId) {
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Request", "request1:error:Invalid signRequestId"));
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension specifies zero left attempts in the very first PIN request.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, ZeroAttemptsAtStart) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage("RequestWithZeroAttempts",
"request1:begun"));
// The textfield has to be disabled, as there are no attempts left.
EXPECT_FALSE(GetActivePinDialogView()->textfield_for_testing()->GetEnabled());
ExtensionTestMessageListener listener("request1:empty", false);
GetActivePinDialogWindow()->Close();
EXPECT_TRUE(listener.WaitUntilSatisfied());
}
// Extension erroneously passes a negative attempts left count.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, NegativeAttempts) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage(
"RequestWithNegativeAttempts", "request1:error:Invalid attemptsLeft"));
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension erroneously attempts to close a non-existing dialog.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, CloseNonExisting) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Stop", "stop1:error:No active dialog from extension."));
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension erroneously attempts to stop a non-existing dialog with an error.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, StopNonExisting) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage(
"StopWithUnknownError", "stop1:error:No active dialog from extension."));
EXPECT_FALSE(GetActivePinDialogView());
}
// Extension erroneously attempts to start or stop the PIN request before the
// user closed the previously stopped with an error PIN request.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
UpdateAlreadyStopped) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage("Request", "request1:begun"));
EnterCode(kWrongPin);
EXPECT_TRUE(SendCommand("StopWithUnknownError"));
EXPECT_TRUE(SendCommandAndWaitForMessage(
"StopWithUnknownError", "stop2:error:No user input received"));
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Request", "request2:error:Previous request not finished"));
EXPECT_FALSE(GetActivePinDialogView()->textfield_for_testing()->GetEnabled());
}
// Extension starts a new PIN request after it stopped the previous one with an
// error.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, StartAfterStop) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage("Request", "request1:begun"));
EnterCode(kWrongPin);
EXPECT_TRUE(SendCommandAndWaitForMessage("Stop", "stop1:success"));
EXPECT_FALSE(GetActivePinDialogView());
EXPECT_TRUE(SendCommandAndWaitForMessage("Request", "request2:begun"));
ExtensionTestMessageListener listener(
base::StringPrintf("request2:success:%s", kCorrectPin), false);
EnterCode(kCorrectPin);
EXPECT_TRUE(listener.WaitUntilSatisfied());
EXPECT_FALSE(GetActivePinDialogView()->textfield_for_testing()->GetEnabled());
}
// Test that no quota is applied to the first PIN requests for each requestId.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest,
RepeatedCloseWithDifferentIds) {
NavigateTo("operated.html");
for (int i = 0;
i <
extensions::api::certificate_provider::kMaxClosedDialogsPer10Minutes + 2;
i++) {
AddFakeSignRequest(kFakeSignRequestId + i);
EXPECT_TRUE(SendCommandAndWaitForMessage(
"Request", base::StringPrintf("request%d:begun", i + 1)));
ExtensionTestMessageListener listener(
base::StringPrintf("request%d:empty", i + 1), false);
ASSERT_TRUE(GetActivePinDialogView());
GetActivePinDialogView()->GetWidget()->CloseWithReason(
views::Widget::ClosedReason::kCloseButtonClicked);
EXPECT_TRUE(listener.WaitUntilSatisfied());
EXPECT_FALSE(GetActivePinDialogView());
EXPECT_TRUE(SendCommand("IncrementRequestId"));
}
}
// Test that disabling the extension closes its PIN dialog.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, ExtensionDisable) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage("Request", "request1:begun"));
EXPECT_TRUE(GetActivePinDialogView());
extensions::TestExtensionRegistryObserver registry_observer(
extensions::ExtensionRegistry::Get(profile()),
pin_request_extension_id());
extensions::ExtensionSystem::Get(profile())
->extension_service()
->DisableExtension(pin_request_extension_id(),
extensions::disable_reason::DISABLE_USER_ACTION);
registry_observer.WaitForExtensionUnloaded();
// Let the events from the extensions subsystem propagate to the code that
// manages the PIN dialog.
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(GetActivePinDialogView());
}
// Test that reloading the extension closes its PIN dialog.
IN_PROC_BROWSER_TEST_F(CertificateProviderRequestPinTest, ExtensionReload) {
AddFakeSignRequest(kFakeSignRequestId);
NavigateTo("operated.html");
EXPECT_TRUE(SendCommandAndWaitForMessage("Request", "request1:begun"));
EXPECT_TRUE(GetActivePinDialogView());
// Create a second browser, in order to suppress Chrome shutdown logic when
// reloading the extension (as the tab with the extension's file gets closed).
CreateBrowser(profile());
// Trigger the chrome.runtime.reload() call from the extension.
extensions::TestExtensionRegistryObserver registry_observer(
extensions::ExtensionRegistry::Get(profile()),
pin_request_extension_id());
EXPECT_TRUE(SendCommand("Reload"));
registry_observer.WaitForExtensionUnloaded();
registry_observer.WaitForExtensionLoaded();
EXPECT_FALSE(GetActivePinDialogView());
}
| 56,085 | 17,650 |
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace settings {
class SettingsUserActionTrackerTest : public testing::Test {
protected:
SettingsUserActionTrackerTest() = default;
~SettingsUserActionTrackerTest() override = default;
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
base::HistogramTester histogram_tester_;
SettingsUserActionTracker tracker_;
};
TEST_F(SettingsUserActionTrackerTest, TestRecordMetrics) {
// Focus the page, perform some tasks, and change a setting.
tracker_.RecordPageFocus();
tracker_.RecordClick();
tracker_.RecordNavigation();
tracker_.RecordSearch();
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
tracker_.RecordSettingChange();
// The "first change" metrics should have been logged.
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumClicksUntilChange.FirstChange",
/*count=*/1);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumNavigationsUntilChange.FirstChange",
/*count=*/1);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumSearchesUntilChange.FirstChange",
/*count=*/1);
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.TimeUntilChange.FirstChange",
/*sample=*/base::TimeDelta::FromSeconds(10),
/*count=*/1);
// Without leaving the page, perform some more tasks, and change another
// setting.
tracker_.RecordClick();
tracker_.RecordNavigation();
tracker_.RecordSearch();
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
tracker_.RecordSettingChange();
// The "subsequent change" metrics should have been logged.
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumClicksUntilChange.SubsequentChange",
/*count=*/1);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumNavigationsUntilChange.SubsequentChange",
/*count=*/1);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumSearchesUntilChange.SubsequentChange",
/*count=*/1);
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.TimeUntilChange.SubsequentChange",
/*sample=*/base::TimeDelta::FromSeconds(10),
/*count=*/1);
// Repeat this, but only after 100ms. This is lower than the minimum value
// required for this metric, so it should be ignored.
tracker_.RecordClick();
tracker_.RecordNavigation();
tracker_.RecordSearch();
task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(100));
tracker_.RecordSettingChange();
// No additional logging should have occurred, so make the same verifications
// as above.
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumClicksUntilChange.SubsequentChange",
/*count=*/1);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumNavigationsUntilChange.SubsequentChange",
/*count=*/1);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumSearchesUntilChange.SubsequentChange",
/*count=*/1);
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.TimeUntilChange.SubsequentChange",
/*sample=*/base::TimeDelta::FromSeconds(10),
/*count=*/1);
// Repeat this once more, and verify that the counts increased.
tracker_.RecordClick();
tracker_.RecordNavigation();
tracker_.RecordSearch();
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(10));
tracker_.RecordSettingChange();
// The "subsequent change" metrics should have been logged.
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumClicksUntilChange.SubsequentChange",
/*count=*/2);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumNavigationsUntilChange.SubsequentChange",
/*count=*/2);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumSearchesUntilChange.SubsequentChange",
/*count=*/2);
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.TimeUntilChange.SubsequentChange",
/*sample=*/base::TimeDelta::FromSeconds(10),
/*count=*/2);
}
TEST_F(SettingsUserActionTrackerTest, TestBlurAndFocus) {
// Focus the page, click, and change a setting.
tracker_.RecordPageFocus();
tracker_.RecordClick();
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(1));
tracker_.RecordSettingChange();
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumClicksUntilChange.FirstChange",
/*count=*/1);
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.TimeUntilChange.FirstChange",
/*sample=*/base::TimeDelta::FromSeconds(1),
/*count=*/1);
// Blur for 59 seconds (not quite a minute), click, and change a setting.
// Since the blur was under a minute, this should count for the "subsequent
// change" metrics.
tracker_.RecordPageBlur();
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(59));
tracker_.RecordPageFocus();
tracker_.RecordClick();
tracker_.RecordSettingChange();
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.BlurredWindowDuration",
/*sample=*/base::TimeDelta::FromSeconds(59),
/*count=*/1);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumClicksUntilChange.SubsequentChange",
/*count=*/1);
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.TimeUntilChange.SubsequentChange",
/*sample=*/base::TimeDelta::FromSeconds(59),
/*count=*/1);
// Now, blur for a full minute, click, and change a setting. Since the blur
// was a full minute, this should count for the "first change" metrics.
tracker_.RecordPageBlur();
task_environment_.FastForwardBy(base::TimeDelta::FromMinutes(1));
tracker_.RecordPageFocus();
task_environment_.FastForwardBy(base::TimeDelta::FromSeconds(5));
tracker_.RecordClick();
tracker_.RecordSettingChange();
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.BlurredWindowDuration",
/*sample=*/base::TimeDelta::FromMinutes(1),
/*count=*/2);
histogram_tester_.ExpectTotalCount(
"ChromeOS.Settings.NumClicksUntilChange.FirstChange",
/*count=*/2);
histogram_tester_.ExpectTimeBucketCount(
"ChromeOS.Settings.TimeUntilChange.FirstChange",
/*sample=*/base::TimeDelta::FromSeconds(5),
/*count=*/1);
}
} // namespace settings.
} // namespace chromeos.
| 6,780 | 2,167 |
#include<iostream>
using namespace std;
int knapsack(int value[], int wt[], int n,int w){
if(n==0 || w == 0){
return 0;
}
if(wt[n-1] > w){
return knapsack(value,wt,n-1,w);
}
return max(knapsack(value,wt,n-1, w-wt[n-1])+value[n-1],knapsack(value,wt,n-1,w));
}
int main()
{
int wt[]= {10,20,30};
int value[]={100,50,150};
int w=50;
cout << knapsack(value,wt,3,w) << endl;
return 0;
} | 441 | 214 |
#include <allegro_flare/allegro_flare.h>
using namespace allegro_flare;
class MyProject : public Screen
{
public:
MyProject(Display *display)
: Screen(display)
{
// watch the executable directory
FileSysWatcher::watch_directory__in_thread(".");
}
void user_event_func() override
{
switch (Framework::current_event->type)
{
case ALLEGRO_EVENT_FILESYS_CHANGE:
std::cout << "DIRECTORY CHANGED!" << std::endl;
break;
default:
break;
}
}
};
int main(int argc, char *argv)
{
MyProject proj = MyProject(nullptr);
Framework::run_loop();
return 0;
}
| 663 | 237 |
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int main(int argc, char* argv[])
{
if(argc!=3)
{
printf("Usage: ./clean megablastFile cleanFile\n");
exit(0);
}
FILE *fin;
FILE *fout;
FILE *fout2;
FILE *fout3;
char *line =new char[1000000];
char *line1 =new char[1000000];
char *line2 =new char[1000000];
char *line3 =new char[1000000];
char *line4 =new char[1000000];
/*********DELETE NEW LINES***********/
fout2=fopen(argv[2],"w");
fin=fopen(argv[1],"r");
while(!feof(fin))
{
fgets (line, 1000000, fin);
if((line[0]==' ' && line[1]==' ' && line[2]=='D' && line[3]=='a' && line[4]=='t' && line[5]=='a' && line[6]=='b' && line[7]=='a'))
{
break;
}
while(!(line[0]=='Q' && line[1]=='u' && line[2]=='e' && line[3]=='r' && line[4]=='y' && line[5]=='='))
{
fgets (line, 1000000, fin);
}
fprintf(fout2,"%s",line);
fgets (line, 1000000, fin);
fgets (line, 1000000, fin);
fprintf(fout2,"%s",line);
fgets (line, 1000000, fin);
fgets (line, 1000000, fin);
if(line[0]=='S' && line[1]=='e' && line[2]=='q')
{
fgets(line, 1000000, fin);
int a=0;
while(line[0]!='>')
{
a++;
fgets(line, 1000000, fin);
if(a<=5 && strcmp(line,"\n")!=0 && line[0]!='>')
fprintf(fout2,"%s",line);
}
}
while(!(line[0]=='E' && line[1]=='f' && line[2]=='f' && line[3]=='e' && line[4]=='c' && line[5]=='t'))
{
fgets (line, 1000000, fin);
}
fgets (line, 1000000, fin);
fgets (line, 1000000, fin);
}
fclose(fin);
fclose(fout2);
return 0;
}
| 1,616 | 898 |
//
// Created by LDH on 12/22/20.
//
#ifndef LEARNC01_ARCFACE_HPP
#define LEARNC01_ARCFACE_HPP
#include <cmath>
#include <vector>
#include <string>
#include "net.h"
using namespace std;
float calcSimilar(std::vector<float> feature1, std::vector<float> feature2);
double calculSimilar(std::vector<float>& v1, std::vector<float>& v2, int distance_metric);
class ArcFace {
public:
ArcFace(AAssetManager *mgr);
~ArcFace();
vector<float> getFeature(ncnn::Mat img);
static ArcFace *face;
private:
ncnn::Net net;
const int feature_dim = 128;
void normalize(vector<float> &feature);
// ncnn::Mat preprocess(ncnn::Mat img, int *info);
// double calculSimilar(std::vector<float>& v1, std::vector<float>& v2, int distance_metric);
};
#endif
| 778 | 300 |
/****************************************************************************************
* @author: kzvd4729 created: 26-05-2018 20:55:53
* solution_verdict: Partially Accepted language: C++14
* run_time: 0.00 sec memory_used: 22.5M
* problem: https://www.codechef.com/LTIME60A/problems/PLUS
****************************************************************************************/
#include<bits/stdc++.h>
#define long long long
using namespace std;
long t,ans,mat[1002][1002],n,m,here,lm;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>t;
while(t--)
{
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>mat[i][j];
ans=-1e12;
for(long i=1;i<=n;i++)
{
for(long j=1;j<=m;j++)
{
long mx1=-1e12,mx2=-1e12,mx3=-1e12,mx4=-1e12;
here=0;
for(int k=1;k<=n;k++)
{
if(i+k>n)break;
here+=mat[i+k][j];
mx1=max(mx1,here);
}
here=0;
for(int k=1;k<=n;k++)
{
if(i-k<1)break;
here+=mat[i-k][j];
mx2=max(mx2,here);
}
here=0;
for(int k=1;k<=m;k++)
{
if(j+k>m)break;
here+=mat[i][j+k];
mx3=max(mx3,here);
}
here=0;
for(int k=1;k<=m;k++)
{
if(j-k<1)break;
here+=mat[i][j-k];
mx4=max(mx4,here);
}
ans=max(ans,mat[i][j]+mx1+mx2+mx3+mx4);
}
}
cout<<ans<<endl;
}
return 0;
} | 1,702 | 664 |
/*
* This file is a part of
*
* ============================================
* ### Pteros molecular modeling library ###
* ============================================
*
* https://github.com/yesint/pteros
*
* (C) 2009-2020, Semen Yesylevskyy
*
* All works, which use Pteros, should cite the following papers:
*
* 1. Semen O. Yesylevskyy, "Pteros 2.0: Evolution of the fast parallel
* molecular analysis library for C++ and python",
* Journal of Computational Chemistry, 2015, 36(19), 1480–1488.
* doi: 10.1002/jcc.23943.
*
* 2. Semen O. Yesylevskyy, "Pteros: Fast and easy to use open-source C++
* library for molecular analysis",
* Journal of Computational Chemistry, 2012, 33(19), 1632–1636.
* doi: 10.1002/jcc.22989.
*
* This is free software distributed under Artistic License:
* http://www.opensource.org/licenses/artistic-license-2.0.php
*
*/
#include "pteros/core/selection.h"
#include "pteros/core/pteros_error.h"
#include "bindings_util.h"
namespace py = pybind11;
using namespace pteros;
using namespace std;
using namespace Eigen;
using namespace pybind11::literals;
#define DEF_PROPERTY(_name,_dtype) \
.def_property(#_name, [](Atom_proxy* obj){return obj->_name();}, [](Atom_proxy* obj,const _dtype& val){obj->_name()=val;})
void make_bindings_Selection(py::module& m){
using RowMatrixXf = Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
py::class_<Atom_proxy>(m, "Atom_proxy")
DEF_PROPERTY(resid,int)
DEF_PROPERTY(resindex,int)
DEF_PROPERTY(resname,string)
DEF_PROPERTY(name,string)
DEF_PROPERTY(chain,char)
DEF_PROPERTY(tag,string)
DEF_PROPERTY(occupancy,float)
DEF_PROPERTY(beta,float)
DEF_PROPERTY(mass,float)
DEF_PROPERTY(charge,float)
DEF_PROPERTY(type,int)
DEF_PROPERTY(atomic_number,int)
DEF_PROPERTY(type_name,string)
DEF_PROPERTY(atom,Atom)
DEF_PROPERTY(x,float)
DEF_PROPERTY(y,float)
DEF_PROPERTY(z,float)
.def_property("xyz", [](Atom_proxy* obj){return obj->xyz();}, [](Atom_proxy* obj,Vector3f_const_ref val){obj->xyz()=val;})
.def_property("vel", [](Atom_proxy* obj){return obj->vel();}, [](Atom_proxy* obj,Vector3f_const_ref val){obj->vel()=val;})
.def_property("force", [](Atom_proxy* obj){return obj->force();}, [](Atom_proxy* obj,Vector3f_const_ref val){obj->force()=val;})
.def_property_readonly("element_name", [](Atom_proxy* obj){return obj->element_name();})
.def_property_readonly("vdw", [](Atom_proxy* obj){return obj->vdw();})
.def_property_readonly("index", [](Atom_proxy* obj){return obj->index();})
;
py::class_<Selection>(m, "Selection")
// Constructors
.def(py::init<>())
.def(py::init<const System&>())
.def(py::init<const System&,std::string,int>(),"sys"_a,"str"_a,"fr"_a=0)
.def(py::init<const System&,int,int>())
.def(py::init<const System&,const std::vector<int>&>())
.def(py::init<const System&,const std::function<void(const System&,int,std::vector<int>&)>&,int>(),"sys"_a,"callback"_a,"fr"_a=0)
.def(py::init<const Selection&>())
// Oparators
.def(py::self == py::self)
.def(py::self != py::self)
.def(py::self | py::self)
.def(py::self & py::self)
.def(py::self - py::self)
.def(~py::self)
// Modification
.def("append", py::overload_cast<const Selection&>(&Selection::append))
.def("append", py::overload_cast<int>(&Selection::append))
.def("remove", py::overload_cast<const Selection&>(&Selection::remove))
.def("remove", py::overload_cast<int>(&Selection::remove))
.def("invert",&Selection::invert)
.def("set_system",&Selection::set_system)
.def("modify", py::overload_cast<string,int>(&Selection::modify),"str"_a,"fr"_a=0)
.def("modify", py::overload_cast<int,int>(&Selection::modify))
.def("modify", py::overload_cast<const std::vector<int>&>(&Selection::modify))
.def("modify", py::overload_cast<const std::function<void(const System&,int,std::vector<int>&)>&,int>(&Selection::modify),"callback"_a,"fr"_a=0)
.def("modify", py::overload_cast<const System&,string,int>(&Selection::modify),"sys"_a,"str"_a,"fr"_a=0)
.def("modify", py::overload_cast<const System&,int,int>(&Selection::modify))
.def("modify", py::overload_cast<const System&,const std::vector<int>&>(&Selection::modify))
.def("modify", py::overload_cast<const System&,const std::function<void(const System&,int,std::vector<int>&)>&,int>(&Selection::modify),"sys"_a,"callback"_a,"fr"_a=0)
.def("apply",&Selection::apply)
.def("update",&Selection::update)
.def("clear",&Selection::clear)
// Subselection
.def("__call__", py::overload_cast<string>(&Selection::operator()), py::keep_alive<0,1>())
.def("__call__", py::overload_cast<int,int>(&Selection::operator()), py::keep_alive<0,1>())
.def("__call__", py::overload_cast<const std::vector<int>&>(&Selection::operator()), py::keep_alive<0,1>())
.def("select", py::overload_cast<string>(&Selection::operator()), py::keep_alive<0,1>())
.def("select", py::overload_cast<int,int>(&Selection::operator()), py::keep_alive<0,1>())
.def("select", py::overload_cast<const std::vector<int>&>(&Selection::operator()), py::keep_alive<0,1>())
// Get and set
.def("get_frame",&Selection::get_frame)
.def("set_frame",&Selection::set_frame)
.def("get_system",&Selection::get_system, py::return_value_policy::reference_internal)
.def("get_text",&Selection::get_text)
.def("get_index",&Selection::get_index)
.def("get_chain",&Selection::get_chain,"unique"_a=false)
.def("set_chain",py::overload_cast<char>(&Selection::set_chain))
.def("set_chain",py::overload_cast<const std::vector<char>&>(&Selection::set_chain))
.def("get_resid",&Selection::get_resid,"unique"_a=false)
.def("set_resid",py::overload_cast<int>(&Selection::set_resid))
.def("set_resid",py::overload_cast<const std::vector<int>&>(&Selection::set_resid))
.def("get_resindex",&Selection::get_resindex,"unique"_a=false)
.def("get_name",&Selection::get_name,"unique"_a=false)
.def("set_name",py::overload_cast<string>(&Selection::set_name))
.def("set_name",py::overload_cast<const std::vector<string>&>(&Selection::set_name))
.def("get_resname",&Selection::get_resname,"unique"_a=false)
.def("set_resname",py::overload_cast<string>(&Selection::set_resname))
.def("set_resname",py::overload_cast<const std::vector<string>&>(&Selection::set_resname))
.def("get_xyz", [](Selection* sel){ return sel->get_xyz(true); }) // pass true for row-major matrix
.def("set_xyz", &Selection::set_xyz) // detects raw-major matrix internally
.def("get_vel", [](Selection* sel){ return sel->get_vel(true); }) // pass true for row-major matrix
.def("set_vel", &Selection::set_vel) // detects raw-major matrix internally
.def("get_force", [](Selection* sel){ return sel->get_force(true); }) // pass true for row-major matrix
.def("set_force", &Selection::set_force) // detects raw-major matrix internally
.def("get_mass",&Selection::get_mass)
.def("set_mass",py::overload_cast<float>(&Selection::set_mass))
.def("set_mass",py::overload_cast<const std::vector<float>&>(&Selection::set_mass))
.def("get_beta",&Selection::get_beta)
.def("set_beta",py::overload_cast<float>(&Selection::set_beta))
.def("set_beta",py::overload_cast<const std::vector<float>&>(&Selection::set_beta))
.def("get_occupancy",&Selection::get_occupancy)
.def("set_occupancy",py::overload_cast<float>(&Selection::set_occupancy))
.def("set_occupancy",py::overload_cast<const std::vector<float>&>(&Selection::set_occupancy))
.def("get_charge",&Selection::get_charge)
.def("get_total_charge",&Selection::get_total_charge)
.def("set_charge",py::overload_cast<float>(&Selection::set_charge))
.def("set_charge",py::overload_cast<const std::vector<float>&>(&Selection::set_charge))
.def("get_tag",&Selection::get_tag,"unique"_a=false)
.def("set_tag",py::overload_cast<string>(&Selection::set_tag))
.def("set_tag",py::overload_cast<const std::vector<string>&>(&Selection::set_tag))
// Properties
.def("center",&Selection::center,"mass_weighted"_a=false,"pbc"_a=noPBC,"pbc_atom"_a=-1)
.def("minmax",[](Selection* sel){Vector3f min,max; sel->minmax(min,max); return py::make_tuple(min,max);})
.def("is_large",&Selection::is_large)
.def("powersasa", [](Selection* sel, float probe_r, bool do_area_per_atom, bool do_total_volume, bool do_vol_per_atom){
float vol;
std::vector<float> area_per_atom;
std::vector<float> volume_per_atom;
float* vol_ptr;
std::vector<float> *area_per_atom_ptr, *volume_per_atom_ptr;
vol_ptr = do_total_volume ? &vol : nullptr;
area_per_atom_ptr = do_area_per_atom ? &area_per_atom : nullptr;
volume_per_atom_ptr = do_vol_per_atom ? &volume_per_atom : nullptr;
float a = sel->powersasa(probe_r,area_per_atom_ptr,vol_ptr,volume_per_atom_ptr);
py::list ret;
ret.append(a);
if(do_area_per_atom) ret.append(area_per_atom);
if(do_total_volume) ret.append(vol);
if(do_vol_per_atom) ret.append(volume_per_atom);
return ret;
}, "probe_r"_a=0.14, "do_area_per_atom"_a=false, "do_total_volume"_a=false, "do_vol_per_atom"_a=false)
.def("sasa", [](Selection* sel, float probe_r, bool do_area_per_atom, int n_sphere_points){
std::vector<float> area_per_atom;
std::vector<float> *area_per_atom_ptr;
area_per_atom_ptr = do_area_per_atom ? &area_per_atom : nullptr;
float a = sel->sasa(probe_r,area_per_atom_ptr,n_sphere_points);
py::list ret;
ret.append(a);
if(do_area_per_atom) ret.append(area_per_atom);
return ret;
}, "probe_r"_a=0.14, "do_area_per_atom"_a=false, "n_sphere_points"_a=960)
.def("average_structure", [](Selection* sel, int b, int e){
return sel->average_structure(b,e,true); // pass true for row-major matrix
}, "b"_a=0, "e"_a=-1)
.def("atom_traj", [](Selection* sel, int i, int b, int e){
return sel->atom_traj(i,b,e,true); // pass true for row-major matrix
}, "i"_a, "b"_a=0, "e"_a=-1)
.def("inertia",[](Selection* sel, Array3i_const_ref pbc, bool pbc_atom){
Vector3f m;
Matrix3f ax;
sel->inertia(m,ax,pbc,pbc_atom);
return py::make_tuple(m,ax.transpose());
},"pbc"_a=noPBC,"pbc_atom"_a=-1)
.def("gyration",&Selection::gyration, "pbc"_a=noPBC,"pbc_atom"_a=-1)
.def("dipole",&Selection::dipole, "is_charged"_a=false,"pbc"_a=noPBC,"pbc_atom"_a=-1)
.def("distance", &Selection::distance, "i"_a, "j"_a, "pbc"_a=fullPBC)
.def("angle", &Selection::angle, "i"_a, "j"_a, "k"_a, "pbc"_a=fullPBC)
.def("dihedral", &Selection::dihedral, "i"_a, "j"_a, "k"_a, "l"_a, "pbc"_a=fullPBC)
.def("num_residues",&Selection::num_residues)
// Geometry transforms
.def("translate", &Selection::translate)
.def("translate_to", &Selection::translate_to, "vec"_a, "mass_weighted"_a=false, "pbc"_a=noPBC, "pbc_atom"_a=-1)
.def("rotate",&Selection::rotate)
.def("wrap", &Selection::wrap, "pbc"_a=fullPBC)
.def("unwrap", &Selection::unwrap, "pbc"_a=fullPBC, "pbc_atom"_a=-1)
.def("unwrap_bonds", &Selection::unwrap_bonds, "d"_a, "pbc"_a=fullPBC, "pbc_atom"_a=-1)
.def("principal_transform", [](Selection* sel, Array3i_const_ref pbc, bool pbc_atom){
Matrix4f m = sel->principal_transform(pbc,pbc_atom).matrix().transpose();
return m;
}, "pbc"_a=noPBC,"pbc_atom"_a=-1)
.def("principal_orient",&Selection::principal_orient,"pbc"_a=noPBC,"pbc_atom"_a=-1)
// Fitting and rmsd
.def("rmsd",py::overload_cast<int>(&Selection::rmsd,py::const_))
.def("rmsd",py::overload_cast<int,int>(&Selection::rmsd,py::const_))
.def("fit_trajectory",&Selection::fit_trajectory, "ref_frame"_a=0, "b"_a=0, "e"_a=-1)
.def("fit",&Selection::fit)
.def("fit_transform", [](Selection* sel, int fr1, int fr2){
Matrix4f m = sel->fit_transform(fr1,fr2).matrix().transpose();
return m;
})
.def("apply_transform", [](Selection* sel, const Eigen::Ref<const Eigen::Matrix4f>& m){
Affine3f t(m.transpose());
sel->apply_transform(t);
})
// Energy
.def("non_bond_energy", &Selection::non_bond_energy, "cutoff"_a=0.0, "pbc"_a=true)
// IO
.def("write", py::overload_cast<string,int,int>(&Selection::write), "fname"_a, "b"_a=0, "e"_a=-1)
// Util
.def("is_large",&Selection::is_large)
.def("size",&Selection::size)
.def("__len__", &Selection::size)
.def("text_based",&Selection::text_based)
.def("coord_dependent",&Selection::coord_dependent)
.def("flatten",&Selection::flatten)
.def("to_gromacs_ndx",&Selection::to_gromacs_ndx)
.def("find_index",&Selection::find_index)
// Indexing and iterating
.def("__iter__", [](Selection* s) {
return py::make_iterator(s->begin(), s->end());
}, py::keep_alive<0,1>() /* Essential: keep object alive while iterator exists */)
.def("__getitem__", [](Selection &s, size_t i) {
if(i >= s.size()) throw py::index_error();
return s[i]; // Returns atom proxy object
}, py::keep_alive<0,1>())
.def("__getitem__", [](Selection &s, py::tuple ind_fr) {
int i = ind_fr[0].cast<int>();
int fr = ind_fr[1].cast<int>();
if(i >= s.size() || fr<0 || fr>=s.get_system()->num_frames()) throw py::index_error();
return s[{i,fr}]; // Returns atom proxy object
}, py::keep_alive<0,1>())
// Splitting
.def("split_by_connectivity", [](Selection* sel,float d,bool periodic){
std::vector<Selection> res;
sel->split_by_connectivity(d,res,periodic);
return res;
})
.def("split_by_residue", [](Selection* sel){
std::vector<Selection> res;
sel->split_by_residue(res);
return res;
})
.def("split_by_chain", [](Selection* sel){
std::vector<Selection> res;
sel->split_by_chain(res);
return res;
})
.def("split_by_molecule", [](Selection* sel){
std::vector<Selection> res;
sel->split_by_molecule(res);
return res;
})
.def("split_by_contiguous_index", [](Selection* sel){
std::vector<Selection> res;
sel->split_by_contiguous_index(res);
return res;
})
.def("split_by_contiguous_residue", [](Selection* sel){
std::vector<Selection> res;
sel->split_by_contiguous_residue(res);
return res;
})
.def("each_residue", [](Selection* sel){
std::vector<Selection> res;
sel->each_residue(res);
return res;
})
// split based on callback have to be implemented on python side
// since no means to bind templated return value!
// dssp
.def("dssp", py::overload_cast<string>(&Selection::dssp, py::const_))
.def("dssp", py::overload_cast<>(&Selection::dssp, py::const_))
// Accessors
.def_property("box", [](Selection* obj){return obj->box();}, [](Selection* obj,const Periodic_box& val){obj->box()=val;})
.def_property("time", [](Selection* obj){return obj->time();}, [](Selection* obj, float val){obj->time()=val;})
// No other accessors are exposed in favor to [] operator
;
// Free functions
m.def("rmsd",[](const Selection& sel1, const Selection& sel2){ return rmsd(sel1,sel2); });
m.def("rmsd",[](const Selection& sel1, int fr1, const Selection& sel2, int fr2){ return rmsd(sel1,fr1,sel2,fr2); });
m.def("fit",[](Selection& sel1, const Selection& sel2){ fit(sel1,sel2); });
m.def("fit_transform",[](Selection& sel1, const Selection& sel2){
Matrix4f m = fit_transform(sel1,sel2).matrix().transpose();
return m;
});
m.def("non_bond_energy", [](const Selection& sel1, const Selection& sel2,float cutoff,int fr,bool pbc){
return non_bond_energy(sel1,sel2,cutoff,fr,pbc);
},"sel1"_a, "sel2"_a, "cutoff"_a=0.0, "fr"_a=-1, "pbc"_a=fullPBC);
m.def("copy_coord",[](const Selection& sel1, int fr1, Selection& sel2, int fr2){ return copy_coord(sel1,fr1,sel2,fr2); });
m.def("copy_coord",[](const Selection& sel1, Selection& sel2){ return copy_coord(sel1,sel2); });
}
| 17,617 | 6,245 |
//1.Subarray with given sum
//https://practice.geeksforgeeks.org/problems/subarray-with-given-sum-1587115621/1
class Solution
{
public:
//Function to find a continuous sub-array which adds up to a given number.
vector<int> subarraySum(int arr[], int n, long long s)
{
// Your code here
int i=0, j=0;
vector<int> ans;
long long sum=0;
while(j<n) {
sum += arr[j++];
while(sum > s) {
sum -= arr[i++];
}
if(sum == s) {
ans.push_back(i+1);
ans.push_back(j);
return ans;
}
}
ans.push_back(-1);
return ans;
}
};
| 714 | 237 |
#include "EditorDoubleValue.h"
#include "ui_EditorDoubleValue.h"
#include "DataProperty/ParameterDouble.h"
#include <QDoubleValidator>
#include <QTimer>
#include <QDebug>
#include "InputValidator.h"
namespace FastCAEDesigner
{
EditorDoubleValue::EditorDoubleValue(DataProperty::ParameterDouble* model, QWidget *parent) :
QDialog(parent),
ui(new Ui::EditorDoubleValue),
_model(model)
{
ui->setupUi(this);
Init();
}
EditorDoubleValue::~EditorDoubleValue()
{
delete ui;
_errorList.clear();
_usedNameList.clear();
delete _validator;
_validator = nullptr;
}
void EditorDoubleValue::SetEditModel(bool b)
{
if (b)
ui->txtName->setEnabled(false);
else
ui->txtName->setEnabled(true);
}
//初始化错误代码对应的错误信息列表
void EditorDoubleValue::InitErrorList()
{
_errorList.insert(NameIsEmpty, tr("Name is empty."));
_errorList.insert(UnitIsEmpty, tr("Unit is empty."));
_errorList.insert(ValueOutOfRange, tr("Value out of range."));
_errorList.insert(RangeSetupError, tr("Range setting error."));
_errorList.insert(TheNameInUse, tr("The name is already in use"));
}
//初始化函数
void EditorDoubleValue::Init()
{
UpdateDataToUi();
_decimals = _model->getAccuracy();
connect(ui->btnOk, SIGNAL(clicked()), this, SLOT(OnBtnOkClicked()));
connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(close()));
//connect(ui->spBox_precision, SIGNAL(valueChanged(int)), this, SLOT(SetInputValidator(int)));
connect(ui->spBox_precision, SIGNAL(valueChanged(int)), this, SLOT(precisionChanged()));
//connect(ui->spBox_precision, SIGNAL(valueChanged(QString)), this, SLOT(OnSetInputValidator(QString)));
SetInputValidator(_decimals);//控件数据限制设定
InitErrorList();
}
//void EditorDoubleValue::OnSetInputValidator(QString decimals)
void EditorDoubleValue::precisionChanged()
{
int deci = ui->spBox_precision->value();
// int deci = decimals.toInt();
SetInputValidator(deci);
}
// void EditorDoubleValue::SetInputValidator(QString decimals)
// {
// int deci = decimals.toInt();
// //SetInputValidator(deci);
// }
void EditorDoubleValue::SetInputValidator(int decimals)
{
//double min = -2147483647;DBL_MIN
//double max = 2147483647;
//double min = DBL_MIN;
//double max = DBL_MAX;
double min = -37777777777;
double max = 37777777777;
_validator = new QDoubleValidator(min, max, decimals, this);
_validator->setNotation(QDoubleValidator::StandardNotation);
ui->txtValue->setValidator(_validator);
ui->txtMin->setValidator(_validator);
ui->txtMax->setValidator(_validator);
}
//校验数据设定是否正确,根据错误的状况返回响应的错误代码
int EditorDoubleValue::IsDataOk()
{
UpdateUiToLocal();
if (_usedNameList.contains(_name))
return TheNameInUse;
if (_name.isEmpty())
return NameIsEmpty;
//if (_unit.isEmpty())
// return UnitIsEmpty;
if (_min > _max)
return RangeSetupError;
if (_val<_min || _val>_max)
return ValueOutOfRange;
return 0;
}
//刷新Ui数据到本地变量
void EditorDoubleValue::UpdateUiToLocal()
{
_name = ui->txtName->text().trimmed();
_unit = ui->txtUnit->text().trimmed();
_val = ui->txtValue->text().toDouble();
_min = ui->txtMin->text().toDouble();
_max = ui->txtMax->text().toDouble();
_range[0] = _min;
_range[1] = _max;
_decimals = ui->spBox_precision->text().toInt();
}
//刷新model数据到UI
void EditorDoubleValue::UpdateDataToUi()
{
ui->txtName->setText(_model->getDescribe());
ui->txtUnit->setText(_model->getUnit());
//ui->txtValue->setText(QString::number(_model->getValue()));
_model->getRange(_range);
ui->txtMin->setText(QString::number(_range[0]));
ui->txtMax->setText(QString::number(_range[1]));
int accuracy = (_model->getAccuracy() > 10) ? 10 : _model->getAccuracy();
ui->spBox_precision->setValue(accuracy);
double d = _model->getValue();
QString s = QString("%1").arg(d, 0, 'f', accuracy);
ui->txtValue->setText(s);
}
//刷新Ui数据到model
void EditorDoubleValue::UpdateUiToData()
{
UpdateUiToLocal();
_model->setDescribe(_name);
_model->setUnit(_unit);
_model->setValue(_val);
_model->setRange(_range);
_model->setAccuracy(_decimals);
}
//确认设定槽函数
void EditorDoubleValue::OnBtnOkClicked()
{
int errorCode = IsDataOk();
if (0 != errorCode)
{
QString errorMsg = _errorList[errorCode];
ui->lbl_info->setText(errorMsg);
ui->lbl_info->show();
QTimer::singleShot(3000, this, SLOT(OnTimeout()));
return;
}
UpdateUiToData();
this->accept();
close();
}
//定时器槽函数
void EditorDoubleValue::OnTimeout()
{
ui->lbl_info->setText("");
ui->lbl_info->hide();
}
//设置已经使用的变量名称列表
void EditorDoubleValue::SetUsedNameList(QList<QString> list)
{
_usedNameList = list;
}
}
| 4,665 | 1,954 |
#pragma once
#include <IRenderingDevice.hpp>
#include "GLUtils.hpp"
namespace Poly
{
struct ScreenSize;
enum class eInternalTextureUsageType
{
NONE,
COLOR_ATTACHEMENT,
DEPTH_ATTACHEMENT,
_COUNT
};
class GLTextureDeviceProxy : public ITextureDeviceProxy
{
public:
GLTextureDeviceProxy(size_t width, size_t height, eInternalTextureUsageType internalUsage, GLuint internalFormat);
GLTextureDeviceProxy(size_t width, size_t height, eTextureUsageType usage);
virtual ~GLTextureDeviceProxy();
void SetContent(eTextureDataFormat inputFormat, const unsigned char* data) override;
void SetSubContent(size_t width, size_t height, size_t offsetX, size_t offsetY, eTextureDataFormat format, const unsigned char* data) override;
GLuint GetTextureID() const { return TextureID; }
void Resize(const ScreenSize& size);
private:
void InitTextureParams();
size_t Width = 0;
size_t Height = 0;
GLuint TextureID = 0;
GLuint InternalFormat;
eInternalTextureUsageType InternalUsage = eInternalTextureUsageType::NONE;
eTextureUsageType Usage = eTextureUsageType::_COUNT;
friend class GLRenderingDevice;
};
} | 1,142 | 385 |
#include "Halide.h"
using namespace Halide;
int main(int argc, char **argv) {
ImageParam in(UInt(8), 3, "input");
Var x("x"), y("y"), c("c"), x1, y1;
Func f("f"), g("g"), h("h"), k("k");
f(x, y, c) = cast<uint8_t>(255 - in(x, y, c));
g(x, y, c) = cast<uint8_t>(2*in(x, y, c));
h(x, y, c) = f(x, y, c) + g(x, y, c);
k(x, y, c) = f(x, y, c) - g(x, y, c);
f.reorder(c, x, y);
g.reorder(c, x, y);
h.reorder(c, x, y);
k.reorder(c, x, y);
//g.compute_with(f, y);
f.gpu_tile(x, y, x1, y1, 16, 16);
g.gpu_tile(x, y, x1, y1, 16, 16);
h.gpu_tile(x, y, x1, y1, 16, 16);
k.gpu_tile(x, y, x1, y1, 16, 16);
Halide::Target target = Halide::get_host_target();
target.set_feature(Halide::Target::CUDA, true);
Pipeline({f, g, h, k}).compile_to_object("build/generated_fct_fusiongpu_ref.o", {in}, "fusiongpu_ref", target);
Pipeline({f, g, h, k}).compile_to_lowered_stmt("build/generated_fct_fusiongpu_ref.txt", {in}, Halide::Text, target);
return 0;
}
| 1,028 | 531 |
#ifndef LASERDISCPLAYER_HH
#define LASERDISCPLAYER_HH
#include "ResampledSoundDevice.hh"
#include "BooleanSetting.hh"
#include "RecordedCommand.hh"
#include "EmuTime.hh"
#include "Schedulable.hh"
#include "DynamicClock.hh"
#include "Filename.hh"
#include "VideoSystemChangeListener.hh"
#include "EventListener.hh"
#include "ThrottleManager.hh"
#include "outer.hh"
namespace openmsx {
class PioneerLDControl;
class HardwareConfig;
class MSXMotherBoard;
class OggReader;
class LDRenderer;
class RawFrame;
class LaserdiscPlayer final : public ResampledSoundDevice
, private EventListener
, private VideoSystemChangeListener
{
public:
LaserdiscPlayer(const HardwareConfig& hwConf,
PioneerLDControl& ldControl);
~LaserdiscPlayer();
// Called from CassettePort
[[nodiscard]] int16_t readSample(EmuTime::param time);
// Called from PioneerLDControl
void setMuting(bool left, bool right, EmuTime::param time);
[[nodiscard]] bool extAck(EmuTime::param /*time*/) const { return ack; }
void extControl(bool bit, EmuTime::param time);
[[nodiscard]] const RawFrame* getRawFrame() const;
template<typename Archive>
void serialize(Archive& ar, unsigned version);
// video interface
[[nodiscard]] MSXMotherBoard& getMotherBoard() { return motherBoard; }
enum RemoteState {
REMOTE_IDLE,
REMOTE_HEADER_PULSE,
NEC_HEADER_SPACE,
NEC_BITS_PULSE,
NEC_BITS_SPACE,
};
enum PlayerState {
PLAYER_STOPPED,
PLAYER_PLAYING,
PLAYER_MULTISPEED,
PLAYER_PAUSED,
PLAYER_STILL
};
enum SeekState {
SEEK_NONE,
SEEK_CHAPTER,
SEEK_FRAME,
SEEK_WAIT,
};
enum StereoMode {
LEFT,
RIGHT,
STEREO
};
enum RemoteProtocol {
IR_NONE,
IR_NEC,
};
private:
void setImageName(std::string newImage, EmuTime::param time);
[[nodiscard]] const Filename& getImageName() const { return oggImage; }
void autoRun();
/** Laserdisc player commands
*/
void play(EmuTime::param time);
void pause(EmuTime::param time);
void stop(EmuTime::param time);
void eject(EmuTime::param time);
void seekFrame(size_t frame, EmuTime::param time);
void stepFrame(bool forwards);
void seekChapter(int chapter, EmuTime::param time);
// Control from MSX
/** Is video output being generated?
*/
void scheduleDisplayStart(EmuTime::param time);
[[nodiscard]] bool isVideoOutputAvailable(EmuTime::param time);
void remoteButtonNEC(unsigned code, EmuTime::param time);
void submitRemote(RemoteProtocol protocol, unsigned code);
void setAck(EmuTime::param time, int wait);
[[nodiscard]] size_t getCurrentSample(EmuTime::param time);
void createRenderer();
// SoundDevice
void generateChannels(float** buffers, unsigned num) override;
bool updateBuffer(unsigned length, float* buffer,
EmuTime::param time) override;
[[nodiscard]] float getAmplificationFactorImpl() const override;
// Schedulable
struct SyncAck final : public Schedulable {
friend class LaserdiscPlayer;
explicit SyncAck(Scheduler& s) : Schedulable(s) {}
void executeUntil(EmuTime::param time) override {
auto& player = OUTER(LaserdiscPlayer, syncAck);
player.execSyncAck(time);
}
} syncAck;
struct SyncOdd final : public Schedulable {
friend class LaserdiscPlayer;
explicit SyncOdd(Scheduler& s) : Schedulable(s) {}
void executeUntil(EmuTime::param time) override {
auto& player = OUTER(LaserdiscPlayer, syncOdd);
player.execSyncFrame(time, true);
}
} syncOdd;
struct SyncEven final : public Schedulable {
friend class LaserdiscPlayer;
explicit SyncEven(Scheduler& s) : Schedulable(s) {}
void executeUntil(EmuTime::param time) override {
auto& player = OUTER(LaserdiscPlayer, syncEven);
player.execSyncFrame(time, false);
}
} syncEven;
void execSyncAck(EmuTime::param time);
void execSyncFrame(EmuTime::param time, bool odd);
[[nodiscard]] EmuTime::param getCurrentTime() const { return syncAck.getCurrentTime(); }
// EventListener
int signalEvent(const std::shared_ptr<const Event>& event) noexcept override;
// VideoSystemChangeListener interface:
void preVideoSystemChange() noexcept override;
void postVideoSystemChange() noexcept override;
MSXMotherBoard& motherBoard;
PioneerLDControl& ldControl;
struct Command final : RecordedCommand {
Command(CommandController& commandController,
StateChangeDistributor& stateChangeDistributor,
Scheduler& scheduler);
void execute(span<const TclObject> tokens, TclObject& result,
EmuTime::param time) override;
[[nodiscard]] std::string help(const std::vector<std::string>& tokens) const override;
void tabCompletion(std::vector<std::string>& tokens) const override;
} laserdiscCommand;
std::unique_ptr<OggReader> video;
Filename oggImage;
std::unique_ptr<LDRenderer> renderer;
void nextFrame(EmuTime::param time);
void setFrameStep();
size_t currentFrame;
int frameStep;
// Audio state
DynamicClock sampleClock;
EmuTime start;
size_t playingFromSample;
size_t lastPlayedSample;
bool muteLeft, muteRight;
StereoMode stereoMode;
// Ext Control
RemoteState remoteState;
EmuTime remoteLastEdge;
unsigned remoteBitNr;
unsigned remoteBits;
bool remoteLastBit;
RemoteProtocol remoteProtocol;
unsigned remoteCode;
bool remoteExecuteDelayed;
// Number of v-blank since code was sent
int remoteVblanksBack;
/* We need to maintain some state for seeking */
SeekState seekState;
/* frame the MSX has requested to wait for */
size_t waitFrame;
// pause playing back on reaching wait frame
bool stillOnWaitFrame;
/* The specific frame or chapter we are seeking to */
int seekNum;
// For ack
bool ack;
// State of the video itself
bool seeking;
PlayerState playerState;
enum PlayingSpeed {
SPEED_STEP3 = -5, // Each frame is repeated 90 times
SPEED_STEP1 = -4, // Each frame is repeated 30 times
SPEED_1IN16 = -3, // Each frame is repeated 16 times
SPEED_1IN8 = -2, // Each frame is repeated 8 times
SPEED_1IN4 = -1, // Each frame is repeated 4 times
SPEED_1IN2 = 0,
SPEED_X1 = 1,
SPEED_X2 = 2,
SPEED_X3 = 3
};
int playingSpeed;
// Loading indicator
BooleanSetting autoRunSetting;
LoadingIndicator loadingIndicator;
int sampleReads;
};
SERIALIZE_CLASS_VERSION(LaserdiscPlayer, 4);
} // namespace openmsx
#endif
| 6,286 | 2,270 |
// Runtime: 60 ms, faster than 35.63% of C++ online submissions for Print Zero Even Odd.
// Memory Usage: 9.2 MB, less than 100.00% of C++ online submissions for Print Zero Even Odd.
#include <atomic>
#include <thread>
class ZeroEvenOdd
{
private:
int n;
std::atomic<bool> isZero{true};
std::atomic<bool> isEven{false};
std::atomic<bool> isOdd{false};
public:
ZeroEvenOdd(int n)
{
this->n = n;
}
// printNumber(x) outputs "x", where x is an integer.
void zero(function<void(int)> printNumber)
{
for (int i = 1; i <= n; ++i)
{
while (!isZero.load())
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
printNumber(0);
isZero.store(false);
if (i % 2 == 0)
{
isEven.store(true);
}
else
{
isOdd.store(true);
}
}
}
void even(function<void(int)> printNumber)
{
for (int i = 2; i <= n; i += 2)
{
while (!isEven.load())
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
printNumber(i);
isEven.store(false);
isZero.store(true);
}
}
void odd(function<void(int)> printNumber)
{
for (int i = 1; i <= n; i += 2)
{
while (!isOdd.load())
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
printNumber(i);
isOdd.store(false);
isZero.store(true);
}
}
};
| 1,683 | 552 |
#include <Arduino.h>
#include "../include/Free_Fonts.h" //include free fonts library from https://github.com/Seeed-Studio/Seeed_Arduino_LCD/blob/master/examples/320x240/Free_Font_Demo/Free_Fonts.h
#include "TFT_eSPI.h"
#include "IRremote.h"
TFT_eSPI tft;
int IR_RECEIVE_PIN = 0;
IRrecv irrecv(IR_RECEIVE_PIN);
String buttonDetected(unsigned long resultsValue);
void dumpCode(decode_results *results);
void updateScreen(decode_results *results);
void setup()
{
// put your setup code here, to run once:
// set up screen
tft.begin();
tft.setRotation(2);
// Start serial
Serial.begin(9600);
// Start the receiver
irrecv.enableIRIn();
}
void loop()
{
// put your main code here, to run repeatedly:
decode_results results; // Somewhere to store the results
if (irrecv.decode(&results))
{ // Grab an IR code
dumpCode(&results); // Output the results as source code
irrecv.resume(); // Prepare for the next value
}
updateScreen(&results);
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpCode(decode_results *results)
{
// Start declaration
Serial.print("results value: ");
Serial.print(results->value);
Serial.println(""); // Newline
Serial.print("unsigned int"); // variable type
Serial.print(" rawData["); // array name
Serial.print(results->rawlen - 1, DEC); // array size
Serial.print("] = {"); // Start declaration
// Dump data
for (unsigned int i = 1; i < results->rawlen; i++)
{
Serial.print(results->rawbuf[i] * MICROS_PER_TICK, DEC);
if (i < results->rawlen - 1)
Serial.print(","); // ',' not needed on last one
if (!(i & 1))
Serial.print(" ");
}
Serial.print("};"); //End declaration
Serial.println(""); // Newline
Serial.println("");
}
void updateScreen(decode_results *results)
{
//Initializing buffer
TFT_eSprite spr = TFT_eSprite(&tft);
// Create buffer (portrait)
spr.createSprite(TFT_WIDTH, TFT_HEIGHT);
// Fill background
spr.fillSprite(TFT_YELLOW);
// Header section
spr.fillRect(0, 0, 240, 30, TFT_WHITE);
spr.setFreeFont(FMB12);
spr.setTextColor(TFT_BLACK);
spr.drawString("Grove IR Receiver", 5, 6);
// Body section
spr.setFreeFont(FMB18);
spr.setTextDatum(MC_DATUM);
spr.drawString("Value", 120, 60);
spr.drawString("detected", 120, 90);
spr.drawString((String)results->value, 120, 120);
spr.setFreeFont(FMB18);
spr.setTextDatum(MC_DATUM);
spr.drawString("Button", 120, 180);
spr.drawString("detected", 120, 210);
spr.drawString(buttonDetected(results->value), 120, 240);
//Push to LCD
spr.pushSprite(0, 0);
// Delete buffer
spr.deleteSprite();
}
String buttonDetected(unsigned long resultsValue)
{
if (resultsValue == 16753245)
{ // unsigned int buttonPower[67] = {9200,4500, 600,550, 600,600, 600,550, 600,550, 650,550, 600,550, 600,600, 600,550, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,600, 600,1650, 600,550, 600,550, 600,600, 600,1650, 600,550, 600,550, 650,1600, 650,550, 600,1650, 600,1650, 600,1650, 600,550, 650,1600, 600};
return "Power";
}
else if (resultsValue == 16736925)
{ // unsigned int buttonMode[67] = {9200,4500, 600,550, 650,550, 600,550, 650,550, 600,550, 600,550, 650,550, 600,550, 600,1650, 650,1600, 600,1650, 650,1600, 650,1600, 650,1600, 650,1650, 600,1650, 600,550, 600,1650, 600,1650, 600,550, 650,550, 600,550, 600,1650, 600,600, 600,1650, 600,550, 600,550, 650,1600, 650,1600, 650,1600, 650,550, 600,1650, 600};
return "Mode";
}
else if (resultsValue == 16769565)
{ // unsigned int buttonMute[67] = {9200,4500, 600,600, 600,550, 600,550, 600,600, 600,550, 600,550, 650,550, 600,550, 650,1600, 600,1650, 650,1600, 650,1600, 650,1600, 650,1600, 650,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,550, 600,550, 650,550, 600,1650, 600,550, 600,600, 600,550, 600,550, 650,1600, 650,1600, 650,1600, 650,550, 600,1650, 600};
return "Mute";
}
else if (resultsValue == 16720605)
{ // unsigned int buttonPlayPause[67] = {9250,4450, 600,600, 600,550, 600,550, 650,550, 600,550, 600,600, 600,550, 600,550, 650,1600, 650,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,550, 600,550, 650,1600, 650,550, 600,550, 600,600, 600,1650, 600,550, 600,1650, 600,1650, 600,550, 650,1600, 650,1600, 650,1600, 650,550, 600,1650, 600};
return "PlayPause";
}
else if (resultsValue == 16712445)
{ // unsigned int buttonPrevious[67] = {9200,4450, 650,550, 600,550, 600,600, 600,550, 600,550, 600,600, 600,550, 600,550, 650,1600, 650,1600, 600,1650, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 600,550, 600,600, 600,550, 600,550, 650,550, 600,1650, 600,550, 600,1650, 600,1650, 600,1650, 650,1600, 650,1600, 650,1600, 600,600, 600,1650, 600};
return "Previous";
}
else if (resultsValue == 16761405)
{ // unsigned int buttonNext[67] = {9200,4450, 650,550, 650,500, 650,550, 600,550, 650,500, 650,550, 600,550, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 600,550, 650,550, 600,550, 650,1600, 650,500, 650,550, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 600,1650, 600};
return "Next";
}
else if (resultsValue == 16769055)
{ // unsigned int buttonEQ[67] = {9250,4450, 600,600, 600,550, 600,600, 600,550, 600,550, 650,550, 600,550, 600,550, 650,1600, 650,1600, 650,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,550, 600,550, 650,550, 600,550, 600,600, 600,550, 600,550, 600,600, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600};
return "EQ";
}
else if (resultsValue == 16754775)
{ // unsigned int buttonMinus[67] = {9250,4450, 650,500, 650,550, 650,500, 650,550, 600,550, 650,500, 650,550, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 650,1600, 650,500, 650,1600, 650,550, 600,550, 650,500, 650,550, 650,1600, 650,500, 650,1600, 650,550, 600,1650, 650,1600, 600,1650, 650};
return "Minus";
}
else if (resultsValue == 16748655)
{ // unsigned int buttonPlus[67] = {9250,4450, 650,550, 650,500, 650,550, 600,550, 600,550, 650,550, 650,500, 650,550, 600,1650, 600,1650, 650,1600, 600,1650, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 600,550, 650,1600, 650,500, 650,550, 650,500, 650,550, 600,550, 650,1600, 650,1600, 650,550, 600,1650, 600,1650, 600,1650, 600,1650, 600};
return "Plus";
}
else if (resultsValue == 16738455)
{ // unsigned int button0[67] = {9200,4500, 600,550, 650,550, 600,550, 600,600, 600,550, 600,550, 650,550, 600,550, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 650,1600, 600,1650, 600,600, 600,1650, 600,1650, 600,550, 600,1650, 600,550, 650,550, 600,550, 600,1650, 650,550, 600,550, 600,1650, 600,550, 650,1600, 650,1600, 650,1600, 650};
return "0";
}
else if (resultsValue == 16750695)
{ // unsigned int buttonShuffle[67] = {9200,4500, 650,500, 650,550, 600,550, 650,500, 650,550, 650,500, 650,550, 600,550, 650,1600, 650,1600, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 650,1600, 650,550, 650,500, 650,1600, 650,1600, 650,550, 600,550, 650,500, 650,550, 650,1600, 650,1600, 650,500, 650,550, 600,1650, 600,1650, 600,1650, 600};
return "Shuffle";
}
else if (resultsValue == 16756815)
{ // unsigned int buttonUSD[67] = {9250,4450, 600,550, 650,550, 600,550, 650,500, 650,550, 600,550, 650,500, 650,550, 650,1600, 650,1600, 600,1650, 600,1650, 650,1600, 650,1600, 600,1650, 600,1650, 650,1600, 650,500, 650,1600, 650,1600, 650,550, 600,550, 650,500, 650,550, 600,550, 650,1600, 650,500, 650,550, 650,1600, 600,1650, 600,1650, 650,1600, 600};
return "USD";
}
else if (resultsValue == 16724175)
{ // unsigned int button1[67] = {9300,4400, 650,550, 600,550, 650,550, 600,550, 650,500, 650,550, 650,500, 650,500, 650,1600, 650,1600, 650,1600, 650,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,550, 650,500, 650,1600, 650,1600, 650,550, 600,550, 650,550, 600,550, 650,1600, 650,1600, 650,500, 650,550, 600,1650, 600,1650, 600,1650, 650,1600, 600};
return "1";
}
else if (resultsValue == 16718055)
{ // unsigned int button2[67] = {9300,4450, 650,500, 650,550, 600,550, 650,550, 600,550, 650,500, 650,550, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 600,550, 650,550, 600,1650, 600,1650, 600,550, 650,500, 650,550, 600,1650, 650,1600, 650,1600, 600,550, 600,600, 650,1600, 600,1650, 600,1650, 650};
return "2";
}
else if (resultsValue == 16743045)
{ // unsigned int button3[67] = {9250,4450, 650,500, 650,550, 650,500, 650,500, 650,550, 650,500, 650,550, 650,500, 650,1600, 650,1600, 600,1650, 650,1600, 650,1600, 600,1650, 600,1650, 650,1600, 600,550, 650,1600, 700,1550, 650,1600, 650,1600, 650,550, 600,1650, 600,550, 650,1600, 650,500, 650,550, 650,500, 650,500, 650,1600, 650,550, 600,1650, 650};
return "3";
}
else if (resultsValue == 16716015)
{ // unsigned int button4[67] = {9250,4450, 650,500, 650,550, 650,500, 650,550, 600,550, 650,500, 650,550, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,1600, 650,550, 600,550, 650,500, 650,1600, 650,550, 650,500, 650,550, 600,550, 650,1600, 650,1600, 650,1600, 650,500, 650,1600, 650,1600, 650,1600, 650,1600, 650};
return "4";
}
else if (resultsValue == 16726215)
{ // unsigned int button5[67] = {9300,4450, 650,500, 650,550, 650,500, 650,550, 600,550, 650,500, 650,550, 650,500, 650,1600, 650,1600, 650,1600, 650,1650, 650,1600, 600,1650, 650,1600, 650,1600, 650,500, 650,550, 650,1600, 650,1600, 650,1600, 650,550, 700,450, 700,500, 600,1650, 600,1650, 650,500, 650,550, 600,550, 650,1600, 650,1600, 650,1600, 650};
return "5";
}
else if (resultsValue == 16734885)
{ // unsigned int button6[67] = {9200,4500, 650,550, 650,500, 650,550, 600,550, 600,550, 650,550, 600,550, 650,550, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 650,550, 600,1650, 600,550, 600,1650, 650,1600, 650,550, 600,1650, 650,500, 650,1600, 650,550, 600,1650, 650,500, 650,550, 600,1650, 650,500, 650,1600, 650};
return "6";
}
else if (resultsValue == 16728765)
{ // unsigned int button7[67] = {9250,4450, 600,600, 600,550, 650,500, 650,550, 600,550, 650,550, 600,550, 600,550, 650,1600, 650,1650, 600,1650, 600,1650, 600,1650, 650,1600, 650,1600, 600,1650, 600,550, 650,1600, 650,550, 600,550, 650,550, 600,550, 650,1600, 650,550, 600,1650, 600,550, 600,1650, 650,1600, 600,1650, 650,1600, 650,550, 600,1650, 600};
return "7";
}
else if (resultsValue == 16730805)
{ // unsigned int button8[67] = {9250,4450, 600,550, 650,550, 600,550, 650,500, 650,550, 650,500, 650,550, 600,550, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,600, 600,1650, 600,550, 650,550, 600,1650, 600,550, 600,1650, 650,500, 650,1600, 650,550, 600,1650, 600,1650, 650,500, 650,1600, 650,550, 600,1650, 600};
return "8";
}
else if (resultsValue == 16732845)
{ // unsigned int button9[67] = {9250,4450, 650,550, 600,550, 650,500, 650,550, 650,500, 650,550, 600,550, 650,500, 650,1600, 650,1600, 650,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,1650, 600,550, 650,1600, 650,550, 600,1650, 600,550, 650,500, 650,1600, 650,550, 650,1600, 650,500, 650,1600, 650,550, 600,1650, 650,1600, 600,550, 650,1600, 650};
return "9";
}
else if (resultsValue == 4294967295)
{ // unsigned int buttonLongPress[3] = {9200,2200, 650};
return "Long Press";
}
else
{
return "UNKNOWN";
}
} | 11,775 | 8,698 |
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 7/20/2019 11:36:22 PM
*************************************************************************/
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<complex>
#include<stack>
#include<bitset>
#include<iomanip>
#include<list>
#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#endif
#define ll long long
#define ull unsigned long long
using namespace std;
const double clf=1e-8;
const int MMAX=0x7fffffff;
const int INF=0xfffffff;
const int mod=1e9+7;
int a[110];
int dp[110];
bool vis[110][110];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
//freopen("C:\\Users\\LENOVO\\Desktop\\out.txt","w",stdout);
int n,sum=0;
cin>>n;
vector<int> v;
vector<int> temp;
for(int i=0;i<n;i++)
cin>>a[i],sum+=a[i];
int res=a[0];
v.push_back(0);
for(int i=1;i<n;i++)
if(a[i]<=a[0]/2)
{
v.push_back(i);
res+=a[i];
}
if(res>sum/2)
{
cout<<v.size()<<endl;
for(auto i:v)
cout<<i+1<<" ";
cout<<endl;
}
else cout<<"0"<<endl;
return 0;
}
| 1,413 | 633 |
#include <libutl/libutl.h>
#include <libutl/AutoPtr.h>
#include <libutl/Bool.h>
#include <libutl/MaxObject.h>
#include <libutl/String.h>
#include <libutl/Uint.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
UTL_CLASS_IMPL_ABC(utl::Object);
////////////////////////////////////////////////////////////////////////////////////////////////////
UTL_NS_BEGIN;
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::clear()
{
AutoPtr<utl::Object> newInstance = this->create();
copy(*newInstance);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
int
Object::compare(const Object& rhs) const
{
// default object comparison logic
// if lhs or rhs has a key, we can re-start the comparison process using the key(s)
const Object& thisKey = getKey();
const Object& rhsKey = rhs.getKey();
if ((&thisKey != this) || (&rhsKey != &rhs))
{
return thisKey.compare(rhsKey);
}
// as a last resort, compare addresses
const void* lhsAddr = this;
const void* rhsAddr = &rhs;
return utl::compare(lhsAddr, rhsAddr);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::copy(const Object& rhs)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::vclone(const Object& rhs)
{
copy(rhs);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::steal(Object& rhs)
{
vclone(rhs);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::dump(Stream& os, uint_t) const
{
// get a string representation
String s = toString();
// get the object's key (if any)
const Object& key = getKey();
// if "toString" hasn't been overloaded (which is indicated by toString() returning only the
// .. class name), also give the key's string representation.
if ((s == getClassName()) && (&key != this) && (key.toString() != key.getClassName()))
{
s += ": ";
s += key.toString();
}
os << s << endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::dumpWithClassName(Stream& os, uint_t indent, uint_t level) const
{
if (indent == 0)
{
os << "=== ";
}
os << getClassName() << endl;
os.indent(indent);
dump(os, level);
os.unindent(indent);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Object&
Object::getKey() const
{
// no key by default
return self;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Object&
Object::getProxiedObject() const
{
// not proxying anything by default
return self;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Object&
Object::getProxiedObject()
{
// not proxying anything by default
return self;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t
Object::hash(size_t size) const
{
if (hasKey())
{
return getKey().hash(size);
}
else
{
size_t n = (size_t)this;
return (n % (size_t)size);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::serialize(Stream&, uint_t, uint_t)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Object*
Object::serializeInNullable(Stream& is, uint_t mode)
{
bool objectExists;
utl::serialize(objectExists, is, io_rd, mode);
if (objectExists)
{
return serializeInBoxed(is, mode);
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::serializeOutNullable(const Object* object, Stream& os, uint_t mode)
{
// first serialize a boolean value indicating whether or not an object is actually present
bool objectExists = (object != nullptr);
utl::serialize(objectExists, os, io_wr, mode);
// if there is an object, serialize it (boxed)
if (objectExists)
{
object->serializeOutBoxed(os, mode);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::serializeNullable(Object*& object, Stream& stream, uint_t io, uint_t mode)
{
if (io == io_rd)
{
object = serializeInNullable(stream, mode);
}
else
{
serializeOutNullable(object, stream, mode);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Object*
Object::serializeInBoxed(Stream& is, uint_t mode)
{
// write the className
String className;
className.serialize(is, io_rd, mode);
// use it to find the associated RunTimeClass object
const RunTimeClass* rtc = RunTimeClass::find(className);
// no RunTimeClass object -> we're done
if (rtc == nullptr)
{
throw StreamSerializeEx(utl::clone(is.getNamePtr()));
}
// use the RunTimeClass object to create an instance of the class
Object* res = rtc->create();
AutoPtr<> resPtr = res;
// serialize into this newly created instance
res->serializeIn(is, mode);
// don't destroy the object if it was serialized successfully
resPtr.release();
return res;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void
Object::serializeOutBoxed(Stream& os, uint_t mode) const
{
String className(getClassName());
className.serialize(os, io_wr, mode);
serializeOut(os, mode);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
String
Object::toString() const
{
String res = getClassName();
const Object& key = getKey();
if (&key != this)
{
res += ": ";
res += key.toString();
}
return res;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Object::operator String() const
{
return toString();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t
Object::allocatedSize() const
{
return getClass()->size() + innerAllocatedSize();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
size_t
Object::innerAllocatedSize() const
{
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
void
Object::addOwnedIt(const class FwdIt* it) const
{
ABORT();
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
void
Object::removeOwnedIt(const class FwdIt* it) const
{
ABORT();
}
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
UTL_NS_END;
| 7,354 | 1,831 |
#include <Arduino.h>
#include "th02.hpp"
#include "upm_utilities.h"
#include "jhd1313m1.h"
int main();
int
main() {
// Set the subplatform for the shield
mraa_add_subplatform(MRAA_GROVEPI, "0");
// Create the temperature & humidity sensor object
upm::TH02 sensor;
// initialize the LCD and check for initialization
jhd1313m1_context lcd = jhd1313m1_init(0, 0x3e, 0x62);
if (!lcd) {
printf("jhd1313m1_i2c_init() failed\n");
return 1;
}
// set the LCD parameters
char string1[20];
char string2[20];
uint8_t rgb[7][3] = {
{0xd1, 0x00, 0x00},
{0xff, 0x66, 0x22},
{0xff, 0xda, 0x21},
{0x33, 0xdd, 0x00},
{0x11, 0x33, 0xcc},
{0x22, 0x00, 0x66},
{0x33, 0x00, 0x44}};
// Read the temperature and humidity printing both the Celsius and
// equivalent Fahrenheit temperature and Relative Humidity, waiting two seconds between readings
while (1) {
float celsius = sensor.getTemperature();
float fahrenheit = (celsius * 9.0 / 5.0 + 32.0);
float humidity = sensor.getHumidity();
printf("%2.3f Celsius, or %2.3f Fahrenheit\n", celsius, fahrenheit);
printf("%2.3f%% Relative Humidity\n", humidity);
snprintf(string1, sizeof(string1), "Temperature:");
snprintf(string2, sizeof(string2), "%2.1f%cF %2.1f%cC", fahrenheit, 223, celsius, 223);
// Alternate rows on the LCD
jhd1313m1_set_cursor(lcd, 0, 0);
jhd1313m1_write(lcd, string1, strlen(string1));
jhd1313m1_set_cursor(lcd, 1, 0);
jhd1313m1_write(lcd, string2, strlen(string2));
// Change the color
uint8_t r = rgb[(int)fahrenheit%7][0];
uint8_t g = rgb[(int)fahrenheit%7][1];
uint8_t b = rgb[(int)fahrenheit%7][2];
jhd1313m1_set_color(lcd, r, g, b);
upm_delay(2);
jhd1313m1_clear(lcd);
snprintf(string1, sizeof(string1), "Humidity:");
snprintf(string2, sizeof(string2), "%2.1f%%", humidity);
// Alternate rows on the LCD
jhd1313m1_set_cursor(lcd, 0, 0);
jhd1313m1_write(lcd, string1, strlen(string1));
jhd1313m1_set_cursor(lcd, 1, 0);
jhd1313m1_write(lcd, string2, strlen(string2));
upm_delay(2);
jhd1313m1_clear(lcd);
}
return 0;
}
| 2,298 | 1,029 |
/* Copyright 2017-2018 All Rights Reserved.
* Gyeonghwan Hong (redcarrottt@gmail.com)
*
* [Contact]
* Gyeonghwan Hong (redcarrottt@gmail.com)
*
* 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 "../inc/NetworkInitializer.h"
#include "../inc/CommandRfkill.h"
#include "../../common/inc/ChildProcess.h"
#include "../../common/inc/DebugLog.h"
#include "../../configs/BtConfig.h"
#include "../../configs/ExpConfig.h"
#include "../../configs/PathConfig.h"
#include "../../configs/WfdConfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace sc;
void NetworkInitializer::initialize(void) {
char cmdLine[500] = {
0,
};
// Step 1. Bluetooth OFF
LOG_VERB("Init (1/3): BT OFF");
CommandRfkill::block_device(DEFAULT_BT_DEVICE_RFKILL_NAME);
snprintf(cmdLine, 500, "%s %s down", HCICONFIG_PATH,
DEFAULT_BT_INTERFACE_NAME);
system(cmdLine);
// Step 2. Bluetooth ON
LOG_VERB("Init (2/3): BT ON");
CommandRfkill::unblock_device(DEFAULT_BT_DEVICE_RFKILL_NAME);
snprintf(cmdLine, 500, "%s %s up piscan", HCICONFIG_PATH,
DEFAULT_BT_INTERFACE_NAME);
system(cmdLine);
// Step 3. Wi-fi Direct OFF
LOG_VERB("Init (3/3). Wi-fi Direct OFF");
snprintf(cmdLine, 500, "killall udhcpd -q", KILLALL_PATH);
system(cmdLine);
// snprintf(cmdLine, 500, "%s %s down", IFCONFIG_PATH,
// DEFAULT_WFD_INTERFACE_NAME);
// system(cmdLine);
#if CONFIG_REALTEK_MODE == 1
#else
// snprintf(cmdLine, 500, "%s %s", IFDOWN_PATH, DEFAULT_WFD_INTERFACE_NAME);
// system(cmdLine);
#endif
// Step 4. Wi-fi ON
LOG_VERB("Init (4/3). Wi-fi Direct ON");
#if CONFIG_REALTEK_MODE == 1
#else
// snprintf(cmdLine, 500, "%s %s", IFUP_PATH,
// DEFAULT_WFD_INTERFACE_NAME);
// system(cmdLine);
#endif
// snprintf(cmdLine, 500, "%s %s up", IFCONFIG_PATH,
// DEFAULT_WFD_INTERFACE_NAME); system(cmdLine);
#if CONFIG_REALTEK_MODE == 1
// Restart wpa_supplicant
snprintf(cmdLine, 500, "%s wpa_supplicant -q", KILLALL_PATH);
system(cmdLine);
sleep(3);
FILE *p2p_conf_file = NULL;
p2p_conf_file = fopen("p2p.conf", "w");
if (p2p_conf_file == NULL) {
LOG_ERR("Cannot write p2p.conf file");
return;
}
fprintf(p2p_conf_file, "ctrl_interface=/var/run/wpa_supplicant \
\nap_scan=1 \
\ndevice_name=SelCon \
\ndevice_type=1-0050F204-1 \
\ndriver_param=p2p_device=1 \
\n\nnetwork={ \
\n\tmode=3 \
\n\tdisabled=2 \
\n\tssid=\"DIRECT-SelCon\" \
\n\tkey_mgmt=WPA-PSK \
\n\tproto=RSN \
\n\tpairwise=CCMP \
\n\tpsk=\"12345670\" \
\n}");
fclose(p2p_conf_file);
snprintf(cmdLine, 500, "%s -Dnl80211 -iwlan1 -cp2p.conf -Bd",
WPA_SUPPLICANT_PATH);
system(cmdLine);
#endif
}
int NetworkInitializer::ping_wpa_cli(char ret[], size_t len) {
char const *const params[] = {"wpa_cli", "-i", DEFAULT_WFD_INTERFACE_NAME,
"ping", NULL};
return ChildProcess::run(WPA_CLI_PATH, params, ret, len, true);
}
void NetworkInitializer::retrieve_wpa_interface_name(std::string &wpaIntfName) {
char wpaIntfNameCstr[100];
char buf[1024];
// In the case of Wi-fi USB Dongle, it uses 'wlanX'.
snprintf(wpaIntfNameCstr, sizeof(wpaIntfNameCstr), DEFAULT_WFD_INTERFACE_NAME,
strlen(DEFAULT_WFD_INTERFACE_NAME));
// In the case of Raspberry Pi 3 Internal Wi-fi Module, it uses 'p2p-wlanX-Y'.
int ret = this->ping_wpa_cli(buf, 1024);
if (ret < 0) {
LOG_ERR("P2P ping call failed");
return;
} else {
char *ptrptr;
char *ptr = strtok_r(buf, "\t \n\'", &ptrptr);
while (ptr != NULL) {
if (strstr(ptr, "p2p-wlan")) {
snprintf(wpaIntfNameCstr, sizeof(wpaIntfNameCstr), "%s", ptr);
} else if (strstr(ptr, "FAIL")) {
LOG_ERR("P2P ping failed");
return;
}
ptr = strtok_r(NULL, "\t \n\'", &ptrptr);
}
}
wpaIntfName.assign(wpaIntfNameCstr, strlen(wpaIntfNameCstr));
} | 4,454 | 1,848 |
#include "coreir/ir/types.h"
#include "coreir/ir/globalvalue.h"
#include "coreir/ir/casting/casting.h"
#include "coreir/ir/context.h"
#include "coreir/ir/namespace.h"
#include "coreir/ir/common.h"
#include "coreir/ir/error.h"
#include "coreir/ir/typegen.h"
#include "coreir/ir/value.h"
using namespace std;
namespace CoreIR {
void Type::print(void) const { cout << "Type: " << (*this) << endl; }
string Type::TypeKind2Str(TypeKind t) {
switch(t) {
case TK_Bit : return "Bit";
case TK_BitIn : return "BitIn";
case TK_Array : return "Array";
case TK_Record : return "Record";
case TK_Named : return "Named";
default : return "NYI";
}
}
Type* Type::Arr(uint i) {
return c->Array(i,this);
}
bool Type::isBaseType() {return isa<BitType>(this) || isa<BitInType>(this) || isa<BitInOutType>(this);}
Type* Type::sel(string selstr) {
if (auto rt = dyn_cast<RecordType>(this)) {
ASSERT(rt->getRecord().count(selstr),"Bad Select!");
//return *(rt->getRecord().find(selstr));
return rt->getRecord().at(selstr);
}
else if (auto at = dyn_cast<ArrayType>(this)) {
ASSERT(isNumber(selstr),selstr + " needs to be a number!");
uint i = std::stoi(selstr,nullptr,0);
ASSERT(i < at->getLen(),"Bad Select!");
return at->getElemType();
}
ASSERT(0,"Bad Select");
}
vector<std::string> Type::getSelects() {
if (auto rt = dyn_cast<RecordType>(this)) {
return rt->getFields();
}
else if (auto at = dyn_cast<ArrayType>(this)) {
vector<std::string> ret;
for (uint i=0; i<at->getLen(); ++i) {
ret.push_back(to_string(i));
}
return ret;
}
else {
return vector<std::string>();
}
}
bool Type::canSel(string selstr) {
if (auto rt = dyn_cast<RecordType>(this)) {
return rt->getRecord().count(selstr);
}
else if (auto at = dyn_cast<ArrayType>(this)) {
if (!isNumber(selstr)) return false;
uint i = std::stoi(selstr,nullptr,0);
return i < at->getLen();
}
return false;
}
bool Type::canSel(SelectPath path) {
if (path.size()==0) return true;
string sel = path.front();
if (!this->canSel(sel)) return false;
path.pop_front();
return this->sel(sel)->canSel(path);
}
bool Type::hasInput() const {
if (isInput() ) return true;
if (isMixed()) {
if (auto at = dyn_cast<ArrayType>(this)) {
return at->getElemType()->hasInput();
}
else if (auto nt = dyn_cast<NamedType>(this)) {
return nt->getRaw()->hasInput();
}
else if (auto rt = dyn_cast<RecordType>(this)) {
bool ret = false;
for (auto field : rt->getRecord()) {
ret |= field.second->hasInput();
}
return ret;
}
assert(0);
}
return false;
}
std::ostream& operator<<(ostream& os, const Type& t) {
os << t.toString();
return os;
}
string RecordType::toString(void) const {
string ret = "{";
uint len = record.size();
uint i=0;
for(auto sel : _order) {
ret += "'" + sel + "':" + record.at(sel)->toString();
ret += (i==len-1) ? "}" : ", ";
++i;
}
return ret;
}
NamedType::NamedType(Namespace* ns, std::string name, Type* raw) : Type(TK_Named,raw->getDir(),ns->getContext()), GlobalValue(GVK_NamedType,ns,name), raw(raw) {}
NamedType::NamedType(Namespace* ns, string name, TypeGen* typegen, Values genargs) : Type(TK_Named,DK_Mixed,ns->getContext()), GlobalValue(GVK_NamedType,ns,name), typegen(typegen), genargs(genargs) {
//Check args here.
checkValuesAreParams(genargs,typegen->getParams());
//Run the typegen
raw = typegen->getType(genargs);
dir = raw->getDir();
}
void NamedType::print() const {
cout << "NYI print on named type" << endl;
}
//Stupid hashing wrapper for enum
RecordType::RecordType(Context* c, RecordParams _record) : Type(TK_Record,DK_Null,c) {
set<uint> dirs; // Slight hack because it is not easy to hash enums
for(auto field : _record) {
checkStringSyntax(field.first);
record.emplace(field.first,field.second);
_order.push_back(field.first);
dirs.insert(field.second->getDir());
}
assert(dirs.count(DK_Null) == 0);
if (dirs.size()==0) {
dir = DK_Null;
}
else if (dirs.size() > 1) {
dir = DK_Mixed;
}
else {
dir = (DirKind) *(dirs.begin());
}
}
RecordType* RecordType::appendField(string label, Type* t) {
checkStringSyntax(label);
ASSERT(this->getRecord().count(label)==0,"Cannot append " + label + " to type: " + this->toString());
RecordParams newParams({{label,t}});
for (auto rparam : this->getRecord()) {
newParams.push_back({rparam.first,rparam.second});
}
return c->Record(newParams);
}
RecordType* RecordType::detachField(string label) {
ASSERT(this->getRecord().count(label)==1,"Cannot detach" + label + " from type: " + this->toString());
RecordParams newParams;
for (auto rparam : this->getRecord()) {
if (rparam.first == label) continue;
newParams.push_back({rparam.first,rparam.second});
}
return c->Record(newParams);
}
uint RecordType::getSize() const {
uint size = 0;
for (auto field : record) {
size += field.second->getSize();
}
return size;
}
bool isClockOrNestedClockType(Type* type, Type* clockType) {
if (type == clockType) {
return true;
} else if (auto arrayType = dyn_cast<ArrayType>(type)) {
return isClockOrNestedClockType(arrayType->getElemType(), clockType);
} else if (auto recordType = dyn_cast<RecordType>(type)) {
bool isNestedClockType = false;
for (auto field : recordType->getRecord()) {
isNestedClockType |= isClockOrNestedClockType(field.second,
clockType);
}
return isNestedClockType;
}
return false;
}
}//CoreIR namespace
| 5,727 | 2,088 |
#include "Camera.h"
void Camera::setX(double x) {
xPosition = x;
}
void Camera::setY(double y) {
yPosition = y;
}
double Camera::getY() {
return yPosition;
}
double Camera::getX() {
return xPosition;
} | 209 | 84 |
#define SECURITY_WIN32 // For sspi.h
#define QCC_OS_GROUP_WINDOWS
#include "intrinfix.h"
#include "windows.fixed.h"
#include <sdkddkver.h>
#include <ks.h>
#include <ksmedia.h>
#include <tuner.h>
#include <segment.h>
#include <msvidctl.h>
#include <regbag.h>
#include <bdatypes.h>
#include <sbe.h>
#include <encdec.h>
#include <tvratings.h>
#include <mpeg2data.h>
#include <atscpsipparser.h>
#include <dsattrib.h>
#include <bdaiface.h>
#include <bdatif.h>
#include <mpeg2psiparser.h>
#include <dvbsiparser.h>
#include <strmif.h>
#include <mpeg2structs.h>
#include <bdamedia.h>
//#include <bdaiface_enums.h>
#include <mpeg2bits.h>
| 633 | 295 |
#include "Grid.hpp"
#include "Tile.hpp"
#include "GridSprite.hpp"
#include "Stuff.hpp"
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
Grid::Grid() :
Sprite(),
atlas(nullptr)
{
}
Grid::~Grid()
{
}
void Grid::load(Context& ctx, const std::string& fn)
{
std::ifstream in(fn);
if (!in.is_open())
{
std::cout << "cannot open " << fn << "\n";
return;
}
json o;
in >> o;
in.close();
if (!json_has(o, "size"))
{
std::cout << "no size field\n";
return;
}
w = o["size"][0].get<int>();
h = o["size"][1].get<int>();
size = o["size"][2].get<int>();
padding = o["size"][3].get<int>();
border = o["size"][4].get<int>();
if (!json_has(o, "atlas"))
{
std::cout << "missing texture atlas field!\n";
return;
}
atlas = Assets::getTexture(o["atlas"]);
if (atlas == nullptr)
{
std::cout << "cannot find texture " << o["atlas"] << "\n";
return;
}
if (!json_has(o, "tiles"))
{
std::cout << "missing tiles field!\n";
return;
}
for (auto& e : o["tiles"])
{
Tile* tile = new Tile();
int x = e[0].get<int>();
int y = e[1].get<int>();
Texture* copy = atlas->subTextureP(
ctx,
border + (x * size) + (x * padding),
border + (y * size) + (y * padding),
e[2].get<int>(),
e[3].get<int>()
);
Texture* tex = new Texture(ctx, *copy);
delete copy;
Assets::registerTexture(ctx, tex, ""); // let Assets handle disposal
tile->setTexture(tex);
tile->solid = (bool)e[4].get<int>();
tiles.push_back(tile);
}
if (!json_has(o, "data"))
{
std::cout << "missing data field!\n";
return;
}
for (auto& e : o["data"])
{
grid.push_back(tiles[e.get<int>()]);
}
}
GridSprite* Grid::at(int x, int y)
{
GridSprite* g = nullptr;
for (auto& e : children)
{
g = dynamic_cast<GridSprite*>(e);
if (g)
{
if (g->getGridPos().equals(Point(x, y)))
{
break;
}
}
g = nullptr;
}
return g;
}
void Grid::draw(Context& ctx, float ex)
{
int r = 0;
int c = 0;
int i = 0;
for (auto& e : grid)
{
r = i / w;
c = i % w;
e->x = c * 32;
e->y = r * 32;
e->draw(ctx, ex);
++i;
}
}
int Grid::ctoi(int x, int y)
{
return y * h + x;
}
Point Grid::itoc(int i)
{
Point p;
p.x = i % w;
p.y = i / w;
return p;
}
bool Grid::checkMove(int x, int y)
{
int index = ctoi(x, y);
bool valid = !grid[index]->solid;
for (auto& e : children)
{
GridSprite* s = nullptr;
s = dynamic_cast<GridSprite*>(e);
if (s != nullptr)
{
valid = valid && !s->getGridPos().equals(Point(x, y));
}
}
return valid;
}
int Grid::getSize()
{
return size;
}
| 3,075 | 1,179 |
#include <eeros/logger/StreamLogWriter.hpp>
#include <eeros/sequencer/Sequencer.hpp>
#include <eeros/sequencer/Sequence.hpp>
#include <eeros/sequencer/Wait.hpp>
#include <eeros/core/Fault.hpp>
#include <signal.h>
#include <chrono>
#include <gtest/gtest.h>
namespace seqTest4 {
using namespace eeros::sequencer;
int count = 0;
int eCount = 0;
int limit = 5;
class MyCondition : public Condition {
bool validate() {return count >= 13 && eCount < 1;} // just trigger once
};
class ExceptionSeq : public Sequence {
public:
ExceptionSeq(std::string name, Sequence* caller) : Sequence(name, caller, true) { }
int action() {
count += 100;
eCount++;
if (eCount == 3) limit = 2;
return 0;
}
};
class MainSequence : public Sequence {
public:
MainSequence(std::string name, Sequencer& seq) : Sequence(name, seq), e1("e1", this), m("mon", this, cond, SequenceProp::abort, &e1) {
addMonitor(&m);
}
int action() {
count = 10;
return count;
}
bool checkExitCondition() {return count++ >= 121;}
ExceptionSeq e1;
MyCondition cond;
Monitor m;
};
// Test condition
TEST(seqTest4, condition) {
auto& sequencer = Sequencer::instance();
sequencer.clearList();
MainSequence mainSeq("Main Sequence", sequencer);
count = 0;
eCount = 0;
mainSeq.m.setBehavior(SequenceProp::abort);
mainSeq();
sequencer.wait();
EXPECT_EQ(count, 114);
EXPECT_EQ(eCount, 1);
}
}
| 1,418 | 527 |
#include "camera.hpp"
#include "engine.hpp"
#include "game_session.hpp"
namespace space
{
CameraProps::CameraProps() : scale(1.0f), following(false), followingRotation(false)
{
}
Camera::Camera(Engine &engine, std::string debugName) : debugName(debugName), _engine(engine), _zoomScale(1.0f)
{
}
void Camera::update(sf::Time dt)
{
setZoomScaleFromEngine();
if (_props.following)
{
SpaceObject *followingObject;
if (_engine.currentSession()->tryGetSpaceObject(_props.followingId, followingObject))
{
auto trans = followingObject->worldTransform();
sf::Vector2f pos(trans.getMatrix()[12], trans.getMatrix()[13]);
_view.setCenter(pos);
//std::cout << "Camera [" << debugName << "]: " << pos.x << ", " << pos.y << std::endl;
}
else
{
std::cout << "Camera [" << debugName << "]: Not found!" << std::endl;
}
}
auto resetRotation = true;
if (_props.followingRotation)
{
SpaceObject *followingObject;
if (_engine.currentSession()->tryGetSpaceObject(_props.followingRotationId, followingObject))
{
resetRotation = false;
_view.setRotation(followingObject->transform().rotation);
}
}
if (resetRotation && _view.getRotation() != 0.0f)
{
_view.setRotation(0.0f);
}
}
void Camera::scale(float scale)
{
if (scale != _props.scale)
{
_props.scale = scale;
updateViewSize();
}
}
void Camera::zoomScale(float scale)
{
if (scale != _zoomScale)
{
_zoomScale = scale;
updateViewSize();
}
}
void Camera::setZoomScaleFromEngine()
{
zoomScale(_engine.cameraScale());
}
void Camera::size(sf::Vector2f size)
{
_size = size;
updateViewSize();
}
void Camera::center(sf::Vector2f center)
{
_view.setCenter(center);
}
void Camera::rotation(float rotation)
{
_view.setRotation(rotation);
}
void Camera::followingId(const ObjectId &id)
{
_props.followingId = id;
_props.following = true;
}
void Camera::following(bool following)
{
_props.following = following;
}
void Camera::followingRotationId(const ObjectId &id)
{
_props.followingRotationId = id;
_props.followingRotation = true;
}
void Camera::followingRotation(bool following)
{
_props.followingRotation = following;
}
const sf::View &Camera::view() const
{
return _view;
}
float Camera::getRotation() const
{
if (_props.followingRotation)
{
SpaceObject *followingObject;
if (_engine.currentSession()->tryGetSpaceObject(_props.followingRotationId, followingObject))
{
return followingObject->transform().rotation;
}
}
return _view.getRotation();
}
void Camera::cameraProps(const CameraProps &props)
{
_props = props;
updateViewSize();
}
void Camera::updateViewSize()
{
auto size = _size / (_props.scale * _zoomScale);
_view.setSize(size);
}
sf::FloatRect Camera::viewport() const
{
auto size = _view.getSize();
auto center = _view.getCenter();
return sf::FloatRect(center.x - size.x * 0.5f, center.y - size.y * 0.5f, size.x, size.y);
}
} | 3,689 | 1,105 |
// Copyright 2021 The WebNN-native Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <memory>
#include <numeric>
#include <vector>
#include "common/Log.h"
#include "examples/LeNet/LeNet.h"
#include "examples/LeNet/MnistUbyte.h"
#include "examples/SampleUtils.h"
const size_t TOP_NUMBER = 3;
void SelectTopKData(std::vector<float> outputData,
std::vector<size_t>& topKIndex,
std::vector<float>& topKData) {
std::vector<size_t> indexes(outputData.size());
std::iota(std::begin(indexes), std::end(indexes), 0);
std::partial_sort(
std::begin(indexes), std::begin(indexes) + TOP_NUMBER, std::end(indexes),
[&outputData](unsigned l, unsigned r) { return outputData[l] > outputData[r]; });
std::sort(outputData.rbegin(), outputData.rend());
for (size_t i = 0; i < TOP_NUMBER; ++i) {
topKIndex[i] = indexes[i];
topKData[i] = outputData[i];
}
}
void PrintResult(webnn::Result output) {
const float* outputBuffer = static_cast<const float*>(output.Buffer());
std::vector<float> outputData(outputBuffer, outputBuffer + output.BufferSize() / sizeof(float));
std::vector<size_t> topKIndex(TOP_NUMBER);
std::vector<float> topKData(TOP_NUMBER);
SelectTopKData(outputData, topKIndex, topKData);
std::cout << std::endl << "Prediction Result:" << std::endl;
std::cout << "#"
<< " "
<< "Label"
<< " "
<< "Probability" << std::endl;
std::cout.precision(2);
for (size_t i = 0; i < TOP_NUMBER; ++i) {
std::cout << i << " ";
std::cout << std::left << std::setw(5) << std::fixed << topKIndex[i] << " ";
std::cout << std::left << std::fixed << 100 * topKData[i] << "%" << std::endl;
}
std::cout << std::endl;
}
void ShowUsage() {
std::cout << std::endl;
std::cout << "LeNet [OPTIONs]" << std::endl << std::endl;
std::cout << "Options:" << std::endl;
std::cout << " -h "
<< "Print this message." << std::endl;
std::cout << " -i \"<path>\" "
<< "Required. Path to an image." << std::endl;
std::cout << " -m \"<path>\" "
<< "Required. Path to a .bin file with trained weights." << std::endl;
}
int main(int argc, const char* argv[]) {
DumpMemoryLeaks();
std::string imagePath, modelPath;
for (int i = 1; i < argc; ++i) {
if (strcmp("-h", argv[i]) == 0) {
ShowUsage();
return 0;
}
if (strcmp("-i", argv[i]) == 0 && i + 1 < argc) {
imagePath = argv[i + 1];
} else if (strcmp("-m", argv[i]) == 0 && i + 1 < argc) {
modelPath = argv[i + 1];
}
}
if (imagePath.empty() || modelPath.empty()) {
dawn::ErrorLog() << "Invalid options.";
ShowUsage();
return -1;
}
MnistUbyte reader(imagePath);
if (!reader.DataInitialized()) {
dawn::ErrorLog() << "The input image is invalid.";
return -1;
}
if (reader.Size() != 28 * 28) {
dawn::ErrorLog() << "The expected size of the input image is 784 (28 * 28), but got "
<< reader.Size() << ".";
return -1;
}
LeNet lenet;
if (!lenet.Load(modelPath)) {
dawn::ErrorLog() << "Failed to load LeNet.";
return -1;
}
if (!lenet.Compile()) {
dawn::ErrorLog() << "Failed to compile LeNet.";
return -1;
}
std::vector<float> input(reader.GetData().get(), reader.GetData().get() + reader.Size());
webnn::Result result = lenet.Compute(input.data(), input.size() * sizeof(float));
if (!result) {
dawn::ErrorLog() << "Failed to compute LeNet.";
return -1;
}
PrintResult(result);
dawn::InfoLog() << "Done.";
}
| 4,478 | 1,502 |
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
int steps = 10000;
cout << steps << "\n";
for(int i = 0; i < steps; i++){
cout << ((rand() % 2 == 0) ? "Left " : "Right ")<< (rand() % 180) + 1 << " " << (rand() % 100) + 1 << "\n";
}
return 0;
}
| 298 | 131 |
#include "loadwindow.h"
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QLabel>
LoadWindow::LoadWindow(): QWidget()
{
#if DEBUG_CREA_FORET
cout<< "Chargement d'une foret à partir d'un fichier "<< endl;
#endif
#if DEBUG_LOAD
cout<< "Taille : " << largeur<< " en largeur "<< hauteur<< " en hauteur" <<endl;
#endif
resize(400, 30);
QVBoxLayout* layLoad= new QVBoxLayout(this);
QLabel* txtLoad= new QLabel("Chargement de la foret");
PB_load= new QProgressBar();
layLoad->addWidget(txtLoad);
layLoad->addWidget(PB_load);
show();
}
LoadWindow::~LoadWindow()
{
delete PB_load;
}
void LoadWindow::setProgress(int pourcentage)
{
PB_load->setValue(pourcentage);
}
void LoadWindow::closeProgress()
{
hide();
delete PB_load;
} | 748 | 307 |
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
vector<int> ans;
void inorder(TreeNode* node)
{
if(!node) return ;
inorder(node->left);
ans.push_back(node->val);
inorder(node->right);
}
void fix(TreeNode* node,int src,int des)
{
if(!node) return ;
fix(node->left,src,des);
if(node->val==src)
{
node->val = des;
}
else if(node->val==des)
{
node->val = src;
}
fix(node->right,src,des);
}
void recoverTree(TreeNode* root) {
inorder(root);
vector<int> diff;
for(int i=0;i< (ans.size()-1 ) ;i++)
{
if(ans[i]>=ans[i+1])
{
diff.push_back(ans[i]);
break;
}
}
for(int i=ans.size()-1;i>=0 ;i--)
{
if(ans[i]<=ans[i-1])
{
diff.push_back(ans[i]);
break;
}
}
fix(root,diff[0],diff[1]);
}
};
| 1,783 | 524 |
#include "ContractWidget.h"
#include "ui_ContractWidget.h"
#include <QCoreApplication>
#include <QGuiApplication>
#include <QClipboard>
#include <QDir>
#include <QMenu>
#include "ChainIDE.h"
#include "datamanager/DataManagerHX.h"
#include "datamanager/DataManagerUB.h"
#include "datamanager/DataManagerCTC.h"
#include "ConvenientOp.h"
class ContractWidget::DataPrivate
{
public:
DataPrivate()
:contextMenu(new QMenu())
{
}
public:
QMenu *contextMenu;//右键菜单
};
Q_DECLARE_METATYPE(DataManagerStruct::ContractInfoPtr)
Q_DECLARE_METATYPE(DataManagerStruct::AddressContractPtr)
ContractWidget::ContractWidget(QWidget *parent) :
QWidget(parent),
_p(new DataPrivate()),
ui(new Ui::ContractWidget)
{
ui->setupUi(this);
InitWidget();
}
ContractWidget::~ContractWidget()
{
delete _p;
_p = nullptr;
delete ui;
}
void ContractWidget::RefreshTree()
{
ui->functionWidget->Clear();
if(ChainIDE::getInstance()->getChainClass() == DataDefine::HX)
{
DataManagerHX::getInstance()->queryAccount();
}
else if(ChainIDE::getInstance()->getChainClass() == DataDefine::UB)
{
DataManagerUB::getInstance()->queryContract();
}
else if(ChainIDE::getInstance()->getChainClass() == DataDefine::CTC)
{
DataManagerCTC::getInstance()->queryAccount();
}
}
void ContractWidget::ContractClicked(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
if(current && current->parent())
{
ui->functionWidget->RefreshContractAddr(current->text(0));
}
}
void ContractWidget::CopyAddr()
{
if(QTreeWidgetItem *item = ui->treeWidget->currentItem())
{
QApplication::clipboard()->setText(item->data(0,Qt::UserRole).value<DataManagerStruct::ContractInfoPtr>()->GetContractAddr());
}
}
void ContractWidget::InitWidget()
{
//初始化右键菜单
ui->treeWidget->installEventFilter(this);
InitContextMenu();
ui->treeWidget->header()->setVisible(false);
ui->treeWidget->header()->setStretchLastSection(true);
ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
ui->splitter->setSizes(QList<int>()<<0.66*this->height()<<0.34*this->height());
connect(ui->treeWidget,&QTreeWidget::currentItemChanged,this,&ContractWidget::ContractClicked);
if(ChainIDE::getInstance()->getChainClass() == DataDefine::HX && (ChainIDE::getInstance()->getStartChainTypes() | DataDefine::NONE))
{
connect(DataManagerHX::getInstance(),&DataManagerHX::queryAccountFinish,DataManagerHX::getInstance(),&DataManagerHX::queryContract);
connect(DataManagerHX::getInstance(),&DataManagerHX::queryContractFinish,this,&ContractWidget::InitTree);
}
else if(ChainIDE::getInstance()->getChainClass() == DataDefine::UB && (ChainIDE::getInstance()->getStartChainTypes() | DataDefine::NONE))
{
connect(DataManagerUB::getInstance(),&DataManagerUB::queryContractFinish,this,&ContractWidget::InitTree);
}
else if(ChainIDE::getInstance()->getChainClass() == DataDefine::CTC && (ChainIDE::getInstance()->getStartChainTypes() | DataDefine::NONE))
{
connect(DataManagerCTC::getInstance(),&DataManagerCTC::queryAccountFinish,DataManagerCTC::getInstance(),&DataManagerCTC::queryContract);
connect(DataManagerCTC::getInstance(),&DataManagerCTC::queryContractFinish,this,&ContractWidget::InitTree);
}
}
void ContractWidget::InitTree()
{
ui->treeWidget->clear();
DataManagerStruct::AddressContractDataPtr data = nullptr;
if(ChainIDE::getInstance()->getChainClass() == DataDefine::HX)
{
data = DataManagerHX::getInstance()->getContract();
}
else if(ChainIDE::getInstance()->getChainClass() == DataDefine::UB)
{
data = DataManagerUB::getInstance()->getContract();
}
else if(ChainIDE::getInstance()->getChainClass() == DataDefine::CTC)
{
data = DataManagerCTC::getInstance()->getContract();
}
if(!data) return ;
for(auto it = data->getAllData().begin();it != data->getAllData().end();++it)
{
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList()<<(*it)->GetOwnerAddr()<<tr("合约描述"));
item->setFlags(Qt::ItemIsEnabled);
item->setData(0,Qt::UserRole,QVariant::fromValue<DataManagerStruct::AddressContractPtr>(*it));
item->setTextAlignment(0,Qt::AlignCenter);
ui->treeWidget->addTopLevelItem(item);
for(auto cont = (*it)->GetContracts().begin();cont != (*it)->GetContracts().end();++cont)
{
QTreeWidgetItem *childitem = new QTreeWidgetItem(QStringList()<<((*cont)->GetContractName().isEmpty()?(*cont)->GetContractAddr():(*cont)->GetContractName())<<(*cont)->GetContractDes());
childitem->setData(0,Qt::UserRole,QVariant::fromValue<DataManagerStruct::ContractInfoPtr>(*cont));
childitem->setToolTip(0,(*cont)->GetContractAddr());
childitem->setTextAlignment(0,Qt::AlignCenter);
item->addChild(childitem);
}
}
ui->treeWidget->expandAll();
}
void ContractWidget::InitContextMenu()
{
QAction *copyAction = new QAction(tr("复制地址"),this);
connect(copyAction,&QAction::triggered,this,&ContractWidget::CopyAddr);
_p->contextMenu->addAction(copyAction);
}
bool ContractWidget::eventFilter(QObject *watched, QEvent *event)
{
if(watched == ui->treeWidget && event->type() == QEvent::ContextMenu)
{
if(QTreeWidgetItem *item = ui->treeWidget->currentItem())
{
if(item->parent() && ui->treeWidget->itemAt(ui->treeWidget->viewport()->mapFromGlobal(QCursor::pos())) == item)
{
_p->contextMenu->exec(QCursor::pos());
}
}
}
return QWidget::eventFilter(watched,event);
}
void ContractWidget::retranslator()
{
ui->retranslateUi(this);
ui->functionWidget->retranslator();
}
| 5,872 | 1,834 |
#include <stack>
#include <fstream>
#include "xml_skeleton_exporter.h"
#include "vendor/rapidxml/rapidxml_print.hpp"
#include "xml_utils.hpp"
#include "config.h"
#include "logger.h"
using namespace rapidxml;
using namespace wcore;
namespace wconvert
{
static void xml_node_add_attribute(xml_document<>& doc, xml_node<>* node, const char* attr_name, const char* attr_val)
{
char* al_attr_name = doc.allocate_string(attr_name);
char* al_attr_val = doc.allocate_string(attr_val);
xml_attribute<>* attr = doc.allocate_attribute(al_attr_name, al_attr_val);
node->append_attribute(attr);
}
static void xml_node_set_value(xml_document<>& doc, xml_node<>* node, const char* value)
{
node->value(doc.allocate_string(value));
}
XMLSkeletonExporter::XMLSkeletonExporter()
{
wcore::CONFIG.get("root.folders.model"_h, exportdir_);
}
XMLSkeletonExporter::~XMLSkeletonExporter()
{
}
static std::string mat4_to_string(const math::mat4& matrix)
{
std::string matrix_str;
for(int ii=0; ii<16; ++ii)
{
matrix_str += std::to_string(matrix[ii]);
if(ii<15)
matrix_str += " ";
}
return matrix_str;
}
static void make_skeletton_DOM(xml_document<>& doc, rapidxml::xml_node<>* parent_xml_node, const Tree<BoneInfo>::nodeT* bone_node)
{
xml_node<>* current_xml_node = doc.allocate_node(node_element, "bone");
parent_xml_node->append_node(current_xml_node);
// Bone name
xml_node_add_attribute(doc, current_xml_node, "name", bone_node->data.name.c_str());
// Bone offset matrix
const math::mat4& offset_matrix = bone_node->data.offset_matrix;
std::string matrix_str(mat4_to_string(offset_matrix));
xml_node<>* matrix_xml_node = doc.allocate_node(node_element, "offset");
current_xml_node->append_node(matrix_xml_node);
xml_node_set_value(doc, matrix_xml_node, matrix_str.c_str());
for(auto* child = bone_node->first_node(); child; child = child->next_sibling())
{
make_skeletton_DOM(doc, current_xml_node, child);
}
}
bool XMLSkeletonExporter::export_skeleton(const AnimatedModelInfo& model_info)
{
std::string filename(model_info.model_name + ".skel");
DLOGN("<i>Exporting</i> skeletton to:", "wconvert");
DLOGI("<p>" + filename + "</p>", "wconvert");
// * Produce XML representation of model data
// Doctype declaration
xml_document<> doc;
xml_node<>* decl = doc.allocate_node(node_declaration);
decl->append_attribute(doc.allocate_attribute("version", "1.0"));
decl->append_attribute(doc.allocate_attribute("encoding", "UTF-8"));
doc.append_node(decl);
// Root node
xml_node<>* root = doc.allocate_node(node_element, "BoneHierarchy");
doc.append_node(root);
xml_node_add_attribute(doc, root, "name", model_info.model_name.c_str());
// Root transform
std::string matrix_str(mat4_to_string(model_info.root_transform));
xml_node<>* root_transform_xml_node = doc.allocate_node(node_element, "offset");
root->append_node(root_transform_xml_node);
xml_node_set_value(doc, root_transform_xml_node, matrix_str.c_str());
// Depth-first traversal of bone hierarchy
// We want to conserve the hierarchy in XML format
make_skeletton_DOM(doc, root, model_info.bone_hierarchy.get_root());
std::ofstream outfile;
outfile.open(exportdir_ / filename);
outfile << doc;
return true;
}
} // namespace wconvert
| 3,425 | 1,213 |
// -*- C++ -*-
/**
* @file hello_sender_exec.cpp
* @author Martin Corino
*
* @copyright Copyright (c) Remedy IT Expertise BV
*/
//@@{__RIDL_REGEN_MARKER__} - HEADER_END : hello_sender_impl.cpp[Header]
#include "hello_sender_exec.h"
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl[user_includes]
#include <thread>
#include "ciaox11/testlib/ciaox11_testlog.h"
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl[user_includes]
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl[user_global_impl]
// Your declarations here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl[user_global_impl]
namespace Hello_Sender_Impl
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl[user_namespace_impl]
//============================================================
// Worker thread for synchronous invocations for MyFoo
//============================================================
void
synch_foo_generator::set_context(
IDL::traits<Hello::CCM_Sender_Context>::ref_type context)
{
this->ciao_context_ = IDL::traits<Hello::CCM_Sender_Context>::narrow (std::move(context));
}
int
synch_foo_generator::svc ()
{
std::this_thread::sleep_for (std::chrono::seconds (3));
CIAOX11_TEST_INFO << "Sender:\t->get_connection_run_my_foo" << std::endl;
IDL::traits<Hello::MyFoo>::ref_type my_foo =
this->ciao_context_->get_connection_run_my_foo();
if (!my_foo)
{
CIAOX11_TEST_ERROR << "ERROR Sender:\t->get_connection_run_my_foo "
<< "returns null" << std::endl;
return 1;
}
try
{
int32_t answer;
for (uint16_t i = 0; i < 11; ++i)
{
my_foo->hello (answer);
CIAOX11_TEST_INFO << "Sender:\tsynch hello " << answer << std::endl;
}
}
catch (const Hello::InternalError& )
{
CIAOX11_TEST_INFO << "Sender:\tsynch hello get expected exception."
<< std::endl;
}
return 0;
}
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl[user_namespace_impl]
/**
* Facet Executor Implementation Class : foo_port_s_foo_prov_exec_i
*/
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[ctor]
foo_port_s_foo_prov_exec_i::foo_port_s_foo_prov_exec_i (
IDL::traits< ::Hello::CCM_Sender_Context>::ref_type context)
: context_ (std::move (context))
{
}
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[ctor]
foo_port_s_foo_prov_exec_i::~foo_port_s_foo_prov_exec_i ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[dtor]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[dtor]
}
/** User defined public operations. */
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[user_public_ops]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[user_public_ops]
/** User defined private operations. */
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[user_private_ops]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i[user_private_ops]
/** Operations and attributes from foo_port_s_foo_prov */
int32_t
foo_port_s_foo_prov_exec_i::hello (
int32_t answer)
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i::hello[_answer]
X11_UNUSED_ARG(answer);
return {};
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::foo_port_s_foo_prov_exec_i::hello[_answer]
}
/**
* Component Executor Implementation Class : Sender_exec_i
*/
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[ctor]
Sender_exec_i::Sender_exec_i ()
{
}
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[ctor]
Sender_exec_i::~Sender_exec_i ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[dtor]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[dtor]
}
/** User defined public operations. */
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[user_public_ops]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[user_public_ops]
/** User defined private operations. */
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[user_private_ops]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[user_private_ops]
/** Session component operations */
void Sender_exec_i::configuration_complete ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[configuration_complete]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[configuration_complete]
}
void Sender_exec_i::ccm_activate ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[ccm_activate]
this->synch_foo_gen_.set_context(this->context_);
this->synch_foo_gen_.activate (THR_NEW_LWP | THR_JOINABLE, 1);
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[ccm_activate]
}
void Sender_exec_i::ccm_passivate ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[ccm_passivate]
this->synch_foo_gen_.wait();
if (my_attrib2() != 11 || my_attrib4().foo_long_struct() != 32 ||
my_attribute()[0] != 123)
{
CIAOX11_TEST_ERROR << " ERROR Sender: expexted attribute values 11, 32 and 123, but received "
<< my_attrib2() << "," << my_attrib4().foo_long_struct() << "," << my_attribute()
<< std::endl;
}
else CIAOX11_TEST_INFO << " Sender: attribute values : "
<< my_attrib2() << "," << my_attrib4().foo_long_struct() << "," << my_attribute()
<< std::endl;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[ccm_passivate]
}
void Sender_exec_i::ccm_remove ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[ccm_remove]
// Your code here
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[ccm_remove]
}
IDL::traits< ::Hello::CCM_PortFooS>::ref_type
Sender_exec_i::get_foo_port_s_foo_prov ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[get_foo_port_s_foo_prov]
if (!this->foo_port_s_foo_prov_)
{
this->foo_port_s_foo_prov_ = CORBA::make_reference <foo_port_s_foo_prov_exec_i> (this->context_);
}
return this->foo_port_s_foo_prov_;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[get_foo_port_s_foo_prov]
}
::Hello::foo_seq
Sender_exec_i::my_attribute ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attribute[getter]
return this->my_attribute_;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attribute[getter]
}
void
Sender_exec_i::my_attribute (
const ::Hello::foo_seq& my_attribute)
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attribute[setter]
this->my_attribute_ = my_attribute;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attribute[setter]
}
::Hello::foo_long
Sender_exec_i::my_attrib2 ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib2[getter]
return this->my_attrib2_;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib2[getter]
}
void
Sender_exec_i::my_attrib2 (
::Hello::foo_long my_attrib2)
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib2[setter]
this->my_attrib2_ = my_attrib2;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib2[setter]
}
::Hello::bar_seq
Sender_exec_i::my_attrib3 ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib3[getter]
return this->my_attrib3_;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib3[getter]
}
void
Sender_exec_i::my_attrib3 (
const ::Hello::bar_seq& my_attrib3)
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib3[setter]
this->my_attrib3_ = my_attrib3;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib3[setter]
}
::Hello::foo_struct
Sender_exec_i::my_attrib4 ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib4[getter]
Hello::foo_struct test {32,"Hi",33};
return test;
//return this->my_attrib4_;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib4[getter]
}
void
Sender_exec_i::my_attrib4 (
const ::Hello::foo_struct& my_attrib4)
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib4[setter]
this->my_attrib4_ = my_attrib4;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib4[setter]
}
int32_t
Sender_exec_i::my_attrib5 ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib5[getter]
return this->my_attrib5_;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib5[getter]
}
void
Sender_exec_i::my_attrib5 (
int32_t my_attrib5)
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib5[setter]
this->my_attrib5_ = my_attrib5;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib5[setter]
}
::Hello::out_seq
Sender_exec_i::my_attrib6 ()
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib6[getter]
return this->my_attrib6_;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib6[getter]
}
void
Sender_exec_i::my_attrib6 (
const ::Hello::out_seq& my_attrib6)
{
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i::my_attrib6[setter]
this->my_attrib6_ = my_attrib6;
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i::my_attrib6[setter]
}
/// Operations from Components::SessionComponent
void
Sender_exec_i::set_session_context (
IDL::traits<Components::SessionContext>::ref_type ctx)
{
// Setting the context of this component.
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl::Sender_exec_i[set_session_context]
this->context_ = IDL::traits< ::Hello::CCM_Sender_Context >::narrow (std::move(ctx));
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl::Sender_exec_i[set_session_context]
}
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl[user_namespace_end_impl]
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl[user_namespace_end_impl]
} // namespace Hello_Sender_Impl
//@@{__RIDL_REGEN_MARKER__} - BEGIN : Hello_Sender_Impl[factory]
extern "C" void
create_Hello_Sender_Impl (
IDL::traits<Components::EnterpriseComponent>::ref_type& component)
{
component = CORBA::make_reference <Hello_Sender_Impl::Sender_exec_i> ();
}
//@@{__RIDL_REGEN_MARKER__} - END : Hello_Sender_Impl[factory]
//@@{__RIDL_REGEN_MARKER__} - BEGIN : hello_sender_impl.cpp[Footer]
// Your footer (code) here
// -*- END -*-
| 11,584 | 4,874 |
// 2020.03.16 - Victor Dods
#include "MainWindow.hpp"
#include <iostream>
#include <QtWidgets>
bool WheelFilter::eventFilter (QObject *obj, QEvent *event)
{
if (event->type() == QEvent::Wheel) {
auto wheel_event = static_cast<QWheelEvent*>(event);
if (wheel_event->modifiers() == Qt::ControlModifier || wheel_event->modifiers() == Qt::ShiftModifier) {
// Returning true filters the event. The idea is to filter it on the QGraphicsView's
// viewport and then let the main window handle the event.
return true;
}
}
return false; // Returning false does not filter the event.
}
MainWindow::MainWindow () {
create_actions();
create_status_bar();
read_settings();
#ifndef QT_NO_SESSIONMANAGER
QGuiApplication::setFallbackSessionManagementEnabled(false);
connect(qApp, &QGuiApplication::commitDataRequest, this, &MainWindow::commit_data);
#endif
setUnifiedTitleAndToolBarOnMac(true);
// Create and populate the scene.
m_scene = new QGraphicsScene(this);
{
auto grid_layout = new QGridLayout();
{
auto label = new QLabel("HIPPO");
label->setTextInteractionFlags(Qt::TextSelectableByMouse);
grid_layout->addWidget(label, 0, 0);
}
grid_layout->addWidget(new QPushButton("THINGY"), 0, 1);
grid_layout->addWidget(new QTextEdit("OSTRICH"), 1, 0);
{
auto subscene = new QGraphicsScene();
{
auto label = new QLabel("TINY HIPPO\nTINY OSTRICH\nTINY DONKEY");
label->setTextInteractionFlags(Qt::TextSelectableByMouse);
subscene->addWidget(label);
}
auto subview = new QGraphicsView();
subview->scale(0.5, 0.5);
subview->setScene(subscene);
grid_layout->addWidget(subview);
}
auto w = new QWidget();
w->setLayout(grid_layout);
m_scene->addWidget(w);
}
// {
// // QWidget *w = new QLabel("HIPPO");
// // QWidget *w = new QPushButton("THINGY");
// QWidget *w = new QTextEdit("OSTRICH");
// m_scene->addWidget(w);
// }
m_view = new QGraphicsView(this);
// NOTE: Rendering of QTextEdit and QPushButton happen incorrectly if the default
// ViewportUpdateMode (which is QGraphicsView::MinimalViewportUpdate) is used.
// Same with SmartViewportUpdate and BoundingRectViewportUpdate. The NoViewportUpdate
// doesn't work because it doesn't update automatically (though perhaps it could work
// if the widgets were manually triggered to re-render).
m_view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); // This works, though there are drop shadows which look weird.
m_view->setScene(m_scene);
// Set the drag mode to hand. Note that the text selection and text entry of QLabel and
// QTextEdit interfere with this, so it's not necessarily easy to do this.
// m_view->setDragMode(QGraphicsView::ScrollHandDrag);
// Install an event filter on the QGraphicsView to override certain behaviors.
auto wheel_filter = new WheelFilter();
m_view->viewport()->installEventFilter(wheel_filter);
this->setCentralWidget(m_view);
}
void MainWindow::closeEvent (QCloseEvent *event) {
// Do stuff, then call event->accept() or event->ignore(). There are probably other
// ways you could respond to the event (see QCloseEvent).
event->accept();
}
// void MainWindow::keyPressEvent (QKeyEvent *event) {
// switch (event->key()) {
// case Qt::Key_Minus:
// m_view->scale(1.0/1.1, 1.0/1.1);
// break;
//
// case Qt::Key_Plus:
// m_view->scale(1.1, 1.1);
// break;
//
// case Qt::Key_BracketLeft:
// m_view->rotate(-15.0);
// break;
//
// case Qt::Key_BracketRight:
// m_view->rotate(15.0);
// break;
// }
// }
void MainWindow::wheelEvent (QWheelEvent *event) {
double constexpr ANGLE_DELTA = 15.0;
double constexpr SCALE_FACTOR = 1.1;
// If only Ctrl button is pressed, zoom.
// If only Shift button is pressed, rotate.
// NOTE: If the modifier is Qt::AltModifier, then the x and y coordinates of angleDelta
// are switched, ostensibly to facilitate horizontal scrolling.
switch (event->modifiers()) {
case Qt::ControlModifier: {
bool wheel_went_up = event->angleDelta().y() >= 0;
if (wheel_went_up)
m_view->scale(SCALE_FACTOR, SCALE_FACTOR);
else
m_view->scale(1.0/SCALE_FACTOR, 1.0/SCALE_FACTOR);
event->accept();
break;
}
case Qt::ShiftModifier: {
bool wheel_went_up = event->angleDelta().y() >= 0;
m_view->rotate((wheel_went_up ? -1.0 : 1.0) * ANGLE_DELTA);
event->accept();
break;
}
}
}
void MainWindow::about () {
QMessageBox::about(
this,
tr("About SEPT Viewer"),
tr("Created 2020.03.16 by Victor Dods")
);
}
void MainWindow::create_actions() {
QMenu *file_menu = menuBar()->addMenu(tr("&File"));
// QToolBar *file_tool_bar = addToolBar(tr("File"));
file_menu->addSeparator();
QAction *exit_action = file_menu->addAction(tr("E&xit"), this, &QWidget::close);
exit_action->setShortcuts(QKeySequence::Quit);
exit_action->setStatusTip(tr("Exit the application"));
QMenu *help_menu = menuBar()->addMenu(tr("&Help"));
QAction *about_action = help_menu->addAction(tr("&About"), this, &MainWindow::about);
about_action->setStatusTip(tr("Show the application's About box"));
QAction *about_qt_action = help_menu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
about_qt_action->setStatusTip(tr("Show the Qt library's About box"));
}
void MainWindow::create_status_bar() {
statusBar()->showMessage(tr("Ready"));
}
void MainWindow::read_settings() {
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
if (geometry.isEmpty()) {
QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
resize(availableGeometry.width(), availableGeometry.height());
move(0, 0);
// resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
// move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2);
} else {
restoreGeometry(geometry);
}
}
void MainWindow::write_settings() {
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
settings.setValue("geometry", saveGeometry());
}
#ifndef QT_NO_SESSIONMANAGER
void MainWindow::commit_data(QSessionManager &manager) {
if (manager.allowsInteraction()) {
// Do stuff, like maybe bring up "are you sure you want to exit?" dialog. If that returns
// with "cancel", then call manager.cancel().
} else {
// Do involuntary backup of state. Could be to an "emergency backup state".
}
}
#endif
| 7,254 | 2,249 |
#include <iostream>
#include <cstdio>
#include <set>
#include <thread>
#include <vector>
void static_or_local_lambda() {
static auto generator = []() {
return 1;
};
auto generator2 = []() {
return 1;
};
std::printf("generator 1:%p\n", &generator);
std::printf("generator 2:%p\n", &generator2);
}
void print_lambda_point() {
static_or_local_lambda();
static_or_local_lambda();
std::thread test([]() {
static_or_local_lambda();
static_or_local_lambda();
});
test.join();
}
void find_if() {
std::vector<int> vector{1,2,3,4,5,6,7,8,9,10};
std::printf("\nvector:\n\t");
for (auto& i : vector) {
std::printf("%d ", i);
}
std::printf("\n");
/**
* param auto in lambda support start in C++14
* in C++11:
* @code
* auto it = std::find_if(std::begin(vector), vector.end(), [](const int& value) {
* return value == 5;
* });
* @endcode
*/
auto it = std::find_if(std::begin(vector), vector.end(), [](const auto& value) {
return value == 5;
});
if (it == vector.end()) {
std::cout << "find_if not found" << std::endl;
} else {
std::cout << "find_if :" << *it << std::endl;
}
}
int main() {
print_lambda_point();
find_if();
return 0;
} | 1,249 | 493 |
/*
* Automatically Generated from Mathematica.
* Tue 8 Jan 2019 23:21:09 GMT-05:00
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "Jvb_VectorNav_to_LeftToeBottom.h"
#ifdef _MSC_VER
#define INLINE __forceinline /* use __forceinline (VC++ specific) */
#else
#define INLINE static inline /* use standard inline */
#endif
/**
* Copied from Wolfram Mathematica C Definitions file mdefs.hpp
* Changed marcos to inline functions (Eric Cousineau)
*/
INLINE double Power(double x, double y) { return pow(x, y); }
INLINE double Sqrt(double x) { return sqrt(x); }
INLINE double Abs(double x) { return fabs(x); }
INLINE double Exp(double x) { return exp(x); }
INLINE double Log(double x) { return log(x); }
INLINE double Sin(double x) { return sin(x); }
INLINE double Cos(double x) { return cos(x); }
INLINE double Tan(double x) { return tan(x); }
INLINE double Csc(double x) { return 1.0/sin(x); }
INLINE double Sec(double x) { return 1.0/cos(x); }
INLINE double ArcSin(double x) { return asin(x); }
INLINE double ArcCos(double x) { return acos(x); }
/* update ArcTan function to use atan2 instead. */
INLINE double ArcTan(double x, double y) { return atan2(y,x); }
INLINE double Sinh(double x) { return sinh(x); }
INLINE double Cosh(double x) { return cosh(x); }
INLINE double Tanh(double x) { return tanh(x); }
#define E 2.71828182845904523536029
#define Pi 3.14159265358979323846264
#define Degree 0.01745329251994329576924
/*
* Sub functions
*/
static void output1(Eigen::Matrix<double,3,14> &p_output1, const Eigen::Matrix<double,14,1> &var1)
{
double t755;
double t858;
double t1275;
double t836;
double t932;
double t1097;
double t723;
double t1301;
double t1663;
double t1678;
double t1798;
double t1100;
double t1727;
double t1776;
double t717;
double t1833;
double t1850;
double t1895;
double t2188;
double t1783;
double t1954;
double t1974;
double t659;
double t2238;
double t2240;
double t2327;
double t650;
double t2967;
double t2976;
double t3026;
double t2951;
double t3048;
double t3062;
double t3128;
double t3131;
double t3079;
double t3175;
double t3191;
double t3232;
double t3298;
double t3304;
double t2839;
double t3623;
double t3624;
double t3589;
double t3592;
double t3631;
double t3646;
double t3649;
double t3671;
double t3688;
double t3710;
double t3711;
double t3724;
double t3562;
double t3563;
double t3593;
double t3605;
double t3687;
double t3744;
double t3758;
double t3777;
double t3785;
double t3789;
double t3807;
double t3820;
double t3500;
double t3522;
double t3565;
double t3569;
double t3775;
double t3852;
double t3855;
double t3902;
double t3911;
double t3919;
double t3926;
double t3927;
double t260;
double t3382;
double t3383;
double t3401;
double t3231;
double t3335;
double t3344;
double t3445;
double t3474;
double t3963;
double t3973;
double t3978;
double t3988;
double t4019;
double t3535;
double t3550;
double t3890;
double t3931;
double t3938;
double t4157;
double t4072;
double t4075;
double t4081;
double t4124;
double t4137;
double t4163;
double t4169;
double t4173;
double t4174;
double t4176;
double t4099;
double t4108;
double t3480;
double t3941;
double t3961;
double t4020;
double t4036;
double t2482;
double t2626;
double t2792;
double t2020;
double t2410;
double t2422;
double t4147;
double t4162;
double t4179;
double t4195;
double t2438;
double t2905;
double t2906;
double t2915;
double t2928;
double t4224;
double t4230;
double t4239;
double t4241;
double t4252;
double t4285;
double t4290;
double t4293;
double t4384;
double t3349;
double t3417;
double t3428;
double t4215;
double t4219;
double t4409;
double t4412;
double t4307;
double t4335;
double t4065;
double t4294;
t755 = Cos(var1[6]);
t858 = Sin(var1[6]);
t1275 = Cos(var1[5]);
t836 = 0.642788*t755;
t932 = -0.766044*t858;
t1097 = t836 + t932;
t723 = Sin(var1[5]);
t1301 = 0.766044*t755;
t1663 = 0.642788*t858;
t1678 = t1301 + t1663;
t1798 = Cos(var1[4]);
t1100 = t723*t1097;
t1727 = t1275*t1678;
t1776 = 0. + t1100 + t1727;
t717 = Sin(var1[4]);
t1833 = t1275*t1097;
t1850 = -1.*t723*t1678;
t1895 = 0. + t1833 + t1850;
t2188 = Sin(var1[3]);
t1783 = -1.*t717*t1776;
t1954 = t1798*t1895;
t1974 = 0. + t1783 + t1954;
t659 = Cos(var1[3]);
t2238 = t1798*t1776;
t2240 = t717*t1895;
t2327 = 0. + t2238 + t2240;
t650 = Cos(var1[2]);
t2967 = -0.766044*t755;
t2976 = -0.642788*t858;
t3026 = t2967 + t2976;
t2951 = -1.*t723*t1097;
t3048 = t1275*t3026;
t3062 = 0. + t2951 + t3048;
t3128 = t723*t3026;
t3131 = 0. + t1833 + t3128;
t3079 = t717*t3062;
t3175 = t1798*t3131;
t3191 = 0. + t3079 + t3175;
t3232 = t1798*t3062;
t3298 = -1.*t717*t3131;
t3304 = 0. + t3232 + t3298;
t2839 = Sin(var1[2]);
t3623 = -1.*t755;
t3624 = 1. + t3623;
t3589 = -1.*t1275;
t3592 = 1. + t3589;
t3631 = -0.0216*t3624;
t3646 = 0.0306*t755;
t3649 = 0.01770000000000005*t858;
t3671 = 0. + t3631 + t3646 + t3649;
t3688 = -1.1135*t3624;
t3710 = -1.1312*t755;
t3711 = 0.052199999999999996*t858;
t3724 = 0. + t3688 + t3710 + t3711;
t3562 = -1.*t1798;
t3563 = 1. + t3562;
t3593 = -0.7055*t3592;
t3605 = -0.0184*t723;
t3687 = t723*t3671;
t3744 = t1275*t3724;
t3758 = 0. + t3593 + t3605 + t3687 + t3744;
t3777 = 0.0184*t3592;
t3785 = -0.7055*t723;
t3789 = t1275*t3671;
t3807 = -1.*t723*t3724;
t3820 = 0. + t3777 + t3785 + t3789 + t3807;
t3500 = -1.*t659;
t3522 = 1. + t3500;
t3565 = -0.0016*t3563;
t3569 = -0.2707*t717;
t3775 = -1.*t717*t3758;
t3852 = t1798*t3820;
t3855 = 0. + t3565 + t3569 + t3775 + t3852;
t3902 = -0.2707*t3563;
t3911 = 0.0016*t717;
t3919 = t1798*t3758;
t3926 = t717*t3820;
t3927 = 0. + t3902 + t3911 + t3919 + t3926;
t260 = Cos(var1[1]);
t3382 = -1.*t2188*t3191;
t3383 = t659*t3304;
t3401 = 0. + t3382 + t3383;
t3231 = t659*t3191;
t3335 = t2188*t3304;
t3344 = 0. + t3231 + t3335;
t3445 = -1.*t650;
t3474 = 1. + t3445;
t3963 = -0.049*t3522;
t3973 = -0.21*t2188;
t3978 = t659*t3855;
t3988 = -1.*t2188*t3927;
t4019 = 0. + t3963 + t3973 + t3978 + t3988;
t3535 = -0.21*t3522;
t3550 = 0.049*t2188;
t3890 = t2188*t3855;
t3931 = t659*t3927;
t3938 = 0. + t3535 + t3550 + t3890 + t3931;
t4157 = Sin(var1[1]);
t4072 = t650*t3401;
t4075 = -1.*t3344*t2839;
t4081 = 0. + t4072 + t4075;
t4124 = -1.*t260;
t4137 = 1. + t4124;
t4163 = -0.049*t3474;
t4169 = t650*t4019;
t4173 = -0.09*t2839;
t4174 = -1.*t3938*t2839;
t4176 = 0. + t4163 + t4169 + t4173 + t4174;
t4099 = t260*t4081;
t4108 = 0. + t4099;
t3480 = -0.09*t3474;
t3941 = t650*t3938;
t3961 = 0.049*t2839;
t4020 = t4019*t2839;
t4036 = 0. + t3480 + t3941 + t3961 + t4020;
t2482 = t2188*t1974;
t2626 = t659*t2327;
t2792 = 0. + t2482 + t2626;
t2020 = t659*t1974;
t2410 = -1.*t2188*t2327;
t2422 = 0. + t2020 + t2410;
t4147 = -0.049*t4137;
t4162 = 0.004500000000000004*t4157;
t4179 = t260*t4176;
t4195 = 0. + t4147 + t4162 + t4179;
t2438 = t650*t2422;
t2905 = -1.*t2792*t2839;
t2906 = 0. + t2438 + t2905;
t2915 = t260*t2906;
t2928 = 0. + t2915;
t4224 = 0.135*t4137;
t4230 = 0.1305*t260;
t4239 = 0.049*t4157;
t4241 = t4157*t4176;
t4252 = 0. + t4224 + t4230 + t4239 + t4241;
t4285 = t650*t2792;
t4290 = t2422*t2839;
t4293 = 0. + t4285 + t4290;
t4384 = 0. + t4157;
t3349 = t650*t3344;
t3417 = t3401*t2839;
t3428 = 0. + t3349 + t3417;
t4215 = t4157*t4081;
t4219 = 0. + t4215;
t4409 = -1.*t260;
t4412 = 0. + t4409;
t4307 = t4157*t2906;
t4335 = 0. + t4307;
t4065 = t3428*t4036;
t4294 = -1.*t4036*t4293;
p_output1(0)=0. + t2928*(t4065 + t4108*t4195 + t4219*t4252) + t4108*(-1.*t2928*t4195 + t4294 - 1.*t4252*t4335);
p_output1(1)=-0.135*t4293 + (-1.*t3428*t4036 - 1.*t4108*t4195 - 1.*t4219*t4252)*t4384 + t4108*(0. + t4195*t4384 + t4252*t4412);
p_output1(2)=-0.135*t3428 + (t2928*t4195 + t4036*t4293 + t4252*t4335)*t4384 + t2928*(0. - 1.*t4195*t4384 - 1.*t4252*t4412);
p_output1(3)=-0.049 + (0. + t4065 + t4081*t4176)*t4293 + t3428*(0. - 1.*t2906*t4176 + t4294);
p_output1(4)=0. + 0.135*t2906 - 0.1305*t3428;
p_output1(5)=0. + 0.135*t4081 + 0.1305*t4293;
p_output1(6)=0.;
p_output1(7)=0. - 0.09*t2422 + 0.049*t2792 - 1.*t3344*t3938 - 1.*t3401*t4019;
p_output1(8)=0. + 0.049*t3344 - 0.09*t3401 + t2792*t3938 + t2422*t4019;
p_output1(9)=0.;
p_output1(10)=0. - 0.21*t1974 + 0.049*t2327 - 1.*t3304*t3855 - 1.*t3191*t3927;
p_output1(11)=0. + 0.049*t3191 - 0.21*t3304 + t1974*t3855 + t2327*t3927;
p_output1(12)=0.;
p_output1(13)=0. + 0.0016*t1776 - 0.2707*t1895 - 1.*t3131*t3758 - 1.*t3062*t3820;
p_output1(14)=0. - 0.2707*t3062 + 0.0016*t3131 + t1776*t3758 + t1895*t3820;
p_output1(15)=0.;
p_output1(16)=0. - 0.7055*t1097 - 0.0184*t1678 - 1.*t3026*t3671 - 1.*t1097*t3724;
p_output1(17)=0. - 0.0184*t1097 - 0.7055*t3026 + t1097*t3671 + t1678*t3724;
p_output1(18)=0.;
p_output1(19)=0.05136484440000011;
p_output1(20)=0.019994554799999897;
p_output1(21)=0;
p_output1(22)=0;
p_output1(23)=0;
p_output1(24)=0;
p_output1(25)=0;
p_output1(26)=0;
p_output1(27)=0;
p_output1(28)=0;
p_output1(29)=0;
p_output1(30)=0;
p_output1(31)=0;
p_output1(32)=0;
p_output1(33)=0;
p_output1(34)=0;
p_output1(35)=0;
p_output1(36)=0;
p_output1(37)=0;
p_output1(38)=0;
p_output1(39)=0;
p_output1(40)=0;
p_output1(41)=0;
}
Eigen::Matrix<double,3,14> Jvb_VectorNav_to_LeftToeBottom(const Eigen::Matrix<double,14,1> &var1)
{
/* Call Subroutines */
Eigen::Matrix<double,3,14> p_output1;
output1(p_output1, var1);
return p_output1;
}
| 9,878 | 6,667 |
#include <assert.h>
#include "star_system_generic.h"
#include "gfx/vec.h"
#include "cmd/planet_generic.h"
#include "cmd/unit_generic.h"
#include "cmd/unit_collide.h"
#include "cmd/collection.h"
#include "gfx/cockpit_generic.h"
#include "audiolib.h"
#include "lin_time.h"
#include "cmd/beam.h"
#include "cmd/bolt.h"
#include <expat.h>
#include "cmd/music.h"
#include "configxml.h"
#include "vs_globals.h"
#include "vegastrike.h"
#include "universe_generic.h"
#include "cmd/nebula_generic.h"
#include "galaxy_gen.h"
#include "cmd/script/mission.h"
#include "in_kb.h"
#include "cmd/script/flightgroup.h"
#include "load_mission.h"
#include "lin_time.h"
#include "cmd/unit_util.h"
#include "cmd/unit_factory.h"
#include "cmd/unit_collide.h"
#include "vs_random.h"
#include "savegame.h"
#include "networking/netclient.h"
#include "in_kb_data.h"
#include "universe_util.h" //get galaxy faction, dude
#include <boost/version.hpp>
#if BOOST_VERSION != 102800
#if defined (_MSC_VER) && _MSC_VER <= 1200
#define Vector Vactor
#endif
#include "cs_boostpython.h"
#if defined (_MSC_VER) && _MSC_VER <= 1200
#undef Vector
#endif
#else
#include <boost/python/detail/extension_class.hpp>
#endif
vector< Vector >perplines;
extern std::vector< unorigdest* >pendingjump;
void TentativeJumpTo( StarSystem *ss, Unit *un, Unit *jumppoint, const std::string &system )
{
for (unsigned int i = 0; i < pendingjump.size(); ++i)
if (pendingjump[i]->un.GetUnit() == un)
return;
ss->JumpTo( un, jumppoint, system );
}
float ScaleJumpRadius( float radius )
{
static float jump_radius_scale = parse_float( vs_config->getVariable( "physics", "jump_radius_scale", "2" ) );
static float game_speed = parse_float( vs_config->getVariable( "physics", "game_speed", "1" ) );
//need this because sys scale doesn't affect j-point size
radius *= jump_radius_scale*game_speed;
return radius;
}
StarSystem::StarSystem()
{
stars = NULL;
bolts = NULL;
collidetable = NULL;
collidemap[Unit::UNIT_ONLY] = new CollideMap( Unit::UNIT_ONLY );
collidemap[Unit::UNIT_BOLT] = new CollideMap( Unit::UNIT_BOLT );
no_collision_time = 0; //(int)(1+2.000/SIMULATION_ATOM);
///adds to jumping table;
name = NULL;
current_stage = MISSION_SIMULATION;
time = 0;
zone = 0;
sigIter = drawList.createIterator();
this->current_sim_location = 0;
}
StarSystem::StarSystem( const char *filename, const Vector ¢r, const float timeofyear )
{
no_collision_time = 0; //(int)(1+2.000/SIMULATION_ATOM);
collidemap[Unit::UNIT_ONLY] = new CollideMap( Unit::UNIT_ONLY );
collidemap[Unit::UNIT_BOLT] = new CollideMap( Unit::UNIT_BOLT );
this->current_sim_location = 0;
///adds to jumping table;
name = NULL;
zone = 0;
_Universe->pushActiveStarSystem( this );
bolts = new bolt_draw;
collidetable = new CollideTable( this );
current_stage = MISSION_SIMULATION;
this->filename = filename;
LoadXML( filename, centr, timeofyear );
if (!name)
name = strdup( filename );
sigIter = drawList.createIterator();
AddStarsystemToUniverse( filename );
time = 0;
_Universe->popActiveStarSystem();
}
extern void ClientServerSetLightContext( int lightcontext );
StarSystem::~StarSystem()
{
if ( _Universe->getNumActiveStarSystem() )
_Universe->activeStarSystem()->SwapOut();
_Universe->pushActiveStarSystem( this );
ClientServerSetLightContext( lightcontext );
delete[] name;
Unit *unit;
for (un_iter iter = drawList.createIterator(); (unit = *iter); ++iter)
unit->Kill( false );
//if the next line goes ANYWHERE else Vega Strike will CRASH!!!!!
//DO NOT MOVE THIS LINE! IT MUST STAY
if (collidetable) delete collidetable;
_Universe->popActiveStarSystem();
vector< StarSystem* >activ;
while ( _Universe->getNumActiveStarSystem() ) {
if (_Universe->activeStarSystem() != this)
activ.push_back( _Universe->activeStarSystem() );
else
fprintf( stderr, "Avoided fatal error in deleting star system %s\n", getFileName().c_str() );
_Universe->popActiveStarSystem();
}
while ( activ.size() ) {
_Universe->pushActiveStarSystem( activ.back() );
activ.pop_back();
}
if ( _Universe->getNumActiveStarSystem() )
_Universe->activeStarSystem()->SwapIn();
RemoveStarsystemFromUniverse();
delete collidemap[Unit::UNIT_ONLY];
delete collidemap[Unit::UNIT_BOLT];
}
/********* FROM STAR SYSTEM XML *********/
void setStaticFlightgroup( vector< Flightgroup* > &fg, const std::string &nam, int faction )
{
while ( faction >= (int) fg.size() ) {
fg.push_back( new Flightgroup() );
fg.back()->nr_ships = 0;
}
if (fg[faction]->nr_ships == 0) {
fg[faction]->flightgroup_nr = faction;
fg[faction]->pos.i = fg[faction]->pos.j = fg[faction]->pos.k = 0;
fg[faction]->nr_ships = 0;
fg[faction]->ainame = "default";
fg[faction]->faction = FactionUtil::GetFaction( faction );
fg[faction]->type = "Base";
fg[faction]->nr_waves_left = 0;
fg[faction]->nr_ships_left = 0;
fg[faction]->name = nam;
}
++fg[faction]->nr_ships;
++fg[faction]->nr_ships_left;
}
Flightgroup * getStaticBaseFlightgroup( int faction )
{
//warning mem leak...not big O(num factions)
static vector< Flightgroup* >fg;
setStaticFlightgroup( fg, "Base", faction );
return fg[faction];
}
Flightgroup * getStaticStarFlightgroup( int faction )
{
//warning mem leak...not big O(num factions)
static vector< Flightgroup* >fg;
setStaticFlightgroup( fg, "Base", faction );
return fg[faction];
}
Flightgroup * getStaticNebulaFlightgroup( int faction )
{
static vector< Flightgroup* >fg;
setStaticFlightgroup( fg, "Nebula", faction );
return fg[faction];
}
Flightgroup * getStaticAsteroidFlightgroup( int faction )
{
static vector< Flightgroup* >fg;
setStaticFlightgroup( fg, "Asteroid", faction );
return fg[faction];
}
Flightgroup * getStaticUnknownFlightgroup( int faction )
{
static vector< Flightgroup* >fg;
setStaticFlightgroup( fg, "Unknown", faction );
return fg[faction];
}
void StarSystem::beginElement( void *userData, const XML_Char *name, const XML_Char **atts )
{
( (StarSystem*) userData )->beginElement( name, AttributeList( atts ) );
}
void StarSystem::endElement( void *userData, const XML_Char *name )
{
( (StarSystem*) userData )->endElement( name );
}
extern string RemoveDotSystem( const char *input );
string StarSystem::getFileName() const
{
return getStarSystemSector( filename )+string( "/" )+RemoveDotSystem( getStarSystemName( filename ).c_str() );
}
string StarSystem::getName()
{
return string( name );
}
void StarSystem::AddUnit( Unit *unit )
{
if ( stats.system_faction == FactionUtil::GetNeutralFaction() )
stats.CheckVitals( this );
if (unit->specInterdiction > 0 || unit->isPlanet() || unit->isJumppoint() || unit->isUnit() == ASTEROIDPTR) {
Unit *un;
bool found = false;
for (un_iter i = gravitationalUnits().createIterator();
(un = *i) != NULL;
++i)
if (un == unit) {
found = true;
break;
}
if (!found)
gravitationalUnits().prepend( unit );
}
drawList.prepend( unit );
unit->activeStarSystem = this; //otherwise set at next physics frame...
UnitFactory::broadcastUnit( unit, GetZone() );
unsigned int priority = UnitUtil::getPhysicsPriority( unit );
//Do we need the +1 here or not - need to look at when current_sim_location is changed relative to this function
//and relative to this function, when the bucket is processed...
unsigned int tmp = 1+( (unsigned int) vsrandom.genrand_int32() )%priority;
this->physics_buffer[(this->current_sim_location+tmp)%SIM_QUEUE_SIZE].prepend( unit );
stats.AddUnit( unit );
}
bool StarSystem::RemoveUnit( Unit *un )
{
for (unsigned int locind = 0; locind < Unit::NUM_COLLIDE_MAPS; ++locind)
if ( !is_null( un->location[locind] ) ) {
collidemap[locind]->erase( un->location[locind] );
set_null( un->location[locind] );
}
bool removed2 = false;
Unit *unit;
for (un_iter iter = gravitationalUnits().createIterator(); (unit = *iter); ++iter)
if (unit == un) {
iter.remove();
removed2 = true;
break; //Shouldn't be in there twice
}
//NOTE: not sure why if(1) was here, but safemode removed it
bool removed = false;
if (1) {
for (un_iter iter = drawList.createIterator(); (unit = *iter); ++iter)
if (unit == un) {
iter.remove();
removed = true;
break;
}
}
if (removed) {
for (unsigned int i = 0; i <= SIM_QUEUE_SIZE; ++i) {
Unit *unit;
for (un_iter iter = physics_buffer[i].createIterator(); (unit = *iter); ++iter)
if (unit == un) {
iter.remove();
removed = true;
//terminate outer loop
i = SIM_QUEUE_SIZE+1;
break;
}
}
stats.RemoveUnit( un );
}
return removed;
}
void StarSystem::ExecuteUnitAI()
{
try {
Unit *unit = NULL;
for (un_iter iter = getUnitList().createIterator(); (unit = *iter); ++iter) {
unit->ExecuteAI();
unit->ResetThreatLevel();
}
}
catch (const boost::python::error_already_set) {
if ( PyErr_Occurred() ) {
PyErr_Print();
PyErr_Clear();
fflush( stderr );
fflush( stdout );
} throw;
}
}
//sorry boyz...I'm just a tourist with a frag nav console--could you tell me where I am?
Unit * getTopLevelOwner() //returns terrible memory--don't dereference...ever...not even aligned
{
return (Unit*) 0x31337; //FIXME How about telling us a little story behind this function? --chuck_starchaser
}
void CarSimUpdate( Unit *un, float height )
{
un->SetVelocity( Vector( un->GetVelocity().i, 0, un->GetVelocity().k ) );
un->curr_physical_state.position = QVector( un->curr_physical_state.position.i,
height,
un->curr_physical_state.position.k );
}
StarSystem::Statistics::Statistics()
{
system_faction = FactionUtil::GetNeutralFaction();
newfriendlycount = 0;
newenemycount = 0;
newcitizencount = 0;
newneutralcount = 0;
friendlycount = 0;
enemycount = 0;
neutralcount = 0;
citizencount = 0;
checkIter = 0;
navCheckIter = 0;
}
void StarSystem::Statistics::CheckVitals( StarSystem *ss )
{
int faction = FactionUtil::GetFactionIndex( UniverseUtil::GetGalaxyFaction( ss->getFileName() ) );
if (faction != system_faction) {
*this = Statistics(); //invoke copy constructor to clear it
this->system_faction = faction;
Unit *un;
for (un_iter ui = ss->getUnitList().createIterator();
(un = *ui) != NULL;
++ui)
this->AddUnit( un ); //siege will take some time
return; //no need to check vitals now, they're all set
}
size_t iter = navCheckIter;
int k = 0;
if ( iter >= navs[0].size() ) {
iter -= navs[0].size();
k = 1;
}
if ( iter >= navs[1].size() ) {
iter -= navs[1].size();
k = 2;
}
size_t totalnavchecking = 25;
size_t totalsyschecking = 25;
while ( iter < totalnavchecking && iter < navs[k].size() ) {
if (navs[k][iter].GetUnit() == NULL) {
navs[k].erase( navs[k].begin()+iter );
} else {
++iter;
++navCheckIter;
}
}
if ( k == 2 && iter >= navs[k].size() )
navCheckIter = 0; //start over next time
size_t sortedsize = ss->collidemap[Unit::UNIT_ONLY]->sorted.size();
int sysfac = system_faction;
size_t counter = checkIter+totalsyschecking;
for (; checkIter < counter && checkIter < sortedsize; ++checkIter) {
Collidable *collide = &ss->collidemap[Unit::UNIT_ONLY]->sorted[checkIter];
if (collide->radius > 0) {
Unit *un = collide->ref.unit;
float rel = UnitUtil::getRelationFromFaction( un, sysfac );
if ( FactionUtil::isCitizenInt( un->faction ) ) {
++newcitizencount;
} else {
if (rel > 0.05)
++newfriendlycount;
else if (rel < 0.)
++newenemycount;
else
++newneutralcount;
}
}
}
if (checkIter >= sortedsize && sortedsize
> (unsigned int) (enemycount+neutralcount+friendlycount
+citizencount)/4 /*suppose at least 1/4 survive a given frame*/) {
citizencount = newcitizencount;
newcitizencount = 0;
enemycount = newenemycount;
newenemycount = 0;
neutralcount = newneutralcount;
newneutralcount = 0;
friendlycount = newfriendlycount;
newfriendlycount = 0;
checkIter = 0; //start over with list
}
}
void StarSystem::Statistics::AddUnit( Unit *un )
{
float rel = UnitUtil::getRelationFromFaction( un, system_faction );
if ( FactionUtil::isCitizenInt( un->faction ) ) {
++citizencount;
} else {
if (rel > 0.05)
++friendlycount;
else if (rel < 0.)
++enemycount;
else
++neutralcount;
}
if ( un->GetDestinations().size() )
jumpPoints[un->GetDestinations()[0]].SetUnit( un );
if ( UnitUtil::isSignificant( un ) ) {
int k = 0;
if (rel > 0) k = 1; //base
if ( un->isPlanet() && !un->isJumppoint() )
k = 1; //friendly planet
//asteroid field/debris field
if ( UnitUtil::isAsteroid( un ) ) k = 2;
navs[k].push_back( UnitContainer( un ) );
}
}
void StarSystem::Statistics::RemoveUnit( Unit *un )
{
float rel = UnitUtil::getRelationFromFaction( un, system_faction );
if ( FactionUtil::isCitizenInt( un->faction ) ) {
--citizencount;
} else {
if (rel > 0.05)
--friendlycount;
else if (rel < 0.)
--enemycount;
else
--neutralcount;
}
if ( un->GetDestinations().size() ) {
//make sure it is there
jumpPoints[(un->GetDestinations()[0])].SetUnit( NULL );
//kill it--stupid I know--but hardly time critical
jumpPoints.erase( jumpPoints.find( un->GetDestinations()[0] ) );
}
if ( UnitUtil::isSignificant( un ) ) {
for (int k = 0; k < 3; ++k)
for (size_t i = 0; i < navs[k].size();) {
if (navs[k][i].GetUnit() == un)
//slow but who cares
navs[k].erase( navs[k].begin()+i );
else ++i; //only increment if you didn't erase current
}
}
}
//Variables for debugging purposes only - eliminate later
unsigned int physicsframecounter = 1;
unsigned int theunitcounter = 0;
unsigned int totalprocessed = 0;
unsigned int movingavgarray[128] = {0};
unsigned int movingtotal = 0;
double aggfire = 0;
int numprocessed = 0;
double targetpick = 0;
void StarSystem::RequestPhysics( Unit *un, unsigned int queue )
{
Unit *unit = NULL;
un_iter iter = this->physics_buffer[queue].createIterator();
while ( (unit = *iter) && *iter != un )
++iter;
if (unit == un) {
un->predicted_priority = 0;
unsigned int newloc = (current_sim_location+1)%SIM_QUEUE_SIZE;
if (newloc != queue)
iter.moveBefore( this->physics_buffer[newloc] );
}
}
void StarSystem::UpdateUnitPhysics( bool firstframe )
{
static bool phytoggle = true;
static int batchcount = SIM_QUEUE_SIZE-1;
double aitime = 0;
double phytime = 0;
double collidetime = 0;
double flattentime = 0;
double bolttime = 0;
targetpick = 0;
aggfire = 0;
numprocessed = 0;
stats.CheckVitals( this );
if (phytoggle) {
for (++batchcount; batchcount > 0; --batchcount) {
//BELOW COMMENTS ARE NO LONGER IN SYNCH
//NOTE: Randomization is necessary to preserve scattering - otherwise, whenever a
//unit goes from low-priority to high-priority and back to low-priority, they
//get synchronized and start producing peaks.
//NOTE2: But... randomization must come only on priority changes. Otherwise, it may
//interfere with subunit scheduling. Luckily, all units that make use of subunit
//scheduling also require a constant base priority, since otherwise priority changes
//will wreak havoc with subunit interpolation. Luckily again, we only need
//randomization on priority changes, so we're fine.
try {
Unit *unit = NULL;
for (un_iter iter = physics_buffer[current_sim_location].createIterator(); (unit = *iter); ++iter) {
int priority = UnitUtil::getPhysicsPriority( unit );
//Doing spreading here and only on priority changes, so as to make AI easier
int predprior = unit->predicted_priority;
//If the priority has really changed (not an initial scattering, because prediction doesn't match)
if (priority != predprior) {
if (predprior == 0)
//Validate snapshot of current interpolated state (this is a reschedule)
unit->curr_physical_state = unit->cumulative_transformation;
//Save priority value as prediction for next scheduling, but don't overwrite yet.
predprior = priority;
//Scatter, so as to achieve uniform distribution
priority = 1+( ( (unsigned int) vsrandom.genrand_int32() )%priority );
}
float backup = SIMULATION_ATOM;
theunitcounter = theunitcounter+1;
SIMULATION_ATOM *= priority;
unit->sim_atom_multiplier = priority;
double aa = queryTime();
unit->ExecuteAI();
double bb = queryTime();
unit->ResetThreatLevel();
//FIXME "firstframe"-- assume no more than 2 physics updates per frame.
unit->UpdatePhysics( identity_transformation, identity_matrix, Vector( 0,
0,
0 ), priority
== 1 ? firstframe : true, &this->gravitationalUnits(), unit );
double cc = queryTime();
aitime += bb-aa;
phytime += cc-bb;
SIMULATION_ATOM = backup;
unit->predicted_priority = predprior;
}
}
catch (const boost::python::error_already_set) {
if ( PyErr_Occurred() ) {
PyErr_Print();
PyErr_Clear();
fflush( stderr );
fflush( stdout );
} throw;
}
double c0 = queryTime();
Bolt::UpdatePhysics( this );
double cc = queryTime();
last_collisions.clear();
double fl0 = queryTime();
collidemap[Unit::UNIT_BOLT]->flatten();
if (Unit::NUM_COLLIDE_MAPS > 1)
collidemap[Unit::UNIT_ONLY]->flatten( *collidemap[Unit::UNIT_BOLT] );
flattentime = queryTime()-fl0;
Unit *unit;
for (un_iter iter = physics_buffer[current_sim_location].createIterator(); (unit = *iter);) {
int priority = unit->sim_atom_multiplier;
float backup = SIMULATION_ATOM;
SIMULATION_ATOM *= priority;
unsigned int newloc = (current_sim_location+priority)%SIM_QUEUE_SIZE;
unit->CollideAll();
SIMULATION_ATOM = backup;
if (newloc == current_sim_location)
++iter;
else
iter.moveBefore( physics_buffer[newloc] );
}
double dd = queryTime();
collidetime += dd-cc;
bolttime += cc-c0;
current_sim_location = (current_sim_location+1)%SIM_QUEUE_SIZE;
++physicsframecounter;
totalprocessed += theunitcounter;
theunitcounter = 0;
}
} else {
Unit *unit = NULL;
for (un_iter iter = getUnitList().createIterator(); (unit = *iter); ++iter) {
unit->ExecuteAI();
last_collisions.clear();
unit->UpdatePhysics( identity_transformation, identity_matrix, Vector( 0,
0,
0 ), firstframe,
&this->gravitationalUnits(), unit );
unit->CollideAll();
}
}
}
extern void TerrainCollide();
extern void UpdateAnimatedTexture();
extern void UpdateCameraSnds();
extern float getTimeCompression();
//server
void ExecuteDirector()
{
unsigned int curcockpit = _Universe->CurrentCockpit();
{
for (unsigned int i = 0; i < active_missions.size(); ++i)
if (active_missions[i]) {
_Universe->SetActiveCockpit( active_missions[i]->player_num );
StarSystem *ss = _Universe->AccessCockpit()->activeStarSystem;
if (ss) _Universe->pushActiveStarSystem( ss );
mission = active_missions[i];
active_missions[i]->DirectorLoop();
if (ss) _Universe->popActiveStarSystem();
}
}
_Universe->SetActiveCockpit( curcockpit );
mission = active_missions[0];
processDelayedMissions();
{
for (unsigned int i = 1; i < active_missions.size();) {
if (active_missions[i]) {
if (active_missions[i]->runtime.pymissions) {
++i;
} else {
unsigned int w = active_missions.size();
active_missions[i]->terminateMission();
if ( w == active_missions.size() ) {
printf( "MISSION NOT ERASED\n" );
break;
}
}
} else {
active_missions.Get()->erase( active_missions.Get()->begin()+i );
}
}
}
}
Unit* StarSystem::nextSignificantUnit()
{
return(*sigIter);
}
void StarSystem::Update( float priority )
{
Unit *unit;
bool firstframe = true;
//No time compression here
float normal_simulation_atom = SIMULATION_ATOM;
time += GetElapsedTime();
_Universe->pushActiveStarSystem( this );
if ( time/SIMULATION_ATOM >= (1./PHY_NUM) ) {
while ( time/SIMULATION_ATOM >= (1.) ) {
//Chew up all SIMULATION_ATOMs that have elapsed since last update
ExecuteDirector();
TerrainCollide();
Unit::ProcessDeleteQueue();
current_stage = MISSION_SIMULATION;
collidetable->Update();
for (un_iter iter = drawList.createIterator(); (unit = *iter); ++iter)
unit->SetNebula( NULL );
UpdateMissiles(); //do explosions
UpdateUnitPhysics( firstframe );
firstframe = false;
}
time -= SIMULATION_ATOM;
}
SIMULATION_ATOM = normal_simulation_atom;
_Universe->popActiveStarSystem();
}
//client
void StarSystem::Update( float priority, bool executeDirector )
{
bool firstframe = true;
double pythontime = 0;
///this makes it so systems without players may be simulated less accurately
for (unsigned int k = 0; k < _Universe->numPlayers(); ++k)
if (_Universe->AccessCockpit( k )->activeStarSystem == this)
priority = 1;
float normal_simulation_atom = SIMULATION_ATOM;
SIMULATION_ATOM /= ( priority/getTimeCompression() );
///just be sure to restore this at the end
time += GetElapsedTime();
_Universe->pushActiveStarSystem( this );
//WARNING PERFORMANCE HACK!!!!!
if (time > 2*SIMULATION_ATOM)
time = 2*SIMULATION_ATOM;
double bolttime = 0;
if ( time/SIMULATION_ATOM >= (1./PHY_NUM) ) {
//Chew up all SIMULATION_ATOMs that have elapsed since last update
while ( time/SIMULATION_ATOM >= (1./PHY_NUM) ) {
if (current_stage == MISSION_SIMULATION) {
TerrainCollide();
UpdateAnimatedTexture();
Unit::ProcessDeleteQueue();
double pythonidea = queryTime();
if ( (run_only_player_starsystem
&& _Universe->getActiveStarSystem( 0 ) == this) || !run_only_player_starsystem )
if (executeDirector)
ExecuteDirector();
pythontime = queryTime()-pythonidea;
static int dothis = 0;
if ( this == _Universe->getActiveStarSystem( 0 ) )
if ( (++dothis)%2 == 0 )
AUDRefreshSounds();
for (unsigned int i = 0; i < active_missions.size(); ++i)
//waste of farkin time
active_missions[i]->BriefingUpdate();
current_stage = PROCESS_UNIT;
} else if (current_stage == PROCESS_UNIT) {
UpdateUnitPhysics( firstframe );
UpdateMissiles(); //do explosions
collidetable->Update();
if ( this == _Universe->getActiveStarSystem( 0 ) )
UpdateCameraSnds();
bolttime = queryTime();
bolttime = queryTime()-bolttime;
current_stage = MISSION_SIMULATION;
firstframe = false;
}
time -= (1./PHY_NUM)*SIMULATION_ATOM;
}
unsigned int i = _Universe->CurrentCockpit();
for (unsigned int j = 0; j < _Universe->numPlayers(); ++j)
if (_Universe->AccessCockpit( j )->activeStarSystem == this) {
_Universe->SetActiveCockpit( j );
_Universe->AccessCockpit( j )->updateAttackers();
if ( _Universe->AccessCockpit( j )->Update() ) {
SIMULATION_ATOM = normal_simulation_atom;
_Universe->SetActiveCockpit( i );
_Universe->popActiveStarSystem();
return;
}
}
_Universe->SetActiveCockpit( i );
}
if ( sigIter.isDone() )
sigIter = drawList.createIterator();
else
++sigIter;
while ( !sigIter.isDone() && !UnitUtil::isSignificant( *sigIter) )
++sigIter;
//If it is done, leave it NULL for this frame then.
//WARNING cockpit does not get here...
SIMULATION_ATOM = normal_simulation_atom;
//WARNING cockpit does not get here...
_Universe->popActiveStarSystem();
}
/*
**************************************************************************************
*** STAR SYSTEM JUMP STUFF **
**************************************************************************************
*/
Hashtable< std::string, StarSystem, 127 >star_system_table;
void StarSystem::AddStarsystemToUniverse( const string &mname )
{
star_system_table.Put( mname, this );
}
void StarSystem::RemoveStarsystemFromUniverse()
{
if ( star_system_table.Get( filename ) )
star_system_table.Delete( filename );
}
StarSystem * GetLoadedStarSystem( const char *system )
{
StarSystem *ss = star_system_table.Get( string( system ) );
std::string ssys( string( system )+string( ".system" ) );
if (!ss)
ss = star_system_table.Get( ssys );
return ss;
}
std::vector< unorigdest* >pendingjump;
bool PendingJumpsEmpty()
{
return pendingjump.empty();
}
extern void SetShieldZero( Unit* );
void StarSystem::ProcessPendingJumps()
{
for (unsigned int kk = 0; kk < pendingjump.size(); ++kk) {
Unit *un = pendingjump[kk]->un.GetUnit();
if (pendingjump[kk]->delay >= 0) {
Unit *jp = pendingjump[kk]->jumppoint.GetUnit();
if (un && jp) {
QVector delta = ( jp->LocalPosition()-un->LocalPosition() );
float dist = delta.Magnitude();
if (pendingjump[kk]->delay > 0) {
float speed = dist/pendingjump[kk]->delay;
bool player = (_Universe->isPlayerStarship( un ) != NULL);
if (dist > 10 && player) {
if (un->activeStarSystem == pendingjump[kk]->orig)
un->SetCurPosition( un->LocalPosition()+SIMULATION_ATOM*delta*(speed/dist) );
} else if (!player) {
un->SetVelocity( Vector( 0, 0, 0 ) );
}
static bool setshieldzero =
XMLSupport::parse_bool( vs_config->getVariable( "physics", "jump_disables_shields", "true" ) );
if (setshieldzero)
SetShieldZero( un );
}
}
double time = GetElapsedTime();
if (time > 1)
time = 1;
pendingjump[kk]->delay -= time;
continue;
} else {
#ifdef JUMP_DEBUG
VSFileSystem::vs_fprintf( stderr, "Volitalizing pending jump animation.\n" );
#endif
_Universe->activeStarSystem()->VolitalizeJumpAnimation( pendingjump[kk]->animation );
}
int playernum = _Universe->whichPlayerStarship( un );
//In non-networking mode or in networking mode or a netplayer wants to jump and is ready or a non-player jump
if ( Network == NULL || playernum < 0 || ( Network != NULL && playernum >= 0 && Network[playernum].readyToJump() ) ) {
Unit *un = pendingjump[kk]->un.GetUnit();
StarSystem *savedStarSystem = _Universe->activeStarSystem();
//Download client descriptions of the new zone (has to be blocking)
if (Network != NULL)
Network[playernum].downloadZoneInfo();
if ( un == NULL || !_Universe->StillExists( pendingjump[kk]->dest )
|| !_Universe->StillExists( pendingjump[kk]->orig ) ) {
#ifdef JUMP_DEBUG
VSFileSystem::vs_fprintf( stderr, "Adez Mon! Unit destroyed during jump!\n" );
#endif
delete pendingjump[kk];
pendingjump.erase( pendingjump.begin()+kk );
--kk;
continue;
}
bool dosightandsound = ( (pendingjump[kk]->dest == savedStarSystem) || _Universe->isPlayerStarship( un ) );
_Universe->setActiveStarSystem( pendingjump[kk]->orig );
if ( un->TransferUnitToSystem( kk, savedStarSystem, dosightandsound ) )
un->DecreaseWarpEnergy( false, 1.0f );
if (dosightandsound)
_Universe->activeStarSystem()->DoJumpingComeSightAndSound( un );
_Universe->AccessCockpit()->OnJumpEnd(un);
delete pendingjump[kk];
pendingjump.erase( pendingjump.begin()+kk );
--kk;
_Universe->setActiveStarSystem( savedStarSystem );
//In networking mode we tell the server we want to go back in game
if (Network != NULL) {
//Find the corresponding networked player
if (playernum >= 0) {
Network[playernum].inGame();
Network[playernum].unreadyToJump();
}
}
}
}
}
double calc_blend_factor( double frac, int priority, unsigned int when_it_will_be_simulated, int cur_simulation_frame )
{
if (when_it_will_be_simulated == SIM_QUEUE_SIZE) {
return 1;
} else {
int relwas = when_it_will_be_simulated-priority;
if (relwas < 0) relwas += SIM_QUEUE_SIZE;
int relcur = cur_simulation_frame-relwas-1;
if (relcur < 0) relcur += SIM_QUEUE_SIZE;
return (relcur+frac)/(double) priority;
}
}
void ActivateAnimation( Unit *jumppoint )
{
jumppoint->graphicOptions.Animating = 1;
Unit *un;
for (un_iter i = jumppoint->getSubUnits(); NULL != (un = *i); ++i)
ActivateAnimation( un );
}
static bool isJumping( const vector< unorigdest* > &pending, Unit *un )
{
for (size_t i = 0; i < pending.size(); ++i)
if (pending[i]->un == un)
return true;
return false;
}
QVector SystemLocation( std::string system );
double howFarToJump();
QVector ComputeJumpPointArrival( QVector pos, std::string origin, std::string destination )
{
QVector finish = SystemLocation( destination );
QVector start = SystemLocation( origin );
QVector dir = finish-start;
if ( dir.MagnitudeSquared() ) {
dir.Normalize();
dir = -dir;
pos = -pos;
pos.Normalize();
if ( pos.MagnitudeSquared() ) pos.Normalize();
return (dir*.5+pos*.125)*howFarToJump();
}
return QVector( 0, 0, 0 );
}
bool StarSystem::JumpTo( Unit *un, Unit *jumppoint, const std::string &system, bool force, bool save_coordinates )
{
if ( ( un->DockedOrDocking()&(~Unit::DOCKING_UNITS) ) != 0 )
return false;
if (Network == NULL || force) {
if (un->jump.drive >= 0)
un->jump.drive = -1;
#ifdef JUMP_DEBUG
VSFileSystem::vs_fprintf( stderr, "jumping to %s. ", system.c_str() );
#endif
StarSystem *ss = star_system_table.Get( system );
std::string ssys( system+".system" );
if (!ss)
ss = star_system_table.Get( ssys );
bool justloaded = false;
if (!ss) {
justloaded = true;
ss = _Universe->GenerateStarSystem( ssys.c_str(), filename.c_str(), Vector( 0, 0, 0 ) );
//NETFIXME: Do we want to generate the system if an AI unit jumps?
}
if ( ss && !isJumping( pendingjump, un ) ) {
#ifdef JUMP_DEBUG
VSFileSystem::vs_fprintf( stderr, "Pushing back to pending queue!\n" );
#endif
bool dosightandsound = ( ( this == _Universe->getActiveStarSystem( 0 ) ) || _Universe->isPlayerStarship( un ) );
int ani = -1;
if (dosightandsound)
ani = _Universe->activeStarSystem()->DoJumpingLeaveSightAndSound( un );
_Universe->AccessCockpit()->OnJumpBegin(un);
pendingjump.push_back( new unorigdest( un, jumppoint, this, ss, un->GetJumpStatus().delay, ani, justloaded,
save_coordinates ? ComputeJumpPointArrival( un->Position(), this->getFileName(),
system ) : QVector( 0, 0, 0 ) ) );
} else {
#ifdef JUMP_DEBUG
VSFileSystem::vs_fprintf( stderr, "Failed to retrieve!\n" );
#endif
return false;
}
if (jumppoint)
ActivateAnimation( jumppoint );
} else
//Networking mode
if (jumppoint) {
Network->jumpRequest( system, jumppoint->GetSerial() );
}
return true;
}
| 36,360 | 11,127 |
#ifndef ASMITH_PARALLEL_FOR_TASK_HPP
#define ASMITH_PARALLEL_FOR_TASK_HPP
// Copyright 2017 Adam Smith
//
// 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 "task_dispatcher.hpp"
#include "task.hpp"
namespace as {
template<class T, class F, class L1, class L2>
class parallel_for_task : public task<void> {
private:
const L1 mCondition;
const L2 mIncrement;
const F mFunction;
const T mBegin;
const T mEnd;
T mIndex;
public:
parallel_for_task(const T aBegin, const T aEnd, const F aFunction, const L1 aCondition, const L2 aIncrement) :
mCondition(aCondition),
mIncrement(aIncrement),
mFunction(aFunction),
mBegin(aBegin),
mEnd(aEnd),
mIndex(aBegin)
{}
void on_execute(as::task_controller& aController) override {
mIndex = mBegin;
on_resume(aController, 0);
}
void on_resume(as::task_controller& aController, uint8_t aLocation) override {
while(mCondition(mIndex, mEnd)) {
#ifndef ASMITH_DISABLE_PARALLEL_FOR_PAUSE
if(is_pause_requested()) pause(aController, aLocation);
#endif
mFunction(mIndex);
mIncrement(mIndex);
}
set_return();
}
};
namespace implementation {
template<class V, class F, class I, class I2, class L1, class L2>
void parallel_for(task_dispatcher& aDispatcher, V aMin, V aMax, F aFunction, size_t aBlocks, task_dispatcher::priority aPriority, I aMinFn, I2 aMaxFn, L1 aCondition, L2 aIncrement) {
std::future<void>* const futures = new std::future<void>[aBlocks];
try{
for(size_t i = 0; i < aBlocks; ++i) {
task_dispatcher::task_ptr task(new parallel_for_task<V,F,L1,L2>(aMinFn(i), aMaxFn(i), aFunction, aCondition, aIncrement));
futures[i] = aDispatcher.schedule<void>(task, aPriority);
}
for(size_t i = 0; i < aBlocks; ++i) futures[i].get();
}catch (std::exception& e) {
delete[] futures;
throw e;
}
delete[] futures;
}
}
template<class I, class F>
void parallel_for_less_than(task_dispatcher& aDispatcher, I aMin, I aMax, F aFunction, uint8_t aBlocks = 4, task_dispatcher::priority aPriority = task_dispatcher::priority::PRIORITY_MEDIUM) {
implementation::parallel_for<I, F>(
aDispatcher,
aMin,
aMax,
aFunction,
aBlocks,
aPriority,
[=](I i)->I {
const I range = aMax - aMin;
const I sub_range = range / aBlocks;
return aMin + (sub_range * i);
},
[=](I i)->I {
const I range = aMax - aMin;
const I sub_range = range / aBlocks;
return i + 1 == aBlocks ? aMax : sub_range * (i + 1);
},
[](const I a, const I b)->bool{ return a < b; },
[](I& i)->void { ++i; }
);
}
template<class I, class F>
void parallel_for_less_than_equals(task_dispatcher& aDispatcher, I aMin, I aMax, F aFunction, uint8_t aBlocks = 4, task_dispatcher::priority aPriority = task_dispatcher::priority::PRIORITY_MEDIUM) {
implementation::parallel_for<I, F>(
aDispatcher,
aMin,
aMax,
aFunction,
aBlocks,
aPriority,
[=](I i)->I {
const I range = aMax - aMin;
const I sub_range = range / aBlocks;
return i == 0 ? aMin : aMin + (sub_range * i) + 1;
},
[=](int i)->I {
const I range = aMax - aMin;
const I sub_range = range / aBlocks;
return i + 1 == aBlocks ? aMax : sub_range * (i + 1);
},
[](const I a, const I b)->bool{ return a <= b; },
[](I& i)->void { ++i; }
);
}
template<class I, class F>
void parallel_for_greater_than(task_dispatcher& aDispatcher, I aMin, I aMax, F aFunction, uint8_t aBlocks = 4, task_dispatcher::priority aPriority = task_dispatcher::priority::PRIORITY_MEDIUM) {
implementation::parallel_for<I, F>(
aDispatcher,
aMin,
aMax,
aFunction,
aBlocks,
aPriority,
[=](I i)->I {
const I range = aMin - aMax;
const I sub_range = range / aBlocks;
return aMin -(sub_range * i);
},
[=](I i)->I {
const I range = aMin - aMax;
const I sub_range = range / aBlocks;
return i + 1 == aBlocks ? aMax : aMin - (sub_range * (i + 1));
},
[](const I a, const I b)->bool{ return a > b; },
[](I& i)->void { --i; }
);
}
template<class I, class F>
void parallel_for_greater_than_equals(task_dispatcher& aDispatcher, I aMin, I aMax, F aFunction, uint8_t aBlocks = 4, task_dispatcher::priority aPriority = task_dispatcher::priority::PRIORITY_MEDIUM) {
implementation::parallel_for<I, F>(
aDispatcher,
aMin,
aMax,
aFunction,
aBlocks,
aPriority,
[=](I i)->I {
const I range = aMin - aMax;
const I sub_range = range / aBlocks;
return i == 0 ? aMin : aMin - (sub_range * i) - 1;
},
[=](I i)->I {
const I range = aMin - aMax;
const I sub_range = range / aBlocks;
return i + 1 == aBlocks ? aMax : aMin - (sub_range * (i + 1));
},
[](const I a, const I b)->bool{ return a >= b; },
[](I& i)->void { --i; }
);
}
}
#endif | 5,313 | 2,292 |
#include "Environment/ASTNode.hpp"
#include "Environment/ASTSemanticAnalyzer.hpp"
#include "Environment/ASTSourcePosition.hpp"
#include "Environment/ASTLiteralValueNode.hpp"
#include "Environment/ASTValuePatternNode.hpp"
#include "Environment/LiteralString.hpp"
#include "Environment/SubclassResponsibility.hpp"
#include "Environment/MacroInvocationContext.hpp"
#include "Environment/BootstrapMethod.hpp"
#include "Environment/BootstrapTypeRegistration.hpp"
namespace Sysmel
{
namespace Environment
{
static BootstrapTypeRegistration<ASTNode> ASTNodeTypeRegistration;
MethodCategories ASTNode::__instanceMethods__()
{
return MethodCategories{
{"accessing", {
makeMethodBinding<ASTSourcePositionPtr (ASTNodePtr)> ("sourcePosition", [](const ASTNodePtr &self) {
return self->sourcePosition;
}, MethodFlags::Pure),
}},
{"converting", {
makeMethodBinding<ASTSourcePositionPtr (ASTNodePtr)> ("parseAsPatternNode", [](const ASTNodePtr &self) {
return self->parseAsPatternNode();
}, MethodFlags::Pure),
}},
};
}
ASTNode::ASTNode()
{
sourcePosition = ASTSourcePosition::empty();
}
AnyValuePtr ASTNode::accept(const ASTVisitorPtr &)
{
SysmelSelfSubclassResponsibility();
}
ASTNodePtr ASTNode::parseAsPatternNode()
{
auto result = basicMakeObject<ASTValuePatternNode> ();
result->sourcePosition = sourcePosition;
result->expectedValue = selfFromThis();
return result;
}
ASTNodePtr ASTNode::parseAsBindingPatternNode()
{
return parseAsPatternNode();
}
ASTNodePtr ASTNode::optimizePatternNodeForExpectedTypeWith(const TypePtr &, const ASTSemanticAnalyzerPtr &semanticAnalyzer)
{
return semanticAnalyzer->recordSemanticErrorInNode(selfFromThis(), "Not a pattern node that can be optimized.");
}
ASTNodePtr ASTNode::expandPatternNodeForExpectedTypeWith(const TypePtr &, const ASTNodePtr &, const ASTSemanticAnalyzerPtr &semanticAnalyzer)
{
return semanticAnalyzer->recordSemanticErrorInNode(selfFromThis(), "Not a pattern node that can be expanded.");
}
bool ASTNode::isASTNode() const
{
return true;
}
bool ASTNode::isASTLiteralSymbolValue() const
{
return false;
}
bool ASTNode::isPureCompileTimeLiteralValueNode() const
{
return false;
}
bool ASTNode::isPureCompileTimeEvaluableNode() const
{
return false;
}
ASTNodePtr ASTNode::asASTNodeRequiredInPosition(const ASTSourcePositionPtr &requiredSourcePosition)
{
(void)requiredSourcePosition;
return selfFromThis();
}
ASTNodePtr ASTNode::asInlinedBlockBodyNode()
{
return selfFromThis();
}
bool ASTNode::isASTIdentifierSymbolValue() const
{
return false;
}
bool ASTNode::isASTLiteralTypeNode() const
{
return false;
}
bool ASTNode::isAlwaysMatchingPattern() const
{
return false;
}
bool ASTNode::isNeverMatchingPattern() const
{
return false;
}
bool ASTNode::isValidForCachingTypeConversionRules() const
{
return true;
}
bool ASTNode::isSuperReference() const
{
return false;
}
ASTNodePtr ASTNode::parseAsArgumentNodeWith(const ASTSemanticAnalyzerPtr &semanticAnalyzer)
{
return semanticAnalyzer->recordSemanticErrorInNode(selfFromThis(), "This is not a valid argument argument specification.");
}
ASTNodePtr ASTNode::parseAsPatternMatchingCaseWith(const ASTSemanticAnalyzerPtr &semanticAnalyzer)
{
return semanticAnalyzer->recordSemanticErrorInNode(selfFromThis(), "Not a valid pattern matching case.");
}
std::string ASTNode::printString() const
{
return sexpressionToPrettyString(asSExpression());
}
ASTNodePtrList ASTNode::children()
{
ASTNodePtrList result;
childrenDo([&](const ASTNodePtr &child) {
if(child)
result.push_back(child);
});
return result;
}
void ASTNode::childrenDo(const ASTIterationBlock &aBlock)
{
(void)aBlock;
}
void ASTNode::allChildrenDo(const ASTIterationBlock &aBlock)
{
ASTIterationBlock recursiveBlock = [&](const ASTNodePtr &child) {
aBlock(child);
child->childrenDo(recursiveBlock);
};
childrenDo(recursiveBlock);
}
void ASTNode::withAllChildrenDo(const ASTIterationBlock &aBlock)
{
aBlock(selfFromThis());
allChildrenDo(aBlock);
}
ASTPragmaNodePtr ASTNode::getPragmaNamed(const AnyValuePtr &requestedPragmaSelector)
{
return nullptr;
}
} // End of namespace Environment
} // End of namespace Sysmel | 4,402 | 1,362 |
// copyright defined in LICENSE.txt
#include "token.hpp"
#include <eosio/database.hpp>
#include <eosio/input_output.hpp>
struct transfer {
eosio::name from = {};
eosio::name to = {};
eosio::asset quantity = {};
eosio::shared_memory<std::string_view> memo = {};
};
void process(token_transfer_request& req, const eosio::database_status& status) {
using query_type = eosio::query_action_trace_range_name_receiver_account_block_trans_action;
auto s = query_database(query_type{
.snapshot_block = get_block_num(req.snapshot_block, status),
.first =
{
.name = "transfer"_n,
.receiver = req.first_key.receiver,
.account = req.first_key.account,
.block_num = get_block_num(req.first_key.block, status),
.transaction_id = req.first_key.transaction_id,
.action_ordinal = req.first_key.action_ordinal,
},
.last =
{
.name = "transfer"_n,
.receiver = req.last_key.receiver,
.account = req.last_key.account,
.block_num = get_block_num(req.last_key.block, status),
.transaction_id = req.last_key.transaction_id,
.action_ordinal = req.last_key.action_ordinal,
},
.max_results = req.max_results,
});
token_transfer_response response;
std::optional<query_type::key> last_key;
std::map<uint32_t, eosio::block_info> block_map;
eosio::for_each_query_result<eosio::action_trace>(s, [&](eosio::action_trace& at) {
last_key = query_type::key::from_data(at);
if (at.transaction_status != eosio::transaction_status::executed)
return true;
// todo: handle bad unpack
auto unpacked = eosio::unpack<transfer>(at.action.data->pos(), at.action.data->remaining());
bool is_notify = at.receiver != at.action.account;
if ((req.include_notify_incoming && is_notify && at.receiver == unpacked.to) ||
(req.include_notify_outgoing && is_notify && at.receiver == unpacked.from) || //
(req.include_nonnotify && !is_notify)) {
auto block_itr = block_map.find(at.block_num);
if(block_itr == block_map.end())
{
auto bs = query_database(eosio::query_block_info_range_index{
.first = get_block_num(eosio::make_absolute_block(at.block_num), status),
.last = get_block_num(eosio::make_absolute_block(at.block_num), status),
.max_results = 1,
});
eosio::for_each_query_result<eosio::block_info>(bs, [&](eosio::block_info& b) {
block_itr = block_map.insert(std::pair<uint32_t, eosio::block_info>{at.block_num, b}).first;
return true;
});
}
response.transfers.push_back(token_transfer{
.key =
{
.receiver = at.receiver,
.account = at.action.account,
.block = eosio::make_absolute_block(at.block_num),
.transaction_id = at.transaction_id,
.action_ordinal = at.action_ordinal,
},
.from = unpacked.from,
.to = unpacked.to,
.quantity = eosio::extended_asset{unpacked.quantity, at.action.account},
.memo = unpacked.memo,
.timestamp = block_itr->second.timestamp
});
}
return true;
});
if (last_key) {
increment_key(*last_key);
response.more = token_transfer_key{
.receiver = last_key->receiver,
.account = last_key->account,
.block = eosio::make_absolute_block(last_key->block_num),
.transaction_id = last_key->transaction_id,
.action_ordinal = last_key->action_ordinal,
};
}
eosio::set_output_data(pack(token_query_response{std::move(response)}));
}
void process(balances_for_multiple_accounts_request& req, const eosio::database_status& status) {
auto s = query_database(eosio::query_contract_row_range_code_table_pk_scope{
.snapshot_block = get_block_num(req.snapshot_block, status),
.first =
{
.code = req.code,
.table = "accounts"_n,
.primary_key = req.sym.raw(),
.scope = req.first_account,
},
.last =
{
.code = req.code,
.table = "accounts"_n,
.primary_key = req.sym.raw(),
.scope = req.last_account,
},
.max_results = req.max_results,
});
balances_for_multiple_accounts_response response;
eosio::for_each_contract_row<eosio::asset>(s, [&](eosio::contract_row& r, eosio::asset* a) {
response.more = eosio::name{r.scope.value + 1};
if (r.present && a)
response.balances.push_back({.account = eosio::name{r.scope}, .amount = eosio::extended_asset{*a, req.code}});
return true;
});
eosio::set_output_data(pack(token_query_response{std::move(response)}));
}
void process(balances_for_multiple_tokens_request& req, const eosio::database_status& status) {
auto s = query_database(eosio::query_contract_row_range_scope_table_pk_code{
.snapshot_block = get_block_num(req.snapshot_block, status),
.first =
{
.scope = req.account,
.table = "accounts"_n,
.primary_key = req.first_key.sym.raw(),
.code = req.first_key.code,
},
.last =
{
.scope = req.account,
.table = "accounts"_n,
.primary_key = req.last_key.sym.raw(),
.code = req.last_key.code,
},
.max_results = req.max_results,
});
balances_for_multiple_tokens_response response;
eosio::for_each_query_result<eosio::contract_row>(s, [&](eosio::contract_row& r) {
response.more = ++bfmt_key{.sym = eosio::symbol_code{r.primary_key}, .code = r.code};
if (!r.present || r.value->remaining() != 16)
return true;
eosio::asset a;
*r.value >> a;
if (!a.is_valid() || a.symbol.code().raw() != r.primary_key)
return true;
if (!response.more->code.value)
response.more->sym = eosio::symbol_code{response.more->sym.raw() + 1};
if (r.present)
response.balances.push_back({.account = eosio::name{r.scope}, .amount = eosio::extended_asset{a, r.code}});
return true;
});
eosio::set_output_data(pack(token_query_response{std::move(response)}));
}
extern "C" __attribute__((eosio_wasm_entry)) void initialize() {}
extern "C" void run_query() {
auto request = eosio::unpack<token_query_request>(eosio::get_input_data());
std::visit([](auto& x) { process(x, eosio::get_database_status()); }, request.value);
}
| 7,476 | 2,320 |
#include <gtest/gtest.h>
#include "nvstrings/NVStrings.h"
#include "./utils.h"
struct TestURL : public GdfTest {
};
TEST_F(TestURL, UrlEncode)
{
std::vector<const char*> hstrs{"www.nvidia.com/rapids?p=é",
"/_file-7.txt",
"a b+c~d",
"e\tfgh\\jklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"0123456789",
" \t\f\n",
nullptr,
""};
NVStrings* strs = NVStrings::create_from_array(hstrs.data(), hstrs.size());
NVStrings* got = strs->url_encode();
const char* expected[] = {"www.nvidia.com%2Frapids%3Fp%3D%C3%A9",
"%2F_file-7.txt",
"a%20b%2Bc~d",
"e%09fgh%5Cjklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"0123456789",
"%20%09%0C%0A",
nullptr,
""};
EXPECT_TRUE(verify_strings(got, expected));
NVStrings::destroy(got);
NVStrings::destroy(strs);
}
TEST_F(TestURL, UrlDecode)
{
std::vector<const char*> hstrs{"www.nvidia.com/rapids/%3Fp%3D%C3%A9",
"/_file-1234567890.txt",
"a%20b%2Bc~defghijklmnopqrstuvwxyz",
"%25-accent%c3%a9d",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"01234567890",
nullptr,
""};
NVStrings* strs = NVStrings::create_from_array(hstrs.data(), hstrs.size());
NVStrings* got = strs->url_decode();
const char* expected[] = {"www.nvidia.com/rapids/?p=é",
"/_file-1234567890.txt",
"a b+c~defghijklmnopqrstuvwxyz",
"%-accentéd",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"01234567890",
nullptr,
""};
EXPECT_TRUE(verify_strings(got, expected));
NVStrings::destroy(got);
NVStrings::destroy(strs);
}
| 2,416 | 832 |
/**
* Copyright (c) 2018 Andrei Ivanov <andrei.i.ivanov@commandus.com>
*
* 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.
*
* @file wpn.cpp
*
*/
#include <string>
#include <cstring>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <signal.h>
#include <argtable3/argtable3.h>
#include <curl/curl.h>
#include "platform.h"
#include "wpn.h"
#include "wp-storage-file.h"
#include "wp-subscribe.h"
#include "wp-push.h"
#include "sslfactory.h"
#include "mcs/mcsclient.h"
#include "utilqr.h"
#include "utilstring.h"
#include "utilvapid.h"
#include "utilrecv.h"
#include "sslfactory.h"
#include "errlist.h"
#define PROMPT_STARTED "Enter q or press Ctrl+C to quit, p to ping"
#define LINK_SUREPHONE_D "https://surephone.commandus.com/?d="
#define LINK_SUREPHONE_QR "https://surephone.commandus.com/qr/?id="
#define DEF_EMAIL_TEMPLATE "<html><body>$subject<br/>Hi, $name<br/>Click the link below on the phone, tablet or other device on which surephone is installed.\
If the program is not already installed, \
<a href=\"https://play.google.com/store/apps/details?id=com.commandus.surephone\">install it</a>.\
<br/>$body</body></html>"
static int quitFlag = 0;
void signalHandler(int signal)
{
switch(signal)
{
case SIGHUP:
std::cerr << MSG_RELOAD_CONFIG_REQUEST << std::endl;
quitFlag = 2;
fclose(0);
break;
case SIGINT:
std::cerr << MSG_INTERRUPTED << std::endl;
quitFlag = 1;
break;
default:
break;
}
}
#ifdef _MSC_VER
// TODO
void setSignalHandler()
{
}
#else
void setSignalHandler()
{
struct sigaction action;
memset(&action, 0, sizeof(struct sigaction));
action.sa_handler = &signalHandler;
sigaction(SIGINT, &action, NULL);
sigaction(SIGHUP, &action, NULL);
}
#endif
#ifdef _MSC_VER
void initWindows()
{
// Initialize Winsock
WSADATA wsaData;
int r = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (r)
{
std::cerr << "WSAStartup error %d" << r << std::endl;
exit(ERR_WSA);
}
}
#endif
void onLog
(
void *env,
int severity,
const char *message
)
{
WpnConfig *c = (WpnConfig *) env;
if (c && c->config && c->config->clientOptions->getVerbosity() >= severity)
{
std::cerr << message;
}
}
/**
* Call dynamically loaded functions to notify user
*/
void onNotify(
void *env,
const char *persistent_id,
const char *from,
const char *appName,
const char *appId,
int64_t sent,
const NotifyMessageC *notification
)
{
WpnConfig *c = (WpnConfig *) env;
if (c && c->config && c->config->clientOptions->getVerbosity() > 2)
{
if (notification)
{
std::cerr << "Body:" << notification->body << std::endl;
}
}
for (std::vector <OnNotifyC>::const_iterator it(((WpnConfig*) env)->onNotifyList.begin()); it != ((WpnConfig*)env)->onNotifyList.end(); ++it)
{
(*it) (env, persistent_id, from, appName, appId, sent, notification);
}
}
void readCommand(
int *quitFlag,
std::istream &strm,
MCSClient *client
)
{
std::string s;
while ((*quitFlag == 0) && (!strm.eof()))
{
strm >> s;
if (s.find_first_of("qQ") == 0)
{
*quitFlag = 1;
break;
}
if (s.find_first_of("pP") == 0)
{
client->ping();
}
}
}
int main(int argc, char** argv)
{
// Signal handler
setSignalHandler();
#ifdef _MSC_VER
initWindows();
#endif
// In windows, this will init the winsock stuff
curl_global_init(CURL_GLOBAL_ALL);
initSSL();
WpnConfig config(argc, argv);
if (config.error())
exit(config.error());
switch (config.cmd)
{
case CMD_LIST:
{
if ((config.outputFormat == 0) && (config.config->clientOptions->getVerbosity() > 0))
std::cout << "subscribeUrl\tsubscribe mode\tendpoint\tauthorized entity\tFCM token\tpushSet" << std::endl;
config.config->subscriptions->write(std::cout, "\t", config.outputFormat);
}
break;
case CMD_LIST_QRCODE:
{
if ((config.outputFormat == 0) && (config.config->clientOptions->getVerbosity() > 0))
std::cout << "FCM QRCodes:" << std::endl;
std::stringstream ss;
std::string foreground = u8"\u2588\u2588";
std::string background = " ";
std::string v = config.config->wpnKeys->getPublicKey();
if (config.invert_qrcode)
v = qr2string(v, foreground, background);
else
v = qr2string(v, background, foreground);
std::cout
<< config.config->wpnKeys->id << "\t"
<< config.config->clientOptions->name << std::endl
<< v << std::endl;
long r = 0;
if (config.config->clientOptions->getVerbosity() > 0) {
for (std::vector<Subscription>::const_iterator it(config.config->subscriptions->list.begin()); it != config.config->subscriptions->list.end(); ++it)
{
std::string v = it->getWpnKeys().getPublicKey();
if (config.invert_qrcode)
v = qr2string(v, foreground, background);
else
v = qr2string(v, background, foreground);
std::cout
<< it->getWpnKeys().id << "\t"
<< it->getName() << std::endl
<< v << std::endl;
}
}
}
break;
case CMD_LIST_LINK:
{
std::stringstream ssBody;
for (std::vector<Subscription>::const_iterator it(config.config->subscriptions->list.begin()); it != config.config->subscriptions->list.end(); ++it)
{
std::stringstream ss;
ss
<< it->getName() << ","
<< it->getAuthorizedEntity() << ","
<< it->getServerKey() << ","
<< it->getToken();
ssBody << LINK_SUREPHONE_D << escapeURLString(ss.str()) << std::endl;
}
std::cout << ssBody.str();
}
break;
case CMD_LIST_EMAIL:
{
if (config.subject.empty()) {
config.subject = "Connect device to wpn";
}
if (config.email_template.empty()) {
config.email_template = DEF_EMAIL_TEMPLATE;
}
std::string m = config.email_template;
size_t p = m.find("$name");
if (p != std::string::npos)
{
m.replace(p, 5, config.cn);
}
p = m.find("$subject");
if (p != std::string::npos)
{
m.replace(p, 8, config.subject);
}
std::stringstream ssBody;
for (std::vector<Subscription>::const_iterator it(config.config->subscriptions->list.begin()); it != config.config->subscriptions->list.end(); ++it)
{
std::stringstream ss;
ss
<< it->getName() << ","
<< it->getAuthorizedEntity() << ","
<< it->getServerKey() << ","
<< it->getToken();
std::string u = escapeURLString(ss.str());
ssBody
<< "<p>"
<< "<a href=\"" << LINK_SUREPHONE_D << u << "\">Connect to "
<< it->getName()
<< "</a>"
<< "</p>"
<< std::endl;
}
p = m.find("$body");
if (p != std::string::npos)
{
m.replace(p, 5, ssBody.str());
}
std::cout << m << std::endl;
}
break;
case CMD_CREDENTIALS:
{
if ((config.outputFormat == 0) && (config.config->clientOptions->getVerbosity() > 0))
std::cout << "application\tandroid\ttoken\tGCM" << std::endl;
config.config->androidCredentials->write(std::cout, "\t", config.outputFormat);
std::cout << std::endl;
}
break;
case CMD_KEYS:
{
if ((config.outputFormat == 0) && (config.config->clientOptions->getVerbosity() > 0))
std::cout << "private\tpublic\tsecret" << std::endl;
config.config->wpnKeys->write(std::cout, "\t", config.outputFormat);
std::cout << std::endl;
}
break;
case CMD_SUBSCRIBE_FCM:
{
std::string d;
std::string headers;
std::string token;
std::string pushset;
int r = subscribeFCM(&d, &headers, token, pushset,
config.config->wpnKeys->getPublicKey(),
config.config->wpnKeys->getAuthSecret(),
config.subscribeUrl, config.getDefaultFCMEndPoint(), config.authorizedEntity,
config.config->clientOptions->getVerbosity());
if ((r < 200) || (r >= 300))
{
std::cerr << "Error " << r << ": " << d << std::endl;
}
else
{
Subscription subscription;
subscription.setToken(token);
subscription.setPushSet(pushset);
subscription.setServerKey(config.serverKey);
subscription.setSubscribeUrl(config.subscribeUrl);
subscription.setSubscribeMode(SUBSCRIBE_FORCE_FIREBASE);
subscription.setEndpoint(config.getDefaultFCMEndPoint());
subscription.setAuthorizedEntity(config.authorizedEntity);
config.config->subscriptions->list.push_back(subscription);
if (config.config->clientOptions->getVerbosity() > 0)
{
subscription.write(std::cout, "\t", config.outputFormat);
}
}
}
break;
case CMD_SUBSCRIBE_VAPID:
{
// TODO
Subscription subscription;
config.config->subscriptions->list.push_back(subscription);
if (config.config->clientOptions->getVerbosity() > 0)
{
subscription.write(std::cout, "\t", config.outputFormat);
}
}
break;
case CMD_UNSUBSCRIBE:
{
if (config.authorizedEntity.empty())
{
// delete all
Subscription f(config.fcm_endpoint, config.authorizedEntity);
for (std::vector<Subscription>::iterator it(config.config->subscriptions->list.begin()); it != config.config->subscriptions->list.end(); ++it)
{
// TODO
}
config.config->subscriptions->list.clear();
}
else
{
Subscription f(config.fcm_endpoint, config.authorizedEntity);
std::vector<Subscription>::iterator it = std::find(config.config->subscriptions->list.begin(),
config.config->subscriptions->list.end(), f);
if (it != config.config->subscriptions->list.end())
config.config->subscriptions->list.erase(it);
}
}
break;
case CMD_PUSH:
{
std::string retval;
std::string token = "";
std::string serverKey;
WpnKeys wpnKeys;
if (!config.private_key.empty()) {
// override Wpn keys
wpnKeys.init(0, 0, config.private_key, config.public_key, config.auth_secret);
}
switch (config.subscriptionMode) {
case SUBSCRIBE_FORCE_FIREBASE:
serverKey = config.serverKey;
break;
case SUBSCRIBE_FORCE_VAPID:
break;
default:
// Load server key from the subscription, by the name
const Subscription *subscription = config.getSubscription(config.name);
if (subscription) {
switch (subscription->getSubscribeMode()) {
case SUBSCRIBE_FORCE_FIREBASE:
config.subscriptionMode = SUBSCRIBE_FORCE_FIREBASE;
serverKey = subscription->getServerKey();
token = subscription->getToken();
break;
case SUBSCRIBE_FORCE_VAPID:
{
config.subscriptionMode = SUBSCRIBE_FORCE_VAPID;
// subscription MUST keep wpn keys
WpnKeys wpnkeys = subscription->getWpnKeys();
wpnKeys.init(subscription->getWpnKeys());
}
break;
default:
break;
}
}
break;
}
std::string body = jsClientNotification("", config.subject, config.body, config.icon, config.link, config.data);
// for VAPID only one endpoint not many
for (std::vector<std::string>::const_iterator it(config.recipientTokens.begin()); it != config.recipientTokens.end(); ++it)
{
int r;
if (config.command.empty())
{
if (config.config->clientOptions->getVerbosity() > 1)
std::cout << "Sending notification to " << *it << std::endl;
switch (config.subscriptionMode) {
case SUBSCRIBE_FORCE_FIREBASE:
r = push2ClientNotificationFCM(&retval, serverKey, *it,
config.subject, config.body, config.icon, config.link, config.data, config.config->clientOptions->getVerbosity());
break;
case SUBSCRIBE_FORCE_VAPID:
if (config.config->clientOptions->getVerbosity() > 3) {
std::cerr << "sender public key: " << wpnKeys.getPublicKey() << std::endl
<< "sender private key: " << wpnKeys.getPrivateKey() << std::endl
<< "endpoint: " << *it << std::endl
<< "public key: " << config.vapid_recipient_p256dh << std::endl
<< "auth secret: " << config.auth_secret << std::endl
<< "body: " << body << std::endl
<< "sub: " << config.sub << std::endl;
}
r = webpushVapid(NULL, retval, wpnKeys.getPublicKey(), wpnKeys.getPrivateKey(), *it, config.vapid_recipient_p256dh, config.auth_secret,
body, config.sub, config.aesgcm ? AESGCM : AES128GCM);
if (config.config->clientOptions->getVerbosity() > 3) {
std::string filename = "aesgcm.bin";
retval = webpushVapidCmd(wpnKeys.getPublicKey(), wpnKeys.getPrivateKey(), filename, *it, config.vapid_recipient_p256dh, config.auth_secret,
body, config.sub, config.aesgcm ? AESGCM : AES128GCM);
}
break;
}
}
else
{
if (config.config->clientOptions->getVerbosity() > 1)
std::cout << "Execute command " << config.command << " on " << *it << std::endl;
switch (config.subscriptionMode) {
case SUBSCRIBE_FORCE_FIREBASE:
r = push2ClientDataFCM(&retval, serverKey, token, *it, "", config.command, 0, "", config.config->clientOptions->getVerbosity());
break;
case SUBSCRIBE_FORCE_VAPID:
r = webpushVapid(NULL, retval, wpnKeys.getPublicKey(), wpnKeys.getPrivateKey(), *it, config.vapid_recipient_p256dh, config.vapid_recipient_auth,
body, config.sub, config.aesgcm ? AESGCM : AES128GCM);
break;
}
}
if (r >= 200 && r < 300)
std::cout << retval << std::endl;
else
std::cerr << "Error " << r << ": " << retval << std::endl;
}
}
break;
case CMD_PRINT_VERSION:
{
std::cout << config.versionString() << std::endl;
break;
}
case CMD_GENERATE_VAPID_KEYS:
{
Subscription subscription;
std::string d;
std::string headers;
config.config->wpnKeys->generate();
/*
int r = subscribe(subscription, SUBSCRIBE_VAPID, *config.wpnKeys,
config.subscribeUrl, config.getDefaultEndPoint(), config.authorizedEntity,
config.serverKey, &d, &headers, config.verbosity);
if ((r < 200) || (r >= 300))
{
std::cerr << "Error " << r << ": " << d << std::endl;
}
else
{
config.subscriptions->list.push_back(subscription);
}
if (config.verbosity > 0)
{
subscription.write(std::cout, "\t", config.outputFormat);
}
*/
std::cout << config.config->wpnKeys->toJsonString() << std::endl;
}
break;
default:
{
do {
quitFlag = 0;
config.loadNotifyFuncs();
MCSClient client(
config.config->subscriptions,
config.config->wpnKeys->getPrivateKey(),
config.config->wpnKeys->getAuthSecret(),
config.config->androidCredentials->getAndroidId(),
config.config->androidCredentials->getSecurityToken(),
onNotify, &config, onLog, &config,
config.config->clientOptions->getVerbosity()
);
// check in
if (config.config->androidCredentials->getAndroidId() == 0)
{
uint64_t androidId = config.config->androidCredentials->getAndroidId();
uint64_t securityToken = config.config->androidCredentials->getSecurityToken();
int r = checkIn(&androidId, &securityToken, config.config->clientOptions->getVerbosity());
if (r < 200 || r >= 300)
{
return ERR_NO_ANDROID_ID_N_TOKEN;
}
config.config->androidCredentials->setAndroidId(androidId);
config.config->androidCredentials->setSecurityToken(securityToken);
}
// register
if (config.config->androidCredentials->getGCMToken().empty())
{
int r;
for (int i = 0; i < 5; i++)
{
std::string gcmToken;
r = registerDevice(&gcmToken,
config.config->androidCredentials->getAndroidId(),
config.config->androidCredentials->getSecurityToken(),
config.config->androidCredentials->getAppId(),
config.config->clientOptions->getVerbosity()
);
if (r >= 200 && r < 300)
{
config.config->androidCredentials->setGCMToken(gcmToken);
break;
}
sleep(1);
}
if (r < 200 || r >= 300)
{
return ERR_NO_FCM_TOKEN;
}
}
client.connect();
std::cerr << PROMPT_STARTED << std::endl;
readCommand(&quitFlag, std::cin, &client);
client.disconnect();
config.unloadNotifyFuncs();
} while (quitFlag == 2);
}
}
config.config->save();
return 0;
}
| 17,143 | 7,480 |
/******************************************************************************************/
/*********** Author : Tran Minh Duc (Snowdence) *******************/
/*********** Email : Snowdence2911@gmail.com *******************/
/*********** Phone : 0982 259 245 *******************
/*********** Project: CyberSoftMedicine - CyberCorp Inc. *******************/
/*********** Date : 9:51 09/04/2017 *******************/
/*********** Compile: Visual Studio 2017 *******************/
/******************************************************************************************/
#include <iostream>
#include <ctime>
#include <string>
#include "SupportFile.h"
#include "NeuralLayer.h"
#include "NeuralProcess.h"
using namespace std;
SupportFile sf;
/// <summary> Admin </summary>
/// <param name="inputNeurons">Số nơ ron đầu vào.</param>
/// <param name="hiddenNeurons">Số nơ ron lớp ẩn.</param>
/// <param name="outputNeurons">Số nơ ron đầu ra.</param>
/// <param name="learningRate">Tốc độ học .</param>
/// <param name="momentum">Hằng số momen mặc định 0.9 .</param>
void trainExperience(int inputNeurons, int hiddenNeurons, int outputNeurons, float learningRate, float momentum, int epochs, char* fileTraining, char* saveWeights)
{
sf.initFileData(inputNeurons, outputNeurons);
if(sf.loadFileData(fileTraining) == false)
{
cout << "Co loi xay ra voi file dao tao. " << endl;
return;
}
NeuralLayer nn(inputNeurons, hiddenNeurons, outputNeurons);
NeuralProcess nT(&nn);
nT.setTrainingParameters(learningRate, momentum, false);
nT.setStoppingConditions(epochs, 95);
nT.trainNetwork(sf.getTrainingDataSet());
nn.saveWeights(saveWeights);
}
void useExperience(int inputNeurons, int hiddenNeurons, int outputNeurons, char* fileTest, char* fileWeights)
{
sf.initFileData(inputNeurons, outputNeurons);
sf.loadFileData(fileTest);
NeuralLayer nn(inputNeurons, hiddenNeurons, outputNeurons);
if (!nn.loadWeights(fileWeights))
{
cout << "Co Loi Xay Ra Voi File Kinh Nghiem " << endl;
return;
}
NeuralProcess nT(&nn);
cout << "\n\n\n" << endl;
cout << "Ket qua tinh toan duoc la : [" << ((*nn.feedForwardPattern(sf.getTrainingDataSet()->trainingSet[0]->pattern) == 0) ? "Lanh tinh" : "Ac tinh") << "]" << endl;
}
void display()
{
cout << "************************************* " << endl;
cout << "------------------------------------- " << endl;
cout << "1. Dao tao mang neuron" << endl;
cout << "2. Su dung kinh nghiem da dao tao " << endl;
cout << "3. Thoat chuong trinh " << endl;
cout << "------------------------------------- " << endl;
cout << "************************************* " << endl;
cout << "" << endl;
cout << "Nhap lua chon cua ban : ";
}
void train()
{
string file = "";
string w = "";
int thehe = 1000;
cout << "Nhap file dao tao: ";
cin >> file;
cout << "Nhap ten file de luu kinh nghiem sau khi dao tao: ";
cin >> w;
char tab1[1024];
char tab2[1024];
trainExperience(9, 16, 1, 0.001, 0.9, thehe, strcpy(tab1, file.c_str()), strcpy(tab2, w.c_str()) );
}
void use() {
string file = "";
string exp = "";
cout << "Nhap ten file can de du doan: ";
cin >> file;
cout << "Nhap ten file kinh nghiem da luu: ";
cin >> exp;
char temp[1024];
char tempp[1024];
useExperience(9, 16, 1,strcpy(temp, file.c_str()) , strcpy(tempp, exp.c_str()) );
}
void main()
{
int option = 0;
LABEL:
display();
cin >> option;
switch (option)
{
case 1:
train();
break;
case 2:
use();
break;
case 3:
goto END;
break;
default:
cout << "Gia tri ban vua nhap khong dung" << endl;
break;
}
cout << "\n\n\n" << endl;
goto LABEL;
//trainExperience(9, 16, 1, 0.001, 0.9, 100, "cancer.txt", "weights.txt");
//useExperience(9, 16, 1, "test.txt", "weights.txt");
END:
system("exit");
} | 3,788 | 1,528 |
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// 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 "sfx/sfxResource.h"
#include "sfx/sfxFileStream.h"
#include "core/util/fourcc.h"
#include "core/resourceManager.h"
// Ugly workaround to keep the constructor protected.
struct SFXResource::_NewHelper
{
static SFXResource* New( String fileName, const ThreadSafeRef< SFXStream >& stream )
{
return new SFXResource( fileName, stream );
}
};
template<>
void* Resource< SFXResource >::create( const Torque::Path& path )
{
String fullPath = path.getFullPath();
// Try to open the stream.
ThreadSafeRef< SFXStream > stream = SFXFileStream::create( fullPath );
if( !stream )
return NULL;
// We have a valid stream... create the resource.
SFXResource* res = SFXResource::_NewHelper::New( fullPath, stream );
return res;
}
template<>
ResourceBase::Signature Resource< SFXResource >::signature()
{
return MakeFourCC( 's', 'f', 'x', 'r' );
}
Resource< SFXResource > SFXResource::load( String filename )
{
return ResourceManager::get().load( filename );
}
SFXResource::SFXResource( String fileName, SFXStream *stream )
: mFileName( fileName ),
mFormat( stream->getFormat() ),
mDuration( stream->getDuration() )
{
}
bool SFXResource::exists( String filename )
{
return SFXFileStream::exists( filename );
}
SFXStream* SFXResource::openStream()
{
return SFXFileStream::create( mFileName );
}
| 2,640 | 816 |
/**
* Copyright (c) 2020 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "spdk/env.h"
#include "SpdkIoBuf.h"
namespace DaqDB {
SpdkIoBufMgr::~SpdkIoBufMgr() {}
SpdkIoBuf *SpdkIoBufMgr::getIoWriteBuf(uint32_t ioSize, uint32_t align) {
SpdkIoBuf *buf = 0;
uint32_t bufIdx = ioSize / 4096;
if (bufIdx < 8) {
buf = block[bufIdx]->getWriteBuf();
if (!buf->getSpdkDmaBuf())
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(ioSize), align, NULL));
} else {
buf = new SpdkIoSizedBuf<1 << 16>(1 << 16, -1);
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(ioSize), align, NULL));
}
return buf;
}
void SpdkIoBufMgr::putIoWriteBuf(SpdkIoBuf *ioBuf) {
if (ioBuf->getIdx() != -1)
ioBuf->putWriteBuf(ioBuf);
else {
delete ioBuf;
}
}
SpdkIoBuf *SpdkIoBufMgr::getIoReadBuf(uint32_t ioSize, uint32_t align) {
SpdkIoBuf *buf = 0;
uint32_t bufIdx = ioSize / 4096;
if (bufIdx < 8) {
buf = block[bufIdx]->getReadBuf();
buf->setIdx(bufIdx);
if (!buf->getSpdkDmaBuf())
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(ioSize), align, NULL));
} else {
buf = new SpdkIoSizedBuf<1 << 16>(1 << 16, -1);
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(ioSize), align, NULL));
}
return buf;
}
void SpdkIoBufMgr::putIoReadBuf(SpdkIoBuf *ioBuf) {
if (ioBuf->getIdx() != -1)
ioBuf->putReadBuf(ioBuf);
else
delete ioBuf;
}
Lock SpdkIoBufMgr::instanceMutex;
SpdkIoBufMgr *SpdkIoBufMgr::instance = 0;
SpdkIoBufMgr *SpdkIoBufMgr::getSpdkIoBufMgr() {
if (!SpdkIoBufMgr::instance) {
WriteLock r_lock(instanceMutex);
SpdkIoBufMgr::instance = new SpdkIoBufMgr();
}
return SpdkIoBufMgr::instance;
}
void SpdkIoBufMgr::putSpdkIoBufMgr() {
if (SpdkIoBufMgr::instance) {
WriteLock r_lock(instanceMutex);
delete SpdkIoBufMgr::instance;
SpdkIoBufMgr::instance = 0;
}
}
SpdkIoBufMgr::SpdkIoBufMgr() {
block[0] = new SpdkIoSizedBuf<4096>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096>(8 * 4096, 7);
}
} // namespace DaqDB
| 3,133 | 1,409 |
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "jni.h"
#include "GraphicsJNI.h"
#include <nativehelper/JNIHelp.h>
#include <minikin/Layout.h>
#include <renderthread/RenderProxy.h>
#include "core_jni_helpers.h"
#include <unistd.h>
namespace android {
static void android_app_ActivityThread_purgePendingResources(JNIEnv* env, jobject clazz) {
// Don't care about return values.
mallopt(M_PURGE, 0);
}
static void
android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor) {
int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
android::uirenderer::renderthread::RenderProxy::dumpGraphicsMemory(fd);
minikin::Layout::dumpMinikinStats(fd);
}
static JNINativeMethod gActivityThreadMethods[] = {
// ------------ Regular JNI ------------------
{ "nPurgePendingResources", "()V",
(void*) android_app_ActivityThread_purgePendingResources },
{ "nDumpGraphicsInfo", "(Ljava/io/FileDescriptor;)V",
(void*) android_app_ActivityThread_dumpGraphics }
};
int register_android_app_ActivityThread(JNIEnv* env) {
return RegisterMethodsOrDie(env, "android/app/ActivityThread",
gActivityThreadMethods, NELEM(gActivityThreadMethods));
}
};
| 1,830 | 568 |
// chp5-while-guess.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <cstdlib>
int main()
{
srand(time(0));
int intMAXNUMBER = 100;
int intRandomNumber = rand() % intMAXNUMBER + 1;
int intGuess = 0;
do {
std::cerr << "N: " << intRandomNumber << std::endl;
std::cout << "Please enter a number between 1 and " << intMAXNUMBER << ": ";
std::cin >> intGuess;
if (intGuess > intRandomNumber) {
std::cout << "You guessed too high..." << std::endl;
}
else if (intGuess < intRandomNumber) {
std::cout << "You guessed too low..." << std::endl;
}
else {
std::cout << "Congrats!" << std::endl;
}
} while (intGuess != intRandomNumber);
return 0;
}
| 803 | 323 |
// Random Rectangle
#include <iostream>
#include <string>
#include <cstdlib>
int main()
{
//Constants, and assigned values
const int MAXHEIGHT = 3;
const int MAX = 40;
unsigned seed = time(0);
srand(seed);
int length = rand();
//Gives length its max value
//the 1 prevents it from outputing nothing
length = rand() % MAX + 1;
//outputs the # rectangle
std::string max;
max.assign(length,'#');
std::cout << max << std::endl;
std::cout << max << std::endl;
std::cout << max << std::endl;
return 0;
}
| 504 | 176 |
// QSS Solver Path Functions
//
// Project: QSS Solver
//
// Developed by Objexx Engineering, Inc. (https://objexx.com) under contract to
// the National Renewable Energy Laboratory of the U.S. Department of Energy
//
// Copyright (c) 2017-2021 Objexx Engineering, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// (3) Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
// GOVERNMENT, 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.
// QSS Headers
#include <QSS/path.hh>
#include <QSS/string.hh>
// C++ Headers
#include <cctype>
#include <regex>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef _WIN32
#include <direct.h>
#include <errno.h>
#else
#include <sys/errno.h>
#endif
#ifdef _WIN32
#ifndef S_ISREG
#define S_ISREG(mode) (((mode)&S_IFMT)==S_IFREG)
#endif
#ifdef _WIN64
#define stat _stat64
#else
#define stat _stat
#endif
#endif
namespace QSS {
namespace path {
// Globals
#ifdef _WIN32
char const sep( '\\' );
std::string const tmp( std::getenv( "TEMP" ) != nullptr ? std::getenv( "TEMP" ) : "." );
#else
char const sep( '/' );
std::string const tmp( "/tmp" );
#endif
// Is Name a File?
bool
is_file( std::string const & name )
{
if ( name.empty() ) return false;
struct stat stat_buf;
#ifdef _WIN32
return ( ( stat( name.c_str(), &stat_buf ) == 0 ) && S_ISREG( stat_buf.st_mode ) && ( stat_buf.st_mode & _S_IREAD ) );
#else
return ( ( stat( name.c_str(), &stat_buf ) == 0 ) && S_ISREG( stat_buf.st_mode ) && ( stat_buf.st_mode & S_IRUSR ) );
#endif
}
// Base Name
std::string
base( std::string const & path )
{
std::size_t ibeg( path.rfind( sep ) );
if ( ibeg == std::string::npos ) {
ibeg = 0;
} else {
++ibeg;
}
std::string const name( path, ibeg, path.length() - ibeg );
std::size_t const idot( name.rfind( '.' ) );
if ( idot == std::string::npos ) {
return name;
} else {
return name.substr( 0u, idot );
}
}
// Directory Name
std::string
dir( std::string const & path )
{
std::size_t l( path.length() ); // Length to search up to
while ( ( l > 0u ) && ( path[ l - 1 ] == sep ) ) --l; // Skip trailing path separators
while ( ( l > 0u ) && ( path[ l - 1 ] != sep ) ) --l; // Skip dir/file name
if ( ( l > 0u ) && ( path[ l - 1 ] == sep ) ) --l; // Skip trailing path separator
if ( l > 0u ) {
return path.substr( 0u, l );
} else {
return std::string( "." );
}
}
// Make a Directory
bool
make_dir( std::string const & dir )
{
#ifdef _WIN32
#ifdef __MINGW32__
return ( ( mkdir( dir.c_str() ) == 0 ) || ( errno == EEXIST ) );
#else
return ( ( _mkdir( dir.c_str() ) == 0 ) || ( errno == EEXIST ) );
#endif
#else
return ( ( mkdir( dir.c_str(), S_IRWXU ) == 0 ) || ( errno == EEXIST ) );
#endif
}
// Make a Path
bool
make_path( std::string const & path )
{
#ifdef _WIN32
// Find the starting position
if ( path.empty() ) return false;
std::string::size_type i( 0 );
std::string::size_type const path_len( path.length() );
if ( path_len >= 2 ) {
if ( ( isalpha( path[ 0 ] ) ) && ( path[ 1 ] == ':' ) ) { // X:
i = 2;
}
}
if ( i < path_len ) i = path.find_first_not_of( ".\\/", i );
// Create the directories of the path
if ( ( i < path_len ) && ( i != std::string::npos ) ) {
while ( ( i = path.find_first_of( "\\/", i ) ) != std::string::npos ) {
if ( i + 1 == path.length() ) { // Last directory
return make_dir( path.substr( 0u, i ) );
} else if ( ! make_dir( path.substr( 0u, i ) ) ) { // Failed
return false;
}
++i;
}
return make_dir( path ); // One more directory
} else { // Nothing to do
return true;
}
#else
// Find the starting position
if ( path.empty() ) return false;
std::string::size_type i( path.find_first_not_of( "./" ) );
std::string::size_type const path_len( path.length() );
// Create the directories of the path
if ( ( i < path_len ) && ( i != std::string::npos ) ) {
while ( ( i = path.find_first_of( "/", i ) ) != std::string::npos ) {
if ( i + 1 == path.length() ) { // Last directory
return make_dir( path.substr( 0u, i ) );
} else if ( ! make_dir( path.substr( 0u, i ) ) ) { // Failed
return false;
}
++i;
}
return make_dir( path ); // One more directory
} else { // Nothing to do
return true;
}
#endif
}
// URI of a Path
std::string
uri( std::string const & path )
{
std::string uri;
for ( char c : path ) {
switch ( c ) {
case '%':
uri += "%25";
break;
case ' ':
uri += "%20";
break;
case '!':
uri += "%21";
break;
case '#':
uri += "%23";
break;
case '$':
uri += "%24";
break;
case '&':
uri += "%26";
break;
case '\'':
uri += "%27";
break;
case '(':
uri += "%28";
break;
case ')':
uri += "%29";
break;
case '*':
uri += "%2A";
break;
case '+':
uri += "%2B";
break;
case ',':
uri += "%2C";
break;
case ':':
uri += "%3A";
break;
case ';':
uri += "%3B";
break;
case '=':
uri += "%3D";
break;
case '?':
uri += "%3F";
break;
case '@':
uri += "%40";
break;
case '[':
uri += "%5B";
break;
case ']':
uri += "%5D";
break;
case '^':
uri += "%5E";
break;
case '`':
uri += "%60";
break;
case '{':
uri += "%7B";
break;
case '}':
uri += "%7D";
break;
#ifdef _WIN32
case '\\':
uri += '/';
break;
#endif
default:
uri += c;
break;
}
}
return uri;
}
// Path of a URI
std::string
un_uri( std::string const & uri )
{
std::string path( uri );
if ( has_prefix( path, "file://" ) ) path.erase( 0, 7 );
path = std::regex_replace( path, std::regex( "%20" ), " " );
path = std::regex_replace( path, std::regex( "%21" ), "!" );
path = std::regex_replace( path, std::regex( "%23" ), "#" );
path = std::regex_replace( path, std::regex( "%24" ), "$" );
path = std::regex_replace( path, std::regex( "%26" ), "&" );
path = std::regex_replace( path, std::regex( "%27" ), "'" );
path = std::regex_replace( path, std::regex( "%28" ), "(" );
path = std::regex_replace( path, std::regex( "%29" ), ")" );
path = std::regex_replace( path, std::regex( "%2A" ), "*" );
path = std::regex_replace( path, std::regex( "%2B" ), "+" );
path = std::regex_replace( path, std::regex( "%2C" ), "," );
path = std::regex_replace( path, std::regex( "%3A" ), ":" );
path = std::regex_replace( path, std::regex( "%3B" ), ";" );
path = std::regex_replace( path, std::regex( "%3D" ), "=" );
path = std::regex_replace( path, std::regex( "%3F" ), "?" );
path = std::regex_replace( path, std::regex( "%40" ), "@" );
path = std::regex_replace( path, std::regex( "%5B" ), "[" );
path = std::regex_replace( path, std::regex( "%5D" ), "]" );
path = std::regex_replace( path, std::regex( "%5E" ), "^" );
path = std::regex_replace( path, std::regex( "%60" ), "`" );
path = std::regex_replace( path, std::regex( "%7B" ), "{" );
path = std::regex_replace( path, std::regex( "%7D" ), "}" );
#ifdef _WIN32
path = std::regex_replace( path, std::regex( "/" ), "\\" );
#endif
path = std::regex_replace( path, std::regex( "%25" ), "%" );
return path;
}
} // path
} // QSS
| 8,416 | 3,493 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/// Segmented Sieve
/// Description: Simple sieve of Eratosthenes with few optimizations.
/// It generates primes below 10^9
/// Tutorial Link: https://github.com/kimwalisch/primesieve/wiki/Segmented-sieve-of-Eratosthenes
///set your CPU's L1 cache size(in bytes)
const int64_t L1D_CACHE_SIZE = 32768;
//to store primes
int64_t ppprimes[9000000], nPrime;
int64_t binary[150000009];
///Generate primes using the segmented sieve of Eratosthenes.
///This algorithm uses O(n log log n) operations and O(sqrt(n)) space.
///@param limit Sieve primes <= limit.
void segmented_sieve(int64_t limit){
int64_t sqrtt = (int64_t) sqrt(limit);
int64_t segment_size = max(sqrtt, L1D_CACHE_SIZE);
int64_t count = (limit<2) ? 0 : 1;
///we sieve primes >= 3
int64_t i = 3;
int64_t n = 3;
int64_t s = 3;
vector<char> sieve(segment_size);
vector<char> is_prime(sqrtt + 1, true);
vector<int64_t> primes;
vector<int64_t> multiples;
ppprimes[nPrime++] = 2;
for(int64_t low = 0; low<=limit; low+=segment_size) {
fill(sieve.begin(), sieve.end(), true);
///current segment = [low, high]
int64_t high = low + segment_size - 1;
high = min(high, limit);
///generate sieving primes using simple sieve of Eratosthenes
for(; i*i<=high; i+=2){
if(is_prime[i]){
for(int64_t j = i*i; j<=sqrtt; j+=i){
is_prime[j] = false;
}
}
}
///initialize sieving primes for segmented sieve
for(; s*s<=high; s+=2){
if(is_prime[s]){
primes.push_back(s);
multiples.push_back(s*s - low);
}
}
///sieve the current segment
for(size_t i=0;i<primes.size();i++){
int64_t j = multiples[i];
for(int64_t k = primes[i]*2; j<segment_size; j+=k){
sieve[j] = false;
}
multiples[i] = j - segment_size;
}
for(; n<=high; n+=2){
if(sieve[n-low]) {/// n is prime
ppprimes[nPrime++] = n;
//pprimes.emplace_back(n);
count++;
//if(count%500==1) printf("%ld\n", n);
}
}
}
//printf("%ld primes found.\n", count);
}
int64_t cnt =0;
void preCalculate(){
int64_t idx=1;
for(int64_t i=0;i<nPrime;i++){
int x = ppprimes[i];
//cout<<x<<" ";
/*
while(x>0){ ///this will count 2->01
int y = x&1 ///3->11
//cout<<y; ///5->101 7->111 11->1011 which is worng
if(y==1) cnt++;
binary[idx++] = cnt;
x = x>>1;
}
//cout<<endl;
*/
int flag = 0;
for(int j=0;j<32;j++){ ///Here is the main ninja techinque
if(x<0){
cnt++;
binary[idx++] = cnt;
flag = 1;
}
else if(flag) {
binary[idx++] = cnt;
}
//cout<<x;
x = x<<1;
}
//cout<<endl;
//cout<<binary[1]<<endl;
//cout<<binary[2]<<endl;
//cout<<binary[3]<<endl;
//cout<<binary[4]<<endl;
//printf("%lld ",cnt);
}
//printf("idx = %ld\n nPrime=%lld\ncnt=%d", idx, nPrime, cnt);
}
int main(int argc, char** argv){
if(argc>=2) {
segmented_sieve(atoll(argv[1]));
}
else {
segmented_sieve(101865020);
}
//cout<<"Completed"<<endl;
preCalculate();
//cout<<"Completed2"<<endl;
unsigned t, n;
cin>>t;
while(t--){
cin>>n;
if(n==0) printf("0\n");
else if(n==1) printf("1\n");
else printf("%u\n", binary[n]);
}
return 0;
}
| 3,242 | 1,665 |
// Copyright Carl Philipp Reh 2006 - 2019.
// 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 SGE_GUI_IMPL_MAKE_CONTAINER_PAIR_HPP_INCLUDED
#define SGE_GUI_IMPL_MAKE_CONTAINER_PAIR_HPP_INCLUDED
#include <sge/gui/impl/swap_pair.hpp>
#include <sge/gui/widget/reference_alignment_pair.hpp>
#include <sge/gui/widget/reference_alignment_vector.hpp>
namespace sge::gui::impl
{
sge::gui::widget::reference_alignment_vector make_container_pair(
sge::gui::widget::reference_alignment_pair const &,
sge::gui::widget::reference_alignment_pair const &,
sge::gui::impl::swap_pair);
}
#endif
| 730 | 295 |
#include "descriptor_init.hpp"
#include "tools_runtime.hpp"
namespace nd::src::graphics::vulkan
{
using namespace nd::src::tools;
DescriptorPool
createDescriptorPool(opt<const DescriptorPoolCfg>::ref cfg, const VkDevice device) noexcept(ND_VK_ASSERT_NOTHROW)
{
ND_SET_SCOPE();
const auto createInfo = VkDescriptorPoolCreateInfo {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.pNext = cfg.next,
.flags = cfg.flags,
.maxSets = cfg.maxSets,
.poolSizeCount = static_cast<u32>(cfg.sizes.size()),
.pPoolSizes = cfg.sizes.data()};
VkDescriptorPool descriptorPool;
ND_VK_ASSERT(vkCreateDescriptorPool(device, &createInfo, ND_VK_ALLOCATION_CALLBACKS, &descriptorPool));
return descriptorPool;
}
DescriptorSetLayout
createDescriptorSetLayout(opt<const DescriptorSetLayoutCfg>::ref cfg, const VkDevice device) noexcept(ND_VK_ASSERT_NOTHROW)
{
ND_SET_SCOPE();
const auto createInfo = VkDescriptorSetLayoutCreateInfo {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
.pNext = cfg.next,
.flags = cfg.flags,
.bindingCount = static_cast<u32>(cfg.bindings.size()),
.pBindings = cfg.bindings.data()};
VkDescriptorSetLayout descriptorSetLayout;
ND_VK_ASSERT(vkCreateDescriptorSetLayout(device, &createInfo, ND_VK_ALLOCATION_CALLBACKS, &descriptorSetLayout));
return descriptorSetLayout;
}
DescriptorSetLayoutObjects
createDescriptorSetLayoutObjects(opt<const DescriptorSetLayoutObjectsCfg>::ref cfg, const VkDevice device) noexcept(ND_VK_ASSERT_NOTHROW)
{
ND_SET_SCOPE();
return {.mesh = createDescriptorSetLayout(cfg.mesh, device)};
}
vec<DescriptorSet>
allocateDescriptorSets(opt<const DescriptorSetCfg>::ref cfg,
opt<const DescriptorPool>::ref descriptorPool,
const VkDevice device) noexcept(ND_VK_ASSERT_NOTHROW)
{
ND_SET_SCOPE();
const auto allocateInfo = VkDescriptorSetAllocateInfo {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
.pNext = cfg.next,
.descriptorPool = descriptorPool,
.descriptorSetCount = static_cast<u32>(cfg.layouts.size()),
.pSetLayouts = cfg.layouts.data()};
auto descriptorSets = vec<DescriptorSet>(cfg.layouts.size());
ND_VK_ASSERT(vkAllocateDescriptorSets(device, &allocateInfo, descriptorSets.data()));
return descriptorSets;
}
} // namespace nd::src::graphics::vulkan
| 3,416 | 942 |
// -*- c-basic-offset: 4 -*-
#ifndef CLICK_STATVECTOR_HH
#define CLICK_STATVECTOR_HH
#include <click/batchelement.hh>
#include <click/multithread.hh>
#include <click/vector.hh>
#include <click/straccum.hh>
#include <click/statvector.hh>
CLICK_DECLS
template <typename T>
class StatVector {
enum{H_MEDIAN,H_AVERAGE,H_DUMP,H_MAX_OBS,H_N_OBS,H_NZ,H_MAX,H_MAX_OBS_VAL};
static String read_handler(Element *e, void *thunk)
{
StatVector *fd = (StatVector*)e->cast("StatVector");
switch ((intptr_t)thunk) {
case H_MAX:
case H_NZ:
case H_MAX_OBS: {
Vector<T> sums(fd->stats.get_value(0).size(),0);
T max_batch_v = -1;
int max_batch_index = -1;
int max_nz = -1;
int nz=0;
for (unsigned j = 0; j < sums.size(); j++) {
for (unsigned i = 0; i < fd->stats.weight(); i++) {
sums[j] += fd->stats.get_value(i)[j];
}
if (sums[j] > max_batch_v) {
max_batch_v = sums[j];
max_batch_index = j;
}
if (sums[j] > 0) {
max_nz = j;
nz++;
}
}
if ((intptr_t)thunk == H_MAX) {
return String(max_nz);
} else if ((intptr_t)thunk == H_NZ) {
return String(nz);
} else
return String(max_batch_index);
}
case H_N_OBS:
case H_MEDIAN: {
Vector<T> sums(fd->stats.get_value(0).size(),0);
T total = 0;
for (unsigned j = 0; j < sums.size(); j++) {
for (unsigned i = 0; i < fd->stats.weight(); i++) {
sums[j] += fd->stats.get_value(i)[j];
}
total += sums[j];
}
if ((intptr_t)thunk == H_N_OBS)
return String(total);
T val = 0;
for (int i = 0; i < sums.size(); i++) {
val += sums[i];
if (val > total/2)
return String(i);
}
return "0";
}
case H_AVERAGE: {
int count = 0;
int total = 0;
for (unsigned i = 0; i < fd->stats.weight(); i++) {
for (unsigned j = 0; j < (unsigned)fd->stats.get_value(i).size(); j++) {
total += fd->stats.get_value(i)[j] * j;
count += fd->stats.get_value(i)[j];
}
}
if (count > 0)
return String((double)total/(double)count);
else
return String(0);
}
case H_DUMP: {
StringAccum s;
Vector<T> sums(fd->stats.get_value(0).size(),0);
for (unsigned i = 0; i < fd->stats.weight(); i++) {
for (unsigned j = 0; j < (unsigned)fd->stats.get_value(i).size(); j++) {
sums[j] += fd->stats.get_value(i)[j];
if (i == fd->stats.weight() - 1 && sums[j] != 0)
s << j << ": " << sums[j] << "\n";
}
}
return s.take_string();
}
default:
return "<error>";
}
}
protected:
per_thread<Vector<T>> stats;
StatVector() {
}
StatVector(Vector<T> v) : stats(v) {
}
void add_stat_handler(Element* e) {
//Value the most seen (gives the value)
e->add_read_handler("most_seen", read_handler, H_MAX_OBS, Handler::f_expensive);
//Value the most seen (gives the frequency of the value)
e->add_read_handler("most_seen_freq", read_handler, H_MAX_OBS_VAL, Handler::f_expensive);
//Maximum value seen
e->add_read_handler("max", read_handler, H_MAX, Handler::f_expensive);
//Number of observations
e->add_read_handler("count", read_handler, H_N_OBS, Handler::f_expensive);
//Number of values that had at least one observations
e->add_read_handler("nval", read_handler, H_NZ, Handler::f_expensive);
//Value for the median number of observations
e->add_read_handler("median", read_handler, H_MEDIAN, Handler::f_expensive);
//Average of value*frequency
e->add_read_handler("average", read_handler, H_AVERAGE, Handler::f_expensive);
e->add_read_handler("avg", read_handler, H_AVERAGE, Handler::f_expensive);
//Dump all value: frequency
e->add_read_handler("dump", read_handler, H_DUMP, Handler::f_expensive);
}
};
CLICK_ENDDECLS
#endif //CLICK_STATVECTOR_HH
| 4,651 | 1,561 |
__________________________________________________________________________________________________
sample 8 ms submission
class Solution {
public:
int smallestRangeI(vector<int>& A, int K) {
const int mx = *max_element(A.begin(), A.end());
const int mn = *min_element(A.begin(), A.end());
if (mx - K <= mn + K)
return 0;
return mx - K - (mn + K);
}
};
auto ___ = []() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
return 0;
}();
__________________________________________________________________________________________________
sample 9864 kb submission
class Solution {
public:
int smallestRangeI(vector<int>& A, int K) {
if(A.size()<2)
return 0;
int min = INT_MAX;
int max = INT_MIN;
for(int i = 0;i<A.size();i++){
if(min>A[i])
min = A[i];
if(max<A[i])
max = A[i];
}
if((max-K)<=(min+K))
return 0;
else
return (max-K)-(min+K);
}
};
__________________________________________________________________________________________________
| 1,175 | 349 |
#include <iostream>
#include <QList>
#include <QString>
#include <cassert>
using namespace std;
int main ()
{
QList<QString> list;
list << "A" << "B" << "C" << "B" << "A";
assert(list.contains("B"));
assert(list.contains("A"));
assert(list.contains("C"));
//assert(list.indexOf("X") == -1); // returns -1
return 0;
}
| 369 | 137 |
///////////////////////////////////////////////////////////////////////////
//
// Copyright 2010
//
// This file is part of starlight.
//
// starlight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// starlight is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with starlight. If not, see <http://www.gnu.org/licenses/>.
//
///////////////////////////////////////////////////////////////////////////
//
// File and Version Information:
// $Rev:: $: revision of last commit
// $Author: jwebb $: author of last commit
// $Date: 2012/11/27 22:27:31 $: date of last commit
//
// Description:
//
//
//
///////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <exception>
#include <cstdlib>
#include "filewriter.h"
using namespace std;
fileWriter::fileWriter()
: _fileName(""),
_fileStream()
{ }
fileWriter::fileWriter(const string& fileName) :
_fileName(fileName)
,_fileStream(fileName.c_str())
{ }
fileWriter::~fileWriter()
{ }
int fileWriter::open()
{
try
{
_fileStream.open(_fileName.c_str());
}
catch (const ios::failure & error)
{
cerr << "I/O exception: " << error.what() << endl;
return EXIT_FAILURE;
}
return 0;
}
int fileWriter::open(const string& fileName)
{
_fileName = fileName;
return open();
}
int fileWriter::close()
{
try
{
_fileStream.close();
}
catch (const ios::failure & error)
{
cerr << "I/O exception: " << error.what() << endl;
return EXIT_FAILURE;
}
return 0;
}
| 2,092 | 639 |
// Vector3.hpp
// A 3d vector class used for defining coordinates in space
#pragma once
#include <cmath>
#include <SFML/System/Vector3.hpp>
namespace fe
{
template <typename dataType>
struct Vector3;
template <typename T>
struct lightVector3;
template<typename dataType, typename vectorType>
Vector3<dataType> operator*(const dataType &lhs, Vector3<vectorType> &rhs);
template<typename dataType, typename vectorType>
Vector3<dataType> operator/(const dataType &lhs, Vector3<vectorType> &rhs);
template<typename dataType, typename vectorType>
void operator*=(const dataType &lhs, Vector3<vectorType> &rhs);
template<typename dataType, typename vectorType>
void operator/=(const dataType &lhs, Vector3<vectorType> &rhs);
template <typename dataType>
struct Vector3
{
dataType x;
dataType y;
dataType z;
Vector3() : x(0), y(0), z(0) {}
Vector3(dataType X, dataType Y, dataType Z) : x(X), y(Y), z(Z) {}
Vector3(const Vector3<dataType> ©) : x(copy.x), y(copy.y), z(copy.z) {}
Vector3(const lightVector3<dataType> ©) : x(copy.x), y(copy.y), z(copy.z) {}
Vector3(const sf::Vector3<dataType> ©) : x(copy.x), y(copy.y), z(copy.z) {}
template <typename otherDataType>
Vector3(const Vector3<otherDataType> ©) : x(static_cast<dataType>(copy.x)), y(static_cast<dataType>(copy.y)), z(static_cast<dataType>(copy.z)) {}
template <typename otherDataType>
Vector3(const lightVector3<otherDataType> ©) : x(static_cast<dataType>(copy.x)), y(static_cast<dataType>(copy.y)), z(static_cast<dataType>(copy.z)) {}
template <typename otherDataType>
Vector3(const sf::Vector3<otherDataType> ©) : x(static_cast<dataType>(copy.x)), y(static_cast<dataType>(copy.y)), z(static_cast<dataType>(copy.z)) {}
Vector3 &operator=(const Vector3<dataType> ©) { if (© != this) { x = copy.x; y = copy.y; z = copy.z; } return *this; }
bool operator==(const Vector3<dataType> &rhs) const { return rhs.x == x && rhs.y == y && rhs.y == y; }
Vector3<dataType> operator+(const Vector3<dataType> &rhs) const { return Vector3<dataType>(rhs.x + x, rhs.y + y, rhs.z + z); }
Vector3<dataType> operator-(const Vector3<dataType> &rhs) const { return Vector3<dataType>(x - rhs.x, y - rhs.y, z - rhs.z); }
Vector3<dataType> operator*(const dataType &rhs) const { return Vector3<dataType>(rhs * x, rhs * y, rhs * z); }
Vector3<dataType> operator/(const dataType &rhs) const { return Vector3<dataType>(x / rhs, y / rhs, z / rhs); }
Vector3<dataType> operator-() const { return Vector3<dataType>(-x, -y, -z); }
template<typename T> Vector3<dataType> operator+(const Vector3<T> &rhs) const { return Vector3<dataType>(static_cast<dataType>(rhs.x) + x, static_cast<dataType>(rhs.y) + y, static_cast<dataType>(rhs.z) + z); }
template<typename T> Vector3<dataType> operator-(const Vector3<T> &rhs) const { return Vector3<dataType>(x - static_cast<dataType>(rhs.x), y - static_cast<dataType>(rhs.y), z - static_cast<dataType>(rhs.z)); }
template<typename T> Vector3<dataType> operator*(const T &rhs) const { return Vector3<dataType>(static_cast<dataType>(rhs) * x, static_cast<dataType>(rhs) * y, static_cast<dataType>(rhs) * z); }
template<typename T> Vector3<dataType> operator/(const T &rhs) const { return Vector3<dataType>(x / static_cast<dataType>(rhs), y / static_cast<dataType>(rhs), z / static_cast<dataType>(rhs)); }
// A way to get the x/y coordinate based on the index provided. Useful in incrementing loops
dataType operator[](const size_t &index) const { if (index == 0) return x; if (index == 1) return y; if (index == 2) return z; return 0.f; }
// A way to get the x/y coordinate based on the index provided. Useful in incrementing loops
dataType operator[](const int &index) const { if (index == 0) return x; if (index == 1) return y; if (index == 2) return z; return 0.f; }
void operator+=(const Vector3 &rhs) { x += rhs.x; y += rhs.y; z += rhs.z; }
void operator-=(const Vector3 &rhs) { x -= rhs.x; y -= rhs.y; z -= rhs.z; }
void operator*=(const dataType &rhs){ x *= rhs; y *= rhs; z *= rhs; }
void operator/=(const dataType &rhs){ x /= rhs; y /= rhs; z /= rhs; }
friend Vector3<dataType> operator*(const dataType &lhs, Vector3<dataType> &rhs);
friend Vector3<dataType> operator/(const dataType &lhs, Vector3<dataType> &rhs);
friend void operator*=(const dataType &lhs, Vector3<dataType> &rhs);
friend void operator/=(const dataType &lhs, Vector3<dataType> &rhs);
float magnitude() const { return std::sqrt(x * x + y * y + z * z); }
float magnitudeSqr() const { return x * x + y * y + z * z; }
Vector3<dataType> normalize() const
{
float mag = magnitude();
if (mag != 0.f)
{
return Vector3<dataType>(x / mag, y / mag, z / mag);
}
return Vector3<dataType>();
}
Vector3<dataType> clamp(float max)
{
// max^3 / (x^3 + y^3) = 3 * Modifier
if (max * max > x * x + y * y + z * z) return *this;
float modifier = std::sqrt((max * max) / (x * x + y * y + z * z));
return modifier < 1.f ? fe::Vector3d(x * modifier, y * modifier, z * modifier) : *this;
}
Vector3<dataType> abs() const { return Vector3(std::abs(x), std::abs(y), std::abs(z)); }
Vector3<dataType> normal() const { return Vector3(-y, x, z); }
float dot(const Vector3<dataType> &other) const { return x * other.x + y * other.y + z * other.z; }
Vector3<dataType> cross(const Vector3<dataType> &other) const { return Vector3<dataType>(y * other.y - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x); }
Vector3<dataType> project(Vector3<dataType> &other) const
{
float mag = other.magnitudeSqr();
if (mag != 0)
{
return Vector3<dataType>(other * (dot(other) / other.magnitudeSqr()));
}
return Vector3();
}
};
// External functions that are useful for Vector operations
template<typename dataType>
Vector3<dataType> lerp(const Vector3<dataType> &a, const Vector3<dataType> &b, const float &percent)
{
return Vector3<dataType>((dataType(1) - percent) * a + (percent * b));
}
template<typename dataType, typename vectorType>
Vector3<dataType> fe::operator*(const dataType &lhs, Vector3<vectorType> &rhs)
{
return rhs * lhs;
}
template<typename dataType, typename vectorType>
Vector3<dataType> fe::operator/(const dataType &lhs, Vector3<vectorType> &rhs)
{
return rhs / lhs;
}
template<typename dataType, typename vectorType>
void fe::operator*=(const dataType &lhs, Vector3<vectorType> &rhs)
{
rhs *= lhs;
}
template<typename dataType, typename vectorType>
void fe::operator/=(const dataType &lhs, Vector3<vectorType> &rhs)
{
rhs /= lhs;
}
template<typename T>
struct lightVector3
{
T x;
T y;
T z;
lightVector3() : x(T()), y(T()), z(T()) {}
lightVector3(T x, T y, T z) : x(x), y(y), z(z) {}
lightVector3(const fe::Vector3<T> ©) : x(copy.x), y(copy.y), z(copy.z) {}
lightVector3<T> operator-(const lightVector3<T> &rhs) { return fe::lightVector3<T>(x - rhs.x, y - rhs.y, z - rhs.z); }
lightVector3<T> operator+(const lightVector3<T> &rhs) { return fe::lightVector3<T>(x + rhs.x, y + rhs.y, z + rhs.z); }
lightVector3<T> operator-(const fe::Vector3<T> &rhs) { return fe::lightVector3<T>(x - rhs.x, y - rhs.y, z - rhs.z); }
lightVector3<T> operator+(const fe::Vector3<T> &rhs) { return fe::lightVector3<T>(x + rhs.x, y + rhs.y, z + rhs.z); }
lightVector2<T> operator*(T rhs) { return fe::lightVector2<T>(x * rhs, y * rhs, z * rhs); }
lightVector2<T> operator/(T rhs) { return fe::lightVector2<T>(x / rhs, y / rhs, z / rhs); }
};
typedef lightVector3<float> lightVector3d;
typedef Vector3<float> Vector3d;
}
| 9,457 | 2,895 |
#ifndef DISPATCH_SU_H_
#define DISPATCH_SU_H_
#include <arpa/inet.h>
#include <psp/libos/persephone.hh>
#include <psp/libos/Request.hh>
#include <fstream>
#define MAX_CLIENTS 64
#define RESA_SAMPLES_NEEDED 5e4
#define UPDATE_PERIOD 5 * 1e3 //5 usec
#define MAX_WINDOWS 8192
struct profiling_windows {
uint64_t tsc_start;
uint64_t tsc_end;
uint64_t count;
double mean_ns;
uint64_t qlen[MAX_TYPES];
uint64_t counts[MAX_TYPES];
uint32_t group_res[MAX_TYPES];
uint32_t group_steal[MAX_TYPES];
bool do_update;
};
class Dispatcher : public Worker {
/* Dispatch mode */
public: enum dispatch_mode {
DFCFS = 0,
CFCFS,
SJF,
DARC,
EDF,
UNKNOWN
};
public: const char *dp_str[6] = {
"DFCFS",
"CFCFS",
"SJF",
"DARC",
"EDF",
"UNKNOWN"
};
public: static enum dispatch_mode str_to_dp(std::string const &dp) {
if (dp == "CFCFS") {
return dispatch_mode::CFCFS;
} else if (dp == "DFCFS") {
return dispatch_mode::DFCFS;
} else if (dp == "SJF") {
return dispatch_mode::SJF;
} else if (dp == "DARC") {
return dispatch_mode::DARC;
} else if (dp == "EDF") {
return dispatch_mode::EDF;
}
return dispatch_mode::UNKNOWN;
}
public: enum dispatch_mode dp;
// peer ID -> number of "compute slot" available (max= max batch size)
public: uint32_t free_peers = 0; // a bitmask of free workers
private: uint8_t last_peer = 0;
public: RequestType *rtypes[static_cast<int>(ReqType::LAST)];
public: uint32_t n_rtypes;
public: uint32_t type_to_nsorder[static_cast<int>(ReqType::LAST)];
public: uint64_t num_rcvd = 0; /** < Total number of received requests */
private: uint32_t n_drops = 0;
private: uint32_t num_dped = 0;
private: uint64_t peer_dpt_tsc[MAX_WORKERS]; // Record last time we dispatched to a peer
public: uint32_t n_workers = 0;
// DARC parameters
public: uint32_t n_resas;
public: uint32_t n_groups = 0;
public: TypeGroups groups[MAX_TYPES];
private: float delta = 0.2; // Similarity factor
public: bool first_resa_done;
public: bool dynamic;
public: uint32_t update_frequency;
public: profiling_windows windows[MAX_WINDOWS];
private: uint32_t prev_active;
private: uint32_t n_windows = 0;
public: uint32_t spillway = 0;
public: int set_darc();
private: int update_darc();
private: int drain_queue(RequestType *&rtype);
private: int dyn_resa_drain_queue(RequestType *&rtype);
private: int dequeue(unsigned long *payload);
private: int setup() override;
private: int work(int status, unsigned long payload) override;
private: int process_request(unsigned long req) override;
public: int signal_free_worker(int peer_id, unsigned long type);
public: int enqueue(unsigned long req, uint64_t cur_tsc);
public: int dispatch();
private: inline int push_to_rqueue(unsigned long req, RequestType *&rtype, uint64_t cur_tsc);
public: void set_dp(std::string &policy) {
dp = Dispatcher::str_to_dp(policy);
}
public: Dispatcher() : Worker(WorkerType::DISPATCH) {
if (cycles_per_ns == 0)
PSP_WARN("Dispatcher set before system TSC was calibrated. DARC update frequency likely 0.");
update_frequency = UPDATE_PERIOD * cycles_per_ns;
}
public: Dispatcher(int worker_id) : Worker(WorkerType::DISPATCH, worker_id) {
if (cycles_per_ns == 0)
PSP_WARN("Dispatcher set before system TSC was calibrated. DARC update frequency likely 0.");
update_frequency = UPDATE_PERIOD * cycles_per_ns;
}
public: ~Dispatcher() {
PSP_INFO(
"Nested dispatcher received " << num_rcvd << " (" << n_batchs_rcvd << " batches)"
<< " dispatched " << num_dped << " but dropped " << n_drops << " requests"
);
PSP_INFO("Latest windows count: " << windows[n_windows].count << ". Performed " << n_windows << " updates.");
for (uint32_t i = 0; i < n_rtypes; ++i) {
PSP_INFO(
"[" << req_type_str[static_cast<int>(rtypes[i]->type)] << "] has "
<< rtypes[i]->rqueue_head - rtypes[i]->rqueue_tail << " pending items"
);
PSP_INFO(
"[" << req_type_str[static_cast<int>(rtypes[i]->type)] << "] average ns: "
<< rtypes[i]->windows_mean_ns / cycles_per_ns
);
delete rtypes[i];
}
PSP_INFO(
"[" << req_type_str[static_cast<int>(rtypes[type_to_nsorder[0]]->type)] << "] has "
<< rtypes[type_to_nsorder[0]]->rqueue_head - rtypes[type_to_nsorder[0]]->rqueue_tail
<< " pending items"
);
delete rtypes[type_to_nsorder[0]];
if (dp == DARC) {
// Record windows statistics
std::string path = generate_log_file_path(label, "server/windows");
std::cout << "dpt log at " << path << std::endl;
std::ofstream output(path);
if (not output.is_open()) {
PSP_ERROR("COULD NOT OPEN " << path);
} else {
output << "ID\tSTART\tEND\tGID\tRES\tSTEAL\tCOUNT\tUPDATED\tQLEN" << std::endl;
for (size_t i = 0; i < n_windows; ++i) {
auto &w = windows[i];
for (size_t j = 0; j < n_rtypes; ++j) {
output << i << "\t" << std::fixed << w.tsc_start / cycles_per_ns
<< "\t" << std::fixed << w.tsc_end / cycles_per_ns
<< "\t" << j
<< "\t" << w.group_res[j] << "\t" << w.group_steal[j]
<< "\t" << w.counts[j] << "\t" << w.do_update
<< "\t" << w.qlen[j]
<< std::endl;
}
}
output.close();
}
}
}
};
#endif //DISPATCH_SU_H_
| 6,152 | 2,131 |
// Copyright 2019 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 "chromeos/services/assistant/assistant_manager_service_impl.h"
#include <utility>
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "chromeos/assistant/internal/internal_util.h"
#include "chromeos/assistant/internal/test_support/fake_alarm_timer_manager.h"
#include "chromeos/assistant/internal/test_support/fake_assistant_manager.h"
#include "chromeos/assistant/internal/test_support/fake_assistant_manager_internal.h"
#include "chromeos/dbus/power/fake_power_manager_client.h"
#include "chromeos/services/assistant/assistant_manager_service.h"
#include "chromeos/services/assistant/public/cpp/features.h"
#include "chromeos/services/assistant/public/mojom/assistant.mojom.h"
#include "chromeos/services/assistant/service_context.h"
#include "chromeos/services/assistant/test_support/fake_assistant_manager_service_delegate.h"
#include "chromeos/services/assistant/test_support/fake_client.h"
#include "chromeos/services/assistant/test_support/fake_service_context.h"
#include "chromeos/services/assistant/test_support/fully_initialized_assistant_state.h"
#include "chromeos/services/assistant/test_support/mock_assistant_interaction_subscriber.h"
#include "chromeos/services/assistant/test_support/mock_media_manager.h"
#include "libassistant/shared/internal_api/assistant_manager_internal.h"
#include "libassistant/shared/public/assistant_manager.h"
#include "services/media_session/public/mojom/media_session.mojom-shared.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace assistant {
using media_session::mojom::MediaSessionAction;
using testing::ElementsAre;
using testing::StrictMock;
using CommunicationErrorType = AssistantManagerService::CommunicationErrorType;
using UserInfo = AssistantManagerService::UserInfo;
namespace {
const char* kNoValue = FakeAssistantManager::kNoValue;
// Action CloneArg<k>(pointer) clones the k-th (0-based) argument of the mock
// function to *pointer. This is analogous to testing::SaveArg<k> except it uses
// mojo::Clone to support mojo types.
//
// Example usage:
// std::vector<MyMojoPtr> ptrs;
// EXPECT_CALL(my_mock, MyMethod(_)).WillOnce(CloneArg<0>(&ptrs));
ACTION_TEMPLATE(CloneArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(pointer)) {
*pointer = mojo::Clone(::std::get<k>(args));
}
#define EXPECT_STATE(_state) \
EXPECT_EQ(_state, assistant_manager_service()->GetState());
// Adds an AlarmTimerEvent of the given |type| to |events|.
static void AddAlarmTimerEvent(
std::vector<assistant_client::AlarmTimerEvent>& events,
assistant_client::AlarmTimerEvent::Type type) {
events.push_back(assistant_client::AlarmTimerEvent());
events.back().type = type;
}
// Adds an AlarmTimerEvent of type TIMER with the given |state| to |events|.
static void AddTimerEvent(
std::vector<assistant_client::AlarmTimerEvent>& events,
assistant_client::Timer::State state) {
AddAlarmTimerEvent(events, assistant_client::AlarmTimerEvent::TIMER);
events.back().timer_data.state = state;
}
// Return the list of all libassistant error codes that are considered to be
// authentication errors. This list is created on demand as there is no clear
// enum that defines these, and we don't want to hard code this list in the
// test.
static std::vector<int> GetAuthenticationErrorCodes() {
const int kMinErrorCode = GetLowestErrorCode();
const int kMaxErrorCode = GetHighestErrorCode();
std::vector<int> result;
for (int code = kMinErrorCode; code <= kMaxErrorCode; ++code) {
if (IsAuthError(code))
result.push_back(code);
}
return result;
}
// Return a list of some libassistant error codes that are not considered to be
// authentication errors. Note we do not return all such codes as there are
// simply too many and testing them all significantly slows down the tests.
static std::vector<int> GetNonAuthenticationErrorCodes() {
return {-99999, 0, 1};
}
class FakeAssistantClient : public FakeClient {
public:
FakeAssistantClient() = default;
void RequestBatteryMonitor(
mojo::PendingReceiver<device::mojom::BatteryMonitor> receiver) override {}
private:
DISALLOW_COPY_AND_ASSIGN(FakeAssistantClient);
};
class AssistantAlarmTimerControllerMock
: public ash::mojom::AssistantAlarmTimerController {
public:
AssistantAlarmTimerControllerMock() = default;
AssistantAlarmTimerControllerMock(const AssistantAlarmTimerControllerMock&) =
delete;
AssistantAlarmTimerControllerMock& operator=(
const AssistantAlarmTimerControllerMock&) = delete;
~AssistantAlarmTimerControllerMock() override = default;
// ash::mojom::AssistantAlarmTimerController:
MOCK_METHOD(void,
OnTimerStateChanged,
(std::vector<ash::mojom::AssistantTimerPtr>),
(override));
};
class CommunicationErrorObserverMock
: public AssistantManagerService::CommunicationErrorObserver {
public:
CommunicationErrorObserverMock() = default;
~CommunicationErrorObserverMock() override = default;
MOCK_METHOD(void,
OnCommunicationError,
(AssistantManagerService::CommunicationErrorType error));
private:
DISALLOW_COPY_AND_ASSIGN(CommunicationErrorObserverMock);
};
class StateObserverMock : public AssistantManagerService::StateObserver {
public:
StateObserverMock() = default;
~StateObserverMock() override = default;
MOCK_METHOD(void, OnStateChanged, (AssistantManagerService::State new_state));
private:
DISALLOW_COPY_AND_ASSIGN(StateObserverMock);
};
class AssistantManagerServiceImplTest : public testing::Test {
public:
AssistantManagerServiceImplTest() = default;
~AssistantManagerServiceImplTest() override = default;
void SetUp() override {
PowerManagerClient::InitializeFake();
FakePowerManagerClient::Get()->SetTabletMode(
PowerManagerClient::TabletMode::OFF, base::TimeTicks());
mojo::PendingRemote<device::mojom::BatteryMonitor> battery_monitor;
assistant_client_.RequestBatteryMonitor(
battery_monitor.InitWithNewPipeAndPassReceiver());
shared_url_loader_factory_ =
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_);
service_context_ = std::make_unique<FakeServiceContext>();
service_context_
->set_main_task_runner(task_environment.GetMainThreadTaskRunner())
.set_power_manager_client(PowerManagerClient::Get())
.set_assistant_state(&assistant_state_);
CreateAssistantManagerServiceImpl(/*libassistant_config=*/{});
}
void CreateAssistantManagerServiceImpl(
base::Optional<std::string> s3_server_uri_override = base::nullopt) {
auto delegate = std::make_unique<FakeAssistantManagerServiceDelegate>();
delegate_ = delegate.get();
assistant_manager_service_ = std::make_unique<AssistantManagerServiceImpl>(
&assistant_client_, service_context_.get(), std::move(delegate),
shared_url_loader_factory_->Clone(), s3_server_uri_override);
}
void TearDown() override {
assistant_manager_service_.reset();
PowerManagerClient::Shutdown();
}
AssistantManagerServiceImpl* assistant_manager_service() {
return assistant_manager_service_.get();
}
ash::AssistantState* assistant_state() { return &assistant_state_; }
FakeAssistantManagerServiceDelegate* delegate() { return delegate_; }
FakeAssistantManager* fake_assistant_manager() {
return delegate_->assistant_manager();
}
FakeAssistantManagerInternal* fake_assistant_manager_internal() {
return delegate_->assistant_manager_internal();
}
FakeAlarmTimerManager* fake_alarm_timer_manager() {
return static_cast<FakeAlarmTimerManager*>(
fake_assistant_manager_internal()->GetAlarmTimerManager());
}
FakeServiceContext* fake_service_context() { return service_context_.get(); }
action::CrosActionModule* action_module() {
return assistant_manager_service_->action_module_for_testing();
}
void Start() {
assistant_manager_service()->Start(UserInfo("<user-id>", "<access-token>"),
/*enable_hotword=*/false);
}
void RunUntilIdle() { base::RunLoop().RunUntilIdle(); }
// Adds a state observer mock, and add the expectation for the fact that it
// auto-fires the observer.
void AddStateObserver(StateObserverMock* observer) {
EXPECT_CALL(*observer,
OnStateChanged(assistant_manager_service()->GetState()));
assistant_manager_service()->AddAndFireStateObserver(observer);
}
void WaitUntilStartIsFinished() {
assistant_manager_service()->WaitUntilStartIsFinishedForTesting();
}
// Raise all the |libassistant_error_codes| as communication errors from
// libassistant, and check that they are reported to our
// |AssistantCommunicationErrorObserver| as errors of type |expected_type|.
void TestCommunicationErrors(const std::vector<int>& libassistant_error_codes,
CommunicationErrorType expected_error) {
Start();
WaitUntilStartIsFinished();
auto* delegate =
fake_assistant_manager_internal()->assistant_manager_delegate();
for (int code : libassistant_error_codes) {
CommunicationErrorObserverMock observer;
assistant_manager_service()->AddCommunicationErrorObserver(&observer);
EXPECT_CALL(observer, OnCommunicationError(expected_error));
delegate->OnCommunicationError(code);
RunUntilIdle();
assistant_manager_service()->RemoveCommunicationErrorObserver(&observer);
ASSERT_TRUE(testing::Mock::VerifyAndClearExpectations(&observer))
<< "Failure for error code " << code;
}
}
private:
base::test::SingleThreadTaskEnvironment task_environment;
FakeAssistantClient assistant_client_{};
FullyInitializedAssistantState assistant_state_;
std::unique_ptr<FakeServiceContext> service_context_;
network::TestURLLoaderFactory url_loader_factory_;
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory_;
FakeAssistantManagerServiceDelegate* delegate_;
std::unique_ptr<AssistantManagerServiceImpl> assistant_manager_service_;
DISALLOW_COPY_AND_ASSIGN(AssistantManagerServiceImplTest);
};
// Tests if the JSON string contains the given path with the given value
#define EXPECT_HAS_PATH_WITH_VALUE(config_string, path, expected_value) \
({ \
base::Optional<base::Value> config = \
base::JSONReader::Read(config_string); \
ASSERT_TRUE(config.has_value()); \
const base::Value* actual = config->FindPath(path); \
base::Value expected = base::Value(expected_value); \
ASSERT_NE(actual, nullptr) \
<< "Path '" << path << "' not found in config: " << config_string; \
EXPECT_EQ(*actual, expected); \
})
} // namespace
TEST_F(AssistantManagerServiceImplTest, StateShouldStartAsStopped) {
EXPECT_STATE(AssistantManagerService::STOPPED);
}
TEST_F(AssistantManagerServiceImplTest,
StateShouldChangeToStartingAfterCallingStart) {
Start();
EXPECT_STATE(AssistantManagerService::STARTING);
}
TEST_F(AssistantManagerServiceImplTest,
StateShouldRemainStartingUntilLibassistantIsStarted) {
Start();
fake_assistant_manager()->BlockStartCalls();
RunUntilIdle();
EXPECT_STATE(AssistantManagerService::STARTING);
fake_assistant_manager()->UnblockStartCalls();
WaitUntilStartIsFinished();
EXPECT_STATE(AssistantManagerService::STARTED);
}
TEST_F(AssistantManagerServiceImplTest,
StateShouldBecomeRunningAfterLibassistantSignalsOnStartFinished) {
Start();
WaitUntilStartIsFinished();
fake_assistant_manager()->device_state_listener()->OnStartFinished();
EXPECT_STATE(AssistantManagerService::RUNNING);
}
TEST_F(AssistantManagerServiceImplTest, ShouldSetStateToStoppedAfterStopping) {
Start();
WaitUntilStartIsFinished();
EXPECT_STATE(AssistantManagerService::STARTED);
assistant_manager_service()->Stop();
EXPECT_STATE(AssistantManagerService::STOPPED);
}
TEST_F(AssistantManagerServiceImplTest,
ShouldReportAuthenticationErrorsToCommunicationErrorObservers) {
TestCommunicationErrors(GetAuthenticationErrorCodes(),
CommunicationErrorType::AuthenticationError);
}
TEST_F(AssistantManagerServiceImplTest,
ShouldReportNonAuthenticationErrorsToCommunicationErrorObservers) {
std::vector<int> non_authentication_errors = GetNonAuthenticationErrorCodes();
// check to ensure these are not authentication errors.
for (int code : non_authentication_errors)
ASSERT_FALSE(IsAuthError(code));
// Run the actual unittest
TestCommunicationErrors(non_authentication_errors,
CommunicationErrorType::Other);
}
TEST_F(AssistantManagerServiceImplTest,
ShouldPassUserInfoToAssistantManagerWhenStarting) {
assistant_manager_service()->Start(UserInfo("<user-id>", "<access-token>"),
/*enable_hotword=*/false);
WaitUntilStartIsFinished();
EXPECT_EQ("<user-id>", fake_assistant_manager()->user_id());
EXPECT_EQ("<access-token>", fake_assistant_manager()->access_token());
}
TEST_F(AssistantManagerServiceImplTest, ShouldPassUserInfoToAssistantManager) {
Start();
WaitUntilStartIsFinished();
assistant_manager_service()->SetUser(
UserInfo("<new-user-id>", "<new-access-token>"));
EXPECT_EQ("<new-user-id>", fake_assistant_manager()->user_id());
EXPECT_EQ("<new-access-token>", fake_assistant_manager()->access_token());
}
TEST_F(AssistantManagerServiceImplTest,
ShouldPassEmptyUserInfoToAssistantManager) {
Start();
WaitUntilStartIsFinished();
assistant_manager_service()->SetUser(base::nullopt);
EXPECT_EQ(kNoValue, fake_assistant_manager()->user_id());
EXPECT_EQ(kNoValue, fake_assistant_manager()->access_token());
}
TEST_F(AssistantManagerServiceImplTest,
ShouldNotCrashWhenSettingUserInfoBeforeStartIsFinished) {
EXPECT_STATE(AssistantManagerService::STOPPED);
assistant_manager_service()->SetUser(UserInfo("<user-id>", "<access-token>"));
Start();
EXPECT_STATE(AssistantManagerService::STARTING);
assistant_manager_service()->SetUser(UserInfo("<user-id>", "<access-token>"));
}
TEST_F(AssistantManagerServiceImplTest,
ShouldPassS3ServerUriOverrideToAssistantManager) {
CreateAssistantManagerServiceImpl("the-uri-override");
Start();
WaitUntilStartIsFinished();
EXPECT_HAS_PATH_WITH_VALUE(delegate()->libassistant_config(),
"testing.s3_grpc_server_uri", "the-uri-override");
}
TEST_F(AssistantManagerServiceImplTest, ShouldPauseMediaManagerOnPause) {
StrictMock<MockMediaManager> mock;
fake_assistant_manager()->SetMediaManager(&mock);
Start();
WaitUntilStartIsFinished();
EXPECT_CALL(mock, Pause);
assistant_manager_service()->UpdateInternalMediaPlayerStatus(
MediaSessionAction::kPause);
}
TEST_F(AssistantManagerServiceImplTest, ShouldResumeMediaManagerOnPlay) {
StrictMock<MockMediaManager> mock;
fake_assistant_manager()->SetMediaManager(&mock);
Start();
WaitUntilStartIsFinished();
EXPECT_CALL(mock, Resume);
assistant_manager_service()->UpdateInternalMediaPlayerStatus(
MediaSessionAction::kPlay);
}
TEST_F(AssistantManagerServiceImplTest, ShouldIgnoreOtherMediaManagerActions) {
const auto unsupported_media_session_actions = {
MediaSessionAction::kPreviousTrack, MediaSessionAction::kNextTrack,
MediaSessionAction::kSeekBackward, MediaSessionAction::kSeekForward,
MediaSessionAction::kSkipAd, MediaSessionAction::kStop,
MediaSessionAction::kSeekTo, MediaSessionAction::kScrubTo,
};
StrictMock<MockMediaManager> mock;
fake_assistant_manager()->SetMediaManager(&mock);
Start();
WaitUntilStartIsFinished();
for (auto action : unsupported_media_session_actions) {
// If this is not ignored, |mock| will complain about an uninterested call.
assistant_manager_service()->UpdateInternalMediaPlayerStatus(action);
}
}
TEST_F(AssistantManagerServiceImplTest,
ShouldNotCrashWhenMediaManagerIsAbsent) {
Start();
WaitUntilStartIsFinished();
assistant_manager_service()->UpdateInternalMediaPlayerStatus(
media_session::mojom::MediaSessionAction::kPlay);
}
TEST_F(AssistantManagerServiceImplTest, ShouldFireStateObserverWhenAddingIt) {
StrictMock<StateObserverMock> observer;
EXPECT_CALL(observer,
OnStateChanged(AssistantManagerService::State::STOPPED));
assistant_manager_service()->AddAndFireStateObserver(&observer);
assistant_manager_service()->RemoveStateObserver(&observer);
}
TEST_F(AssistantManagerServiceImplTest, ShouldFireStateObserverWhenStarting) {
StrictMock<StateObserverMock> observer;
AddStateObserver(&observer);
fake_assistant_manager()->BlockStartCalls();
EXPECT_CALL(observer,
OnStateChanged(AssistantManagerService::State::STARTING));
Start();
assistant_manager_service()->RemoveStateObserver(&observer);
fake_assistant_manager()->UnblockStartCalls();
}
TEST_F(AssistantManagerServiceImplTest, ShouldFireStateObserverWhenStarted) {
StrictMock<StateObserverMock> observer;
AddStateObserver(&observer);
EXPECT_CALL(observer,
OnStateChanged(AssistantManagerService::State::STARTING));
EXPECT_CALL(observer,
OnStateChanged(AssistantManagerService::State::STARTED));
Start();
WaitUntilStartIsFinished();
assistant_manager_service()->RemoveStateObserver(&observer);
}
TEST_F(AssistantManagerServiceImplTest,
ShouldFireStateObserverWhenLibAssistantSignalsOnStartFinished) {
Start();
WaitUntilStartIsFinished();
StrictMock<StateObserverMock> observer;
AddStateObserver(&observer);
EXPECT_CALL(observer,
OnStateChanged(AssistantManagerService::State::RUNNING));
fake_assistant_manager()->device_state_listener()->OnStartFinished();
assistant_manager_service()->RemoveStateObserver(&observer);
}
TEST_F(AssistantManagerServiceImplTest, ShouldFireStateObserverWhenStopping) {
Start();
WaitUntilStartIsFinished();
StrictMock<StateObserverMock> observer;
AddStateObserver(&observer);
EXPECT_CALL(observer,
OnStateChanged(AssistantManagerService::State::STOPPED));
assistant_manager_service()->Stop();
assistant_manager_service()->RemoveStateObserver(&observer);
}
TEST_F(AssistantManagerServiceImplTest,
ShouldNotFireStateObserverAfterItIsRemoved) {
StrictMock<StateObserverMock> observer;
AddStateObserver(&observer);
assistant_manager_service()->RemoveStateObserver(&observer);
EXPECT_CALL(observer, OnStateChanged).Times(0);
Start();
}
TEST_F(AssistantManagerServiceImplTest,
ShouldUpdateActionModuleWhenAmbientModeStateChanged) {
EXPECT_FALSE(action_module()->IsAmbientModeEnabledForTesting());
assistant_manager_service()->EnableAmbientMode(true);
EXPECT_TRUE(action_module()->IsAmbientModeEnabledForTesting());
assistant_manager_service()->EnableAmbientMode(false);
EXPECT_FALSE(action_module()->IsAmbientModeEnabledForTesting());
}
// OnTimersResponse() is only supported when features::kAssistantTimersV2 is
// enabled. By default it is disabled, should we expect no subscribers to be
// notified of OnTimersResponse() events.
TEST_F(AssistantManagerServiceImplTest,
ShouldNotNotifyIteractionSubscribersOfTimersResponse) {
StrictMock<MockAssistantInteractionSubscriber> subscriber;
mojo::Receiver<mojom::AssistantInteractionSubscriber> receiver(&subscriber);
assistant_manager_service()->AddAssistantInteractionSubscriber(
receiver.BindNewPipeAndPassRemote());
EXPECT_CALL(subscriber, OnTimersResponse).Times(0);
assistant_manager_service()->OnShowTimers({});
base::RunLoop().RunUntilIdle();
}
TEST_F(AssistantManagerServiceImplTest,
ShouldNotifyInteractionSubscribersOfTimersResponseInV2) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kAssistantTimersV2);
StrictMock<MockAssistantInteractionSubscriber> subscriber;
mojo::Receiver<mojom::AssistantInteractionSubscriber> receiver(&subscriber);
assistant_manager_service()->AddAssistantInteractionSubscriber(
receiver.BindNewPipeAndPassRemote());
EXPECT_CALL(subscriber, OnTimersResponse(ElementsAre("1", "2"))).Times(1);
assistant_manager_service()->OnShowTimers({"1", "2"});
base::RunLoop().RunUntilIdle();
}
TEST_F(AssistantManagerServiceImplTest,
ShouldNotifyAlarmTimerControllerOfOnlyRingingTimers) {
Start();
WaitUntilStartIsFinished();
assistant_manager_service()->OnStartFinished();
StrictMock<AssistantAlarmTimerControllerMock> alarm_timer_controller;
fake_service_context()->set_assistant_alarm_timer_controller(
&alarm_timer_controller);
std::vector<ash::mojom::AssistantTimerPtr> timers;
EXPECT_CALL(alarm_timer_controller, OnTimerStateChanged)
.WillOnce(CloneArg<0>(&timers));
std::vector<assistant_client::AlarmTimerEvent> events;
// Ignore NONE, ALARMs, and SCHEDULED/PAUSED timers.
AddAlarmTimerEvent(events, assistant_client::AlarmTimerEvent::Type::NONE);
AddAlarmTimerEvent(events, assistant_client::AlarmTimerEvent::Type::ALARM);
AddTimerEvent(events, assistant_client::Timer::State::SCHEDULED);
AddTimerEvent(events, assistant_client::Timer::State::PAUSED);
// Accept FIRED timers.
AddTimerEvent(events, assistant_client::Timer::State::FIRED);
fake_alarm_timer_manager()->SetAllEvents(std::move(events));
fake_alarm_timer_manager()->NotifyRingingStateListeners();
base::RunLoop().RunUntilIdle();
ASSERT_EQ(1u, timers.size());
EXPECT_EQ(ash::mojom::AssistantTimerState::kFired, timers[0]->state);
}
TEST_F(AssistantManagerServiceImplTest,
ShouldNotifyAlarmTimerControllerOfAnyTimersInV2) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kAssistantTimersV2);
StrictMock<AssistantAlarmTimerControllerMock> alarm_timer_controller;
fake_service_context()->set_assistant_alarm_timer_controller(
&alarm_timer_controller);
// We expect OnTimerStateChanged() to be invoked when starting LibAssistant.
EXPECT_CALL(alarm_timer_controller, OnTimerStateChanged).Times(1);
Start();
WaitUntilStartIsFinished();
assistant_manager_service()->OnStartFinished();
testing::Mock::VerifyAndClearExpectations(&alarm_timer_controller);
std::vector<ash::mojom::AssistantTimerPtr> timers;
EXPECT_CALL(alarm_timer_controller, OnTimerStateChanged)
.WillOnce(CloneArg<0>(&timers));
std::vector<assistant_client::AlarmTimerEvent> events;
// Ignore NONE and ALARMs.
AddAlarmTimerEvent(events, assistant_client::AlarmTimerEvent::Type::NONE);
AddAlarmTimerEvent(events, assistant_client::AlarmTimerEvent::Type::ALARM);
// Accept SCHEDULED/PAUSED/FIRED timers.
AddTimerEvent(events, assistant_client::Timer::State::SCHEDULED);
AddTimerEvent(events, assistant_client::Timer::State::PAUSED);
AddTimerEvent(events, assistant_client::Timer::State::FIRED);
fake_alarm_timer_manager()->SetAllEvents(std::move(events));
fake_alarm_timer_manager()->NotifyRingingStateListeners();
base::RunLoop().RunUntilIdle();
ASSERT_EQ(3u, timers.size());
EXPECT_EQ(ash::mojom::AssistantTimerState::kScheduled, timers[0]->state);
EXPECT_EQ(ash::mojom::AssistantTimerState::kPaused, timers[1]->state);
EXPECT_EQ(ash::mojom::AssistantTimerState::kFired, timers[2]->state);
}
TEST_F(AssistantManagerServiceImplTest,
ShouldNotifyAlarmTimerControllerOfTimersWhenStartingLibAssistantInV2) {
// Enable timers V2.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kAssistantTimersV2);
// Pre-populate the AlarmTimerManager with a single scheduled timer.
std::vector<assistant_client::AlarmTimerEvent> events;
AddTimerEvent(events, assistant_client::Timer::State::SCHEDULED);
fake_alarm_timer_manager()->SetAllEvents(std::move(events));
// Bind AssistantAlarmTimerController.
StrictMock<AssistantAlarmTimerControllerMock> alarm_timer_controller;
fake_service_context()->set_assistant_alarm_timer_controller(
&alarm_timer_controller);
// Expect (and capture) |timers| to be sent to AssistantAlarmTimerController.
std::vector<ash::mojom::AssistantTimerPtr> timers;
EXPECT_CALL(alarm_timer_controller, OnTimerStateChanged)
.WillOnce(CloneArg<0>(&timers));
// Start LibAssistant.
Start();
WaitUntilStartIsFinished();
assistant_manager_service()->OnStartFinished();
// Verify AssistantAlarmTimerController is notified of the scheduled timer.
ASSERT_EQ(1u, timers.size());
EXPECT_EQ(ash::mojom::AssistantTimerState::kScheduled, timers[0]->state);
}
} // namespace assistant
} // namespace chromeos
| 25,637 | 7,876 |
/* $Id: count_eq_queries_random.cpp 1386 2010-10-12 16:59:18Z davidpiegdon $
* vim: fdm=marker
*
* This file is part of libalf.
*
* libalf is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libalf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libalf. If not, see <http://www.gnu.org/licenses/>.
*
* (c) 2008,2009 Lehrstuhl Softwaremodellierung und Verifikation (I2), RWTH Aachen University
* and Lehrstuhl Logik und Theorie diskreter Systeme (I7), RWTH Aachen University
* Author: David R. Piegdon <david-i2@piegdon.de>
*
*/
#include <iostream>
#include <ostream>
#include <iterator>
#include <fstream>
#include <algorithm>
#include <libalf/alf.h>
#include <libalf/algorithm_NLstar.h>
#include <amore++/nondeterministic_finite_automaton.h>
#include <amore++/deterministic_finite_automaton.h>
#include <liblangen/dfa_randomgenerator.h>
#include "amore_alf_glue.h"
using namespace std;
using namespace libalf;
using namespace liblangen;
ostream_logger my_logger(&cout, LOGGER_DEBUG);
int learn_via_NLstar(int asize, amore::finite_automaton * model)
{{{
statistics stats;
knowledgebase<bool> knowledge;
int iteration;
bool success = false;
// create NLstar table and teach it the automaton
NLstar_table<bool> ot(&knowledge, &my_logger, asize);
for(iteration = 1; iteration <= 100; iteration++) {
conjecture *cj;
while( NULL == (cj = ot.advance()) ) {
// resolve missing knowledge:
stats.queries.uniq_membership += amore_alf_glue::automaton_answer_knowledgebase(*model, knowledge);
}
list<int> counterexample;
stats.queries.equivalence++;
if(amore_alf_glue::automaton_equivalence_query(*model, cj, counterexample)) {
// equivalent
cout << "success.\n";
success = true;
break;
}
delete cj;
ot.add_counterexample(counterexample);
}
if(success) {
// cout << "success.\n";
return stats.queries.equivalence;
} else {
cout << "failed!\n";
return -1;
}
}}}
int main(int argc, char**argv)
{{{
bool f_is_dfa;
int f_asize, f_state_count;
set<int> f_initial, f_final;
map<int, map<int, set<int> > > f_transitions;
int num = 0;
if(argc != 3) {
printf("give asize and state-count as parameter\n");
return -1;
}
int asize = atoi(argv[1]);
unsigned int size = atoi(argv[2]);
int checked = 0;
int skipped = 0;
int found = 0;
int print_skipper = 0;
dfa_randomgenerator drng;
while(1) {
drng.generate(asize, size, f_is_dfa, f_asize, f_state_count, f_initial, f_final, f_transitions);
amore::finite_automaton *model = amore::construct_amore_automaton(f_is_dfa, f_asize, f_state_count, f_initial, f_final, f_transitions);
model->minimize();
if(model->get_state_count() < size) {
skipped++;
} else {
checked++;
unsigned int eq_queries = learn_via_NLstar(asize, model);
if(eq_queries > size) {
found++;
char filename[128];
ofstream file;
snprintf(filename, 128, "hit-a%d-s%d-%02d.dot", asize, size, num);
basic_string<int32_t> serialized = model->serialize();
file.open(filename); file << model->visualize(); file.close();
snprintf(filename, 128, "hit-a%d-s%d-%02d.atm", asize, size, num);
basic_string_to_file(serialized, filename);
my_logger(LOGGER_WARN, "\nmatch found with asize %d, state count %d, eq queries %d. saved as %s.\n",
asize, size, eq_queries, filename);
num++;
}
}
delete model;
if(checked > 0) {
print_skipper++;
print_skipper %= 10;
if(print_skipper == 0) {
printf("asize %d, states %d; %d, checked %d, found %d (%f%% of checked) \r",
asize, size,
skipped+checked, checked, found, ((double)found) / checked * 100);
}
}
}
}}}
| 4,134 | 1,673 |
#include <test.inline/test.inline.hpp>
ETAIO_ABI( ETAio::testinline, (reqauth)(forward) )
| 91 | 38 |